Fix T50976: Blender UI problems with certain theme files.

Core of the issue was that some of our Theme colors are RGB-only, but
were loaded as RGBA.

Note that tracking all possible cases is pretty impossible, so we'll
have to tackle those as they get reported am afraid.
This commit is contained in:
Bastien Montagne 2017-04-05 10:59:46 +02:00
parent 2f700b8280
commit 1f6037c887
Notes: blender-bot 2023-02-14 07:39:46 +01:00
Referenced by issue #50976, Blender UI problems with certain theme files
4 changed files with 14 additions and 3 deletions

View File

@ -414,7 +414,8 @@ void UI_draw_icon_tri(float x, float y, char dir, const float color[4])
static void ui_draw_tria_rect(const rctf *rect, char dir)
{
float color[4];
UI_GetThemeColor4fv(TH_TITLE, color);
UI_GetThemeColor3fv(TH_TITLE, color);
color[3] = 1.0f;
if (dir == 'h') {
float half = 0.5f * BLI_rctf_size_y(rect);
@ -553,7 +554,8 @@ static void ui_draw_aligned_panel_header(uiStyle *style, uiBlock *block, const r
pnl_icons = (panel->labelofs + PNL_ICON + 5) / block->aspect + 0.001f;
/* draw text label */
UI_GetThemeColor4ubv(TH_TITLE, col_title);
UI_GetThemeColor3ubv(TH_TITLE, col_title);
col_title[3] = 255;
hrect = *rect;
if (dir == 'h') {
@ -718,7 +720,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
if (panel->control & UI_PNL_CLOSE) {
const int ofsx = 6;
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_TITLE);
immUniformThemeColor3(TH_TITLE);
ui_draw_x_icon(pos, rect->xmin + 2 + ofsx, rect->ymax + 2);
immUnbindProgram();
}

View File

@ -47,6 +47,7 @@ void immBindBuiltinProgram(GPUBuiltinShader shader_id);
* Extend immUniformColor to take Blender's themes
*/
void immUniformThemeColor(int color_id);
void immUniformThemeColor3(int color_id);
void immUniformThemeColorShade(int color_id, int offset);
void immUniformThemeColorShadeAlpha(int color_id, int color_offset, int alpha_offset);
void immUniformThemeColorBlendShade(int color_id1, int color_id2, float fac, int offset);

View File

@ -45,6 +45,13 @@ void immUniformThemeColor(int color_id)
immUniformColor4fv(color);
}
void immUniformThemeColor3(int color_id)
{
float color[3];
UI_GetThemeColor3fv(color_id, color);
immUniformColor3fv(color);
}
void immUniformThemeColorShade(int color_id, int offset)
{
float color[4];

View File

@ -600,6 +600,7 @@ const char *uiLayoutIntrospect(uiLayout *layout) RET_NULL
void UI_reinit_font(void) RET_NONE
int UI_rnaptr_icon_get(struct bContext *C, struct PointerRNA *ptr, int rnaicon, const bool big) RET_ZERO
struct bTheme *UI_GetTheme(void) RET_NULL
void UI_GetThemeColor3fv(int colorid, float col[4]) RET_NONE
void UI_GetThemeColor4fv(int colorid, float col[4]) RET_NONE
void UI_GetThemeColorShade4fv(int colorid, int offset, float col[4]) RET_NONE
void UI_GetThemeColorShadeAlpha4fv(int colorid, int coloffset, int alphaoffset, float col[4]) RET_NONE