Fix T79075: Tool popup fails with experimental vertex colors enabled
Register key-maps from tools in functions.
This commit is contained in:
@@ -271,19 +271,24 @@ class ToolSelectPanelHelper:
|
|||||||
yield item, i
|
yield item, i
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
# Special internal function, gives use items that contain keymaps.
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _tools_flatten_with_keymap(tools):
|
def _tools_flatten_with_dynamic(tools, *, context):
|
||||||
|
"""
|
||||||
|
Expands dynamic items, indices aren't aligned with other flatten functions.
|
||||||
|
The context may be None, use as signal to return all items.
|
||||||
|
"""
|
||||||
for item_parent in tools:
|
for item_parent in tools:
|
||||||
if item_parent is None:
|
if item_parent is None:
|
||||||
continue
|
yield None
|
||||||
for item in item_parent if (type(item_parent) is tuple) else (item_parent,):
|
for item in item_parent if (type(item_parent) is tuple) else (item_parent,):
|
||||||
# skip None or generator function
|
if item is None:
|
||||||
if item is None or _item_is_fn(item):
|
yield None
|
||||||
continue
|
elif _item_is_fn(item):
|
||||||
if item.keymap is not None:
|
yield from ToolSelectPanelHelper._tools_flatten_with_dynamic(item(context), context=context)
|
||||||
|
else:
|
||||||
yield item
|
yield item
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _tool_get_active(cls, context, space_type, mode, with_icon=False):
|
def _tool_get_active(cls, context, space_type, mode, with_icon=False):
|
||||||
"""
|
"""
|
||||||
@@ -484,8 +489,12 @@ class ToolSelectPanelHelper:
|
|||||||
else:
|
else:
|
||||||
context_descr = context_mode.replace("_", " ").title()
|
context_descr = context_mode.replace("_", " ").title()
|
||||||
|
|
||||||
for item in cls._tools_flatten_with_keymap(tools):
|
for item in cls._tools_flatten_with_dynamic(tools, context=None):
|
||||||
|
if item is None:
|
||||||
|
continue
|
||||||
keymap_data = item.keymap
|
keymap_data = item.keymap
|
||||||
|
if keymap_data is None:
|
||||||
|
continue
|
||||||
if callable(keymap_data[0]):
|
if callable(keymap_data[0]):
|
||||||
cls._km_action_simple(kc_default, kc_default, context_descr, item.label, keymap_data)
|
cls._km_action_simple(kc_default, kc_default, context_descr, item.label, keymap_data)
|
||||||
|
|
||||||
@@ -498,8 +507,13 @@ class ToolSelectPanelHelper:
|
|||||||
|
|
||||||
for context_mode_test, tools in cls.tools_all():
|
for context_mode_test, tools in cls.tools_all():
|
||||||
if context_mode_test == context_mode:
|
if context_mode_test == context_mode:
|
||||||
for item in cls._tools_flatten_with_keymap(tools):
|
for item in cls._tools_flatten(tools):
|
||||||
km_name = item.keymap[0]
|
if item is None:
|
||||||
|
continue
|
||||||
|
keymap_data = item.keymap
|
||||||
|
if keymap_data is None:
|
||||||
|
continue
|
||||||
|
km_name = keymap_data[0]
|
||||||
# print((km.name, cls.bl_space_type, 'WINDOW', []))
|
# print((km.name, cls.bl_space_type, 'WINDOW', []))
|
||||||
|
|
||||||
if km_name in visited:
|
if km_name in visited:
|
||||||
|
|||||||
@@ -2496,15 +2496,17 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
|
|||||||
_defs_sculpt.cloth_filter,
|
_defs_sculpt.cloth_filter,
|
||||||
lambda context: (
|
lambda context: (
|
||||||
(_defs_sculpt.color_filter,)
|
(_defs_sculpt.color_filter,)
|
||||||
if bpy.context.preferences.view.show_developer_ui and \
|
if context is None or (
|
||||||
bpy.context.preferences.experimental.use_sculpt_vertex_colors
|
context.preferences.view.show_developer_ui and
|
||||||
|
context.preferences.experimental.use_sculpt_vertex_colors)
|
||||||
else ()
|
else ()
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
lambda context: (
|
lambda context: (
|
||||||
(_defs_sculpt.mask_by_color,)
|
(_defs_sculpt.mask_by_color,)
|
||||||
if bpy.context.preferences.view.show_developer_ui and \
|
if context is None or (
|
||||||
bpy.context.preferences.experimental.use_sculpt_vertex_colors
|
context.preferences.view.show_developer_ui and
|
||||||
|
context.preferences.experimental.use_sculpt_vertex_colors)
|
||||||
else ()
|
else ()
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
|
|||||||
Reference in New Issue
Block a user