[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21327] branches/soc-2009-aligorith/source /blender/editors/animation/fmodifier_ui.c: NLA SoC: UI-Drawing for Generator and Envelope FModifiers Restored

Joshua Leung aligorith at gmail.com
Fri Jul 3 01:27:11 CEST 2009


Revision: 21327
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21327
Author:   aligorith
Date:     2009-07-03 01:27:11 +0200 (Fri, 03 Jul 2009)

Log Message:
-----------
NLA SoC: UI-Drawing for Generator and Envelope FModifiers Restored

These now use a hybrid drawing approach - using the layout engine for just layouts, but still mostly using old-style buttons in many places where button callbacks and/or special data-access methods are needed (or where RNA wrapping isn't in place yet).

Modified Paths:
--------------
    branches/soc-2009-aligorith/source/blender/editors/animation/fmodifier_ui.c

Modified: branches/soc-2009-aligorith/source/blender/editors/animation/fmodifier_ui.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/animation/fmodifier_ui.c	2009-07-02 22:22:35 UTC (rev 21326)
+++ branches/soc-2009-aligorith/source/blender/editors/animation/fmodifier_ui.c	2009-07-02 23:27:11 UTC (rev 21327)
@@ -136,24 +136,23 @@
 /* draw settings for generator modifier */
 static void draw_modifier__generator(uiLayout *layout, FModifier *fcm, short width)
 {
-	// XXX TEMP WARNING
-	uiItemL(layout, "Generator FModifier UI not yet implemented again", ICON_ERROR);
-	
-#if 0 // TODO: port to the new system
 	FMod_Generator *data= (FMod_Generator *)fcm->data;
-	uiBlock *block= uiLayoutGetBlock(layout);
-	char gen_mode[]="Generator Type%t|Expanded Polynomial%x0|Factorised Polynomial%x1";
-	int cy= yco - 30;
+	uiLayout *col, *row;
+	uiBlock *block;
 	uiBut *but;
+	PointerRNA ptr;
 	
+	/* init the RNA-pointer */
+	RNA_pointer_create(NULL, &RNA_FModifierFunctionGenerator, fcm, &ptr);
+	
 	/* basic settings (backdrop + mode selector + some padding) */
+	col= uiLayoutColumn(layout, 1);
+	block= uiLayoutGetBlock(layout);
 	uiBlockBeginAlign(block);
-		but= uiDefButI(block, MENU, B_FMODIFIER_REDRAW, gen_mode, 10,cy,width-30,19, &data->mode, 0, 0, 0, 0, "Selects type of generator algorithm.");
+		but= uiDefButR(block, MENU, B_FMODIFIER_REDRAW, NULL, 0, 0, width-30, UI_UNIT_Y, &ptr, "mode", -1, 0, 0, -1, -1, NULL);
 		uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL);
-		cy -= 20;
 		
-		uiDefButBitI(block, TOG, FCM_GENERATOR_ADDITIVE, B_FMODIFIER_REDRAW, "Additive", 10,cy,width-30,19, &data->flag, 0, 0, 0, 0, "Values generated by this modifier are applied on top of the existing values instead of overwriting them");
-		cy -= 35;
+		uiDefButR(block, TOG, B_FMODIFIER_REDRAW, NULL, 0, 0, width-30, UI_UNIT_Y, &ptr, "additive", -1, 0, 0, -1, -1, NULL);
 	uiBlockEndAlign(block);
 	
 	/* now add settings for individual modes */
@@ -165,31 +164,38 @@
 			unsigned int i;
 			
 			/* draw polynomial order selector */
-			but= uiDefButI(block, NUM, B_FMODIFIER_REDRAW, "Poly Order: ", 10,cy,width-30,19, &data->poly_order, 1, 100, 0, 0, "'Order' of the Polynomial - for a polynomial with n terms, 'order' is n-1");
-			uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL);
-			cy -= 35;
+			row= uiLayoutRow(layout, 0);
+			block= uiLayoutGetBlock(row);
+				but= uiDefButI(block, NUM, B_FMODIFIER_REDRAW, "Poly Order: ", 10,0,width-30,19, &data->poly_order, 1, 100, 0, 0, "'Order' of the Polynomial - for a polynomial with n terms, 'order' is n-1");
+				uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL);
 			
+			
 			/* draw controls for each coefficient and a + sign at end of row */
-			uiDefBut(block, LABEL, 1, "y = ", 0, cy, 50, 20, NULL, 0.0, 0.0, 0, 0, "");
+			row= uiLayoutRow(layout, 1);
+			block= uiLayoutGetBlock(row);
+				uiDefBut(block, LABEL, 1, "y = ", 0, 0, 50, 20, NULL, 0.0, 0.0, 0, 0, "");
 			
 			cp= data->coefficients;
 			for (i=0; (i < data->arraysize) && (cp); i++, cp++) {
 				/* coefficient */
-				uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 50, cy, 150, 20, cp, -UI_FLT_MAX, UI_FLT_MAX, 10, 3, "Coefficient for polynomial");
+				uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 0, 0, 150, 20, cp, -UI_FLT_MAX, UI_FLT_MAX, 10, 3, "Coefficient for polynomial");
 				
 				/* 'x' param (and '+' if necessary) */
