diff options
author | Ton Roosendaal <ton@blender.org> | 2005-10-30 01:27:07 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2005-10-30 01:27:07 +0400 |
commit | 4664db487297f41c20e30de1598e6f5dadabcd5e (patch) | |
tree | dea7fc1ff40c6f33524dc2966216ba74aa1c9197 /source/blender/src | |
parent | 4ad59e30a05f10355cf88d8e94dfd51bfbc66ca5 (diff) |
SHIFT+S snap to frame for both Action and NLA window.
Diffstat (limited to 'source/blender/src')
-rw-r--r-- | source/blender/src/editaction.c | 45 | ||||
-rw-r--r-- | source/blender/src/editipo_mods.c | 10 | ||||
-rw-r--r-- | source/blender/src/editnla.c | 22 | ||||
-rw-r--r-- | source/blender/src/header_action.c | 14 | ||||
-rw-r--r-- | source/blender/src/header_nla.c | 4 |
5 files changed, 87 insertions, 8 deletions
diff --git a/source/blender/src/editaction.c b/source/blender/src/editaction.c index 0ba59b07337..bd7e978daec 100644 --- a/source/blender/src/editaction.c +++ b/source/blender/src/editaction.c @@ -1542,6 +1542,7 @@ void delete_actionchannel_keys(void) allqueue(REDRAWNLA, 0); } + static void delete_actionchannels (void) { bConstraintChannel *conchan=NULL, *nextconchan; @@ -1641,7 +1642,8 @@ void sethandles_actionchannel_keys(int code) allqueue(REDRAWNLA, 0); } -void set_ipotype_actionchannels(int ipotype) { +void set_ipotype_actionchannels(int ipotype) +{ bAction *act; bActionChannel *chan; @@ -1687,6 +1689,35 @@ void set_ipotype_actionchannels(int ipotype) { allqueue(REDRAWNLA, 0); } +void set_snap_actionchannels(void) +{ + + bAction *act; + bActionChannel *chan; + + /* Get the selected action, exit if none are selected + */ + act = G.saction->action; + if (!act) + return; + + /* Loop through the channels */ + for (chan = act->chanbase.first; chan; chan=chan->next){ + if (chan->ipo) { + snap_ipo_keys(chan->ipo); + } + } + + /* Clean up and redraw stuff */ + remake_action_ipos (act); + BIF_undo_push("Snap Ipo Action channel"); + allspace(REMAKEIPO, 0); + allqueue(REDRAWACTION, 0); + allqueue(REDRAWIPO, 0); + allqueue(REDRAWNLA, 0); +} + + static void select_all_keys_frames(bAction *act, short *mval, short *mvalo, int selectmode) { @@ -2152,11 +2183,15 @@ void winqreadactionspace(ScrArea *sa, void *spacedata, BWinEvent *evt) case SKEY: if (mval[0]>=ACTWIDTH) { - if (key) { - transform_meshchannel_keys('s', key); + if(G.qual & LR_SHIFTKEY) { + if(okee("Snap to frame")) + set_snap_actionchannels(); } - else if (act) { - transform_actionchannel_keys ('s', 0); + else { + if (key) + transform_meshchannel_keys('s', key); + else if (act) + transform_actionchannel_keys ('s', 0); } } break; diff --git a/source/blender/src/editipo_mods.c b/source/blender/src/editipo_mods.c index 468e49b3ec8..fc890a8bd9f 100644 --- a/source/blender/src/editipo_mods.c +++ b/source/blender/src/editipo_mods.c @@ -549,8 +549,18 @@ void sethandles_ipo_keys(Ipo *ipo, int code) } break; } +} +static int snap_bezier(BezTriple *bezt) +{ + if(bezt->f2 & SELECT) + bezt->vec[1][0]= (float)(floor(bezt->vec[1][0]+0.5)); + return 0; +} +void snap_ipo_keys(Ipo *ipo) +{ + ipo_keys_bezier_loop(ipo, snap_bezier, calchandles_ipocurve); } static void ipo_curves_auto_horiz(void) diff --git a/source/blender/src/editnla.c b/source/blender/src/editnla.c index 790494d9d44..00857d3c841 100644 --- a/source/blender/src/editnla.c +++ b/source/blender/src/editnla.c @@ -230,6 +230,24 @@ void reset_action_strips(int val) allqueue (REDRAWNLA, 0); } +void snap_action_strips(void) +{ + Base *base; + bActionStrip *strip; + + for (base=G.scene->base.first; base; base=base->next) { + for (strip = base->object->nlastrips.last; strip; strip=strip->prev) { + if (strip->flag & ACTSTRIP_SELECT) { + strip->start= floor(strip->start+0.5); + } + } + } + BIF_undo_push("Snap NLA strips"); + allqueue (REDRAWVIEW3D, 0); + allqueue (REDRAWACTION, 0); + allqueue (REDRAWNLA, 0); +} + void winqreadnlaspace(ScrArea *sa, void *spacedata, BWinEvent *evt) { unsigned short event= evt->event; @@ -334,6 +352,10 @@ void winqreadnlaspace(ScrArea *sa, void *spacedata, BWinEvent *evt) else if(val==2) reset_action_strips(2); } + else if(G.qual & LR_SHIFTKEY) { + if(okee("Snap Strips to Frame")) + snap_action_strips(); + } else { if (mval[0]>=NLAWIDTH) transform_nlachannel_keys ('s', 0); diff --git a/source/blender/src/header_action.c b/source/blender/src/header_action.c index 55617c0bed5..cd3628ef857 100644 --- a/source/blender/src/header_action.c +++ b/source/blender/src/header_action.c @@ -91,6 +91,7 @@ #define ACTMENU_KEY_DUPLICATE 0 #define ACTMENU_KEY_DELETE 1 #define ACTMENU_KEY_BAKE 2 +#define ACTMENU_KEY_SNAP 3 #define ACTMENU_KEY_TRANSFORM_MOVE 0 #define ACTMENU_KEY_TRANSFORM_SCALE 1 @@ -607,6 +608,9 @@ static void do_action_keymenu(void *arg, int event) case ACTMENU_KEY_BAKE: bake_action_with_client (G.saction->action, OBACT, 0.01); break; + case ACTMENU_KEY_SNAP: + set_snap_actionchannels(); + break; } } @@ -620,9 +624,12 @@ static uiBlock *action_keymenu(void *arg_unused) uiBlockSetButmFunc(block, do_action_keymenu, NULL); uiDefIconTextBlockBut(block, action_keymenu_transformmenu, - NULL, ICON_RIGHTARROW_THIN, - "Transform", 0, yco-=20, 120, 20, ""); - + NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 20, ""); + + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, + "Snap to Frame|Shift S", 0, yco-=20, + menuwidth, 19, NULL, 0.0, 0.0, 0, ACTMENU_KEY_SNAP, ""); + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); @@ -630,6 +637,7 @@ static uiBlock *action_keymenu(void *arg_unused) "Duplicate|Shift D", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, ACTMENU_KEY_DUPLICATE, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete|X", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, diff --git a/source/blender/src/header_nla.c b/source/blender/src/header_nla.c index 1f885c67215..636334e2e9a 100644 --- a/source/blender/src/header_nla.c +++ b/source/blender/src/header_nla.c @@ -273,6 +273,9 @@ static void do_nla_stripmenu(void *arg, int event) case 9: /* reset start/end of action */ reset_action_strips(2); break; + case 10: /* snap to frame */ + snap_action_strips(); + break; } } @@ -288,6 +291,7 @@ static uiBlock *nla_stripmenu(void *arg_unused) uiDefIconTextBlockBut(block, nla_strip_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 20, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Strip Size|ALT S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Action Start/End|ALT S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Snap to Frame|Shift S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 10, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); |