[Bf-blender-cvs] [00f22403ac9] blender2.8: Manipulator: replace hard coded color w/ theme

Campbell Barton noreply at git.blender.org
Wed Aug 9 10:11:51 CEST 2017


Commit: 00f22403ac9dce95117cb6ef5c948f1da881f05d
Author: Campbell Barton
Date:   Tue Aug 8 17:06:24 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB00f22403ac9dce95117cb6ef5c948f1da881f05d

Manipulator: replace hard coded color w/ theme

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

M	release/scripts/startup/bl_ui/space_userpref.py
M	source/blender/editors/include/UI_resources.h
M	source/blender/editors/interface/resources.c
M	source/blender/editors/mesh/editmesh_bisect.c
M	source/blender/editors/mesh/editmesh_extrude.c
M	source/blender/editors/space_view3d/view3d_manipulator_camera.c
M	source/blender/editors/space_view3d/view3d_manipulator_forcefield.c
M	source/blender/editors/space_view3d/view3d_manipulator_lamp.c
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/intern/rna_userdef.c

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

diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 7a777194d83..dcd8e4a7735 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -909,7 +909,7 @@ class USERPREF_PT_theme(Panel):
             col.separator()
             col.separator()
 
-            col.label("Axis Colors:")
+            col.label("Axis & Manipulator Colors:")
 
             row = col.row()
 
@@ -927,9 +927,13 @@ class USERPREF_PT_theme(Panel):
             padding = subsplit.split(percentage=0.15)
             colsub = padding.column()
             colsub = padding.column()
+            colsub.row().prop(ui, "manipulator_primary")
+            colsub.row().prop(ui, "manipulator_secondary")
+            colsub.row().prop(ui, "manipulator_a")
+            colsub.row().prop(ui, "manipulator_b")
 
-            layout.separator()
-            layout.separator()
+            col.separator()
+            col.separator()
         elif theme.theme_area == 'BONE_COLOR_SETS':
             col = split.column()
 
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index 3867815144b..7d2837ffe4e 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -279,6 +279,12 @@ enum {
 	TH_AXIS_Y,
 	TH_AXIS_Z,
 
+	TH_MANIPULATOR_HI,
+	TH_MANIPULATOR_PRIMARY,
+	TH_MANIPULATOR_SECONDARY,
+	TH_MANIPULATOR_A,
+	TH_MANIPULATOR_B,
+
 	TH_LOW_GRAD,
 	TH_HIGH_GRAD,
 	TH_SHOW_BACK_GRAD,
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 274429d5390..1e1d08a3a9c 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -667,6 +667,17 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
 				case TH_AXIS_Z:
 					cp = btheme->tui.zaxis; break;
 
+				case TH_MANIPULATOR_HI:
+					cp = btheme->tui.manipulator_hi; break;
+				case TH_MANIPULATOR_PRIMARY:
+					cp = btheme->tui.manipulator_primary; break;
+				case TH_MANIPULATOR_SECONDARY:
+					cp = btheme->tui.manipulator_secondary; break;
+				case TH_MANIPULATOR_A:
+					cp = btheme->tui.manipulator_a; break;
+				case TH_MANIPULATOR_B:
+					cp = btheme->tui.manipulator_b; break;
+
 				case TH_INFO_SELECTED:
 					cp = ts->info_selected;
 					break;
@@ -837,6 +848,15 @@ static void ui_theme_space_init_handles_color(ThemeSpace *theme_space)
 	rgba_char_args_set(theme_space->act_spline, 0xdb, 0x25, 0x12, 255);
 }
 
+static void ui_theme_space_init_manipulator_colors(bTheme *btheme)
+{
+	rgba_char_args_set(btheme->tui.manipulator_hi, 255, 255, 255, 255);
+	rgba_char_args_set(btheme->tui.manipulator_primary, 222, 255, 13, 255);
+	rgba_char_args_set(btheme->tui.manipulator_secondary, 0, 255, 255, 255);
+	rgba_char_args_set(btheme->tui.manipulator_a, 23, 127, 23, 255);
+	rgba_char_args_set(btheme->tui.manipulator_b, 127, 23, 23, 255);
+}
+
 /**
  * initialize default theme
  * \note: when you add new colors, created & saved themes need initialized
@@ -877,6 +897,9 @@ void ui_theme_init_default(void)
 	/* common (new) variables */
 	ui_theme_init_new(btheme);
 	
