Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2016-10-13 23:06:44 +0300
committerDalai Felinto <dfelinto@gmail.com>2016-10-13 23:08:51 +0300
commit05cf74622f6b50d92cf077dcfb9d5086f4018e50 (patch)
treea0022fbcd7ec9d18a1e537ea4acc75c10cd6d8a4
parent945f8e3f93ac3c2dbc8ee0d8504040b6bcaa41b8 (diff)
more theme color functions: UI_GetThemeColorBlendShade4fv, immUniformThemeColorBlendShade
-rw-r--r--source/blender/editors/include/UI_resources.h2
-rw-r--r--source/blender/editors/interface/resources.c25
-rw-r--r--source/blender/gpu/GPU_immediate.h1
-rw-r--r--source/blender/gpu/intern/gpu_immediate.c9
4 files changed, 36 insertions, 1 deletions
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index b3641f39d93..be03647d6f4 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -353,6 +353,8 @@ void UI_GetThemeColor4fv(int colorid, float col[4]);
// get four color values, range 0.0-1.0, complete with shading offset for the RGB components
void UI_GetThemeColorShade4fv(int colorid, int offset, float col[4]);
void UI_GetThemeColorShadeAlpha4fv(int colorid, int coloffset, int alphaoffset, float col[4]);
+// get four color values, range 0.0-1.0, complete with shading offset for the RGB components and blending
+void UI_GetThemeColorBlendShade4fv(int colorid1, int colorid2, float fac, int offset, float col[4]);
// get the 3 or 4 byte values
void UI_GetThemeColor3ubv(int colorid, unsigned char col[3]);
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 9d9cae6f347..4cd2b5bbf21 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -1488,6 +1488,31 @@ void UI_GetThemeColorShadeAlpha4fv(int colorid, int coloffset, int alphaoffset,
col[3] = ((float)a) / 255.0f;
}
+void UI_GetThemeColorBlendShade4fv(int colorid1, int colorid2, float fac, int offset, float col[4])
+{
+ int r, g, b, a;
+ const unsigned char *cp1, *cp2;
+
+ cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
+ cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
+
+ CLAMP(fac, 0.0f, 1.0f);
+
+ r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
+ CLAMP(r, 0, 255);
+ g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
+ CLAMP(g, 0, 255);
+ b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
+ CLAMP(b, 0, 255);
+ a = offset + floorf((1.0f - fac) * cp1[3] + fac * cp2[3]);
+ CLAMP(a, 0, 255);
+
+ col[0] = ((float)r) / 255.0f;
+ col[1] = ((float)g) / 255.0f;
+ col[2] = ((float)b) / 255.0f;
+ col[3] = ((float)a) / 255.0f;
+}
+
/* get the color, in char pointer */
void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
{
diff --git a/source/blender/gpu/GPU_immediate.h b/source/blender/gpu/GPU_immediate.h
index cce5f519c76..1b4f26a7640 100644
--- a/source/blender/gpu/GPU_immediate.h
+++ b/source/blender/gpu/GPU_immediate.h
@@ -43,3 +43,4 @@ void immBindBuiltinProgram(GPUBuiltinShader shader_id);
*/
void immUniformThemeColor(int colorid);
void immUniformThemeColorShade(int colorid, int offset);
+void immUniformThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset);
diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c
index 444a8850452..e0241dba893 100644
--- a/source/blender/gpu/intern/gpu_immediate.c
+++ b/source/blender/gpu/intern/gpu_immediate.c
@@ -50,4 +50,11 @@ void immUniformThemeColorShade(int colorid, int offset)
float color[4];
UI_GetThemeColorShade4fv(colorid, offset, color);
immUniformColor4fv(color);
-} \ No newline at end of file
+}
+
+void immUniformThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
+{
+ float color[4];
+ UI_GetThemeColorBlendShade4fv(colorid1, colorid2, fac, offset, color);
+ immUniformColor4fv(color);
+}