diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2021-02-12 22:24:38 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2021-02-12 22:24:38 +0300 |
commit | 152f5205c57be8cb4450178bf7c4d25c5824d9f9 (patch) | |
tree | 7c5eae9bd2ef5cb59732f8f6151b21322f730325 /rigify/utils/layers.py | |
parent | 814c3a693f671228ad905881f03ad7c80d1d8d0f (diff) |
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.
Diffstat (limited to 'rigify/utils/layers.py')
-rw-r--r-- | rigify/utils/layers.py | 23 |
1 files changed, 21 insertions, 2 deletions
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") |