-				if (i == 0)
-					strcpy(xval, "");
-				else if (i == 1)
-					strcpy(xval, "x");
-				else
-					sprintf(xval, "x^%d", i);
-				uiDefBut(block, LABEL, 1, xval, 200, cy, 50, 20, NULL, 0.0, 0.0, 0, 0, "Power of x");
+				if (i) {
+					if (i == 1)
+						strcpy(xval, "x");
+					else
+						sprintf(xval, "x^%d", i);
+					uiDefBut(block, LABEL, 1, xval, 0, 0, 50, 20, NULL, 0.0, 0.0, 0, 0, "Power of x");
+				}
 				
-				if ( (i != (data->arraysize - 1)) || ((i==0) && data->arraysize==2) )
-					uiDefBut(block, LABEL, 1, "+", 250, cy, 30, 20, NULL, 0.0, 0.0, 0, 0, "");
-				
-				cy -= 20;
+				if ( (i != (data->arraysize - 1)) || ((i==0) && data->arraysize==2) ) {
+					uiDefBut(block, LABEL, 1, "+", 0,0 , 30, 20, NULL, 0.0, 0.0, 0, 0, "");
+					
+					/* next coefficient on a new row */
+					row= uiLayoutRow(layout, 1);
+					block= uiLayoutGetBlock(row);
+				}
 			}
 		}
 			break;
@@ -200,37 +206,43 @@
 			unsigned int i;
 			
 			/* draw polynomial order selector */
-			but= uiDefButI(block, NUM, B_FMODIFIER_REDRAW, "Poly Order: ", 10,cy,width-30,19, &data->poly_order, 1, 100, 0, 0, "'Order' of the Polynomial - for a polynomial with n terms, 'order' is n-1");
-			uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL);
-			cy -= 35;
+			row= uiLayoutRow(layout, 0);
+			block= uiLayoutGetBlock(row);
+				but= uiDefButI(block, NUM, B_FMODIFIER_REDRAW, "Poly Order: ", 0,0,width-30,19, &data->poly_order, 1, 100, 0, 0, "'Order' of the Polynomial - for a polynomial with n terms, 'order' is n-1");
+				uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL);
 			
+			
 			/* draw controls for each pair of coefficients */
-			uiDefBut(block, LABEL, 1, "y = ", 0, cy, 50, 20, NULL, 0.0, 0.0, 0, 0, "");
+			row= uiLayoutRow(layout, 1);
+			block= uiLayoutGetBlock(row);
+				uiDefBut(block, LABEL, 1, "y = ", 0, 0, 50, 20, NULL, 0.0, 0.0, 0, 0, "");
 			
 			cp= data->coefficients;
 			for (i=0; (i < data->poly_order) && (cp); i++, cp+=2) {
 				/* opening bracket */
-				uiDefBut(block, LABEL, 1, "(", 40, cy, 50, 20, NULL, 0.0, 0.0, 0, 0, "");
+				uiDefBut(block, LABEL, 1, "(", 0, 0, 20, 20, NULL, 0.0, 0.0, 0, 0, "");
 				
 				/* coefficients */
-				uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 50, cy, 100, 20, cp, -UI_FLT_MAX, UI_FLT_MAX, 10, 3, "Coefficient of x");
+				uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 0, 0, 100, 20, cp, -UI_FLT_MAX, UI_FLT_MAX, 10, 3, "Coefficient of x");
 				
-				uiDefBut(block, LABEL, 1, "x + ", 150, cy, 30, 20, NULL, 0.0, 0.0, 0, 0, "");
+				uiDefBut(block, LABEL, 1, "x + ", 0, 0, 40, 20, NULL, 0.0, 0.0, 0, 0, "");
 				
-				uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 180, cy, 100, 20, cp+1, -UI_FLT_MAX, UI_FLT_MAX, 10, 3, "Second coefficient");
+				uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 0, 0, 100, 20, cp+1, -UI_FLT_MAX, UI_FLT_MAX, 10, 3, "Second coefficient");
 				
 				/* closing bracket and '+' sign */
-				if ( (i != (data->poly_order - 1)) || ((i==0) && data->poly_order==2) )
-					uiDefBut(block, LABEL, 1, ") ?", 280, cy, 30, 20, NULL, 0.0, 0.0, 0, 0, "");
-				else
-					uiDefBut(block, LABEL, 1, ")", 280, cy, 30, 20, NULL, 0.0, 0.0, 0, 0, "");
-				
-				cy -= 20;
+				if ( (i != (data->poly_order - 1)) || ((i==0) && data->poly_order==2) ) {
+					uiDefBut(block, LABEL, 1, ") +", 0, 0, 30, 20, NULL, 0.0, 0.0, 0, 0, "");
+					
+					/* set up new row for the next pair of coefficients*/
+					row= uiLayoutRow(layout, 1);
+					block= uiLayoutGetBlock(row);
+				}
+				else 
+					uiDefBut(block, LABEL, 1, ")", 0, 0, 20, 20, NULL, 0.0, 0.0, 0, 0, "");
 			}
 		}
 			break;
 	}
