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-07 12:55:11 +0300
committerMatt Ebb <matt@mke3.net>2010-01-07 12:55:11 +0300
commitcf9b728c6a1cb600c721bea1823206047ab1c5c7 (patch)
tree981352c911d626f84da09010b00a50d0201524fe /source/blender/editors/interface/interface_templates.c
parent4463597dcd382a84be8a2a59e03adcfe149c23b2 (diff)
Color Picker work:
Restored the old Eyedropper tool from the 2.4 colour picker. Now it's an operator, working nicely using rna properties (fixes #19475 and some todo items) This ended up being a bit more work than expected, it involved converting the colour picker to use RNA properties directly, rather than temporary values. This has several advantages, including being able to type in RGB values greater than 1, however there are still some redraw issues with sliders. Also removed the alternate color pickers after this time spent testing, the current one should be sufficient, or alternatives to the wheel can possibly become preferences in the current design. Converting the picker to RNA also made it very trivial to make a cool new ColorWheel template, which can be embedded in UI layouts. I've enabled it already in texture/vertex paint brush properties and the sequence editor color correction: http://mke3.net/blender/devel/2.5/colorwheels.jpg
Diffstat (limited to 'source/blender/editors/interface/interface_templates.c')
-rw-r--r--source/blender/editors/interface/interface_templates.c45
1 files changed, 28 insertions, 17 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 6b36e60fa6c..b22fb279f37 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -1449,7 +1449,7 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand
if(coba->tot) {
CBData *cbd= coba->data + coba->cur;
-#if 1
+
/* better to use rna so we can animate them */
PointerRNA ptr;
RNA_pointer_create(cb->ptr.id.data, &RNA_ColorRampElement, cbd, &ptr);
@@ -1457,15 +1457,6 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand
//uiItemR(layout, NULL, 0, &ptr, "position", 0);
bt= uiDefButF(block, NUM, 0, "Pos:", 0+xoffs,40+yoffs,100, 20, &cbd->pos, 0.0, 1.0, 10, 0, "The position of the active color stop");
uiButSetNFunc(bt, colorband_pos_cb, MEM_dupallocN(cb), coba);
-
-#else
- bt= uiDefButF(block, NUM, 0, "Pos:", 0+xoffs,40+yoffs,100, 20, &cbd->pos, 0.0, 1.0, 10, 0, "The position of the active color stop");
- uiButSetNFunc(bt, colorband_pos_cb, MEM_dupallocN(cb), coba);
- bt= uiDefButF(block, COL, 0, "", 110+xoffs,40+yoffs,80,20, &(cbd->r), 0, 0, 0, B_BANDCOL, "The color value for the active color stop");
- uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
- bt= uiDefButF(block, NUMSLI, 0, "A ", 200+xoffs,40+yoffs,100,20, &cbd->a, 0.0, 1.0, 10, 0, "The alpha value of the active color stop");
- uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
-#endif
}
}
@@ -1484,16 +1475,9 @@ static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand
if(coba->tot) {
CBData *cbd= coba->data + coba->cur;
-#if 1
PointerRNA ptr;
RNA_pointer_create(cb->ptr.id.data, &RNA_ColorRampElement, cbd, &ptr);
uiItemR(layout, "", 0, &ptr, "color", 0);
-#else
- bt= uiDefButF(block, COL, 0, "", xs+4.0f*unit,butr->ymin+20.0f,2.0f*unit,20, &(cbd->r), 0, 0, 0, B_BANDCOL, "The color value for the active color stop");
- uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
- bt= uiDefButF(block, NUMSLI, 0, "A:", xs+6.0f*unit,butr->ymin+20.0f,4.0f*unit,20, &(cbd->a), 0.0f, 1.0f, 10, 2, "The alpha value of the active color stop");
- uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
-#endif
}
bt= uiDefButS(block, MENU, 0, "Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4",
@@ -1876,6 +1860,33 @@ void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, char *propname, i
MEM_freeN(cb);
}
+/********************* ColorWheel Template ************************/
+
+#define WHEEL_SIZE 100
+
+void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, char *propname, int value_slider)
+{
+ PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
+ uiBlock *block= uiLayoutGetBlock(layout);
+ uiLayout *row;
+
+ if (!prop) {
+ printf("uiTemplateColorWheel: property not found: %s\n", propname);
+ return;
+ }
+
+ row= uiLayoutRow(layout, 1);
+
+ uiDefButR(block, HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, propname, -1, 0.0, 0.0, 0, 0, "");
+
+ uiItemS(row);
+
+ if (value_slider)
+ uiDefButR(block, HSVCUBE, 0, "", WHEEL_SIZE+6, 0, 14, WHEEL_SIZE, ptr, propname, -1, 0.0, 0.0, 4, 0, "");
+
+}
+
+
/********************* TriColor (ThemeWireColorSet) Template ************************/
void uiTemplateTriColorSet(uiLayout *layout, PointerRNA *ptr, char *propname)