Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-07-05 11:08:10 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-07-05 11:08:10 +0400
commitd9e9aa1e4d7a63f7ed9a6c8ae6097eeb55b2e6dc (patch)
treecd6006ead8f6efbc838476abcb017395e034a78d /source
parent1c3512121357c37cf6a7b8b22e627a77c8cf02e5 (diff)
changes to color wheel commit.
- use a flag rather then a2 for locking color. - remove float from button added for color wheel size, use a2 instead. - holding shift on the color wheel gives higher precission.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/include/UI_interface.h2
-rw-r--r--source/blender/editors/interface/interface_handlers.c19
-rw-r--r--source/blender/editors/interface/interface_intern.h1
-rw-r--r--source/blender/editors/interface/interface_templates.c10
-rw-r--r--source/blender/editors/interface/interface_widgets.c4
5 files changed, 20 insertions, 16 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index fea8c32b43b..00a7c5c9f48 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -142,7 +142,7 @@ typedef struct uiLayout uiLayout;
#define UI_BUT_ALIGN_DOWN (1<<17)
#define UI_BUT_DISABLED (1<<18)
-#define UI_BUT_UNUSED (1<<19)
+#define UI_BUT_COLOR_LOCK (1<<19)
#define UI_BUT_ANIMATED (1<<20)
#define UI_BUT_ANIMATED_KEY (1<<21)
#define UI_BUT_DRIVEN (1<<22)
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 999b92e6854..6eb96b32efe 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -3047,7 +3047,7 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
return WM_UI_HANDLER_CONTINUE;
}
-static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, int mx, int my)
+static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, int mx, int my, int shift)
{
rcti rect;
int changed= 1;
@@ -3061,23 +3061,24 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, int mx
/* exception, when using color wheel in 'locked' value state:
* allow choosing a hue for black values, by giving a tiny increment */
- if (but->a2 == 1) { // lock
+ if (but->flag & UI_BUT_COLOR_LOCK) { // lock
if (hsv[2] == 0.f) hsv[2] = 0.0001f;
}
if(U.uiflag & USER_CONTINUOUS_MOUSE) {
+ float fac= shift ? 0.02 : 0.1;
/* slow down the mouse, this is fairly picky */
- mx = (data->dragstartx*0.9 + mx*0.1);
- my = (data->dragstarty*0.9 + my*0.1);
+ mx = (data->dragstartx*(1.0f-fac) + mx*fac);
+ my = (data->dragstarty*(1.0f-fac) + my*fac);
}
-
+
ui_hsvcircle_vals_from_pos(hsv, hsv+1, &rect, (float)mx, (float)my);
hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
- if(but->flag & UI_BUT_VEC_SIZE_LOCK) {
+ if((but->flag & UI_BUT_VEC_SIZE_LOCK) && (rgb[0] || rgb[1] || rgb[2])) {
normalize_v3(rgb);
- mul_v3_fl(rgb, but->color_lum);
+ mul_v3_fl(rgb, but->a2);
}
ui_set_but_vectorf(but, rgb);
@@ -3106,7 +3107,7 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
- if(ui_numedit_but_HSVCIRCLE(but, data, mx, my))
+ if(ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift))
ui_numedit_apply(C, block, but, data);
return WM_UI_HANDLER_BREAK;
@@ -3157,7 +3158,7 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle
}
else if(event->type == MOUSEMOVE) {
if(mx!=data->draglastx || my!=data->draglasty) {
- if(ui_numedit_but_HSVCIRCLE(but, data, mx, my))
+ if(ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift))
ui_numedit_apply(C, block, but, data);
}
}
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 078e337f8f9..cb8130573fe 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -173,7 +173,6 @@ struct uiBut {
float hardmin, hardmax, softmin, softmax;
float a1, a2, hsv[3]; // hsv is temp memory for hsv buttons
float aspect;
- float color_lum; /* used only for color buttons so far */
uiButHandleFunc func;
void *func_arg1;
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index ae5f81a56a9..59a67f9a541 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -1965,19 +1965,23 @@ void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, char *propname, int
printf("uiTemplateColorWheel: property not found: %s\n", propname);
return;
}
-
+
RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision);
col = uiLayoutColumn(layout, 0);
row= uiLayoutRow(col, 1);
- but= uiDefButR(block, HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, propname, -1, 0.0, 0.0, 0, lock, "");
+ but= uiDefButR(block, HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, propname, -1, 0.0, 0.0, 0, 0, "");
+
+ if(lock) {
+ but->flag |= UI_BUT_COLOR_LOCK;
+ }
if(lock_luminosity) {
float color[4]; /* incase of alpha */
but->flag |= UI_BUT_VEC_SIZE_LOCK;
RNA_property_float_get_array(ptr, prop, color);
- but->color_lum= len_v3(color); /* abuse the soft-max though this is a kind of soft-max */
+ but->a2= len_v3(color);
}
uiItemS(row);
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index b7a1874cd2b..5bebf71167d 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1656,10 +1656,10 @@ void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect)
rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
copy_v3_v3(hsvo, hsv);
- /* exception: if 'lock' is set (stored in but->a2),
+ /* exception: if 'lock' is set
* lock the value of the color wheel to 1.
* Useful for color correction tools where you're only interested in hue. */
- if (but->a2) hsv[2] = 1.f;
+ if (but->flag & UI_BUT_COLOR_LOCK) hsv[2] = 1.f;
hsv_to_rgb(0.f, 0.f, hsv[2], colcent, colcent+1, colcent+2);