-#endif 
 }
 
 /* --------------- */
@@ -469,51 +481,54 @@
 /* draw settings for envelope modifier */
 static void draw_modifier__envelope(uiLayout *layout, FModifier *fcm, short width)
 {
-	uiItemL(layout, "Envelope FModifier UI not yet recoded in layout engine", ICON_ERROR);
-#if 0 // XXX FIXME: recode in new layout style
 	FMod_Envelope *env= (FMod_Envelope *)fcm->data;
 	FCM_EnvelopeData *fed;
-	uiBlock *block= uiLayoutGetBlock(layout);
+	uiLayout *col, *row;
+	uiBlock *block;
 	uiBut *but;
-	int cy= (yco - 28);
+	PointerRNA ptr;
 	int i;
 	
-	/* General Settings */
-	uiDefBut(block, LABEL, 1, "Envelope:", 10, cy, 100, 20, NULL, 0.0, 0.0, 0, 0, "Settings for cycling before first keyframe");
-	cy -= 20;
+	/* init the RNA-pointer */
+	RNA_pointer_create(NULL, &RNA_FModifierEnvelope, fcm, &ptr);
 	
-	uiBlockBeginAlign(block);
-		uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "Reference Val:", 10, cy, 300, 20, &env->midval, -UI_FLT_MAX, UI_FLT_MAX, 10, 3, "");
-		cy -= 20;
+	/* general settings */
+	col= uiLayoutColumn(layout, 1);
+		uiItemL(col, "Envelope:", 0);
+		uiItemR(col, NULL, 0, &ptr, "reference_value", 0, 0, 0);
 		
-		uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "Min:", 10, cy, 150, 20, &env->min, -UI_FLT_MAX, env->max, 10, 3, "Minimum value (relative to Reference Value) that is used as the 'normal' minimum value");
-		uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "Max:", 160, cy, 150, 20, &env->max, env->min, UI_FLT_MAX, 10, 3, "Maximum value (relative to Reference Value) that is used as the 'normal' maximum value");
-		cy -= 35;
-	uiBlockEndAlign(block);
-	
-	
-	/* Points header */
-	uiDefBut(block, LABEL, 1, "Control Points:", 10, cy, 150, 20, NULL, 0.0, 0.0, 0, 0, "");
-	
-	but= uiDefBut(block, BUT, B_FMODIFIER_REDRAW, "Add Point", 160,cy,150,19, NULL, 0, 0, 0, 0, "Adds a new control-point to the envelope on the current frame");
-	uiButSetFunc(but, fmod_envelope_addpoint_cb, env, NULL);
-	cy -= 35;
-	
-	/* Points List */
+		row= uiLayoutRow(col, 1);
+			uiItemR(row, "Min", 0, &ptr, "default_minimum", 0, 0, 0);
+			uiItemR(row, "Max", 0, &ptr, "default_maximum", 0, 0, 0);
+			
+	/* control points header */
+	// TODO: move this control-point control stuff to using the new special widgets for lists
+	// the current way is far too cramped
+	row= uiLayoutRow(layout, 0);
+	block= uiLayoutGetBlock(row);
+		
+		uiDefBut(block, LABEL, 1, "Control Points:", 0, 0, 150, 20, NULL, 0.0, 0.0, 0, 0, "");
+		
+		but= uiDefBut(block, BUT, B_FMODIFIER_REDRAW, "Add Point", 0,0,150,19, NULL, 0, 0, 0, 0, "Adds a new control-point to the envelope on the current frame");
+		uiButSetFunc(but, fmod_envelope_addpoint_cb, env, NULL);
+		
+	/* control points list */
 	for (i=0, fed=env->data; i < env->totvert; i++, fed++) {
+		/* get a new row to operate on */
+		row= uiLayoutRow(layout, 1);
+		block= uiLayoutGetBlock(row);
+		
 		uiBlockBeginAlign(block);
-			but=uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "Fra:", 2, cy, 90, 20, &fed->time, -UI_FLT_MAX, UI_FLT_MAX, 10, 1, "Frame that envelope point occurs");
+			but=uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "Fra:", 0, 0, 90, 20, &fed->time, -UI_FLT_MAX, UI_FLT_MAX, 10, 1, "Frame that envelope point occurs");
 			uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL);
 			
-			uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "Min:", 92, cy, 100, 20, &fed->min, -UI_FLT_MAX, UI_FLT_MAX, 10, 2, "Minimum bound of envelope at this point");

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list