Page Menu
Home
Search
Configure Global Search
Log In
Files
F11159
armaturelayers4.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Shane Ambler (sambler)
Nov 13 2013, 2:21 PM
Size
7 KB
Subscribers
None
armaturelayers4.patch
View Options
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index fadb4f2..3f91d51 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -78,6 +78,8 @@ void ARMATURE_OT_flags_set(struct wmOperatorType *ot);
void ARMATURE_OT_armature_layers(struct wmOperatorType *ot);
void ARMATURE_OT_bone_layers(struct wmOperatorType *ot);
+void ARMATURE_OT_all_bone_layers(struct wmOperatorType *ot);
+void ARMATURE_OT_all_bone_protected_layers(struct wmOperatorType *ot);
/* ******************************************************* */
/* Pose-Mode Operators */
diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c
index 908aa5b..14461f1 100644
--- a/source/blender/editors/armature/armature_ops.c
+++ b/source/blender/editors/armature/armature_ops.c
@@ -84,6 +84,8 @@ void ED_operatortypes_armature(void)
WM_operatortype_append(ARMATURE_OT_armature_layers);
WM_operatortype_append(ARMATURE_OT_bone_layers);
+ WM_operatortype_append(ARMATURE_OT_all_bone_layers);
+ WM_operatortype_append(ARMATURE_OT_all_bone_protected_layers);
/* SKETCH */
WM_operatortype_append(SKETCH_OT_gesture);
diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c
index 3bbbb27..dffdb7a 100644
--- a/source/blender/editors/armature/poseobject.c
+++ b/source/blender/editors/armature/poseobject.c
@@ -1593,6 +1593,10 @@ static int pose_armature_layers_exec (bContext *C, wmOperator *op)
PointerRNA ptr;
int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
+ /* sanity checking */
+ if (arm == NULL)
+ return OPERATOR_CANCELLED;
+
/* get the values set in the operator properties */
RNA_boolean_get_array(op->ptr, "layers", layers);
@@ -1645,6 +1649,124 @@ void ARMATURE_OT_armature_layers (wmOperatorType *ot)
RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers to make visible");
}
+/* change visiblilty of all armature layers */
+static int armature_all_layers_poll(bContext *C)
+{
+ return 1; /* we always want to say yes as the menu decides if it exsists which means it is always active */
+}
+
+static int armature_all_layers_toggle_exec (bContext *C, wmOperator *op)
+{
+ Object *ob= CTX_data_active_object(C);
+ bArmature *arm= (ob)? ob->data : NULL;
+ PointerRNA ptr;
+ int x, vis, layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
+
+ /* sanity checking */
+ if (arm == NULL)
+ return OPERATOR_CANCELLED;
+
+ /* get pointer for armature */
+ RNA_id_pointer_create((ID *)arm, &ptr);
+
+ /* get the current layer values */
+ RNA_boolean_get_array(&ptr, "layers", layers);
+
+ /* add up the number of layers that are visible */
+ vis= 0;
+ for(x=0;x<32;x++)
+ vis= vis+(layers[x]>0);
+
+ if(vis < 16)
+ vis= 1; /* less than 50% visible make them all visible */
+ else
+ vis= 0; /* more than 50% visible make them all invisible */
+
+ /* set the layers visibility */
+ for(x=0;x<32;x++)
+ layers[x]= vis;
+
+ if(!vis) layers[0]= 1; /* make sure one layer is visible */
+ /* could we have an active armature layer/s that can be restored in the event of turning off layers? */
+
+ /* save visibility settings to the armature */
+ RNA_boolean_set_array(&ptr, "layers", layers);
+
+ /* note, notifier might evolve */
+ WM_event_add_notifier(C, NC_OBJECT|ND_POSE|ND_SPACE_PROPERTIES, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void ARMATURE_OT_all_bone_layers (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Toggle Armature Layers Visibility";
+ ot->idname= "ARMATURE_OT_all_bone_layers";
+ ot->description= "Toggle all armature layers visibility";
+
+ /* callbacks */
+ ot->exec= armature_all_layers_toggle_exec;
+ ot->poll= armature_all_layers_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int armature_all_proxy_layers_toggle_exec (bContext *C, wmOperator *op)
+{
+ Object *ob= CTX_data_active_object(C);
+ bArmature *arm= (ob)? ob->data : NULL;
+ PointerRNA ptr;
+ int x, vis, layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
+
+ /* sanity checking */
+ if (arm == NULL)
+ return OPERATOR_CANCELLED;
+
+ /* get pointer for armature */
+ RNA_id_pointer_create((ID *)arm, &ptr);
+
+ /* get the current layer values */
+ RNA_boolean_get_array(&ptr, "layers_protected", layers);
+
+ /* add up the number of layers that are visible */
+ vis= 0;
+ for(x=0;x<32;x++)
+ vis= vis+(layers[x]>0);
+
+ if(vis < 16)
+ vis= 1; /* less than 50% visible make them all visible */
+ else
+ vis= 0; /* more than 50% visible make them all invisible */
+
+ /* set the layers visibility */
+ for(x=0;x<32;x++)
+ layers[x]= vis;
+
+ /* save visibility settings to the armature */
+ RNA_boolean_set_array(&ptr, "layers_protected", layers);
+
+ /* note, notifier might evolve */
+ WM_event_add_notifier(C, NC_OBJECT|ND_POSE|ND_SPACE_PROPERTIES, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void ARMATURE_OT_all_bone_protected_layers (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Toggle Protected Armature Layers Visibility";
+ ot->idname= "ARMATURE_OT_all_bone_protected_layers";
+ ot->description= "Toggle all armature protected layers visibility";
+
+ /* callbacks */
+ ot->exec= armature_all_proxy_layers_toggle_exec;
+ ot->poll= armature_all_layers_poll;
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
/* ------------------- */
/* Present a popup to get the layers that should be used */
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 484c78c..b2570b5 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -4138,6 +4138,20 @@ static int ui_but_menu(bContext *C, uiBut *but)
uiItemS(layout);
+ /* add layer visibility options to the bone layers menu */
+ if( BLI_strcasecmp(name, "Visible Layers")==0 )
+ {
+ uiItemO(layout, "Togglle All Bone Layers Visibility", 0, "ARMATURE_OT_all_bone_layers");
+ uiItemS(layout);
+ }
+
+ if( BLI_strcasecmp(name, "Layer Proxy Protection")==0 )
+ {
+ uiItemO(layout, "Toggle All Protected Layers Visibility", 0, "ARMATURE_OT_all_bone_protected_layers");
+ uiItemS(layout);
+ }
+
+
/* Property Operators */
//Copy Property Value
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
30/4d/f19dfad2a06c27c2a42c0b6f6e22
Event Timeline
Log In to Comment