diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-02-10 10:02:53 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-02-10 10:06:56 +0400 |
commit | 2f01be2b2fe563f634c9f653260940b2a9a78d6d (patch) | |
tree | a97e7b7146fdbee9da50a84324de2785cd6d9324 /source | |
parent | 311883fc3b397ccd40a88dc48da3bc094b3a093a (diff) |
UI: panel tabs, use simple color interpolation that ignores alpha
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/BLI_math_vector.h | 5 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_vector.c | 27 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 32 |
3 files changed, 48 insertions, 16 deletions
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 3c0f215b165..22ff9a3ce6e 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -189,6 +189,11 @@ void interp_v4_v4v4v4(float p[4], const float v1[4], const float v2[4], const fl void interp_v4_v4v4v4v4(float p[4], const float v1[4], const float v2[4], const float v3[4], const float v4[4], const float w[4]); void interp_v3_v3v3v3_uv(float p[3], const float v1[3], const float v2[3], const float v3[3], const float uv[2]); +void interp_v3_v3v3_char(char target[3], const char a[3], const char b[3], const float t); +void interp_v3_v3v3_uchar(unsigned char target[3], const unsigned char a[3], const unsigned char b[3], const float t); +void interp_v4_v4v4_char(char target[4], const char a[4], const char b[4], const float t); +void interp_v4_v4v4_uchar(unsigned char target[4], const unsigned char a[4], const unsigned char b[4], const float t); + void mid_v3_v3v3(float r[3], const float a[3], const float b[3]); void mid_v2_v2v2(float r[2], const float a[2], const float b[2]); void mid_v3_v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3]); diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index 367166578ae..54615a5264d 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -109,6 +109,33 @@ void interp_v3_v3v3v3_uv(float p[3], const float v1[3], const float v2[3], const p[2] = v1[2] + ((v2[2] - v1[2]) * uv[0]) + ((v3[2] - v1[2]) * uv[1]); } +void interp_v3_v3v3_uchar(char unsigned target[3], const unsigned char a[3], const unsigned char b[3], const float t) +{ + float s = 1.0f - t; + + target[0] = (char)floorf(s * a[0] + t * b[0]); + target[1] = (char)floorf(s * a[1] + t * b[1]); + target[2] = (char)floorf(s * a[2] + t * b[2]); +} +void interp_v3_v3v3_char(char target[3], const char a[3], const char b[3], const float t) +{ + interp_v3_v3v3_char((char *)target, (const char *)a, (const char *)b, t); +} + +void interp_v4_v4v4_uchar(char unsigned target[4], const unsigned char a[4], const unsigned char b[4], const float t) +{ + float s = 1.0f - t; + + target[0] = (char)floorf(s * a[0] + t * b[0]); + target[1] = (char)floorf(s * a[1] + t * b[1]); + target[2] = (char)floorf(s * a[2] + t * b[2]); + target[3] = (char)floorf(s * a[3] + t * b[3]); +} +void interp_v4_v4v4_char(char target[4], const char a[4], const char b[4], const float t) +{ + interp_v4_v4v4_char((char *)target, (const char *)a, (const char *)b, t); +} + void mid_v3_v3v3(float v[3], const float v1[3], const float v2[3]) { v[0] = 0.5f * (v1[0] + v2[0]); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 362df8b3d12..1c6ea14b60b 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -1419,34 +1419,34 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) /* Primary theme colors */ unsigned char theme_col_back[4]; - unsigned char theme_col_text[4]; - unsigned char theme_col_text_hi[4]; + unsigned char theme_col_text[3]; + unsigned char theme_col_text_hi[3]; /* Tab colors */ unsigned char theme_col_tab_bg[4]; - unsigned char theme_col_tab_active[4]; - unsigned char theme_col_tab_inactive[4]; + unsigned char theme_col_tab_active[3]; + unsigned char theme_col_tab_inactive[3]; /* Secondary theme colors */ - unsigned char theme_col_tab_outline[4]; - unsigned char theme_col_tab_divider[4]; /* line that divides tabs from the main area */ - unsigned char theme_col_tab_highlight[4]; - unsigned char theme_col_tab_highlight_inactive[4]; + unsigned char theme_col_tab_outline[3]; + unsigned char theme_col_tab_divider[3]; /* line that divides tabs from the main area */ + unsigned char theme_col_tab_highlight[3]; + unsigned char theme_col_tab_highlight_inactive[3]; UI_GetThemeColor4ubv(TH_BACK, theme_col_back); - UI_GetThemeColor4ubv(TH_TEXT, theme_col_text); - UI_GetThemeColor4ubv(TH_TEXT_HI, theme_col_text_hi); + UI_GetThemeColor3ubv(TH_TEXT, theme_col_text); + UI_GetThemeColor3ubv(TH_TEXT_HI, theme_col_text_hi); UI_GetThemeColor4ubv(TH_TAB_BACK, theme_col_tab_bg); - UI_GetThemeColor4ubv(TH_TAB_ACTIVE, theme_col_tab_active); - UI_GetThemeColor4ubv(TH_TAB_INACTIVE, theme_col_tab_inactive); - UI_GetThemeColor4ubv(TH_TAB_OUTLINE, theme_col_tab_outline); + UI_GetThemeColor3ubv(TH_TAB_ACTIVE, theme_col_tab_active); + UI_GetThemeColor3ubv(TH_TAB_INACTIVE, theme_col_tab_inactive); + UI_GetThemeColor3ubv(TH_TAB_OUTLINE, theme_col_tab_outline); - blend_color_interpolate_byte(theme_col_tab_divider, theme_col_back, theme_col_tab_outline, 0.3f); - blend_color_interpolate_byte(theme_col_tab_highlight, theme_col_back, theme_col_text_hi, 0.2f); - blend_color_interpolate_byte(theme_col_tab_highlight_inactive, theme_col_tab_inactive, theme_col_text_hi, 0.12f); + interp_v3_v3v3_uchar(theme_col_tab_divider, theme_col_back, theme_col_tab_outline, 0.3f); + interp_v3_v3v3_uchar(theme_col_tab_highlight, theme_col_back, theme_col_text_hi, 0.2f); + interp_v3_v3v3_uchar(theme_col_tab_highlight_inactive, theme_col_tab_inactive, theme_col_text_hi, 0.12f); is_alpha = (ar->overlap && (theme_col_back[3] != 255)); |