[Bf-blender-cvs] [f496518] wiggly-widgets: Get axes colors from theme setting again

Julian Eisel noreply at git.blender.org
Tue Aug 18 07:03:59 CEST 2015


Commit: f4965181cb86838a9eeeeab30c59780599508086
Author: Julian Eisel
Date:   Tue Aug 18 07:02:00 2015 +0200
Branches: wiggly-widgets
https://developer.blender.org/rBf4965181cb86838a9eeeeab30c59780599508086

Get axes colors from theme setting again

(and update theme colors to be the colors we used previously for the new manipulator)

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

M	source/blender/blenkernel/BKE_blender.h
M	source/blender/editors/interface/resources.c
M	source/blender/editors/transform/manipulator_widget.c

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

diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index 2a9583b..1032e32 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,7 +42,7 @@ extern "C" {
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         275
-#define BLENDER_SUBVERSION      4
+#define BLENDER_SUBVERSION      5
 /* Several breakages with 270, e.g. constraint deg vs rad */
 #define BLENDER_MINVERSION      270
 #define BLENDER_MINSUBVERSION   5
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 5eaee73..545092b 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -856,9 +856,9 @@ void ui_theme_init_default(void)
 	
 	rgba_char_args_set_fl(btheme->tui.widget_emboss, 1.0f, 1.0f, 1.0f, 0.02f);
 
-	rgba_char_args_set(btheme->tui.xaxis, 220,   0,   0, 255);
-	rgba_char_args_set(btheme->tui.yaxis,   0, 220,   0, 255);
-	rgba_char_args_set(btheme->tui.zaxis,   0,   0, 220, 255);
+	rgba_char_args_set_fl(btheme->tui.xaxis, 1.0f, 0.27f, 0.27f, 1.0f); /* red */
+	rgba_char_args_set_fl(btheme->tui.yaxis, 0.27f, 1.0f, 0.27f, 1.0f); /* green */
+	rgba_char_args_set_fl(btheme->tui.zaxis, 0.27f, 0.27f, 1.0f, 1.0f); /* blue */
 
 	btheme->tui.menu_shadow_fac = 0.5f;
 	btheme->tui.menu_shadow_width = 12;
@@ -2243,16 +2243,6 @@ void init_userdef_do_versions(void)
 				rgba_char_args_set(btheme->tv3d.skin_root, 180, 77, 77, 255);
 		}
 	}
-	
-	if (!USER_VERSION_ATLEAST(264, 9)) {
-		bTheme *btheme;
-		
-		for (btheme = U.themes.first; btheme; btheme = btheme->next) {
-			rgba_char_args_set(btheme->tui.xaxis, 220,   0,   0, 255);
-			rgba_char_args_set(btheme->tui.yaxis,   0, 220,   0, 255);
-			rgba_char_args_set(btheme->tui.zaxis,   0,   0, 220, 255);
-		}
-	}
 
 	if (!USER_VERSION_ATLEAST(267, 0)) {
 		/* Freestyle color settings */
@@ -2639,6 +2629,15 @@ void init_userdef_do_versions(void)
 		U.node_margin = 80;
 	}
 
+	if (!USER_VERSION_ATLEAST(275, 5)) {
+		bTheme *btheme;
+		for (btheme = U.themes.first; btheme; btheme = btheme->next) {
+			rgba_char_args_set_fl(btheme->tui.xaxis, 1.0f, 0.27f, 0.27f, 1.0f); /* red */
+			rgba_char_args_set_fl(btheme->tui.yaxis, 0.27f, 1.0f, 0.27f, 1.0f); /* green */
+			rgba_char_args_set_fl(btheme->tui.zaxis, 0.27f, 0.27f, 1.0f, 1.0f); /* blue */
+		}
+	}
+
 	if (U.pixelsize == 0.0f)
 		U.pixelsize = 1.0f;
 	
diff --git a/source/blender/editors/transform/manipulator_widget.c b/source/blender/editors/transform/manipulator_widget.c
index e6c69d7..3bf15df 100644
--- a/source/blender/editors/transform/manipulator_widget.c
+++ b/source/blender/editors/transform/manipulator_widget.c
@@ -221,6 +221,24 @@ static bool manipulator_is_axis_visible(const RegionView3D *rv3d, const int axis
 	return false;
 }
 
