Revision: 18920 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18920 Author: mfoxdogg Date: 2009-02-11 04:46:14 +0100 (Wed, 11 Feb 2009)
Log Message: ----------- 2.5 ****** -ported (de)select all for editarmature and pose mode - please review my loops and notifiers as i think they are pretty ugly 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 02:09:41 UTC (rev 18919) +++ branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h 2009-02-11 03:46:14 UTC (rev 18920) @@ -41,12 +41,14 @@ void ARMATURE_OT_subdivide_multi(struct wmOperatorType *ot); void ARMATURE_OT_parent_set(struct wmOperatorType *ot); void ARMATURE_OT_parent_clear(struct wmOperatorType *ot); +void ARMATURE_OT_de_select_all(struct wmOperatorType *ot); void POSE_OT_hide(struct wmOperatorType *ot); void POSE_OT_reveil(struct wmOperatorType *ot); 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); #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 02:09:41 UTC (rev 18919) +++ branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c 2009-02-11 03:46:14 UTC (rev 18920) @@ -107,6 +107,7 @@ /* Both operators ARMATURE_OT_xxx and POSE_OT_xxx here */ void ED_operatortypes_armature(void) { + /* EDIT ARMATURE */ WM_operatortype_append(ARMATURE_OT_align_bones); WM_operatortype_append(ARMATURE_OT_calculate_roll); WM_operatortype_append(ARMATURE_OT_switch_direction); @@ -117,12 +118,18 @@ WM_operatortype_append(ARMATURE_OT_parent_set); WM_operatortype_append(ARMATURE_OT_parent_clear); + WM_operatortype_append(ARMATURE_OT_de_select_all); + + /* POSE */ WM_operatortype_append(POSE_OT_hide); WM_operatortype_append(POSE_OT_reveil); + WM_operatortype_append(POSE_OT_rot_clear); WM_operatortype_append(POSE_OT_loc_clear); WM_operatortype_append(POSE_OT_scale_clear); + WM_operatortype_append(POSE_OT_de_select_all); + WM_operatortype_append(ARMATURE_OT_test); // XXX temp test for context iterators... to be removed } @@ -147,6 +154,8 @@ WM_keymap_add_item(keymap, "ARMATURE_OT_set_parent", PKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_clear_parent", PKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "ARMATURE_OT_de_select_all", AKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "ARMATURE_OT_test", TKEY, KM_PRESS, 0, 0); // XXX temp test for context iterators... to be removed /* Pose ------------------------ */ @@ -161,5 +170,7 @@ WM_keymap_add_item(keymap, "POSE_OT_rot_clear", RKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "POSE_OT_loc_clear", GKEY, KM_PRESS, KM_ALT, 0); 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); } Modified: branches/blender2.5/blender/source/blender/editors/armature/editarmature.c =================================================================== --- branches/blender2.5/blender/source/blender/editors/armature/editarmature.c 2009-02-11 02:09:41 UTC (rev 18919) +++ branches/blender2.5/blender/source/blender/editors/armature/editarmature.c 2009-02-11 03:46:14 UTC (rev 18920) @@ -3509,7 +3509,62 @@ RNA_def_enum(ot->srna, "type", prop_editarm_clear_parent_types, 0, "ClearType", "What way to clear parenting"); } +/* ****** (de)select All *******/ +static int armature_de_select_all_exec(bContext *C, wmOperator *op) +{ + Object *obedit = CTX_data_edit_object(C); + bArmature *arm= obedit->data; + EditBone *ebone; + int sel=1; + + /* Determine if there are any selected bones + And therefore whether we are selecting or deselecting */ + CTX_DATA_BEGIN(C, EditBone *, selbone, selected_editable_bones) { + if (selbone->flag & (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)){ + sel=0; + break; + } + } + CTX_DATA_END; + + /* Set the flags */ + for (ebone=arm->edbo->first;ebone;ebone=ebone->next) { + if (sel==1) { + /* select bone */ + if(arm->layer & ebone->layer && (ebone->flag & BONE_HIDDEN_A)==0) { + ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + if(ebone->parent) + ebone->parent->flag |= (BONE_TIPSEL); + } + } + else { + /* deselect bone */ + ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL | BONE_ACTIVE); + } + } + + /* undo? */ + WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); + + return OPERATOR_FINISHED; +} + +void ARMATURE_OT_de_select_all(wmOperatorType *ot) +{ + + /* identifiers */ + ot->name= "deselect all editbone"; + ot->idname= "ARMATURE_OT_de_select_all"; + + /* api callbacks */ + ot->exec= armature_de_select_all_exec; + ot->poll= ED_operator_editarmature; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + +} /* ***************** EditBone Alignment ********************* */ /* helper to fix a ebone position if its parent has moved due to alignment*/ @@ -4329,7 +4384,53 @@ /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} +} + + +static int pose_de_select_all_exec(bContext *C, wmOperator *op) +{ + Object *ob= CTX_data_active_object(C); + bArmature *arm= ob->data; + bPoseChannel *pchan; + EditBone *ebone; + int sel=1; + + /* Determine if there are any selected bones + And therefore whether we are selecting or deselecting */ + CTX_DATA_BEGIN(C, bPoseChannel *, selbone, selected_pchans) { + sel=0; + break; + } + CTX_DATA_END; + + /* Set the flags */ + for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + if ((pchan->bone->layer & arm->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) { + if (sel==0) pchan->bone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL|BONE_ACTIVE); + else pchan->bone->flag |= BONE_SELECTED; + } + } + + WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); + + return OPERATOR_FINISHED; +} + +void POSE_OT_de_select_all(wmOperatorType *ot) +{ + + /* identifiers */ + ot->name= "deselect all bones"; + ot->idname= "POSE_OT_de_select_all"; + + /* api callbacks */ + ot->exec= pose_de_select_all_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