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:
authorCampbell Barton <ideasman42@gmail.com>2010-06-28 20:07:21 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-06-28 20:07:21 +0400
commitd40497480924dfb6d7f3413aae4280a95e3dd240 (patch)
treeebbcb4079479f6bc3d1d8791d3716d79218e74f5 /source/blender/editors/interface/interface_templates.c
parentb082401e88dcca4a511f1064af8db66470c3d9c9 (diff)
flip button for color ramps (durian request), these should be done as operators in a menu with copy/paste. added own todo.
Diffstat (limited to 'source/blender/editors/interface/interface_templates.c')
-rw-r--r--source/blender/editors/interface/interface_templates.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 70112e1fd09..52772aaf0e5 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -1333,6 +1333,29 @@ static void colorband_del_cb(bContext *C, void *cb_v, void *coba_v)
rna_update_cb(C, cb_v, NULL);
}
+static void colorband_flip_cb(bContext *C, void *cb_v, void *coba_v)
+{
+ CBData data_tmp[MAXCOLORBAND];
+
+ ColorBand *coba= coba_v;
+ int a;
+
+ for(a=0; a<coba->tot; a++) {
+ data_tmp[a]= coba->data[coba->tot - (a + 1)];
+ }
+ for(a=0; a<coba->tot; a++) {
+ data_tmp[a].pos = 1.0f - data_tmp[a].pos;
+ coba->data[a]= data_tmp[a];
+ }
+
+ /* may as well flip the cur*/
+ coba->cur= coba->tot - (coba->cur + 1);
+
+ ED_undo_push(C, "Flip colorband");
+
+ rna_update_cb(C, cb_v, NULL);
+}
+
/* offset aligns from bottom, standard width 300, height 115 */
static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand *coba, int xoffs, int yoffs, RNAUpdateCb *cb)
@@ -1343,12 +1366,17 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand
if(coba==NULL) return;
- bt= uiDefBut(block, BUT, 0, "Add", 0+xoffs,100+yoffs,50,20, 0, 0, 0, 0, 0, "Add a new color stop to the colorband");
+ bt= uiDefBut(block, BUT, 0, "Add", 0+xoffs,100+yoffs,40,20, 0, 0, 0, 0, 0, "Add a new color stop to the colorband");
uiButSetNFunc(bt, colorband_add_cb, MEM_dupallocN(cb), coba);
- bt= uiDefBut(block, BUT, 0, "Delete", 60+xoffs,100+yoffs,50,20, 0, 0, 0, 0, 0, "Delete the active position");
+ bt= uiDefBut(block, BUT, 0, "Delete", 45+xoffs,100+yoffs,45,20, 0, 0, 0, 0, 0, "Delete the active position");
uiButSetNFunc(bt, colorband_del_cb, MEM_dupallocN(cb), coba);
+
+ /* XXX, todo for later - convert to operator - campbell */
+ bt= uiDefBut(block, BUT, 0, "F", 95+xoffs,100+yoffs,20,20, 0, 0, 0, 0, 0, "Flip colorband");
+ uiButSetNFunc(bt, colorband_flip_cb, MEM_dupallocN(cb), coba);
+
uiDefButS(block, NUM, 0, "", 120+xoffs,100+yoffs,80, 20, &coba->cur, 0.0, (float)(MAX2(0, coba->tot-1)), 0, 0, "Choose active color stop");
bt= uiDefButS(block, MENU, 0, "Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4",
@@ -1359,6 +1387,8 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand
bt= uiDefBut(block, BUT_COLORBAND, 0, "", xoffs,65+yoffs,300,30, coba, 0, 0, 0, 0, "");
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
+
+
if(coba->tot) {
CBData *cbd= coba->data + coba->cur;
@@ -1381,8 +1411,10 @@ static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand
uiBlockBeginAlign(block);
bt= uiDefBut(block, BUT, 0, "Add", xs,butr->ymin+20.0f,2.0f*unit,20, NULL, 0, 0, 0, 0, "Add a new color stop to the colorband");
uiButSetNFunc(bt, colorband_add_cb, MEM_dupallocN(cb), coba);
- bt= uiDefBut(block, BUT, 0, "Delete", xs+2.0f*unit,butr->ymin+20.0f,2.0f*unit,20, NULL, 0, 0, 0, 0, "Delete the active position");
+ bt= uiDefBut(block, BUT, 0, "Delete", xs+2.0f*unit,butr->ymin+20.0f,1.5f*unit,20, NULL, 0, 0, 0, 0, "Delete the active position");
uiButSetNFunc(bt, colorband_del_cb, MEM_dupallocN(cb), coba);
+ bt= uiDefBut(block, BUT, 0, "F", xs+3.5f*unit,butr->ymin+20.0f,0.5f*unit,20, NULL, 0, 0, 0, 0, "Flip the color ramp");
+ uiButSetNFunc(bt, colorband_flip_cb, MEM_dupallocN(cb), coba);
uiBlockEndAlign(block);
if(coba->tot) {