[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29772] trunk/blender/source/blender/ editors/interface/interface_templates.c: flip button for color ramps ( durian request), these should be done as operators in a menu with copy/ paste.

Campbell Barton ideasman42 at gmail.com
Mon Jun 28 18:07:21 CEST 2010


Revision: 29772
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29772
Author:   campbellbarton
Date:     2010-06-28 18:07:21 +0200 (Mon, 28 Jun 2010)

Log Message:
-----------
flip button for color ramps (durian request), these should be done as operators in a menu with copy/paste. added own todo.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface_templates.c

Modified: trunk/blender/source/blender/editors/interface/interface_templates.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_templates.c	2010-06-28 15:29:18 UTC (rev 29771)
+++ trunk/blender/source/blender/editors/interface/interface_templates.c	2010-06-28 16:07:21 UTC (rev 29772)
@@ -1333,7 +1333,30 @@
 	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 @@
 
 	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 @@
 	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 @@
 	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) {





More information about the Bf-blender-cvs mailing list