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.
This commit is contained in:
Joshua Leung 2011-02-26 06:28:24 +00:00
parent 6a25ecb799
commit 7a55884b62
5 changed files with 91 additions and 2 deletions

@ -225,6 +225,9 @@ class DOPESHEET_MT_marker(bpy.types.Menu):
layout.separator()
layout.prop(st, "show_pose_markers")
if st.show_pose_markers is False:
layout.operator("action.markers_make_local")
#######################################
# Keyframe Editing

@ -365,7 +365,7 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag)
}
#ifdef DURIAN_CAMERA_SWITCH
if(marker->camera && marker->camera->restrictflag & OB_RESTRICT_RENDER) {
if(marker->camera && (marker->camera->restrictflag & OB_RESTRICT_RENDER)) {
float col[4];
glGetFloatv(GL_CURRENT_COLOR, col);
col[3]= 0.4;

@ -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";
@ -134,6 +134,88 @@ void ACTION_OT_new (wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
/* ************************************************************************** */
/* 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 */

@ -104,6 +104,8 @@ void ACTION_OT_mirror(struct wmOperatorType *ot);
void ACTION_OT_new(struct wmOperatorType *ot);
void ACTION_OT_markers_make_local(struct wmOperatorType *ot);
/* defines for snap keyframes
* NOTE: keep in sync with eEditKeyframes_Snap (in ED_keyframes_edit.h)
*/

@ -79,6 +79,8 @@ void action_operatortypes(void)
WM_operatortype_append(ACTION_OT_previewrange_set);
WM_operatortype_append(ACTION_OT_view_all);
WM_operatortype_append(ACTION_OT_markers_make_local);
}
/* ************************** registration - keymaps **********************************/