column.separator()
col = column.column()
-
+
+ col.prop(system, "color_picker_type")
+
+ column.separator()
+
col.prop(system, "use_weight_color_range", text="Custom Weight Paint Range")
sub = col.column()
sub.active = system.use_weight_color_range
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)
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);
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;
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)
{
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 */
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);
/* 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
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);
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);
short glreslimit;
short ndof_pan, ndof_rotate;
short curssize, ipo_new;
+ short color_picker_type;
+ short pad2[3];
char versemaster[160];
char verseuser[160];
#define GP_PAINT_DOSMOOTH (1<<0)
#define GP_PAINT_DOSIMPLIFY (1<<1)
+/* color picker types */
+#define USER_CP_CIRCLE 0
+#define USER_CP_SQUARE_SV 1
+#define USER_CP_SQUARE_HS 2
+#define USER_CP_SQUARE_HV 3
+
/* theme drawtypes */
#define TH_MINIMAL 0
#define TH_ROUNDSHADED 1
RNA_def_property_range(prop, 4, 10);
RNA_def_property_ui_text(prop, "Object Origin Size", "Diameter in Pixels for Object/Lamp origin display.");
RNA_def_property_update(prop, 0, "rna_userdef_update");
-
-
}
static void rna_def_userdef_edit(BlenderRNA *brna)
{USER_ADD_VIEWALIGNED, "VIEW", 0, "View", "Align newly added objects to the world coordinates"},
{0, NULL, 0, NULL, NULL}};
-
srna= RNA_def_struct(brna, "UserPreferencesEdit", NULL);
RNA_def_struct_sdna(srna, "UserDef");
RNA_def_struct_nested(brna, srna, "UserPreferences");
RNA_def_property_enum_items(prop, new_interpolation_types);
RNA_def_property_enum_sdna(prop, NULL, "ipo_new");
RNA_def_property_ui_text(prop, "New Interpolation Type", "");
-
+
prop= RNA_def_property(srna, "grease_pencil_manhattan_distance", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "gp_manhattendist");
RNA_def_property_range(prop, 0, 100);
{USER_DRAW_OVERLAP, "OVERLAP", 0, "Overlap", "Redraw all overlapping regions, minimal memory usage but more redraws."},
{USER_DRAW_FULL, "FULL", 0, "Full", "Do a full redraw each time, slow, only use for reference or when all else fails."},
{0, NULL, 0, NULL, NULL}};
-
+
+ static EnumPropertyItem color_picker_types[] = {
+ {USER_CP_CIRCLE, "CIRCLE", 0, "Circle", "A circular Hue/Saturation color wheel, with Value slider"},
+ {USER_CP_SQUARE_SV, "SQUARE_SV", 0, "Square (SV + H)", "A square showing Saturation/Value, with Hue slider"},
+ {USER_CP_SQUARE_HS, "SQUARE_HS", 0, "Square (HS + V)", "A square showing Hue/Saturation, with Value slider"},
+ {USER_CP_SQUARE_HV, "SQUARE_HV", 0, "Square (HV + S)", "A square showing Hue/Value, with Saturation slider"},
+ {0, NULL, 0, NULL, NULL}};
+
/* hardcoded here, could become dynamic somehow */
static EnumPropertyItem language_items[] = {
{0, "ENGLISH", 0, "English", ""},
RNA_def_property_ui_text(prop, "Weight Color Range", "Color range used for weight visualization in weight painting mode.");
RNA_def_property_update(prop, 0, "rna_UserDef_weight_color_update");
+ prop= RNA_def_property(srna, "color_picker_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, color_picker_types);
+ RNA_def_property_enum_sdna(prop, NULL, "color_picker_type");
+ RNA_def_property_ui_text(prop, "Color Picker Type", "Different styles of displaying the color picker widget");
+
prop= RNA_def_property(srna, "enable_all_codecs", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_ALLWINCODECS);
RNA_def_property_ui_text(prop, "Enable All Codecs", "Enables automatic saving of preview images in the .blend file (Windows only).");