UI: support for tool settings in the top-bar

This uses the operators last used properties
to store settings to use on the next execution.
This commit is contained in:
Campbell Barton 2018-04-27 14:13:16 +02:00
parent 9504652687
commit 85ea14df2f
2 changed files with 18 additions and 4 deletions

View File

@ -87,8 +87,13 @@ class ToolDef:
icon = None
# An optional manipulator group to activate when the tool is set or None for no widget.
widget = None
# An optional triple of: ``(operator_id, operator_properties, keymap_item_args)``.
# Optional keymap for tool, either:
# - A function that populates a keymaps passed in as an argument.
# - A tuple filled with triple's of:
# ``(operator_id, operator_properties, keymap_item_args)``.
keymap = None
# Optional draw settings (operator options, toolsettings).
draw_settings = None
class ToolSelectPanelHelper:
@ -344,6 +349,10 @@ class ToolSelectPanelHelper:
# Indent until we have better icon scaling.
layout.label(" " + item.text, icon_value=icon_value)
draw_settings = item.draw_settings
if draw_settings is not None:
draw_settings(context, layout)
# The purpose of this menu is to be a generic popup to select between tools
# in cases when a single tool allows to select alternative tools.

View File

@ -314,10 +314,17 @@ class _defs_edit_mesh:
widget = None
keymap = (
("mesh.knife_tool",
dict(wait_for_input=False, use_occlude_geometry=True, only_selected=False),
dict(wait_for_input=False),
dict(type='ACTIONMOUSE', value='PRESS')),
)
@classmethod
def draw_settings(cls, context, layout):
wm = context.window_manager
props = wm.operator_properties_last("mesh.knife_tool")
layout.prop(props, "use_occlude_geometry")
layout.prop(props, "only_selected")
class bisect(ToolDef):
text = "Bisect"
icon = "ops.mesh.bisect"
@ -374,8 +381,6 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
def tools_all(cls):
yield from cls._tools.items()
# Internal Data
# for reuse
_tools_transform = (
_defs_transform.translate,