First operator done as a test and to get to know the ropes. "Select Parent" in pose...
authorRoland Hess <me@harkyman.com>
Wed, 11 Feb 2009 16:17:34 +0000 (16:17 +0000)
committerRoland Hess <me@harkyman.com>
Wed, 11 Feb 2009 16:17:34 +0000 (16:17 +0000)
source/blender/editors/armature/armature_intern.h
source/blender/editors/armature/armature_ops.c
source/blender/editors/armature/editarmature.c

index 2e021c2f4ae53ddf5c71c465c5b7b0718569d80e..a6fa50cfc6a76d5d44e28ea820709f7d6ecfbbf6 100644 (file)
@@ -49,6 +49,7 @@ void POSE_OT_rot_clear(struct wmOperatorType *ot);
 void POSE_OT_loc_clear(struct wmOperatorType *ot);
 void POSE_OT_scale_clear(struct wmOperatorType *ot);
 void POSE_OT_de_select_all(struct wmOperatorType *ot);
+void POSE_OT_select_parent(struct wmOperatorType *ot);
 
 #endif /* ED_ARMATURE_INTERN_H */
 
index 65345094720643c7062f8888e254b056e35907a5..5f482e13183619802b0718f6b86f8f6a08d3f177 100644 (file)
@@ -129,6 +129,8 @@ void ED_operatortypes_armature(void)
        WM_operatortype_append(POSE_OT_scale_clear);
        
        WM_operatortype_append(POSE_OT_de_select_all);
+
+       WM_operatortype_append(POSE_OT_select_parent);
        
        WM_operatortype_append(ARMATURE_OT_test); // XXX temp test for context iterators... to be removed
 }
@@ -172,5 +174,7 @@ void ED_keymap_armature(wmWindowManager *wm)
        WM_keymap_add_item(keymap, "POSE_OT_scale_clear", SKEY, KM_PRESS, KM_ALT, 0);
        
        WM_keymap_add_item(keymap, "POSE_OT_de_select_all", AKEY, KM_PRESS, 0, 0);
+
+       WM_keymap_add_item(keymap, "POSE_OT_select_parent", PKEY, KM_PRESS, KM_SHIFT, 0);
 }
 
index e18497c42c85a9d89fe2b590c1eb03fbddc52e33..125f9bb889db172864506252772adfb1bf04861b 100644 (file)
@@ -4420,6 +4420,43 @@ void POSE_OT_de_select_all(wmOperatorType *ot)
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
+}
+
+static int pose_select_parent_exec(bContext *C, wmOperator *op)
+{
+       Object *ob= CTX_data_active_object(C);
+       bArmature *arm= ob->data;
+       bPoseChannel *pchan,*parent;
+
+       /*      Determine if there is an active bone */
+       pchan=CTX_data_active_pchan(C);
+       if (pchan) {
+               parent=pchan->parent;
+               if ((parent) && !(parent->bone->flag & BONE_HIDDEN_P)) {
+                       parent->bone->flag |= BONE_SELECTED;
+                       parent->bone->flag |= BONE_ACTIVE;
+                       pchan->bone->flag &= ~BONE_ACTIVE;
+               }
+       }
+
+       WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, NULL);
+       
+       return OPERATOR_FINISHED;
+}
+
+void POSE_OT_select_parent(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "select parent bone";
+       ot->idname= "POSE_OT_select_parent";
+
+       /* api callbacks */
+       ot->exec= pose_select_parent_exec;
+       ot->poll= ED_operator_posemode;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       
 }
 /* ************* hide/unhide pose bones ******************* */