[Bf-blender-cvs] [150218e58b2] blender2.8: Ruler Tool: Fix non readable text

Clément Foucault noreply at git.blender.org
Mon Nov 12 13:50:28 CET 2018


Commit: 150218e58b24e2e1d61d9f7321d6148b54a54be7
Author: Clément Foucault
Date:   Sat Nov 10 18:40:59 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB150218e58b24e2e1d61d9f7321d6148b54a54be7

Ruler Tool: Fix non readable text

The ruler tool is using a hard coded background color. Invert it if the
text color is bright. In the future we should maybe use a theme color
instead of guessing as it does not work well with middle gray colors.

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

M	source/blender/editors/space_view3d/view3d_gizmo_ruler.c
M	source/blender/editors/space_view3d/view3d_ruler.c

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

diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
index f35b88950d7..34709e434ac 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
@@ -507,7 +507,6 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz)
 	RegionView3D *rv3d = ar->regiondata;
 	const float cap_size = 4.0f;
 	const float bg_margin = 4.0f * U.pixelsize;
-	const float bg_radius = 4.0f * U.pixelsize;
 	const float arc_size = 64.0f * U.pixelsize;
 #define ARC_STEPS 24
 	const int arc_steps = ARC_STEPS;
@@ -528,6 +527,11 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz)
 	UI_GetThemeColor3ubv(TH_TEXT, color_text);
 	UI_GetThemeColor3ubv(TH_WIRE, color_wire);
 
+	/* Avoid white on white text. (TODO Fix by using theme) */
+	if ((int)color_text[0] + (int)color_text[1] + (int)color_text[2] > 127 * 3 * 0.6f) {
+		copy_v3_fl(color_back, 0.0f);
+	}
+
 	const bool is_act = (gz->flag & WM_GIZMO_DRAW_HOVER);
 	float dir_ruler[2];
 	float co_ss[3][2];
diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c
index 0d61fa30ebf..208f147f943 100644
--- a/source/blender/editors/space_view3d/view3d_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_ruler.c
@@ -419,7 +419,6 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
 //	ARegion *ar = ruler_info->ar;
 	const float cap_size = 4.0f;
 	const float bg_margin = 4.0f * U.pixelsize;
-	const float bg_radius = 4.0f * U.pixelsize;
 	const float arc_size = 64.0f * U.pixelsize;
 #define ARC_STEPS 24
 	const int arc_steps = ARC_STEPS;
@@ -441,6 +440,11 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
 	UI_GetThemeColor3ubv(TH_TEXT, color_text);
 	UI_GetThemeColor3ubv(TH_WIRE, color_wire);
 
+	/* Avoid white on white text. (TODO Fix by using theme) */
+	if ((int)color_text[0] + (int)color_text[1] + (int)color_text[2] > 127 * 3 * 0.6f) {
+		copy_v3_fl(color_back, 0.0f);
+	}
+
 	for (ruler_item = ruler_info->items.first, i = 0; ruler_item; ruler_item = ruler_item->next, i++) {
 		const bool is_act = (i == ruler_info->item_active);
 		float dir_ruler[2];



More information about the Bf-blender-cvs mailing list