UI: Add menu to show the toolbar
For people who prefer to keep the toolbar hidden, expose as a menu (currently Shift-Space).
This commit is contained in:
@@ -2356,6 +2356,26 @@ class WM_OT_tool_set_by_name(Operator):
|
||||
return {'CANCELLED'}
|
||||
|
||||
|
||||
class WM_OT_toolbar(Operator):
|
||||
bl_idname = "wm.toolbar"
|
||||
bl_label = "Toolbar"
|
||||
|
||||
def execute(self, context):
|
||||
|
||||
def draw_menu(popover, context):
|
||||
from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
|
||||
space_type = context.space_data.type
|
||||
cls = ToolSelectPanelHelper._tool_class_from_space_type(space_type)
|
||||
if cls is None:
|
||||
self.report({'WARNING'}, "Toolbar not found for {space_type!r}")
|
||||
return {'CANCELLED'}
|
||||
cls.draw_cls(popover.layout, context, detect_layout=False)
|
||||
|
||||
wm = context.window_manager
|
||||
wm.popup_menu(draw_menu)
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
classes = (
|
||||
BRUSH_OT_active_index_set,
|
||||
WM_OT_addon_disable,
|
||||
@@ -2411,4 +2431,5 @@ classes = (
|
||||
WM_OT_owner_enable,
|
||||
WM_OT_url_open,
|
||||
WM_OT_tool_set_by_name,
|
||||
WM_OT_toolbar,
|
||||
)
|
||||
|
||||
@@ -432,7 +432,7 @@ class ToolSelectPanelHelper:
|
||||
|
||||
|
||||
@classmethod
|
||||
def draw_cls(cls, layout, context):
|
||||
def draw_cls(cls, layout, context, detect_layout=True):
|
||||
# Use a classmethod so it can be called outside of a panel context.
|
||||
|
||||
# XXX, this UI isn't very nice.
|
||||
@@ -447,7 +447,11 @@ class ToolSelectPanelHelper:
|
||||
"name", None,
|
||||
)
|
||||
|
||||
ui_gen, show_text = cls._layout_generator_detect_from_region(layout, context.region)
|
||||
if detect_layout:
|
||||
ui_gen, show_text = cls._layout_generator_detect_from_region(layout, context.region)
|
||||
else:
|
||||
ui_gen = ToolSelectPanelHelper._layout_generator_single_column(layout)
|
||||
show_text = True
|
||||
|
||||
# Start iteration
|
||||
ui_gen.send(None)
|
||||
|
||||
@@ -4637,7 +4637,10 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
|
||||
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", -1);
|
||||
WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", UPARROWKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", DOWNARROWKEY, KM_PRESS, KM_CTRL, 0);
|
||||
/* we already have two keys for this, disabled for use by WM_OT_toolbar */
|
||||
#if 0
|
||||
WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", SPACEKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
#endif
|
||||
kmi = WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", F10KEY, KM_PRESS, KM_ALT, 0);
|
||||
RNA_boolean_set(kmi->ptr, "use_hide_panels", true);
|
||||
|
||||
|
||||
@@ -3959,6 +3959,8 @@ void wm_window_keymap(wmKeyConfig *keyconf)
|
||||
WM_keymap_add_menu(keymap, "USERPREF_MT_ndof_settings", NDOF_BUTTON_MENU, KM_PRESS, 0, 0);
|
||||
#endif
|
||||
|
||||
WM_keymap_add_item(keymap, "WM_OT_toolbar", SPACEKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
|
||||
/* Space switching */
|
||||
kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", F3KEY, KM_PRESS, KM_SHIFT, 0);
|
||||
RNA_string_set(kmi->ptr, "data_path", "area.type");
|
||||
|
||||
Reference in New Issue
Block a user