UI/BPY: Remove grid layout for UI lists
The grid layout for UI lists wasn't used in practice from all we can
tell. It was badly maintained for a long time (bugs went unnoticed). I
think it was added for an earlier version of the asset UI design.
This was planned for removal in 5.0, see blender/blender#110461.
Usages in bundled scripts were already removed in efa8d942b8.
Pull Request: https://projects.blender.org/blender/blender/pulls/146656
This commit is contained in:
committed by
Julian Eisel
parent
f1d0f79302
commit
eef971e377
@@ -30,20 +30,14 @@ class MATERIAL_UL_matslots_example(bpy.types.UIList):
|
||||
ob = data
|
||||
slot = item
|
||||
ma = slot.material
|
||||
# draw_item must handle the three layout types... Usually 'DEFAULT' and 'COMPACT' can share the same code.
|
||||
if self.layout_type in {'DEFAULT', 'COMPACT'}:
|
||||
# You should always start your row layout by a label (icon + text), or a non-embossed text field,
|
||||
# this will also make the row easily selectable in the list! The later also enables ctrl-click rename.
|
||||
# We use icon_value of label, as our given icon is an integer value, not an enum ID.
|
||||
# Note "data" names should never be translated!
|
||||
if ma:
|
||||
layout.prop(ma, "name", text="", emboss=False, icon_value=icon)
|
||||
else:
|
||||
layout.label(text="", translate=False, icon_value=icon)
|
||||
# 'GRID' layout type should be as compact as possible (typically a single icon!).
|
||||
elif self.layout_type == 'GRID':
|
||||
layout.alignment = 'CENTER'
|
||||
layout.label(text="", icon_value=icon)
|
||||
# You should always start your row layout by a label (icon + text), or a non-embossed text field,
|
||||
# this will also make the row easily selectable in the list! The later also enables ctrl-click rename.
|
||||
# We use icon_value of label, as our given icon is an integer value, not an enum ID.
|
||||
# Note "data" names should never be translated!
|
||||
if ma:
|
||||
layout.prop(ma, "name", text="", emboss=False, icon_value=icon)
|
||||
else:
|
||||
layout.label(text="", translate=False, icon_value=icon)
|
||||
|
||||
|
||||
# And now we can use this list everywhere in Blender. Here is a small example panel.
|
||||
|
||||
@@ -66,24 +66,18 @@ class MESH_UL_vgroups_slow(bpy.types.UIList):
|
||||
|
||||
# assert(isinstance(item, bpy.types.VertexGroup)
|
||||
vgroup = item
|
||||
if self.layout_type in {'DEFAULT', 'COMPACT'}:
|
||||
# Here we use one feature of new filtering feature: it can pass data to draw_item, through flt_flag
|
||||
# parameter, which contains exactly what filter_items set in its filter list for this item!
|
||||
# In this case, we show empty groups grayed out.
|
||||
if flt_flag & self.VGROUP_EMPTY:
|
||||
col = layout.column()
|
||||
col.enabled = False
|
||||
col.alignment = 'LEFT'
|
||||
col.prop(vgroup, "name", text="", emboss=False, icon_value=icon)
|
||||
else:
|
||||
layout.prop(vgroup, "name", text="", emboss=False, icon_value=icon)
|
||||
icon = 'LOCKED' if vgroup.lock_weight else 'UNLOCKED'
|
||||
layout.prop(vgroup, "lock_weight", text="", icon=icon, emboss=False)
|
||||
elif self.layout_type == 'GRID':
|
||||
layout.alignment = 'CENTER'
|
||||
if flt_flag & self.VGROUP_EMPTY:
|
||||
layout.enabled = False
|
||||
layout.label(text="", icon_value=icon)
|
||||
# Here we use one feature of new filtering feature: it can pass data to draw_item, through flt_flag
|
||||
# parameter, which contains exactly what filter_items set in its filter list for this item!
|
||||
# In this case, we show empty groups grayed out.
|
||||
if flt_flag & self.VGROUP_EMPTY:
|
||||
col = layout.column()
|
||||
col.enabled = False
|
||||
col.alignment = 'LEFT'
|
||||
col.prop(vgroup, "name", text="", emboss=False, icon_value=icon)
|
||||
else:
|
||||
layout.prop(vgroup, "name", text="", emboss=False, icon_value=icon)
|
||||
icon = 'LOCKED' if vgroup.lock_weight else 'UNLOCKED'
|
||||
layout.prop(vgroup, "lock_weight", text="", icon=icon, emboss=False)
|
||||
|
||||
def draw_filter(self, context, layout):
|
||||
# Nothing much to say here, it's usual UI code...
|
||||
|
||||
Reference in New Issue
Block a user