Revision: 21318
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21318
Author:   aligorith
Date:     2009-07-02 14:41:03 +0200 (Thu, 02 Jul 2009)

Log Message:
-----------
NLA SoC: FModifier drawing converted to use Layout Engine

* Most of the F-Modifiers have been ported to use the layout engine + RNA for 
drawing their buttons now. This plays much nicer with various button-layouts.
--> As a nice demo, try adding a Noise Modifier to a NLA-strip, and change the 
'size' setting to about 2 to see some effects.

* Generator and Envelope modifiers haven't been ported yet since they're quite 
complex (requiring more time + energy), and as such, have been made to have 
some temporary error prints instead. Will check on this tomorrow.

* Finished/cleaned up the RNA-wrapping of most FModifiers. 


TODO's (help requested... Brecht?):
Generator modifier's UI cannot be wrapped yet using the layout engine (though I 
might try using the old system only), as I'm having some trouble wrapping the 
coefficients array for this (see rna_fcurve.c - rna_def_fmodifier_generator())

Modified Paths:
--------------
    branches/soc-2009-aligorith/source/blender/editors/animation/fmodifier_ui.c
    branches/soc-2009-aligorith/source/blender/editors/include/ED_anim_api.h
    
branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_buttons.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_buttons.c
    branches/soc-2009-aligorith/source/blender/makesrna/RNA_access.h
    branches/soc-2009-aligorith/source/blender/makesrna/intern/rna_fcurve.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 12:35:46 UTC (rev 21317)
+++ branches/soc-2009-aligorith/source/blender/editors/animation/fmodifier_ui.c 
2009-07-02 12:41:03 UTC (rev 21318)
@@ -97,7 +97,7 @@
 // XXX for now, roundbox has it's callback func set to NULL to not intercept 
events
 #define DRAW_BACKDROP(height) \
        { \
-               uiDefBut(block, ROUNDBOX, B_REDR, "", -3, *yco-height, width+3, 
height-1, NULL, 5.0, 0.0, 12.0, (float)rb_col, ""); \
+               uiDefBut(block, ROUNDBOX, B_REDR, "", -3, yco-height, width+3, 
height-1, NULL, 5.0, 0.0, 12.0, (float)rb_col, ""); \
        }
 
 /* callback to verify modifier data */
@@ -134,26 +134,19 @@
 /* --------------- */
        
 /* draw settings for generator modifier */
-static void draw_modifier__generator(uiBlock *block, FModifier *fcm, int *yco, 
short *height, short width, short active, int rb_col)
+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;
+       int cy= yco - 30;
        uiBut *but;
        
-       /* set the height */
-       (*height) = 90;
-       switch (data->mode) {
-               case FCM_GENERATOR_POLYNOMIAL: /* polynomial expression */
-                       (*height) += 20*(data->poly_order+1) + 20;
-                       break;
-               case FCM_GENERATOR_POLYNOMIAL_FACTORISED: /* factorised 
polynomial */
-                       (*height) += 20 * data->poly_order + 15;
-                       break;
-       }
-       
        /* basic settings (backdrop + mode selector + some padding) */
-       DRAW_BACKDROP((*height));
        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.");
                uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL);
@@ -237,97 +230,79 @@
                }
                        break;
        }
+#endif 
 }
 
 /* --------------- */
 
 /* draw settings for noise modifier */
-static void draw_modifier__fn_generator(uiBlock *block, FModifier *fcm, int 
*yco, short *height, short width, short active, int rb_col)
+static void draw_modifier__fn_generator(uiLayout *layout, FModifier *fcm, 
short width)
 {
-       FMod_FunctionGenerator *data= (FMod_FunctionGenerator *)fcm->data;
-       int cy= (*yco - 30), cy1= (*yco - 50), cy2= (*yco - 70);
-       char fn_type[]="Built-In Function%t|Sin%x0|Cos%x1|Tan%x2|Square 
Root%x3|Natural Log%x4|Normalised Sin%x5";
+       uiLayout *col= uiLayoutColumn(layout, 0); // no grouping for now
+       PointerRNA ptr;
        
-       /* set the height */
-       (*height) = 80;
+       /* init the RNA-pointer */
+       RNA_pointer_create(NULL, &RNA_FModifierFunctionGenerator, fcm, &ptr);
        
-       /* basic settings (backdrop + some padding) */
-       DRAW_BACKDROP((*height));
-       
-       uiDefButI(block, MENU, B_FMODIFIER_REDRAW, fn_type,
-                         3, cy, 300, 20, &data->type, 0, 0, 0, 0, "Type of 
function used to generate values");
-       
-       
-       uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "Amplitude:", 
-                         3, cy1, 150, 20, &data->amplitude, 0.000001, 10000.0, 
0.01, 3, "Scale factor determining the maximum/minimum values.");
-       uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "Value Offset:", 
-                         3, cy2, 150, 20, &data->value_offset, 0.0, 10000.0, 
0.01, 3, "Constant factor to offset values by.");
-       
-       uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "Phase Multiplier:", 
-                         155, cy1, 150, 20, &data->phase_multiplier, 0.0, 
100000.0, 0.1, 3, "Scale factor determining the 'speed' of the function.");
-       uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "Phase Offset:", 
-                         155, cy2, 150, 20, &data->phase_offset, 0.0, 
100000.0, 0.1, 3, "Constant factor to offset time by for function.");
-
+       /* add the settings */
+       uiItemR(col, NULL, 0, &ptr, "amplitude", 0, 0, 0);
+       uiItemR(col, NULL, 0, &ptr, "phase_multiplier", 0, 0, 0);
+       uiItemR(col, NULL, 0, &ptr, "phase_offset", 0, 0, 0);
+       uiItemR(col, NULL, 0, &ptr, "value_offset", 0, 0, 0);
 }
 
 /* --------------- */
 
 /* draw settings for cycles modifier */
