diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-04-22 18:16:39 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-04-22 18:45:14 +0300 |
commit | e6d1fb87c6b0184416ce202ccba6a96a3ee04552 (patch) | |
tree | 39e1e321364129dfae355ecff938f0bafb5eae33 /release | |
parent | b8e7991811dcf6fa698077f850fef17be83d2abb (diff) |
UI: Initial popover support for panels
- UILayout.popover(.. panel_type ..)
A single panel
- UILayout.popover_group(.. panel categories ..)
Expands all panels matching args.
Currently used in the topbar for redo and paint options.
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/modules/bpy_types.py | 9 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/space_topbar.py | 25 |
2 files changed, 34 insertions, 0 deletions
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 1124070fea2..324bb43d890 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -144,6 +144,15 @@ class WindowManager(bpy_types.ID): finally: self.popmenu_end__internal(popup) + def popover(self, draw_func, title="", icon='NONE'): + import bpy + popup = self.popover_begin__internal(title, icon) + + try: + draw_func(popup, bpy.context) + finally: + self.popover_end__internal(popup) + def popup_menu_pie(self, event, draw_func, title="", icon='NONE'): import bpy pie = self.piemenu_begin__internal(title, icon, event) diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py index e9258f10882..868c60b6a1a 100644 --- a/release/scripts/startup/bl_ui/space_topbar.py +++ b/release/scripts/startup/bl_ui/space_topbar.py @@ -113,12 +113,37 @@ class TOPBAR_HT_lower_bar(Header): act_mode_item = bpy.types.Object.bl_rna.properties['mode'].enum_items[object_mode] layout.operator_menu_enum("object.mode_set", "mode", text=act_mode_item.name, icon=act_mode_item.icon) + mode = context.mode + + # Example of how toolsettings can be accessed as pop-overs. + if mode == 'SCULPT': + layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context="", category="Tools") + elif mode == 'PAINT_VERTEX': + layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context="", category="Tools") + elif mode == 'PAINT_WEIGHT': + layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context="", category="Tools") + elif mode == 'PAINT_TEXTURE': + layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context="", category="Tools") + def draw_right(self, context): layout = self.layout # Placeholder layout.operator("ed.undo_history", text="...") + # Last Action (redo) + layout.label("Last Action:") + operators = context.window_manager.operators + op = operators[-1] if operators else None + row = layout.row() + row.enabled = op is not None + row.popover( + space_type='VIEW_3D', + region_type='TOOL_PROPS', + panel_type="VIEW3D_PT_last_operator", + text=op.name if op else "Last Action...", + ) + class INFO_MT_editor_menus(Menu): bl_idname = "INFO_MT_editor_menus" |