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
diff options
context:
space:
mode:
authorMatt Ebb <matt@mke3.net>2010-01-09 09:44:54 +0300
committerMatt Ebb <matt@mke3.net>2010-01-09 09:44:54 +0300
commit3564eb7763b2c6ea0410c47e06773c5b456f2b63 (patch)
treeb2bbc70eb191e0dfeb1935e64a6d0e163ac40e5b /source/blender/editors
parentd2b27d00ff1f0f937d5b19a81aa50850af7b0fbe (diff)
Added user preferences for color picker type, includes colour wheel + 3 square types.
Find it in prefs -> system
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/interface/interface_handlers.c18
-rw-r--r--source/blender/editors/interface/interface_regions.c69
-rw-r--r--source/blender/editors/interface/interface_widgets.c68
3 files changed, 117 insertions, 38 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 597f5a9d8cd..916a48b7442 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -2711,21 +2711,27 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
CLAMP(y, 0.0, 1.0);
if(but->a1==0) {
- hsv[0]= x;
- hsv[2]= y;
+ hsv[2]= x;
+ hsv[1]= y;
}
else if(but->a1==1) {
hsv[0]= x;
- hsv[1]= y;
+ hsv[2]= y;
}
else if(but->a1==2) {
- hsv[2]= x;
+ hsv[0]= x;
hsv[1]= y;
}
else if(but->a1==3) {
hsv[0]= x;
}
- else {
+ else if(but->a1==4) {
+ hsv[1]= x;
+ }
+ else if(but->a1==5) {
+ hsv[2]= x;
+ }
+ else if (but->a1==9){
/* vertical 'value' strip */
hsv[2]= y;
if (color_profile)
@@ -3791,7 +3797,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
retval= ui_do_but_BUT(C, but, data, event);
break;
case COL:
- if(but->a1 == -1) // signal to prevent calling up color picker
+ if(but->a1 == 9) // signal to prevent calling up color picker
retval= ui_do_but_EXIT(C, but, data, event);
else
retval= ui_do_but_BLOCK(C, but, data, event);
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index d4302aa9c52..c7ea06e2166 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -1647,10 +1647,6 @@ static void close_popup_cb(bContext *C, void *bt1, void *arg)
popup->menuretval= UI_RETURN_OK;
}
-/* picker sizes S hsize, F full size, D spacer, B button/pallette height */
-#define SPICK1 150.0
-#define DPICK1 6.0
-
static void picker_new_hide_reveal(uiBlock *block, short colormode)
{
uiBut *bt;
@@ -1682,6 +1678,46 @@ static void do_picker_new_mode_cb(bContext *C, void *bt1, void *colv)
picker_new_hide_reveal(bt->block, colormode);
}
+/* picker sizes S hsize, F full size, D spacer, B button/pallette height */
+#define SPICK1 150.0
+#define DPICK1 6.0
+
+#define PICKER_H 150
+#define PICKER_W 150
+#define PICKER_SPACE 6
+#define PICKER_BAR 14
+
+#define PICKER_TOTAL_W (PICKER_W+PICKER_SPACE+PICKER_BAR)
+
+static void circle_picker(uiBlock *block, PointerRNA *ptr, const char *propname)
+{
+ uiBut *bt;
+
+ /* HS circle */
+ bt= uiDefButR(block, HSVCIRCLE, 0, "", 0, 0, PICKER_H, PICKER_W, ptr, propname, -1, 0.0, 0.0, 0, 0, "");
+ uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
+
+ /* value */
+ uiDefButR(block, HSVCUBE, 0, "", PICKER_W+PICKER_SPACE,0,PICKER_BAR,PICKER_H, ptr, propname, -1, 0.0, 0.0, 9, 0, "");
+ uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
+}
+
+
+static void square_picker(uiBlock *block, PointerRNA *ptr, const char *propname, int type)
+{
+ uiBut *bt;
+ int bartype = type + 3;
+
+ /* HS square */
+ bt= uiDefButR(block, HSVCUBE, 0, "", 0, PICKER_BAR+PICKER_SPACE, PICKER_TOTAL_W, PICKER_H, ptr, propname, -1, 0.0, 0.0, type, 0, "");
+ uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
+
+ /* value */
+ uiDefButR(block, HSVCUBE, 0, "", 0, 0, PICKER_TOTAL_W, PICKER_BAR, ptr, propname, -1, 0.0, 0.0, bartype, 0, "");
+ uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
+}
+
+
/* a HS circle, V slider, rgb/hsv/hex sliders */
static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyRNA *prop)
{
@@ -1693,7 +1729,7 @@ static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyR
static char hexcol[128];
const char *propname = RNA_property_identifier(prop);
- width= (SPICK1+DPICK1+14);
+ width= PICKER_TOTAL_W;
butwidth = width - UI_UNIT_X - 10;
/* existence of profile means storage is in linear colour space, with display correction */
@@ -1704,14 +1740,21 @@ static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyR
RNA_property_float_get_array(ptr, prop, rgb);
rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
-
- /* HS circle */
- bt= uiDefButR(block, HSVCIRCLE, 0, "", 0, 0, SPICK1, SPICK1, ptr, propname, -1, 0.0, 0.0, 0, 0, "");
- uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
-
- /* value */
- uiDefButR(block, HSVCUBE, 0, "", SPICK1+DPICK1,0,14,SPICK1, ptr, propname, -1, 0.0, 0.0, 4, 0, "");
- uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
+
+ switch (U.color_picker_type) {
+ case USER_CP_CIRCLE:
+ circle_picker(block, ptr, propname);
+ break;
+ case USER_CP_SQUARE_SV:
+ square_picker(block, ptr, propname, 0);
+ break;
+ case USER_CP_SQUARE_HS:
+ square_picker(block, ptr, propname, 1);
+ break;
+ case USER_CP_SQUARE_HV:
+ square_picker(block, ptr, propname, 2);
+ break;
+ }
/* mode */
uiBlockBeginAlign(block);
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 7b251b2d22e..82c79c32c6c 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1616,34 +1616,52 @@ static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect)
/* draw series of gouraud rects */
glShadeModel(GL_SMOOTH);
- if(but->a1==0) { // H and V vary
+
+ if(but->a1==0) { // S and V vary
+ hsv_to_rgb(h, 0.0, 0.0, &col1[0][0], &col1[0][1], &col1[0][2]);
+ hsv_to_rgb(h, 0.333, 0.0, &col1[1][0], &col1[1][1], &col1[1][2]);
+ hsv_to_rgb(h, 0.666, 0.0, &col1[2][0], &col1[2][1], &col1[2][2]);
+ hsv_to_rgb(h, 1.0, 0.0, &col1[3][0], &col1[3][1], &col1[3][2]);
+ x= v; y= s;
+ }
+ else if(but->a1==1) { // H and V vary
hsv_to_rgb(0.0, s, 0.0, &col1[0][0], &col1[0][1], &col1[0][2]);
hsv_to_rgb(0.0, s, 0.333, &col1[1][0], &col1[1][1], &col1[1][2]);
hsv_to_rgb(0.0, s, 0.666, &col1[2][0], &col1[2][1], &col1[2][2]);
hsv_to_rgb(0.0, s, 1.0, &col1[3][0], &col1[3][1], &col1[3][2]);
x= h; y= v;
}
- else if(but->a1==1) { // H and S vary
+ else if(but->a1==2) { // H and S vary
hsv_to_rgb(0.0, 0.0, v, &col1[0][0], &col1[0][1], &col1[0][2]);
hsv_to_rgb(0.0, 0.333, v, &col1[1][0], &col1[1][1], &col1[1][2]);
hsv_to_rgb(0.0, 0.666, v, &col1[2][0], &col1[2][1], &col1[2][2]);
hsv_to_rgb(0.0, 1.0, v, &col1[3][0], &col1[3][1], &col1[3][2]);
x= h; y= s;
}
- else if(but->a1==2) { // S and V vary
- hsv_to_rgb(h, 0.0, 0.0, &col1[0][0], &col1[0][1], &col1[0][2]);
- hsv_to_rgb(h, 0.333, 0.0, &col1[1][0], &col1[1][1], &col1[1][2]);
- hsv_to_rgb(h, 0.666, 0.0, &col1[2][0], &col1[2][1], &col1[2][2]);
- hsv_to_rgb(h, 1.0, 0.0, &col1[3][0], &col1[3][1], &col1[3][2]);
- x= v; y= s;
- }
- else if(but->a1==3) { // only hue slider
+ else if(but->a1==3) { // only H
hsv_to_rgb(0.0, 1.0, 1.0, &col1[0][0], &col1[0][1], &col1[0][2]);
VECCOPY(col1[1], col1[0]);
VECCOPY(col1[2], col1[0]);
VECCOPY(col1[3], col1[0]);
x= h; y= 0.5;
}
+ else if(but->a1==4) { // only S
+ hsv_to_rgb(1.0, 0.0, 1.0, &col1[1][0], &col1[1][1], &col1[1][2]);
+ VECCOPY(col1[0], col1[1]);
+ VECCOPY(col1[2], col1[1]);
+ VECCOPY(col1[3], col1[1]);
+ x= s; y= 0.5;
+ }
+ else if(but->a1==5) { // only V
+ hsv_to_rgb(1.0, 1.0, 0.0, &col1[2][0], &col1[2][1], &col1[2][2]);
+ VECCOPY(col1[0], col1[2]);
+ VECCOPY(col1[1], col1[2]);
+ VECCOPY(col1[3], col1[2]);
+ x= v; y= 0.5;
+ }
+
+
+ /* old below */
for(dx=0.0; dx<1.0; dx+= 0.05) {
// previous color
@@ -1653,30 +1671,42 @@ static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect)
VECCOPY(col0[3], col1[3]);
// new color
- if(but->a1==0) { // H and V vary
+ if(but->a1==0) { // S and V vary
+ hsv_to_rgb(h, 0.0, dx, &col1[0][0], &col1[0][1], &col1[0][2]);
+ hsv_to_rgb(h, 0.333, dx, &col1[1][0], &col1[1][1], &col1[1][2]);
+ hsv_to_rgb(h, 0.666, dx, &col1[2][0], &col1[2][1], &col1[2][2]);
+ hsv_to_rgb(h, 1.0, dx, &col1[3][0], &col1[3][1], &col1[3][2]);
+ }
+ else if(but->a1==1) { // H and V vary
hsv_to_rgb(dx, s, 0.0, &col1[0][0], &col1[0][1], &col1[0][2]);
hsv_to_rgb(dx, s, 0.333, &col1[1][0], &col1[1][1], &col1[1][2]);
hsv_to_rgb(dx, s, 0.666, &col1[2][0], &col1[2][1], &col1[2][2]);
hsv_to_rgb(dx, s, 1.0, &col1[3][0], &col1[3][1], &col1[3][2]);
}
- else if(but->a1==1) { // H and S vary
+ else if(but->a1==2) { // H and S vary
hsv_to_rgb(dx, 0.0, v, &col1[0][0], &col1[0][1], &col1[0][2]);
hsv_to_rgb(dx, 0.333, v, &col1[1][0], &col1[1][1], &col1[1][2]);
hsv_to_rgb(dx, 0.666, v, &col1[2][0], &col1[2][1], &col1[2][2]);
hsv_to_rgb(dx, 1.0, v, &col1[3][0], &col1[3][1], &col1[3][2]);
}
- else if(but->a1==2) { // S and V vary
- hsv_to_rgb(h, 0.0, dx, &col1[0][0], &col1[0][1], &col1[0][2]);
- hsv_to_rgb(h, 0.333, dx, &col1[1][0], &col1[1][1], &col1[1][2]);
- hsv_to_rgb(h, 0.666, dx, &col1[2][0], &col1[2][1], &col1[2][2]);
- hsv_to_rgb(h, 1.0, dx, &col1[3][0], &col1[3][1], &col1[3][2]);
- }
else if(but->a1==3) { // only H
hsv_to_rgb(dx, 1.0, 1.0, &col1[0][0], &col1[0][1], &col1[0][2]);
VECCOPY(col1[1], col1[0]);
VECCOPY(col1[2], col1[0]);
VECCOPY(col1[3], col1[0]);
}
+ else if(but->a1==4) { // only S
+ hsv_to_rgb(h, dx, 1.0, &col1[1][0], &col1[1][1], &col1[1][2]);
+ VECCOPY(col1[0], col1[1]);
+ VECCOPY(col1[2], col1[1]);
+ VECCOPY(col1[3], col1[1]);
+ }
+ else if(but->a1==5) { // only V
+ hsv_to_rgb(h, 1.0, dx, &col1[2][0], &col1[2][1], &col1[2][2]);
+ VECCOPY(col1[0], col1[2]);
+ VECCOPY(col1[1], col1[2]);
+ VECCOPY(col1[3], col1[2]);
+ }
// rect
sx1= rect->xmin + dx*(rect->xmax-rect->xmin);
@@ -2589,7 +2619,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
break;
case HSVCUBE:
- if(but->a1==4) // vertical V slider, uses new widget draw now
+ if(but->a1==9) // vertical V slider, uses new widget draw now
ui_draw_but_HSV_v(but, rect);
else // other HSV pickers...
ui_draw_but_HSVCUBE(but, rect);