Revision: 18927
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18927
Author:   harkyman
Date:     2009-02-11 17:17:34 +0100 (Wed, 11 Feb 2009)

Log Message:
-----------
First operator done as a test and to get to know the ropes. "Select Parent" in 
pose mode. Had to move the command to Shift-P, as naked P is taken up by some 
crazy person's script command.

Modified Paths:
--------------
    
branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h
    branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c
    branches/blender2.5/blender/source/blender/editors/armature/editarmature.c

Modified: 
branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h   
    2009-02-11 14:56:35 UTC (rev 18926)
+++ 
branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h   
    2009-02-11 16:17:34 UTC (rev 18927)
@@ -49,6 +49,7 @@
 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 */
 

Modified: 
branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c  
2009-02-11 14:56:35 UTC (rev 18926)
+++ branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c  
2009-02-11 16:17:34 UTC (rev 18927)
@@ -129,6 +129,8 @@
        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 @@
        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);
 }
 

Modified: 
branches/blender2.5/blender/source/blender/editors/armature/editarmature.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/editarmature.c  
2009-02-11 14:56:35 UTC (rev 18926)
+++ branches/blender2.5/blender/source/blender/editors/armature/editarmature.c  
2009-02-11 16:17:34 UTC (rev 18927)
@@ -4421,6 +4421,43 @@
        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 ******************* */
 
 static int hide_selected_pose_bone(Object *ob, Bone *bone, void *ptr) 


_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to