[Bf-blender-cvs] [2f01be2] master: UI: panel tabs, use simple color interpolation that ignores alpha

Campbell Barton noreply at git.blender.org
Mon Feb 10 07:07:20 CET 2014


Commit: 2f01be2b2fe563f634c9f653260940b2a9a78d6d
Author: Campbell Barton
Date:   Mon Feb 10 17:02:53 2014 +1100
https://developer.blender.org/rB2f01be2b2fe563f634c9f653260940b2a9a78d6d

UI: panel tabs, use simple color interpolation that ignores alpha

===================================================================

M	source/blender/blenlib/BLI_math_vector.h
M	source/blender/blenlib/intern/math_vector.c
M	source/blender/editors/interface/interface_panel.c

===================================================================

diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 3c0f215..22ff9a3 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 3671665..54615a5 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 362df8b..1c6ea14 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));




More information about the Bf-blender-cvs mailing list