Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_ui/space_topbar.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 Header, Menu, Panel | from bpy.types import Header, Menu, Panel | ||||
| from bpy.app.translations import ( | from bpy.app.translations import ( | ||||
| pgettext_iface as iface_, | pgettext_iface as iface_, | ||||
| contexts as i18n_contexts, | contexts as i18n_contexts, | ||||
| ) | ) | ||||
| class TOPBAR_HT_tool_bar(Header): | |||||
| bl_space_type = 'TOPBAR' | |||||
| bl_region_type = 'WINDOW' | |||||
| def draw(self, context): | |||||
| import sys | |||||
| region = context.region | |||||
| layout = self.layout | |||||
| window = context.window | |||||
| screen = context.screen | |||||
| scene = context.scene | |||||
| #row = layout.row() | |||||
| #col = row.column() | |||||
| layout.operator_context = 'INVOKE_AREA' | |||||
| layout.menu("TOPBAR_MT_file_new", text="", icon='FILE_NEW') | |||||
| row = layout.row(align=True) | |||||
| row.operator("wm.open_mainfile", text="", icon='FILE_FOLDER', emboss=False) | |||||
| sub = row.row(align=True) | |||||
| sub.menu("TOPBAR_MT_file_open_recent", text="", icon='TRIA_DOWN') | |||||
| layout.separator() | |||||
| layout.separator() | |||||
| if context.blend_data.is_saved: | |||||
| layout.operator_context = 'EXEC_AREA' | |||||
| layout.operator("wm.save_mainfile", text="", icon='FILE_TICK', emboss=False) | |||||
| else: | |||||
| layout.operator_context = 'INVOKE_AREA' | |||||
| layout.operator("wm.save_as_mainfile", text="", icon='FILE_TICK', emboss=False) | |||||
| layout.separator() | |||||
| layout.separator() | |||||
| layout.operator_context = 'INVOKE_DEFAULT' | |||||
| layout.operator("ed.undo", icon='LOOP_BACK', text="", emboss=False) | |||||
| layout.operator("ed.redo", icon='LOOP_FORWARDS', text="", emboss=False) | |||||
| layout.operator("screen.repeat_last", icon='FILE_REFRESH', text="", emboss=False) | |||||
| layout.operator("screen.redo_last", icon='OPTIONS', text="", emboss=False) | |||||
| layout.separator() | |||||
| layout.separator() | |||||
| layout.operator("wm.search_menu", text="", icon='VIEWZOOM', emboss=False) | |||||
| layout.operator("screen.userpref_show", text="", icon='PREFERENCES', emboss=False) | |||||
| layout.operator("wm.window_new", icon='WINDOW', text="", emboss=False) | |||||
| if sys.platform[:3] == "win": | |||||
| layout.operator("wm.console_toggle", icon='CONSOLE', text="", emboss=False) | |||||
| layout.separator() | |||||
| layout.separator() | |||||
| tool_settings = context.tool_settings | |||||
| layout.prop(tool_settings, "use_keyframe_insert_auto", text="", toggle=True) | |||||
| if not screen.is_animation_playing: | |||||
| layout.operator("screen.animation_play", text="", icon='PLAY', emboss=False) | |||||
| else: | |||||
| layout.operator("screen.animation_play", text="", icon='PAUSE', emboss=False) | |||||
| layout.prop(scene, "frame_current", text="") | |||||
| layout.separator() | |||||
| layout.separator() | |||||
| rd = scene.render | |||||
| if rd.has_multiple_engines: | |||||
| layout.prop(rd, "engine", text="") | |||||
| layout.operator("render.render", text="", icon='RENDER_STILL', emboss=False).use_viewport = True | |||||
| props = layout.operator("render.render", text="", icon='RENDER_ANIMATION', emboss=False) | |||||
| props.animation = True | |||||
| props.use_viewport = True | |||||
| class TOPBAR_HT_upper_bar(Header): | class TOPBAR_HT_upper_bar(Header): | ||||
| bl_space_type = 'TOPBAR' | bl_space_type = 'TOPBAR' | ||||
| bl_region_type = 'HEADER' | |||||
| def draw(self, context): | def draw(self, context): | ||||
| region = context.region | region = context.region | ||||
| if region.alignment == 'RIGHT': | if region.alignment == 'RIGHT': | ||||
| self.draw_right(context) | self.draw_right(context) | ||||
| else: | else: | ||||
| self.draw_left(context) | self.draw_left(context) | ||||
| ▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | |||||
| layout.operator("screen.workspace_cycle", | layout.operator("screen.workspace_cycle", | ||||
| text="Next Workspace").direction = 'NEXT' | text="Next Workspace").direction = 'NEXT' | ||||
| layout.operator("screen.workspace_cycle", | layout.operator("screen.workspace_cycle", | ||||
| text="Previous Workspace").direction = 'PREV' | text="Previous Workspace").direction = 'PREV' | ||||
| layout.separator() | layout.separator() | ||||
| layout.prop(context.screen, "show_toptoolbar") | |||||
| layout.prop(context.screen, "show_statusbar") | layout.prop(context.screen, "show_statusbar") | ||||
| layout.separator() | layout.separator() | ||||
| layout.operator("screen.screenshot") | layout.operator("screen.screenshot") | ||||
| # Showing the status in the area doesn't work well in this case. | # Showing the status in the area doesn't work well in this case. | ||||
| # - From the top-bar, the text replaces the file-menu (not so bad but strange). | # - From the top-bar, the text replaces the file-menu (not so bad but strange). | ||||
| ▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | |||||
| icon = 'CAMERA_DATA' | icon = 'CAMERA_DATA' | ||||
| elif self.is_using_pose_markers(context): | elif self.is_using_pose_markers(context): | ||||
| icon = 'ARMATURE_DATA' | icon = 'ARMATURE_DATA' | ||||
| row = self.row_with_icon(layout, icon) | row = self.row_with_icon(layout, icon) | ||||
| row.prop(marker, "name", text="") | row.prop(marker, "name", text="") | ||||
| classes = ( | classes = ( | ||||
| TOPBAR_HT_tool_bar, | |||||
| TOPBAR_HT_upper_bar, | TOPBAR_HT_upper_bar, | ||||
| TOPBAR_MT_file_context_menu, | TOPBAR_MT_file_context_menu, | ||||
| TOPBAR_MT_workspace_menu, | TOPBAR_MT_workspace_menu, | ||||
| TOPBAR_MT_editor_menus, | TOPBAR_MT_editor_menus, | ||||
| TOPBAR_MT_blender, | TOPBAR_MT_blender, | ||||
| TOPBAR_MT_blender_system, | TOPBAR_MT_blender_system, | ||||
| TOPBAR_MT_file, | TOPBAR_MT_file, | ||||
| TOPBAR_MT_file_new, | TOPBAR_MT_file_new, | ||||
| Show All 24 Lines | |||||