+	/* Manipulator. */
+	ui_theme_space_init_manipulator_colors(btheme);
+
 	/* space view3d */
 	rgba_char_args_set_fl(btheme->tv3d.back,       0.225, 0.225, 0.225, 1.0);
 	rgba_char_args_set(btheme->tv3d.text,       0, 0, 0, 255);
@@ -2892,6 +2915,25 @@ void init_userdef_do_versions(void)
 			btheme->ttime.time_keyframe[3] = btheme->ttime.time_gp_keyframe[3] = 255;
 		}
 	}
+
+	if (!USER_VERSION_ATLEAST(278, 6)) {
+		/* Clear preference flags for re-use. */
+		U.flag &= ~(
+		    USER_FLAG_DEPRECATED_1 | USER_FLAG_DEPRECATED_2 | USER_FLAG_DEPRECATED_3 |
+		    USER_FLAG_DEPRECATED_6 | USER_FLAG_DEPRECATED_7 |
+		    USER_FLAG_DEPRECATED_9 | USER_FLAG_DEPRECATED_10);
+		U.uiflag &= ~(
+		    USER_UIFLAG_DEPRECATED_7);
+		U.transopts &= ~(
+		    USER_TR_DEPRECATED_2 | USER_TR_DEPRECATED_3 | USER_TR_DEPRECATED_4 |
+		    USER_TR_DEPRECATED_6 | USER_TR_DEPRECATED_7);
+		U.gameflags &= ~(
+		    USER_GL_RENDER_DEPRECATED_0 | USER_GL_RENDER_DEPRECATED_1 |
+		    USER_GL_RENDER_DEPRECATED_3 | USER_GL_RENDER_DEPRECATED_4);
+
+		U.uiflag |= USER_LOCK_CURSOR_ADJUST;
+	}
+
 	if (!USER_VERSION_ATLEAST(280, 1)) {
 		/* interface_widgets.c */
 		struct uiWidgetColors wcol_tab = {
@@ -2912,31 +2954,15 @@ void init_userdef_do_versions(void)
 		}
 	}
 
-	if (!USER_VERSION_ATLEAST(278, 6)) {
-		/* Clear preference flags for re-use. */
-		U.flag &= ~(
-		    USER_FLAG_DEPRECATED_1 | USER_FLAG_DEPRECATED_2 | USER_FLAG_DEPRECATED_3 |
-		    USER_FLAG_DEPRECATED_6 | USER_FLAG_DEPRECATED_7 |
-		    USER_FLAG_DEPRECATED_9 | USER_FLAG_DEPRECATED_10);
-		U.uiflag &= ~(
-		    USER_UIFLAG_DEPRECATED_7);
-		U.transopts &= ~(
-		    USER_TR_DEPRECATED_2 | USER_TR_DEPRECATED_3 | USER_TR_DEPRECATED_4 |
-		    USER_TR_DEPRECATED_6 | USER_TR_DEPRECATED_7);
-		U.gameflags &= ~(
-		    USER_GL_RENDER_DEPRECATED_0 | USER_GL_RENDER_DEPRECATED_1 |
-		    USER_GL_RENDER_DEPRECATED_3 | USER_GL_RENDER_DEPRECATED_4);
-
-		U.uiflag |= USER_LOCK_CURSOR_ADJUST;
-	}
-
 	/**
 	 * Include next version bump.
 	 *
 	 * (keep this block even if it becomes empty).
 	 */
-	{
-		
+	if (((bTheme *)U.themes.first)->tui.manipulator_hi[3] == 0) {
+		for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) {
+			ui_theme_space_init_manipulator_colors(btheme);
+		}
 	}
 
 	if (U.pixelsize == 0.0f)
diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c
index 9b97484c8d9..9f011140e49 100644
--- a/source/blender/editors/mesh/editmesh_bisect.c
+++ b/source/blender/editors/mesh/editmesh_bisect.c
@@ -50,6 +50,8 @@
 #include "ED_screen.h"
 #include "ED_view3d.h"
 
+#include "UI_resources.h"
+
 #include "mesh_intern.h"  /* own include */
 
 #define USE_MANIPULATOR
