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:
authorJoshua Leung <aligorith@gmail.com>2009-07-03 03:27:11 +0400
committerJoshua Leung <aligorith@gmail.com>2009-07-03 03:27:11 +0400
commite9c85406e4f24eeab8818b3b58862c3798c0dc14 (patch)
tree3001d7b12a0e9559584b343bd6f7ccf5a0b93d24 /source/blender/editors/animation
parent441bcaae2e63d3f757ee336fb051a9cb851e3e33 (diff)
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).
Diffstat (limited to 'source/blender/editors/animation')
-rw-r--r--source/blender/editors/animation/fmodifier_ui.c159
1 files changed, 87 insertions, 72 deletions
diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c
index 19c7d049758..3be96031526 100644
--- a/source/blender/editors/animation/fmodifier_ui.c
+++ b/source/blender/editors/animation/fmodifier_ui.c
@@ -136,24 +136,23 @@ static void delete_fmodifier_cb (bContext *C, void *fmods_v, void *fcm_v)
/* 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 @@ static void draw_modifier__generator(uiLayout *layout, FModifier *fcm, short wid
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 != (data->arraysize - 1)) || ((i==0) && data->arraysize==2) )
- uiDefBut(block, LABEL, 1, "+", 250, cy, 30, 20, NULL, 0.0, 0.0, 0, 0, "");
+ 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");
+ }
- 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 @@ static void draw_modifier__generator(uiLayout *layout, FModifier *fcm, short wid
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 @@ static void fmod_envelope_deletepoint_cb (bContext *C, void *fcm_dv, void *ind_v
/* 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");
- uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "Max:", 192, cy, 100, 20, &fed->max, -UI_FLT_MAX, UI_FLT_MAX, 10, 2, "Maximum bound of envelope at this point");
+ uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "Min:", 0, 0, 100, 20, &fed->min, -UI_FLT_MAX, UI_FLT_MAX, 10, 2, "Minimum bound of envelope at this point");
+ uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "Max:", 0, 0, 100, 20, &fed->max, -UI_FLT_MAX, UI_FLT_MAX, 10, 2, "Maximum bound of envelope at this point");
- but= uiDefIconBut(block, BUT, B_FMODIFIER_REDRAW, ICON_X, 292, cy, 18, 20, NULL, 0.0, 0.0, 0.0, 0.0, "Delete envelope control point");
+ but= uiDefIconBut(block, BUT, B_FMODIFIER_REDRAW, ICON_X, 0, 0, 18, 20, NULL, 0.0, 0.0, 0.0, 0.0, "Delete envelope control point");
uiButSetFunc(but, fmod_envelope_deletepoint_cb, env, SET_INT_IN_POINTER(i));
uiBlockBeginAlign(block);
- cy -= 25;
}
-#endif
}
/* --------------- */