-static void draw_modifier__cycles(uiBlock *block, FModifier *fcm, int *yco, 
short *height, short width, short active, int rb_col)
+static void draw_modifier__cycles(uiLayout *layout, FModifier *fcm, short 
width)
 {
-       FMod_Cycles *data= (FMod_Cycles *)fcm->data;
-       char cyc_mode[]="Cycling Mode%t|No Cycles%x0|Repeat Motion%x1|Repeat 
with Offset%x2|Repeat Mirrored%x3";
-       int cy= (*yco - 30), cy1= (*yco - 50), cy2= (*yco - 70);
+       uiLayout *split, *col;
+       PointerRNA ptr;
        
-       /* set the height */
-       (*height) = 80;
+       /* init the RNA-pointer */
+       RNA_pointer_create(NULL, &RNA_FModifierCycles, fcm, &ptr);
        
-       /* basic settings (backdrop + some padding) */
-       DRAW_BACKDROP((*height));
+       /* split into 2 columns 
+        * NOTE: the mode comboboxes shouldn't get labels, otherwise there 
isn't enough room
+        */
+       split= uiLayoutSplit(layout, 0.5f);
        
-       /* 'before' range */
-       uiDefBut(block, LABEL, 1, "Before:", 4, cy, 80, 20, NULL, 0.0, 0.0, 0, 
0, "Settings for cycling before first keyframe");
-       uiBlockBeginAlign(block);
-               uiDefButS(block, MENU, B_FMODIFIER_REDRAW, cyc_mode, 
3,cy1,150,20, &data->before_mode, 0, 0, 0, 0, "Cycling mode to use before first 
keyframe");
-               uiDefButS(block, NUM, B_FMODIFIER_REDRAW, "Max Cycles:", 3, 
cy2, 150, 20, &data->before_cycles, 0, 10000, 10, 3, "Maximum number of cycles 
to allow (0 = infinite)");
-       uiBlockEndAlign(block);
-       
-       /* 'after' range */
-       uiDefBut(block, LABEL, 1, "After:", 155, cy, 80, 20, NULL, 0.0, 0.0, 0, 
0, "Settings for cycling after last keyframe");
-       uiBlockBeginAlign(block);
-               uiDefButS(block, MENU, B_FMODIFIER_REDRAW, cyc_mode, 
157,cy1,150,20, &data->after_mode, 0, 0, 0, 0, "Cycling mode to use after first 
keyframe");
-               uiDefButS(block, NUM, B_FMODIFIER_REDRAW, "Max Cycles:", 157, 
cy2, 150, 20, &data->after_cycles, 0, 10000, 10, 3, "Maximum number of cycles 
to allow (0 = infinite)");
-       uiBlockEndAlign(block);
+       /* before range */
+       col= uiLayoutColumn(split, 1);
+       uiItemL(col, "Before:", 0);
+       uiItemR(col, "", 0, &ptr, "before_mode", 0, 0, 0);
+       uiItemR(col, NULL, 0, &ptr, "before_cycles", 0, 0, 0);
+               
+       /* after range */
+       col= uiLayoutColumn(split, 1);
+       uiItemL(col, "After:", 0);
+       uiItemR(col, "", 0, &ptr, "after_mode", 0, 0, 0);
+       uiItemR(col, NULL, 0, &ptr, "after_cycles", 0, 0, 0);
 }
 
 /* --------------- */
 
 /* draw settings for noise modifier */
-static void draw_modifier__noise(uiBlock *block, FModifier *fcm, int *yco, 
short *height, short width, short active, int rb_col)
+static void draw_modifier__noise(uiLayout *layout, FModifier *fcm, short width)
 {
-       FMod_Noise *data= (FMod_Noise *)fcm->data;
-       int cy= (*yco - 30), cy1= (*yco - 50), cy2= (*yco - 70);
-       char blend_mode[]="Modification %t|Replace %x0|Add %x1|Subtract 
%x2|Multiply %x3";
+       uiLayout *split, *col;
+       PointerRNA ptr;
        
-       /* set the height */
-       (*height) = 80;
+       /* init the RNA-pointer */
+       RNA_pointer_create(NULL, &RNA_FModifierNoise, fcm, &ptr);
        
-       /* basic settings (backdrop + some padding) */
-       DRAW_BACKDROP((*height));
+       /* split into 2 columns */
+       split= uiLayoutSplit(layout, 0.5f);
        
-       uiDefButS(block, MENU, B_FMODIFIER_REDRAW, blend_mode,
-                         3, cy, 150, 20, &data->modification, 0, 0, 0, 0, 
"Method of combining the results of this modifier and other modifiers.");
+       /* col 1 */
+       col= uiLayoutColumn(split, 0);
+       uiItemR(col, NULL, 0, &ptr, "size", 0, 0, 0);
+       uiItemR(col, NULL, 0, &ptr, "strength", 0, 0, 0);
        
-       uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "Size:", 
-                         3, cy1, 150, 20, &data->size, 0.000001, 10000.0, 
0.01, 3, "");
-       uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "Strength:", 
-                         3, cy2, 150, 20, &data->strength, 0.0, 10000.0, 0.01, 
3, "");
-       
-       uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "Phase:", 
-                         155, cy1, 150, 20, &data->phase, 0.0, 100000.0, 0.1, 
3, "");
-       uiDefButS(block, NUM, B_FMODIFIER_REDRAW, "Depth:", 
-                         155, cy2, 150, 20, &data->depth, 0, 128, 1, 3, "");
-
+       /* col 2 */
+       col= uiLayoutColumn(split, 0);
+       uiItemR(col, NULL, 0, &ptr, "phase", 0, 0, 0);
+       uiItemR(col, NULL, 0, &ptr, "depth", 0, 0, 0);
 }
 
 /* --------------- */
@@ -492,22 +467,17 @@
 }
 
 /* draw settings for envelope modifier */
