Added operator which makes selected scene markers into local 'pose'
authorJoshua Leung <aligorith@gmail.com>
Sat, 26 Feb 2011 06:28:24 +0000 (06:28 +0000)
committerJoshua Leung <aligorith@gmail.com>
Sat, 26 Feb 2011 06:28:24 +0000 (06:28 +0000)
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.

release/scripts/ui/space_dopesheet.py
source/blender/editors/animation/anim_markers.c
source/blender/editors/space_action/action_edit.c
source/blender/editors/space_action/action_intern.h
source/blender/editors/space_action/action_ops.c

index 3a3f3f4033e36becacda0b9716a5f545016f1fc7..f68df00c8066bdcffd686b3284a57ad17e9454ce 100644 (file)
@@ -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
index 6aa8e010cc2b6221e4559347513cce4d454df20d..eaf7590f7dc05a01f4f72bc9f0ad734c258eabd5 100644 (file)
@@ -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;
index 2c3a88c390e7d633eeca283fd6c7495d1a476b3c..4f7bddc5c4023d05ac12b28e389a7b5f000b0257 100644 (file)
@@ -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 */
 
index feaf2c2d786b0cf39b8aa3c650e58553dda5331b..f9a5ac1093da6dee1fdad1d3f1260a9c8e8d1246 100644 (file)
@@ -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)
  */
index acb2fa09d0476a0719a6c65e006131e95b82297b..e82c26488b5ac2df7e0cab25f934a52fcb553b4e 100644 (file)
@@ -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 **********************************/