Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_ui/space_toolsystem_common.py
| # SPDX-License-Identifier: GPL-2.0-or-later | # SPDX-License-Identifier: GPL-2.0-or-later | ||||
| import bpy | import bpy | ||||
| from bpy.types import ( | from bpy.types import ( | ||||
| Menu, | Menu, | ||||
| ) | ) | ||||
| from bpy.app.translations import pgettext_tip as tip_ | from bpy.app.translations import pgettext_tip as tip_ | ||||
| from bpy.app.translations import pgettext_iface as iface_ | |||||
| __all__ = ( | __all__ = ( | ||||
| "ToolDef", | "ToolDef", | ||||
| "ToolSelectPanelHelper", | "ToolSelectPanelHelper", | ||||
| "activate_by_id", | "activate_by_id", | ||||
| "activate_by_id_or_cycle", | "activate_by_id_or_cycle", | ||||
| "description_from_id", | "description_from_id", | ||||
| "keymap_from_id", | "keymap_from_id", | ||||
| ▲ Show 20 Lines • Show All 773 Lines • ▼ Show 20 Lines | ): | ||||
| cls = ToolSelectPanelHelper._tool_class_from_space_type(space_type) | cls = ToolSelectPanelHelper._tool_class_from_space_type(space_type) | ||||
| item, tool, icon_value = cls._tool_get_active(context, space_type, mode, with_icon=True) | item, tool, icon_value = cls._tool_get_active(context, space_type, mode, with_icon=True) | ||||
| if item is None: | if item is None: | ||||
| return None | return None | ||||
| # Note: we could show 'item.text' here but it makes the layout jitter when switching tools. | # Note: we could show 'item.text' here but it makes the layout jitter when switching tools. | ||||
| # Add some spacing since the icon is currently assuming regular small icon size. | # Add some spacing since the icon is currently assuming regular small icon size. | ||||
| if show_tool_icon_always: | if show_tool_icon_always: | ||||
| layout.label(text=" " + item.label, icon_value=icon_value) | layout.label(text=" " + iface_(item.label, "Operator"), icon_value=icon_value) | ||||
| layout.separator() | layout.separator() | ||||
| else: | else: | ||||
| if context.space_data.show_region_toolbar: | if context.space_data.show_region_toolbar: | ||||
| layout.template_icon(icon_value=0, scale=0.5) | layout.template_icon(icon_value=0, scale=0.5) | ||||
| else: | else: | ||||
| layout.template_icon(icon_value=icon_value, scale=0.5) | layout.template_icon(icon_value=icon_value, scale=0.5) | ||||
| layout.separator() | layout.separator() | ||||
| Show All 14 Lines | ): | ||||
| label = "Active Tool" | label = "Active Tool" | ||||
| split = layout.split(factor=0.33) | split = layout.split(factor=0.33) | ||||
| row = split.row() | row = split.row() | ||||
| row.alignment = 'RIGHT' | row.alignment = 'RIGHT' | ||||
| row.label(text="Drag:") | row.label(text="Drag:") | ||||
| row = split.row() | row = split.row() | ||||
| row.context_pointer_set("tool", tool) | row.context_pointer_set("tool", tool) | ||||
| row.popover(panel="TOPBAR_PT_tool_fallback", text=label) | row.popover(panel="TOPBAR_PT_tool_fallback", text=iface_(label, "Operator")) | ||||
| return tool | return tool | ||||
| # Show a list of tools in the popover. | # Show a list of tools in the popover. | ||||
| @staticmethod | @staticmethod | ||||
| def draw_fallback_tool_items(layout, context): | def draw_fallback_tool_items(layout, context): | ||||
| space_type = context.space_data.type | space_type = context.space_data.type | ||||
| if space_type == 'PROPERTIES': | if space_type == 'PROPERTIES': | ||||
| ▲ Show 20 Lines • Show All 387 Lines • Show Last 20 Lines | |||||