[Bf-extensions-cvs] [152f5205] master: Rigify: revert D8801 to restore dots marking layers of the active bone.

Alexander Gavrilov noreply at git.blender.org
Fri Feb 12 20:27:08 CET 2021


Commit: 152f5205c57be8cb4450178bf7c4d25c5824d9f9
Author: Alexander Gavrilov
Date:   Fri Feb 12 22:24:38 2021 +0300
Branches: master
https://developer.blender.org/rBA152f5205c57be8cb4450178bf7c4d25c5824d9f9

Rigify: revert D8801 to restore dots marking layers of the active bone.

The built-in layer button UI only draws dots if the property
belongs to an Armature, as a special behavior hard-coded in C.

This returns to drawing the UI from Python but using cleaner code.

===================================================================

M	rigify/utils/layers.py

===================================================================

diff --git a/rigify/utils/layers.py b/rigify/utils/layers.py
index 52deeac0..1f65863d 100644
--- a/rigify/utils/layers.py
+++ b/rigify/utils/layers.py
@@ -63,6 +63,24 @@ def set_bone_layers(bone, layers, combine=False):
 # UI utilities
 #=============================================
 
+
+def layout_layer_buttons(layout, params, option, active_layers):
+    "Draw a layer selection button UI with certain layers marked with dots."
+    outer = layout.row()
+
+    for x in [0, 8]:
+        col = outer.column(align=True)
+
+        for y in [0, 16]:
+            row = col.row(align=True)
+
+            for i in range(x+y, x+y+8):
+                row.prop(
+                    params, option, index=i, toggle=True, text="",
+                    icon="LAYER_ACTIVE" if active_layers[i] else "NONE"
+                )
+
+
 class ControlLayersOption:
     def __init__(self, name, toggle_name=None, toggle_default=True, description="Set of control layers"):
         self.name = name
@@ -131,8 +149,9 @@ class ControlLayersOption:
         if not active:
             return
 
-        row = box.row(align=True)
-        row.prop(params, self.layers_option, text="")
+        active_layers = bpy.context.active_pose_bone.bone.layers[:]
+
+        layout_layer_buttons(box, params, self.layers_option, active_layers)
 
 
 ControlLayersOption.FK = ControlLayersOption('fk', description="Layers for the FK controls to be on")



More information about the Bf-extensions-cvs mailing list