diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-03-12 21:12:39 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-03-12 21:12:58 +0400 |
commit | 4fa93b1ea44608f0bf135c6f4b98ba42d7e5dacc (patch) | |
tree | 88ba533e210b49fb695943c020f8cfa2d6a1292f /source | |
parent | 2e128baefdfd14b9614a01c11008a2efeeb2a918 (diff) |
Code cleanup (tm): Some code deduplication for HSL
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 42 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 3 |
2 files changed, 24 insertions, 21 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index f25e045f237..e43b84c9113 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -4273,6 +4273,22 @@ static void clamp_axis_max_v3(float v[3], const float max) } } +static void ui_rgb_to_color_picker_HSVCUBE_compat_v(uiBut *but, const float rgb[3], float hsv[3]) +{ + if (but->a1 == UI_GRAD_L_ALT) + rgb_to_hsl_compat_v(rgb, hsv); + else + rgb_to_hsv_compat_v(rgb, hsv); +} + +static void ui_color_picker_to_rgb_HSVCUBE_v(uiBut *but, const float hsv[3], float rgb[3]) +{ + if (but->a1 == UI_GRAD_L_ALT) + hsl_to_rgb_v(hsv, rgb); + else + hsv_to_rgb_v(hsv, rgb); +} + static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx, int my, const enum eSnapType snap, const bool shift) @@ -4300,10 +4316,7 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, if (use_display_colorspace) ui_block_to_display_space_v3(but->block, rgb); - if (but->a1 == UI_GRAD_L_ALT) - rgb_to_hsl_compat_v(rgb, hsv); - else - rgb_to_hsv_compat_v(rgb, hsv); + ui_rgb_to_color_picker_HSVCUBE_compat_v(but, rgb, hsv); /* only apply the delta motion, not absolute */ if (shift) { @@ -4318,10 +4331,8 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, ui_block_to_display_space_v3(but->block, rgb); copy_v3_v3(hsvo, ui_block_hsv_get(but->block)); - if (but->a1 == UI_GRAD_L_ALT) - rgb_to_hsl_compat_v(rgb, hsvo); - else - rgb_to_hsv_compat_v(rgb, hsvo); + + ui_rgb_to_color_picker_HSVCUBE_compat_v(but, rgb, hsvo); /* and original position */ ui_hsvcube_pos_from_vals(but, &rect_i, hsvo, &xpos, &ypos); @@ -4376,10 +4387,7 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, } } - if (but->a1 == UI_GRAD_L_ALT) - hsl_to_rgb_v(hsv, rgb); - else - hsv_to_rgb_v(hsv, rgb); + ui_color_picker_to_rgb_HSVCUBE_v(but, hsv, rgb); if (use_display_colorspace) ui_block_to_scene_linear_v3(but->block, rgb); @@ -4412,10 +4420,7 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, if (use_display_colorspace) ui_block_to_display_space_v3(but->block, rgb); - if (but->a1 == UI_GRAD_L_ALT) - rgb_to_hsl_compat_v(rgb, hsv); - else - rgb_to_hsv_compat_v(rgb, hsv); + ui_rgb_to_color_picker_HSVCUBE_compat_v(but, rgb, hsv); switch ((int)but->a1) { case UI_GRAD_SV: @@ -4462,10 +4467,7 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, /* ndof specific: the changes above aren't clamping */ hsv_clamp_v(hsv, hsv_v_max); - if (but->a1 == UI_GRAD_L_ALT) - hsl_to_rgb_v(hsv, rgb); - else - hsv_to_rgb_v(hsv, rgb); + ui_color_picker_to_rgb_HSVCUBE_v(but, hsv, rgb); if (use_display_colorspace) ui_block_to_scene_linear_v3(but->block, rgb); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 263365b174d..d3901371765 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2351,7 +2351,8 @@ static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect) if (color_profile) ui_block_to_display_space_v3(but->block, rgb); - if(but->a1 == UI_GRAD_L_ALT) + + if (but->a1 == UI_GRAD_L_ALT) rgb_to_hsl_v(rgb, hsv); else rgb_to_hsv_v(rgb, hsv); |