diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/include/BIF_editaction.h | 6 | ||||
-rw-r--r-- | source/blender/src/editaction.c | 61 | ||||
-rw-r--r-- | source/blender/src/editipo_mods.c | 12 | ||||
-rw-r--r-- | source/blender/src/header_action.c | 86 |
4 files changed, 163 insertions, 2 deletions
diff --git a/source/blender/include/BIF_editaction.h b/source/blender/include/BIF_editaction.h index 3ca0bbdb1f8..9e2f9e63b73 100644 --- a/source/blender/include/BIF_editaction.h +++ b/source/blender/include/BIF_editaction.h @@ -38,6 +38,12 @@ #define SET_IPO_LINEAR 2 #define SET_IPO_BEZIER 3 +#define SET_EXTEND_POPUP 0 +#define SET_EXTEND_CONSTANT 1 +#define SET_EXTEND_EXTRAPOLATION 2 +#define SET_EXTEND_CYCLIC 3 +#define SET_EXTEND_CYCLICEXTRAPOLATION 4 + #define CHANNELHEIGHT 16 #define CHANNELSKIP 2 #define NAMEWIDTH 128 diff --git a/source/blender/src/editaction.c b/source/blender/src/editaction.c index 2b76fafdf01..53b23884f31 100644 --- a/source/blender/src/editaction.c +++ b/source/blender/src/editaction.c @@ -1743,6 +1743,67 @@ void set_ipotype_actionchannels(int ipotype) allqueue(REDRAWNLA, 0); } +void set_extendtype_actionchannels(int extendtype) +{ + bAction *act; + bActionChannel *chan; + short event; + + /* Get the selected action, exit if none are selected + */ + act = G.saction->action; + if (!act) + return; + + if (extendtype == SET_EXTEND_POPUP) { + /* Present a popup menu asking the user what type + * of IPO curve he/she/GreenBTH wants. ;) + */ + event + = pupmenu("Channel Extending Type %t|" + "Constant %x1|" + "Extrapolation %x2|" + "Cyclic %x3|" + "Cyclic extrapolation %x4"); + if(event < 1) return; + extendtype = event; + } + + /* Loop through the channels and for the selected ones set + * the type for each Ipo curve in the channel Ipo (based on + * the value from the popup). + */ + for (chan = act->chanbase.first; chan; chan=chan->next){ + if (chan->flag & ACHAN_SELECTED) { + if (chan->ipo) { + switch (extendtype) { + case SET_EXTEND_CONSTANT: + setexprap_ipoloop(chan->ipo, IPO_HORIZ); + break; + case SET_EXTEND_EXTRAPOLATION: + setexprap_ipoloop(chan->ipo, IPO_DIR); + break; + case SET_EXTEND_CYCLIC: + setexprap_ipoloop(chan->ipo, IPO_CYCL); + break; + case SET_EXTEND_CYCLICEXTRAPOLATION: + setexprap_ipoloop(chan->ipo, IPO_CYCLX); + break; + } + } + } + } + + /* Clean up and redraw stuff + */ + remake_action_ipos (act); + BIF_undo_push("Set Ipo type Action channel"); + allspace(REMAKEIPO, 0); + allqueue(REDRAWACTION, 0); + allqueue(REDRAWIPO, 0); + allqueue(REDRAWNLA, 0); +} + void set_snap_actionchannels(void) { diff --git a/source/blender/src/editipo_mods.c b/source/blender/src/editipo_mods.c index fc890a8bd9f..d228effc951 100644 --- a/source/blender/src/editipo_mods.c +++ b/source/blender/src/editipo_mods.c @@ -669,6 +669,16 @@ void setipotype_ipo(Ipo *ipo, int code) } } +void setexprap_ipoloop(Ipo *ipo, int code) +{ + IpoCurve *icu; + + /* Loop through each curve in the Ipo + */ + for (icu=ipo->curve.first; icu; icu=icu->next) + icu->extrap= code; +} + void set_ipotype(void) { EditIpo *ei; @@ -1121,5 +1131,3 @@ void set_exprap_ipo(int mode) editipo_changed(G.sipo, 1); BIF_undo_push("Set extrapolation Ipo"); } - - diff --git a/source/blender/src/header_action.c b/source/blender/src/header_action.c index 7c245132cb7..608153e10b5 100644 --- a/source/blender/src/header_action.c +++ b/source/blender/src/header_action.c @@ -106,6 +106,11 @@ #define ACTMENU_KEY_INTERP_LINEAR 1 #define ACTMENU_KEY_INTERP_BEZIER 2 +#define ACTMENU_KEY_EXTEND_CONST 0 +#define ACTMENU_KEY_EXTEND_EXTRAPOLATION 1 +#define ACTMENU_KEY_EXTEND_CYCLIC 2 +#define ACTMENU_KEY_EXTEND_CYCLICEXTRAPOLATION 3 + void do_action_buttons(unsigned short event) { Object *ob= OBACT; @@ -587,6 +592,84 @@ static uiBlock *action_keymenu_intpolmenu(void *arg_unused) return block; } +static void do_action_keymenu_extendmenu(void *arg, int event) +{ + Key *key; + + key = get_action_mesh_key(); + + switch(event) + { + case ACTMENU_KEY_EXTEND_CONST: + if (key) { + /* to do */ + } + else { + set_extendtype_actionchannels(SET_EXTEND_CONSTANT); + } + break; + case ACTMENU_KEY_EXTEND_EXTRAPOLATION: + if (key) { + /* to do */ + } + else { + set_extendtype_actionchannels(SET_EXTEND_EXTRAPOLATION); + } + break; + case ACTMENU_KEY_EXTEND_CYCLIC: + if (key) { + /* to do */ + } + else { + set_extendtype_actionchannels(SET_EXTEND_CYCLIC); + } + break; + case ACTMENU_KEY_EXTEND_CYCLICEXTRAPOLATION: + if (key) { + /* to do */ + } + else { + set_extendtype_actionchannels(SET_EXTEND_CYCLICEXTRAPOLATION); + } + break; + } + + scrarea_queue_winredraw(curarea); +} + +static uiBlock *action_keymenu_extendmenu(void *arg_unused) +{ + uiBlock *block; + short yco= 0, menuwidth=120; + + block= uiNewBlock(&curarea->uiblocks, "action_keymenu_extendmenu", + UI_EMBOSSP, UI_HELV, G.curscreen->mainwin); + uiBlockSetButmFunc(block, do_action_keymenu_extendmenu, NULL); + + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, + "Constant", 0, yco-=20, + menuwidth, 19, NULL, 0.0, 0.0, 0, + ACTMENU_KEY_EXTEND_CONST, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, + "Extrapolation", 0, yco-=20, + menuwidth, 19, NULL, 0.0, 0.0, 0, + ACTMENU_KEY_EXTEND_EXTRAPOLATION, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, + "Cyclic", 0, yco-=20, + menuwidth, 19, NULL, 0.0, 0.0, 0, + ACTMENU_KEY_EXTEND_CYCLIC, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, + "Cyclic Extrapolation", 0, yco-=20, + menuwidth, 19, NULL, 0.0, 0.0, 0, + ACTMENU_KEY_EXTEND_CYCLICEXTRAPOLATION, ""); + + uiBlockSetDirection(block, UI_RIGHT); + uiTextBoundsBlock(block, 60); + + return block; +} + + static void do_action_keymenu(void *arg, int event) { SpaceAction *saction; @@ -669,6 +752,9 @@ static uiBlock *action_keymenu(void *arg_unused) uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + uiDefIconTextBlockBut(block, action_keymenu_extendmenu, + NULL, ICON_RIGHTARROW_THIN, + "Extend Mode", 0, yco-=20, 120, 20, ""); uiDefIconTextBlockBut(block, action_keymenu_intpolmenu, NULL, ICON_RIGHTARROW_THIN, "Interpolation Mode", 0, yco-=20, 120, 20, ""); |