added changing the extending / extrapolation type of the IPO curves of selected actions in the action editor (to the menu - code to handle hotkey (to rise a popup) is there too but unused & untested now).

This commit is contained in:
Toni Alatalo
2005-11-10 18:12:53 +00:00
parent 44ed7f25b7
commit 4c76b74b00
4 changed files with 163 additions and 2 deletions

View File

@@ -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

View File

@@ -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)
{

View File

@@ -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");
}

View File

@@ -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, "");