diff options
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/animation/fmodifier_ui.c | 56 | ||||
-rw-r--r-- | source/blender/editors/include/ED_anim_api.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_buttons.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_edit.c | 31 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_buttons.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_edit.c | 50 |
6 files changed, 113 insertions, 30 deletions
diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index cd0a00fa859..7a618f4d222 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -134,7 +134,7 @@ 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) +static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, short width) { FMod_Generator *data= (FMod_Generator *)fcm->data; uiLayout *col, *row; @@ -143,7 +143,7 @@ static void draw_modifier__generator(uiLayout *layout, FModifier *fcm, short wid PointerRNA ptr; /* init the RNA-pointer */ - RNA_pointer_create(NULL, &RNA_FModifierFunctionGenerator, fcm, &ptr); + RNA_pointer_create(id, &RNA_FModifierFunctionGenerator, fcm, &ptr); /* basic settings (backdrop + mode selector + some padding) */ col= uiLayoutColumn(layout, 1); @@ -248,31 +248,36 @@ static void draw_modifier__generator(uiLayout *layout, FModifier *fcm, short wid /* --------------- */ /* draw settings for noise modifier */ -static void draw_modifier__fn_generator(uiLayout *layout, FModifier *fcm, short width) +static void draw_modifier__fn_generator(uiLayout *layout, ID *id, FModifier *fcm, short width) { - uiLayout *col= uiLayoutColumn(layout, 0); // no grouping for now + uiLayout *col; PointerRNA ptr; /* init the RNA-pointer */ - RNA_pointer_create(NULL, &RNA_FModifierFunctionGenerator, fcm, &ptr); + RNA_pointer_create(id, &RNA_FModifierFunctionGenerator, fcm, &ptr); /* 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); + col= uiLayoutColumn(layout, 1); + uiItemR(col, "", 0, &ptr, "type", 0, 0, 0); + uiItemR(col, NULL, 0, &ptr, "additive", 0, 0, 1); + + col= uiLayoutColumn(layout, 0); // no grouping for now + 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(uiLayout *layout, FModifier *fcm, short width) +static void draw_modifier__cycles(uiLayout *layout, ID *id, FModifier *fcm, short width) { uiLayout *split, *col; PointerRNA ptr; /* init the RNA-pointer */ - RNA_pointer_create(NULL, &RNA_FModifierCycles, fcm, &ptr); + RNA_pointer_create(id, &RNA_FModifierCycles, fcm, &ptr); /* split into 2 columns * NOTE: the mode comboboxes shouldn't get labels, otherwise there isn't enough room @@ -295,13 +300,16 @@ static void draw_modifier__cycles(uiLayout *layout, FModifier *fcm, short width) /* --------------- */ /* draw settings for noise modifier */ -static void draw_modifier__noise(uiLayout *layout, FModifier *fcm, short width) +static void draw_modifier__noise(uiLayout *layout, ID *id, FModifier *fcm, short width) { uiLayout *split, *col; PointerRNA ptr; /* init the RNA-pointer */ - RNA_pointer_create(NULL, &RNA_FModifierNoise, fcm, &ptr); + RNA_pointer_create(id, &RNA_FModifierNoise, fcm, &ptr); + + /* blending mode */ + uiItemR(layout, NULL, 0, &ptr, "modification", 0, 0, 0); /* split into 2 columns */ split= uiLayoutSplit(layout, 0.5f); @@ -479,7 +487,7 @@ 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) +static void draw_modifier__envelope(uiLayout *layout, ID *id, FModifier *fcm, short width) { FMod_Envelope *env= (FMod_Envelope *)fcm->data; FCM_EnvelopeData *fed; @@ -490,7 +498,7 @@ static void draw_modifier__envelope(uiLayout *layout, FModifier *fcm, short widt int i; /* init the RNA-pointer */ - RNA_pointer_create(NULL, &RNA_FModifierEnvelope, fcm, &ptr); + RNA_pointer_create(id, &RNA_FModifierEnvelope, fcm, &ptr); /* general settings */ col= uiLayoutColumn(layout, 1); @@ -534,13 +542,13 @@ static void draw_modifier__envelope(uiLayout *layout, FModifier *fcm, short widt /* --------------- */ /* draw settings for limits modifier */ -static void draw_modifier__limits(uiLayout *layout, FModifier *fcm, short width) +static void draw_modifier__limits(uiLayout *layout, ID *id, FModifier *fcm, short width) { uiLayout *split, *col, *row; PointerRNA ptr; /* init the RNA-pointer */ - RNA_pointer_create(NULL, &RNA_FModifierLimits, fcm, &ptr); + RNA_pointer_create(id, &RNA_FModifierLimits, fcm, &ptr); /* row 1: minimum */ { @@ -582,7 +590,7 @@ static void draw_modifier__limits(uiLayout *layout, FModifier *fcm, short width) /* --------------- */ -void ANIM_uiTemplate_fmodifier_draw (uiLayout *layout, ListBase *modifiers, FModifier *fcm) +void ANIM_uiTemplate_fmodifier_draw (uiLayout *layout, ID *id, ListBase *modifiers, FModifier *fcm) { FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm); uiLayout *box, *row, *subrow; @@ -639,27 +647,27 @@ void ANIM_uiTemplate_fmodifier_draw (uiLayout *layout, ListBase *modifiers, FMod /* draw settings for individual modifiers */ switch (fcm->type) { case FMODIFIER_TYPE_GENERATOR: /* Generator */ - draw_modifier__generator(box, fcm, width); + draw_modifier__generator(box, id, fcm, width); break; case FMODIFIER_TYPE_FN_GENERATOR: /* Built-In Function Generator */ - draw_modifier__fn_generator(box, fcm, width); + draw_modifier__fn_generator(box, id, fcm, width); break; case FMODIFIER_TYPE_CYCLES: /* Cycles */ - draw_modifier__cycles(box, fcm, width); + draw_modifier__cycles(box, id, fcm, width); break; case FMODIFIER_TYPE_ENVELOPE: /* Envelope */ - draw_modifier__envelope(box, fcm, width); + draw_modifier__envelope(box, id, fcm, width); break; case FMODIFIER_TYPE_LIMITS: /* Limits */ - draw_modifier__limits(box, fcm, width); + draw_modifier__limits(box, id, fcm, width); break; case FMODIFIER_TYPE_NOISE: /* Noise */ - draw_modifier__noise(box, fcm, width); + draw_modifier__noise(box, id, fcm, width); break; default: /* unknown type */ diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index df4e704cae8..87811fa34f9 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -300,7 +300,7 @@ struct uiLayout; /* draw a given F-Modifier for some layout/UI-Block */ // XXX not quite complete yet -void ANIM_uiTemplate_fmodifier_draw(struct uiLayout *layout, ListBase *modifiers, struct FModifier *fcm); +void ANIM_uiTemplate_fmodifier_draw(struct uiLayout *layout, struct ID *id, ListBase *modifiers, struct FModifier *fcm); /* ************************************************* */ /* ASSORTED TOOLS */ diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 17bc78f9ee6..0e48d56ac90 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -388,7 +388,7 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa) for (fcm= fcu->modifiers.first; fcm; fcm= fcm->next) { col= uiLayoutColumn(pa->layout, 1); - ANIM_uiTemplate_fmodifier_draw(col, &fcu->modifiers, fcm); + ANIM_uiTemplate_fmodifier_draw(col, ale->id, &fcu->modifiers, fcm); } MEM_freeN(ale); diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 9a50c5cc203..2cade676817 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -73,6 +73,7 @@ #include "BKE_report.h" #include "BKE_utildefines.h" +#include "UI_interface.h" #include "UI_view2d.h" #include "BIF_transform.h" @@ -1743,6 +1744,34 @@ void GRAPH_OT_smooth (wmOperatorType *ot) /* ******************** Add F-Modifier Operator *********************** */ +/* present a special customised popup menu for this, with some filtering */ +static int graph_fmodifier_add_invoke (bContext *C, wmOperator *op, wmEvent *event) +{ + uiPopupMenu *pup; + uiLayout *layout; + int i; + + pup= uiPupMenuBegin(C, "Add F-Curve Modifier", 0); + layout= uiPupMenuLayout(pup); + + /* start from 1 to skip the 'Invalid' modifier type */ + for (i = 1; i < FMODIFIER_NUM_TYPES; i++) { + FModifierTypeInfo *fmi= get_fmodifier_typeinfo(i); + + /* check if modifier is valid for this context */ + if (fmi == NULL) + continue; + + /* add entry to add this type of modifier */ + uiItemEnumO(layout, fmi->name, 0, "GRAPH_OT_fmodifier_add", "type", i); + } + uiItemS(layout); + + uiPupMenuEnd(C, pup); + + return OPERATOR_CANCELLED; +} + static int graph_fmodifier_add_exec(bContext *C, wmOperator *op) { bAnimContext ac; @@ -1793,7 +1822,7 @@ void GRAPH_OT_fmodifier_add (wmOperatorType *ot) ot->idname= "GRAPH_OT_fmodifier_add"; /* api callbacks */ - ot->invoke= WM_menu_invoke; + ot->invoke= graph_fmodifier_add_invoke; ot->exec= graph_fmodifier_add_exec; ot->poll= graphop_active_fcurve_poll; diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index 7eb10866b8c..38ac59cbc9e 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -341,7 +341,7 @@ static void nla_panel_modifiers(const bContext *C, Panel *pa) for (fcm= strip->modifiers.first; fcm; fcm= fcm->next) { col= uiLayoutColumn(pa->layout, 1); - ANIM_uiTemplate_fmodifier_draw(col, &strip->modifiers, fcm); + ANIM_uiTemplate_fmodifier_draw(col, strip_ptr.id.data, &strip->modifiers, fcm); } } diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 9910e62b262..10b25beddff 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -386,6 +386,12 @@ static int nlaedit_add_transition_exec (bContext *C, wmOperator *op) /* check if there's space between the two */ if (IS_EQ(s1->end, s2->start)) continue; + /* make neither one is a transition + * - although this is impossible to create with the standard tools, + * the user may have altered the settings + */ + if (ELEM(NLASTRIP_TYPE_TRANSITION, s1->type, s2->type)) + continue; /* allocate new strip */ strip= MEM_callocN(sizeof(NlaStrip), "NlaStrip"); @@ -577,8 +583,18 @@ static int nlaedit_delete_exec (bContext *C, wmOperator *op) nstrip= strip->next; /* if selected, delete */ - if (strip->flag & NLASTRIP_FLAG_SELECT) + if (strip->flag & NLASTRIP_FLAG_SELECT) { + /* if a strip either side of this was a transition, delete those too */ + if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION)) + free_nlastrip(&nlt->strips, strip->prev); + if ((nstrip) && (nstrip->type == NLASTRIP_TYPE_TRANSITION)) { + nstrip= nstrip->next; + free_nlastrip(&nlt->strips, strip->next); + } + + /* finally, delete this strip */ free_nlastrip(&nlt->strips, strip); + } } } @@ -1026,6 +1042,36 @@ void NLA_OT_clear_scale (wmOperatorType *ot) /* ******************** Add F-Modifier Operator *********************** */ +/* present a special customised popup menu for this, with some filtering */ +static int nla_fmodifier_add_invoke (bContext *C, wmOperator *op, wmEvent *event) +{ + uiPopupMenu *pup; + uiLayout *layout; + int i; + + pup= uiPupMenuBegin(C, "Add F-Modifier", 0); + layout= uiPupMenuLayout(pup); + + /* start from 1 to skip the 'Invalid' modifier type */ + for (i = 1; i < FMODIFIER_NUM_TYPES; i++) { + FModifierTypeInfo *fmi= get_fmodifier_typeinfo(i); + + /* check if modifier is valid for this context */ + if (fmi == NULL) + continue; + if (i == FMODIFIER_TYPE_CYCLES) /* we already have repeat... */ + continue; + + /* add entry to add this type of modifier */ + uiItemEnumO(layout, fmi->name, 0, "NLA_OT_fmodifier_add", "type", i); + } + uiItemS(layout); + + uiPupMenuEnd(C, pup); + + return OPERATOR_CANCELLED; +} + static int nla_fmodifier_add_exec(bContext *C, wmOperator *op) { bAnimContext ac; @@ -1089,7 +1135,7 @@ void NLA_OT_fmodifier_add (wmOperatorType *ot) ot->idname= "NLA_OT_fmodifier_add"; /* api callbacks */ - ot->invoke= WM_menu_invoke; + ot->invoke= nla_fmodifier_add_invoke; ot->exec= nla_fmodifier_add_exec; ot->poll= nlaop_poll_tweakmode_off; |