@@ -619,6 +621,10 @@ static void manipulator_mesh_bisect_setup(const bContext *C, wmManipulatorGroup
 	man->translate_c = WM_manipulator_new_ptr(wt_grab, mgroup, NULL);
 	man->rotate_c = WM_manipulator_new_ptr(wt_dial, mgroup, NULL);
 
+	UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->translate_z->color);
+	UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->translate_c->color);
+	UI_GetThemeColor3fv(TH_MANIPULATOR_SECONDARY, man->rotate_c->color);
+
 	RNA_enum_set(man->translate_z->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_NORMAL);
 	RNA_enum_set(man->translate_c->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_RING);
 
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c
index e7be66e0276..315882bd764 100644
--- a/source/blender/editors/mesh/editmesh_extrude.c
+++ b/source/blender/editors/mesh/editmesh_extrude.c
@@ -53,6 +53,8 @@
 #include "ED_transform.h"
 #include "ED_view3d.h"
 
+#include "UI_resources.h"
+
 #include "MEM_guardedalloc.h"
 
 #include "mesh_intern.h"  /* own include */
@@ -1083,6 +1085,12 @@ static void manipulator_mesh_spin_setup(const bContext *C, wmManipulatorGroup *m
 	man->rotate_c = WM_manipulator_new_ptr(wt_dial, mgroup, NULL);
 	man->angle_z = WM_manipulator_new_ptr(wt_dial, mgroup, NULL);
 
+	UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->translate_z->color);
+	UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, man->translate_c->color);
+	UI_GetThemeColor3fv(TH_MANIPULATOR_SECONDARY, man->rotate_c->color);
+	UI_GetThemeColor3fv(TH_AXIS_Z, man->angle_z->color);
+
+
 	RNA_enum_set(man->translate_z->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_NORMAL);
 	RNA_enum_set(man->translate_c->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_RING);
 
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_camera.c b/source/blender/editors/space_view3d/view3d_manipulator_camera.c
index 51467775298..26af554f13a 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_camera.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_camera.c
@@ -37,6 +37,8 @@
 #include "ED_screen.h"
 #include "ED_manipulator_library.h"
 
+#include "UI_resources.h"
+
 #include "MEM_guardedalloc.h"
 
 #include "RNA_access.h"
@@ -105,37 +107,32 @@ static void WIDGETGROUP_camera_setup(const bContext *C, wmManipulatorGroup *mgro
 	/* dof distance */
 	{
 		wmManipulator *mpr;
-		const float color[4] = {1.0f, 0.3f, 0.0f, 1.0f};
-		const float color_hi[4] = {1.0f, 0.3f, 0.0f, 1.0f};
-
 		mpr = camgroup->dop_dist = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL);
 		RNA_enum_set(mpr->ptr, "draw_style",  ED_MANIPULATOR_ARROW_STYLE_CROSS);
 		WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_HOVER, true);
-		WM_manipulator_set_color(mpr, color);
-		WM_manipulator_set_color_highlight(mpr, color_hi);
+
+		UI_GetThemeColor3fv(TH_MANIPULATOR_A, mpr->color);
+		UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi);
 	}
 
 	/* focal length
 	 * - logic/calculations are similar to BKE_camera_view_frame_ex, better keep in sync */
 	{
 		wmManipulator *mpr;
-		const float color[4] = {1.0f, 1.0, 0.27f, 0.5f};
-		const float color_hi[4] = {1.0f, 1.0, 0.27f, 1.0f};
-
 		mpr = camgroup->focal_len = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL);
 		RNA_enum_set(mpr->ptr, "draw_style",  ED_MANIPULATOR_ARROW_STYLE_CONE);
 		RNA_enum_set(mpr->ptr, "draw_options",  ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED);
 
-		WM_manipulator_set_color(mpr, color);
-		WM_manipulator_set_color_highlight(mpr, color_hi);
+		UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color);
+		UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi);
 		cameragroup_property_setup(mpr, ob, ca, false);
 
 		mpr = camgroup->ortho_scale = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL);
 		RNA_enum_set(mpr->ptr, "draw_style",  ED_MANIPULATOR_ARROW_STYLE_CONE);
 		RNA_enum_set(mpr->ptr, "draw_options",  ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED);
 
-		WM_manipulator_set_color(mpr, color);
-		WM_manipulator_set_color_highlight(mpr, color_hi);
+		UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color);
+		UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi);
 		cameragroup_property_setup(mpr, ob, ca, true);
 	}
 }
diff --git a/source/blender/editors/space_view3d/view3d

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list