diff options
author | Joshua Leung <aligorith@gmail.com> | 2011-02-26 09:28:24 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2011-02-26 09:28:24 +0300 |
commit | 7a55884b627e62951c62630fae10eeab569fe3af (patch) | |
tree | 9d251cce3ebb14e603dee965eba7fa732e4dddca /source/blender/editors/space_action/action_edit.c | |
parent | 6a25ecb799f441af2d38bb9fbb8a3d13599cdd59 (diff) |
Added operator which makes selected scene markers into local 'pose'
markers.
This is useful for when working with lipsync shots, where you've used
markers for noting down key syllables and want to separate these out
into chunks to manage things better.
Diffstat (limited to 'source/blender/editors/space_action/action_edit.c')
-rw-r--r-- | source/blender/editors/space_action/action_edit.c | 84 |
1 files changed, 83 insertions, 1 deletions
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 2c3a88c390e..4f7bddc5c40 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -121,7 +121,7 @@ static int act_new_exec(bContext *C, wmOperator *UNUSED(op)) void ACTION_OT_new (wmOperatorType *ot) { /* identifiers */ - ot->name= "New"; + ot->name= "New Action"; ot->idname= "ACTION_OT_new"; ot->description= "Create new action"; @@ -135,6 +135,88 @@ void ACTION_OT_new (wmOperatorType *ot) } /* ************************************************************************** */ +/* POSE MARKERS STUFF */ + +/* *************************** Localise Markers ***************************** */ + +/* ensure that there is: + * 1) an active action editor + * 2) that the mode will have an active action available + * 3) that the set of markers being shown are the scene markers, not the list we're merging + * 4) that there are some selected markers + */ +static int act_markers_make_local_poll(bContext *C) +{ + SpaceAction *sact = CTX_wm_space_action(C); + + /* 1) */ + if (sact == NULL) + return 0; + + /* 2) */ + if (ELEM(sact->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY) == 0) + return 0; + if (sact->action == NULL) + return 0; + + /* 3) */ + if (sact->flag & SACTION_POSEMARKERS_SHOW) + return 0; + + /* 4) */ + return ED_markers_get_first_selected(ED_context_get_markers(C)) != NULL; +} + +static int act_markers_make_local_exec (bContext *C, wmOperator *op) +{ + ListBase *markers = ED_context_get_markers(C); + + SpaceAction *sact = CTX_wm_space_action(C); + bAction *act = (sact)? sact->action : NULL; + + TimeMarker *marker, *markern=NULL; + + /* sanity checks */ + if (ELEM(NULL, markers, act)) + return OPERATOR_CANCELLED; + + /* migrate markers */ + for (marker = markers->first; marker; marker = markern) { + markern = marker->next; + + /* move if marker is selected */ + if (marker->flag & SELECT) { + BLI_remlink(markers, marker); + BLI_addtail(&act->markers, marker); + } + } + + /* now enable the "show posemarkers only" setting, so that we can see that something did happen */ + sact->flag |= SACTION_POSEMARKERS_SHOW; + + /* notifiers - both sets, as this change affects both */ + WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + + return OPERATOR_FINISHED; +} + +void ACTION_OT_markers_make_local (wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Make Markers Local"; + ot->idname= "ACTION_OT_markers_make_local"; + ot->description= "Move selected scene markers to the active Action as local 'pose' markers"; + + /* callbacks */ + ot->exec = act_markers_make_local_exec; + ot->poll = act_markers_make_local_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/* ************************************************************************** */ /* KEYFRAME-RANGE STUFF */ /* *************************** Calculate Range ************************** */ |