diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-08-08 10:06:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-08-09 11:02:10 +0300 |
commit | 00f22403ac9dce95117cb6ef5c948f1da881f05d (patch) | |
tree | d02eb2b0a6cb46e0b13a0d250456972c50f45d23 /source/blender/editors | |
parent | fdb1c81117a3595044d65aef5e6ecfafe30471e7 (diff) |
Manipulator: replace hard coded color w/ theme
Diffstat (limited to 'source/blender/editors')
7 files changed, 89 insertions, 52 deletions
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_manipulator_forcefield.c b/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c index e3bfd0ac300..6a34f493caf 100644 --- a/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c +++ b/source/blender/editors/space_view3d/view3d_manipulator_forcefield.c @@ -36,6 +36,8 @@ #include "ED_screen.h" #include "ED_manipulator_library.h" +#include "UI_resources.h" + #include "MEM_guardedalloc.h" #include "RNA_access.h" @@ -59,9 +61,6 @@ static bool WIDGETGROUP_forcefield_poll(const bContext *C, wmManipulatorGroupTyp static void WIDGETGROUP_forcefield_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) { - const float col[4] = {0.8f, 0.8f, 0.45f, 0.5f}; - const float col_hi[4] = {0.8f, 0.8f, 0.45f, 1.0f}; - /* only wind effector for now */ wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__); mgroup->customdata = wwrapper; @@ -71,8 +70,9 @@ static void WIDGETGROUP_forcefield_setup(const bContext *UNUSED(C), wmManipulato RNA_enum_set(mpr->ptr, "draw_options", ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED); ED_manipulator_arrow3d_set_ui_range(mpr, -200.0f, 200.0f); ED_manipulator_arrow3d_set_range_fac(mpr, 6.0f); - WM_manipulator_set_color(mpr, col); - WM_manipulator_set_color_highlight(mpr, col_hi); + + UI_GetThemeColor3fv(TH_MANIPULATOR_PRIMARY, mpr->color); + UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); } static void WIDGETGROUP_forcefield_refresh(const bContext *C, wmManipulatorGroup *mgroup) diff --git a/source/blender/editors/space_view3d/view3d_manipulator_lamp.c b/source/blender/editors/space_view3d/view3d_manipulator_lamp.c index 4b550fd0b2e..9e5120ad1f0 100644 --- a/source/blender/editors/space_view3d/view3d_manipulator_lamp.c +++ b/source/blender/editors/space_view3d/view3d_manipulator_lamp.c @@ -36,6 +36,8 @@ #include "ED_screen.h" #include "ED_manipulator_library.h" +#include "UI_resources.h" + #include "MEM_guardedalloc.h" #include "RNA_access.h" @@ -63,9 +65,6 @@ static bool WIDGETGROUP_lamp_spot_poll(const bContext *C, wmManipulatorGroupType static void WIDGETGROUP_lamp_spot_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) { - const float color[4] = {0.5f, 0.5f, 1.0f, 1.0f}; - const float color_hi[4] = {0.8f, 0.8f, 0.45f, 1.0f}; - wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__); wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_arrow_3d", mgroup, NULL); @@ -75,8 +74,8 @@ static void WIDGETGROUP_lamp_spot_setup(const bContext *UNUSED(C), wmManipulator mgroup->customdata = wwrapper; ED_manipulator_arrow3d_set_range_fac(mpr, 4.0f); - WM_manipulator_set_color(mpr, color); - WM_manipulator_set_color_highlight(mpr, color_hi); + + UI_GetThemeColor3fv(TH_MANIPULATOR_SECONDARY, mpr->color); } static void WIDGETGROUP_lamp_spot_refresh(const bContext *C, wmManipulatorGroup *mgroup) @@ -172,9 +171,6 @@ static bool WIDGETGROUP_lamp_area_poll(const bContext *C, wmManipulatorGroupType static void WIDGETGROUP_lamp_area_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) { - const float color[4] = {1.0f, 1.0f, 0.5f, 1.0f}; - const float color_hi[4] = {1.0f, 1.0f, 1.0f, 1.0f}; - wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__); wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, NULL); wmManipulator *mpr = wwrapper->manipulator; @@ -184,8 +180,9 @@ static void WIDGETGROUP_lamp_area_setup(const bContext *UNUSED(C), wmManipulator mgroup->customdata = wwrapper; 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_PRIMARY, mpr->color); + UI_GetThemeColor3fv(TH_MANIPULATOR_HI, mpr->color_hi); } static void WIDGETGROUP_lamp_area_refresh(const bContext *C, wmManipulatorGroup *mgroup) @@ -252,17 +249,14 @@ static bool WIDGETGROUP_lamp_target_poll(const bContext *C, wmManipulatorGroupTy static void WIDGETGROUP_lamp_target_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) { - const float color[4] = {1.0f, 1.0f, 0.5f, 1.0f}; - const float color_hi[4] = {1.0f, 1.0f, 1.0f, 1.0f}; - wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__); wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_grab_3d", mgroup, NULL); wmManipulator *mpr = wwrapper->manipulator; mgroup->customdata = wwrapper; - 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); mpr->scale_basis = 0.05f; |