[Bf-blender-cvs] [4935e2449b] blender2.8: BLF can use Theme colors

Mike Erwin noreply at git.blender.org
Wed Feb 1 22:44:32 CET 2017


Commit: 4935e2449b2c0d52eb27f4889533d72c8e12df94
Author: Mike Erwin
Date:   Wed Feb 1 16:44:00 2017 -0500
Branches: blender2.8
https://developer.blender.org/rB4935e2449b2c0d52eb27f4889533d72c8e12df94

BLF can use Theme colors

For anything fancier than regular Theme colors (shading, alpha, etc.) do this:

unsigned char color[4]
UI_GetThemeColor[Fancy]4ubv(... color)
BLF_color4ubv(fontid, color)

That way the BLF color API stays simple.

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

M	source/blender/blenfont/BLF_api.h
M	source/blender/blenfont/intern/blf.c

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

diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h
index afb391e33e..856234dad4 100644
--- a/source/blender/blenfont/BLF_api.h
+++ b/source/blender/blenfont/BLF_api.h
@@ -65,6 +65,7 @@ void BLF_position(int fontid, float x, float y, float z);
 void BLF_size(int fontid, int size, int dpi);
 
 /* goal: small but useful color API */
+void BLF_ThemeColor(int fontid, int colorid);
 void BLF_color4ubv(int fontid, const unsigned char rgba[4]);
 void BLF_color3ubv(int fontid, const unsigned char rgb[3]);
 void BLF_color3ubv_alpha(int fontid, const unsigned char rgb[3], unsigned char alpha);
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 58c6f095ae..01feb652f3 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -50,9 +50,10 @@
 #include "BLI_math.h"
 #include "BLI_threads.h"
 
-#include "BIF_gl.h"
 #include "BLF_api.h"
 
+#include "UI_resources.h"
+
 #include "IMB_colormanagement.h"
 
 #ifndef BLF_STANDALONE
@@ -466,6 +467,15 @@ void BLF_blur(int fontid, int size)
 }
 #endif
 
+void BLF_ThemeColor(int fontid, int colorid)
+{
+	FontBLF *font = blf_get(fontid);
+
+	if (font) {
+		UI_GetThemeColor4ubv(colorid, font->color);
+	}
+}
+
 void BLF_color4ubv(int fontid, const unsigned char rgba[4])
 {
 	FontBLF *font = blf_get(fontid);




More information about the Bf-blender-cvs mailing list