Page MenuHome

armaturelayers2.patch

armaturelayers2.patch

Index: source/blender/editors/armature/armature_ops.c
===================================================================
--- source/blender/editors/armature/armature_ops.c (revision 31450)
+++ source/blender/editors/armature/armature_ops.c (working copy)
@@ -84,7 +84,9 @@
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);
WM_operatortype_append(SKETCH_OT_delete);
Index: source/blender/editors/armature/armature_intern.h
===================================================================
--- source/blender/editors/armature/armature_intern.h (revision 31450)
+++ source/blender/editors/armature/armature_intern.h (working copy)
@@ -78,6 +78,8 @@
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 */
Index: source/blender/editors/armature/poseobject.c
===================================================================
--- source/blender/editors/armature/poseobject.c (revision 31450)
+++ source/blender/editors/armature/poseobject.c (working copy)
@@ -1593,6 +1593,10 @@
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,120 @@
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_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, 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= ED_operator_editarmature;
+
+ /* 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, "layer_protection", 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, "layer_protection", layers);
+
+ /* note, notifier might evolve */
+ WM_event_add_notifier(C, NC_OBJECT|ND_POSE, 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= ED_operator_editarmature;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
/* ------------------- */
/* Present a popup to get the layers that should be used */
Index: source/blender/editors/interface/interface_handlers.c
===================================================================
--- source/blender/editors/interface/interface_handlers.c (revision 31450)
+++ source/blender/editors/interface/interface_handlers.c (working copy)
@@ -4115,6 +4115,19 @@
uiItemS(layout);
+ /* add layer visibility options to the bone layers menu */
+ if( strcmp(name, "Visible Layers")==0 )
+ {
+ uiItemO(layout, "Togglle All Bone Layers Visibility", 0, "ARMATURE_OT_all_bone_layers");
+ uiItemS(layout);
+ }
+
+ if( strcmp(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

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
b6/fc/fdbfe69af5ddba291607631c645c

Event Timeline