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
path: root/source
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2014-04-25 19:07:30 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2014-04-25 19:22:49 +0400
commit18060d863207d98a06b743437f2353516605436e (patch)
tree12c659f67eca3ed79e8ab81f267f86bb5faf25a4 /source
parentdd86773969e6eb6db69495dfee07688fe4bdf8bd (diff)
Fix T39895: Displaying the armature layers popup in edit mode always fails.
In fact, armature layers operators (set layers, and show all) were kind of messy and broken in Edit mode (Select layers had two different operators for Pose and Edit modes, both using the same funcs that could only work in Pose mode, Show All was supposed to be used in both modes but again, its exec code could only work in Pose one). Fixed that by: * Using only one op for each task, for both modes (with adapted poll func). * Replacing 'object from context' access by an helper that returns the right Armature object in both Edit and Pose modes.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/armature/armature_intern.h1
-rw-r--r--source/blender/editors/armature/armature_ops.c5
-rw-r--r--source/blender/editors/armature/pose_edit.c73
3 files changed, 39 insertions, 40 deletions
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index f3db9042879..1d054ffc2e9 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -133,7 +133,6 @@ void POSE_OT_rotation_mode_set(struct wmOperatorType *ot);
void POSE_OT_quaternions_flip(struct wmOperatorType *ot);
-void POSE_OT_armature_layers(struct wmOperatorType *ot);
void POSE_OT_bone_layers(struct wmOperatorType *ot);
/* ******************************************************* */
diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c
index f3c23c1f202..b7e38546ca2 100644
--- a/source/blender/editors/armature/armature_ops.c
+++ b/source/blender/editors/armature/armature_ops.c
@@ -139,7 +139,6 @@ void ED_operatortypes_armature(void)
WM_operatortype_append(POSE_OT_quaternions_flip);
- WM_operatortype_append(POSE_OT_armature_layers);
WM_operatortype_append(POSE_OT_bone_layers);
WM_operatortype_append(POSE_OT_propagate);
@@ -284,7 +283,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_toggle", WKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_enable", WKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_disable", WKEY, KM_PRESS, KM_ALT, 0);
-
+
/* armature/bone layers */
WM_keymap_add_item(keymap, "ARMATURE_OT_layers_show_all", ACCENTGRAVEKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_armature_layers", MKEY, KM_PRESS, KM_SHIFT, 0);
@@ -385,7 +384,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
/* armature/bone layers */
WM_keymap_add_item(keymap, "ARMATURE_OT_layers_show_all", ACCENTGRAVEKEY, KM_PRESS, KM_CTRL, 0);
- WM_keymap_add_item(keymap, "POSE_OT_armature_layers", MKEY, KM_PRESS, KM_SHIFT, 0);
+ WM_keymap_add_item(keymap, "ARMATURE_OT_armature_layers", MKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "POSE_OT_bone_layers", MKEY, KM_PRESS, 0, 0);
/* special transforms: */
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index 4705d106248..26ea4835b7d 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -707,17 +707,37 @@ void POSE_OT_rotation_mode_set(wmOperatorType *ot)
/* ********************************************** */
-/* Show all armature layers */
-static int pose_armature_layers_showall_poll(bContext *C)
+static int armature_layers_poll(bContext *C)
{
- /* this single operator can be used in posemode OR editmode for armatures */
+ /* Armature layers operators can be used in posemode OR editmode for armatures */
return ED_operator_posemode(C) || ED_operator_editarmature(C);
}
+static bArmature *armature_layers_get_data(Object **ob)
+{
+ bArmature *arm = NULL;
+
+ /* Sanity checking and handling of posemode. */
+ if (*ob) {
+ Object *tob = BKE_object_pose_armature_get(*ob);
+ if (tob) {
+ *ob = tob;
+ arm = (*ob)->data;
+ }
+ else if ((*ob)->type == OB_ARMATURE) {
+ arm = (*ob)->data;
+ }
+ }
+
+ return arm;
+}
+
+/* Show all armature layers */
+
static int pose_armature_layers_showall_exec(bContext *C, wmOperator *op)
{
- Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
- bArmature *arm = (ob) ? ob->data : NULL;
+ Object *ob = CTX_data_active_object(C);
+ bArmature *arm = armature_layers_get_data(&ob);
PointerRNA ptr;
int maxLayers = (RNA_boolean_get(op->ptr, "all")) ? 32 : 16;
int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
@@ -754,7 +774,7 @@ void ARMATURE_OT_layers_show_all(wmOperatorType *ot)
/* callbacks */
ot->exec = pose_armature_layers_showall_exec;
- ot->poll = pose_armature_layers_showall_poll;
+ ot->poll = armature_layers_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -766,10 +786,10 @@ void ARMATURE_OT_layers_show_all(wmOperatorType *ot)
/* ------------------- */
/* Present a popup to get the layers that should be used */
-static int pose_armature_layers_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+static int armature_layers_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
- bArmature *arm = (ob) ? ob->data : NULL;
+ Object *ob = CTX_data_active_object(C);
+ bArmature *arm = armature_layers_get_data(&ob);
PointerRNA ptr;
int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
@@ -787,13 +807,14 @@ static int pose_armature_layers_invoke(bContext *C, wmOperator *op, const wmEven
}
/* Set the visible layers for the active armature (edit and pose modes) */
-static int pose_armature_layers_exec(bContext *C, wmOperator *op)
+static int armature_layers_exec(bContext *C, wmOperator *op)
{
- Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
+ Object *ob = CTX_data_active_object(C);
+ bArmature *arm = armature_layers_get_data(&ob);
PointerRNA ptr;
int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
- if (ELEM(NULL, ob, ob->data)) {
+ if (arm == NULL) {
return OPERATOR_CANCELLED;
}
@@ -801,7 +822,7 @@ static int pose_armature_layers_exec(bContext *C, wmOperator *op)
RNA_boolean_get_array(op->ptr, "layers", layers);
/* get pointer for armature, and write data there... */
- RNA_id_pointer_create((ID *)ob->data, &ptr);
+ RNA_id_pointer_create((ID *)arm, &ptr);
RNA_boolean_set_array(&ptr, "layers", layers);
/* note, notifier might evolve */
@@ -810,26 +831,6 @@ static int pose_armature_layers_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-
-void POSE_OT_armature_layers(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Change Armature Layers";
- ot->idname = "POSE_OT_armature_layers";
- ot->description = "Change the visible armature layers";
-
- /* callbacks */
- ot->invoke = pose_armature_layers_invoke;
- ot->exec = pose_armature_layers_exec;
- ot->poll = ED_operator_posemode;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
- RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers to make visible");
-}
-
void ARMATURE_OT_armature_layers(wmOperatorType *ot)
{
/* identifiers */
@@ -838,9 +839,9 @@ void ARMATURE_OT_armature_layers(wmOperatorType *ot)
ot->description = "Change the visible armature layers";
/* callbacks */
- ot->invoke = pose_armature_layers_invoke;
- ot->exec = pose_armature_layers_exec;
- ot->poll = ED_operator_editarmature;
+ ot->invoke = armature_layers_invoke;
+ ot->exec = armature_layers_exec;
+ ot->poll = armature_layers_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;