-static void draw_modifier__envelope(uiBlock *block, FModifier *fcm, int *yco, 
short *height, short width, short active, int rb_col)
+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);
        uiBut *but;
-       int cy= (*yco - 28);
+       int cy= (yco - 28);
        int i;
        
-       /* set the height:
-        *      - basic settings + variable height from envelope controls
-        */
-       (*height) = 115 + (35 * env->totvert);
-       
-       /* basic settings (backdrop + general settings + some padding) */
-       DRAW_BACKDROP((*height));
-       
        /* 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;
@@ -543,83 +513,104 @@
                uiBlockBeginAlign(block);
                cy -= 25;
        }
+#endif
 }
 
 /* --------------- */
 
 /* draw settings for limits modifier */
-static void draw_modifier__limits(uiBlock *block, FModifier *fcm, int *yco, 
short *height, short width, short active, int rb_col)
+static void draw_modifier__limits(uiLayout *layout, FModifier *fcm, short 
width)
 {
-       FMod_Limits *data= (FMod_Limits *)fcm->data;
-       const int togButWidth = 50;
-       const int textButWidth = ((width/2)-togButWidth);
+       uiLayout *split, *col, *row;
+       PointerRNA ptr;
        
-       /* set the height */
-       (*height) = 60;
+       /* init the RNA-pointer */
+       RNA_pointer_create(NULL, &RNA_FModifierLimits, fcm, &ptr);
        
-       /* basic settings (backdrop + some padding) */
-       DRAW_BACKDROP((*height));
+       /* row 1: minimum */
+       {
+               row= uiLayoutRow(layout, 0);
+               
+               /* split into 2 columns */
+               split= uiLayoutSplit(layout, 0.5f);
+               
+               /* x-minimum */
+               col= uiLayoutColumn(split, 1);
+               uiItemR(col, NULL, 0, &ptr, "use_minimum_x", 0, 0, 0);
+               uiItemR(col, NULL, 0, &ptr, "minimum_x", 0, 0, 0);
+                       
+               /* y-minimum*/
+               col= uiLayoutColumn(split, 1);

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to