Changeset View
Standalone View
source/blender/editors/interface/resources.c
| Context not available. | |||||
| } | } | ||||
| /* plus alpha */ | /* plus alpha */ | ||||
| void UI_ThemeColor4(int colorid) | const unsigned char *UI_ThemeColor4(int colorid) | ||||
merwin: Leave UI_ThemeColor functions alone for now. Lots of drawing code uses these!
Use existing… | |||||
kgeogeoAuthorUnsubmitted Not Done Inline ActionsNo part of blender use the return of this function, it can still be a problem?? As you say it's used a lot of time, that why i make it, it's and will be a lot easier to make all the modification with this. But you know it better than me for sure, I hope.... :-)))))) kgeogeo: No part of blender use the return of this function, it can still be a problem??
As you say… | |||||
SeverinUnsubmitted Not Done Inline ActionsI'd prefer to get rid of the UI_ThemeColorXXX functions and only keep the UI_GetThemeColorXXX ones. I guess after 3.2 core profile transition they'll be useless anyway since it doesn't use color states (right?). Severin: I'd prefer to get rid of the UI_ThemeColorXXX functions and only keep the UI_GetThemeColorXXX… | |||||
kgeogeoAuthorUnsubmitted Not Done Inline Actionsit's was me idee too, when 3.2 core will be activated we only delete glColor4ubv(cp); for eg. no? kgeogeo: it's was me idee too, when 3.2 core will be activated we only delete glColor4ubv(cp); for eg. | |||||
merwinUnsubmitted Not Done Inline Actions
Right, those functions will be obsolete. After that maybe we can redo the theme color API. merwin: > they'll be useless anyway since it doesn't use color states
Right, those functions will be… | |||||
merwinUnsubmitted Not Done Inline ActionsHmm, good points... All this makes me start thinking about a better API for using theme colors! But that's not really part of the immediate mode task. UI_ThemeColor updates current OpenGL state to use a theme color. With your change it does that *and* returns a convenient pointer. I still prefer the UI_GetThemeColor functions for this, since you are just getting a color. Yes it's less convenient to call. But it's not that bad. merwin: Hmm, good points... All this makes me start thinking about a better API for using theme colors! | |||||
| { | { | ||||
| const unsigned char *cp; | const unsigned char *cp; | ||||
| cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); | cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); | ||||
| glColor4ubv(cp); | glColor4ubv(cp); //keep it for now | ||||
| return cp; | |||||
| } | } | ||||
| /* set the color with offset for shades */ | /* set the color with offset for shades */ | ||||
| void UI_ThemeColorShade(int colorid, int offset) | const unsigned char *UI_ThemeColorShade(int colorid, int offset) | ||||
| { | { | ||||
| int r, g, b; | int r, g, b; | ||||
| const unsigned char *cp; | const unsigned char *cp; | ||||
| static unsigned char col[4]; | |||||
| cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); | cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); | ||||
| r = offset + (int) cp[0]; | r = offset + (int) cp[0]; | ||||
| CLAMP(r, 0, 255); | CLAMP(r, 0, 255); | ||||
| Context not available. | |||||
| CLAMP(g, 0, 255); | CLAMP(g, 0, 255); | ||||
| b = offset + (int) cp[2]; | b = offset + (int) cp[2]; | ||||
| CLAMP(b, 0, 255); | CLAMP(b, 0, 255); | ||||
| glColor4ub(r, g, b, cp[3]); | glColor4ub(r, g, b, cp[3]); //keep it for now | ||||
| col[0] = (unsigned char)r; | |||||
| col[1] = (unsigned char)g; | |||||
| col[2] = (unsigned char)b; | |||||
| col[3] = cp[3]; | |||||
| return col; | |||||
| } | } | ||||
| void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset) | const unsigned char *UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset) | ||||
| { | { | ||||
| int r, g, b, a; | int r, g, b, a; | ||||
| const unsigned char *cp; | const unsigned char *cp; | ||||
| static unsigned char col[4]; | |||||
| cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); | cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); | ||||
| r = coloffset + (int) cp[0]; | r = coloffset + (int) cp[0]; | ||||
| Context not available. | |||||
| CLAMP(b, 0, 255); | CLAMP(b, 0, 255); | ||||
| a = alphaoffset + (int) cp[3]; | a = alphaoffset + (int) cp[3]; | ||||
| CLAMP(a, 0, 255); | CLAMP(a, 0, 255); | ||||
| glColor4ub(r, g, b, a); | |||||
| glColor4ub(r, g, b, a); //keep it for now | |||||
| col[0] = (unsigned char)r; | |||||
| col[1] = (unsigned char)g; | |||||
| col[2] = (unsigned char)b; | |||||
| col[3] = (unsigned char)a; | |||||
| return col; | |||||
| } | } | ||||
| void UI_GetThemeColorBlend3ubv(int colorid1, int colorid2, float fac, unsigned char col[3]) | void UI_GetThemeColorBlend3ubv(int colorid1, int colorid2, float fac, unsigned char col[3]) | ||||
| Context not available. | |||||
Leave UI_ThemeColor functions alone for now. Lots of drawing code uses these!
Use existing UI_GetThemeColor functions to fetch color values (you might need to add one or two missing functions).