+static void manipulator_get_axis_color(const int axis_idx, float r_col[4])
+{
+	switch (axis_idx) {
+		case MAN_AXIS_TRANS_X:
+		case MAN_AXIS_ROT_X:
+			UI_GetThemeColor4fv(TH_AXIS_X, r_col);
+			break;
+		case MAN_AXIS_TRANS_Y:
+		case MAN_AXIS_ROT_Y:
+			UI_GetThemeColor4fv(TH_AXIS_Y, r_col);
+			break;
+		case MAN_AXIS_TRANS_Z:
+		case MAN_AXIS_ROT_Z:
+			UI_GetThemeColor4fv(TH_AXIS_Z, r_col);
+			break;
+	}
+}
+
 
 /* **************** Preparation Stuff **************** */
 
@@ -829,10 +847,6 @@ static ManipulatorGroup *manipulatorgroup_init(
 {
 	ManipulatorGroup *man;
 
-	const float color_green[4] = {0.27f, 1.0f, 0.27f, 1.0f};
-	const float color_red[4] = {1.0f, 0.27f, 0.27f, 1.0f};
-	const float color_blue[4] = {0.27f, 0.27f, 1.0f, 1.0f};
-
 	if (init_trans == false && init_rot == false)
 		return NULL;
 
@@ -842,17 +856,11 @@ static ManipulatorGroup *manipulatorgroup_init(
 		man->translate_x = WIDGET_arrow_new(wgroup, "translate_x", WIDGET_ARROW_STYLE_NORMAL);
 		man->translate_y = WIDGET_arrow_new(wgroup, "translate_y", WIDGET_ARROW_STYLE_NORMAL);
 		man->translate_z = WIDGET_arrow_new(wgroup, "translate_z", WIDGET_ARROW_STYLE_NORMAL);
-		WIDGET_arrow_set_color(man->translate_x, color_red);
-		WIDGET_arrow_set_color(man->translate_y, color_green);
-		WIDGET_arrow_set_color(man->translate_z, color_blue);
 	}
 	if (init_rot) {
 		man->rotate_x = WIDGET_dial_new(wgroup, "rotate_x", WIDGET_DIAL_STYLE_RING_CLIPPED);
 		man->rotate_y = WIDGET_dial_new(wgroup, "rotate_y", WIDGET_DIAL_STYLE_RING_CLIPPED);
 		man->rotate_z = WIDGET_dial_new(wgroup, "rotate_z", WIDGET_DIAL_STYLE_RING_CLIPPED);
-		WIDGET_dial_set_color(man->rotate_x, color_red);
-		WIDGET_dial_set_color(man->rotate_y, color_green);
-		WIDGET_dial_set_color(man->rotate_z, color_blue);
 	}
 
 	return man;
@@ -898,19 +906,24 @@ void WIDGETGROUP_manipulator_draw(const struct bContext *C, struct wmWidgetGroup
 	{
 		const short atype = manipulator_get_axis_type(man, axis);
 		const bool is_trans = (atype == MAN_AXES_TRANSLATE);
+		float col[4];
 
 		if (manipulator_is_axis_visible(rv3d, i) == false) {
 			WM_widget_flag_set(axis, WM_WIDGET_HIDDEN, true);
 			continue;
 		}
 
+		manipulator_get_axis_color(i, col);
+
 		/* should be added according to the order of axis */
 		WM_widget_set_origin(axis, rv3d->twmat[3]);
 		if (is_trans) {
 			WIDGET_arrow_set_direction(axis, rv3d->twmat[i]);
+			WIDGET_arrow_set_color(axis, col);
 		}
 		else {
 			WIDGET_dial_set_direction(axis, rv3d->twmat[i - 3]);
+			WIDGET_dial_set_color(axis, col);
 		}
 
 		WM_widget_operator(axis, is_trans ? "TRANSFORM_OT_translate" : "TRANSFORM_OT_rotate");




More information about the Bf-blender-cvs mailing list