Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Fox <mfoxdogg@gmail.com>2009-02-11 06:46:14 +0300
committerMichael Fox <mfoxdogg@gmail.com>2009-02-11 06:46:14 +0300
commitba32199b23fb1b745109d7b25b8d7c6cdf903cd1 (patch)
treeb76804e8c499bcf1154451a5e95f1fa4ba95b8dd /source/blender/editors/armature
parent50a6d77fc04cc030bf2d10cb414920502fc6e646 (diff)
2.5
****** -ported (de)select all for editarmature and pose mode - please review my loops and notifiers as i think they are pretty ugly
Diffstat (limited to 'source/blender/editors/armature')
-rw-r--r--source/blender/editors/armature/armature_intern.h2
-rw-r--r--source/blender/editors/armature/armature_ops.c11
-rw-r--r--source/blender/editors/armature/editarmature.c93
3 files changed, 105 insertions, 1 deletions
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index 0f416c240d2..2e021c2f4ae 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -41,12 +41,14 @@ void ARMATURE_OT_subdivide_simple(struct wmOperatorType *ot);
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 */
diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c
index 896982627da..65345094720 100644
--- a/source/blender/editors/armature/armature_ops.c
+++ b/source/blender/editors/armature/armature_ops.c
@@ -107,6 +107,7 @@ void ARMATURE_OT_test(wmOperatorType *ot)
/* 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 @@ void ED_operatortypes_armature(void)
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 @@ void ED_keymap_armature(wmWindowManager *wm)
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 @@ void ED_keymap_armature(wmWindowManager *wm)
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);
}
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index 6262642f7f9..e18497c42c8 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -3509,7 +3509,56 @@ void ARMATURE_OT_parent_clear(wmOperatorType *ot)
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 */
+ if (CTX_DATA_COUNT(C, selected_bones) > 0) sel=0;
+
+ /* 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_OBJECT|ND_BONE_SELECT, NULL);
+
+ 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 +4378,49 @@ void POSE_OT_rot_clear(wmOperatorType *ot)
/* 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 */
+ if (CTX_DATA_COUNT(C, selected_pchans) > 0) sel=0;
+
+ /* 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_OBJECT|ND_BONE_SELECT, NULL);
+
+ 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)