Tool System: remove custom tool registration
API is not ready for beta (likely to change).
This commit is contained in:
parent
6491d50d02
commit
1b870bce85
Notes:
blender-bot
2023-02-14 05:01:20 +01:00
Referenced by issue #59077, Poor hair editing performance
|
@ -717,48 +717,6 @@ def register_submodule_factory(module_name, submodule_names):
|
|||
return register, unregister
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Tool Registraion
|
||||
|
||||
def register_tool(space_type, context_mode, tool_def):
|
||||
from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
|
||||
cls = ToolSelectPanelHelper._tool_class_from_space_type(space_type)
|
||||
if cls is None:
|
||||
raise Exception(f"Space type {space_type!r} has no toolbar")
|
||||
tools = cls._tools[context_mode]
|
||||
|
||||
keymap_data = tool_def.keymap
|
||||
if keymap_data is not None:
|
||||
if context_mode is None:
|
||||
context_descr = "All"
|
||||
else:
|
||||
context_descr = context_mode.replace("_", " ").title()
|
||||
from bpy import context
|
||||
wm = context.window_manager
|
||||
kc = wm.keyconfigs.default
|
||||
if callable(keymap_data[0]):
|
||||
cls._km_action_simple(kc, context_descr, tool_def.text, keymap_data)
|
||||
|
||||
tools.append(tool_def)
|
||||
|
||||
|
||||
def unregister_tool(space_type, context_mode, tool_def):
|
||||
from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
|
||||
cls = ToolSelectPanelHelper._tool_class_from_space_type(space_type)
|
||||
if cls is None:
|
||||
raise Exception(f"Space type {space_type!r} has no toolbar")
|
||||
tools = cls._tools[context_mode]
|
||||
tools.remove(tool_def)
|
||||
|
||||
keymap_data = tool_def.keymap
|
||||
if keymap_data is not None:
|
||||
from bpy import context
|
||||
wm = context.window_manager
|
||||
kc = wm.keyconfigs.default
|
||||
km = keymap_data[0]
|
||||
kc.keymaps.remove(km)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Manual lookups, each function has to return a basepath and a sequence
|
||||
# of...
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
# This example adds an object mode tool to the toolbar.
|
||||
# This is just the circle-select tool.
|
||||
import bpy
|
||||
from bpy.utils.toolsystem import ToolDef
|
||||
|
||||
@ToolDef.from_fn
|
||||
def my_tool():
|
||||
def draw_settings(context, layout, tool):
|
||||
props = tool.operator_properties("view3d.select_circle")
|
||||
layout.prop(props, "radius")
|
||||
return dict(
|
||||
text="My Circle Select",
|
||||
description=(
|
||||
"This is a tooltip\n"
|
||||
"with multiple lines"
|
||||
),
|
||||
icon="ops.generic.select_circle",
|
||||
widget=None,
|
||||
keymap=(
|
||||
("view3d.select_circle", dict(deselect=False), dict(type='LEFTMOUSE', value='PRESS')),
|
||||
("view3d.select_circle", dict(deselect=True), dict(type='LEFTMOUSE', value='PRESS', ctrl=True)),
|
||||
),
|
||||
draw_settings=draw_settings,
|
||||
)
|
||||
|
||||
|
||||
def register():
|
||||
bpy.utils.register_tool('VIEW_3D', 'OBJECT', my_tool)
|
||||
|
||||
|
||||
def unregister():
|
||||
bpy.utils.unregister_tool('VIEW_3D', 'OBJECT', my_tool)
|
||||
|
||||
if __name__ == "__main__":
|
||||
register()
|
Loading…
Reference in New Issue