UI Experiment: Top Bar Quick Buttons #116967

Open
Harley Acheson wants to merge 1 commits from Harley/blender:TopBarIcons into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
4 changed files with 103 additions and 3 deletions

View File

@ -11,8 +11,98 @@ from bpy.app.translations import (
)
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
layout.operator_context = 'INVOKE_AREA'
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.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.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.menu("TOPBAR_MT_undo_history", text="", icon='TRIA_DOWN')
layout.operator("screen.repeat_last", icon='FILE_REFRESH', text="", emboss=False)
layout.operator("screen.redo_last", icon='OPTIONS', text="", emboss=False)
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()
tool_settings = context.tool_settings
layout.prop(tool_settings, "use_keyframe_insert_auto", text="", toggle=True, emboss=False)
row = layout.row(align=True)
row.operator("screen.frame_jump", text="", icon='REW', emboss=False).end = False
row.operator("screen.keyframe_jump", text="", icon='PREV_KEYFRAME', emboss=False).next = False
if not screen.is_animation_playing:
# if using JACK and A/V sync:
# hide the play-reversed button
# since JACK transport doesn't support reversed playback
if scene.sync_mode == 'AUDIO_SYNC' and context.preferences.system.audio_device == 'JACK':
row.scale_x = 2
row.operator("screen.animation_play", text="", icon='PLAY', emboss=False)
row.scale_x = 1
else:
row.operator("screen.animation_play", text="", icon='PLAY_REVERSE', emboss=False).reverse = True
row.operator("screen.animation_play", text="", icon='PLAY', emboss=False)
else:
row.scale_x = 2
row.operator("screen.animation_play", text="", icon='PAUSE', emboss=False)
row.scale_x = 1
row.operator("screen.keyframe_jump", text="", icon='NEXT_KEYFRAME', emboss=False).next = True
row.operator("screen.frame_jump", text="", icon='FF', emboss=False).end = True
layout.prop(scene, "frame_current", text="")
layout.separator()
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
rd = scene.render
if rd.has_multiple_engines:
layout.label(text="Render Engine")
layout.prop(rd, "engine", text="")
class TOPBAR_HT_upper_bar(Header):
bl_space_type = 'TOPBAR'
bl_region_type = 'HEADER'
def draw(self, context):
region = context.region
@ -665,6 +755,7 @@ class TOPBAR_MT_window(Menu):
layout.separator()
layout.prop(context.screen, "show_toptoolbar")
layout.prop(context.screen, "show_statusbar")
layout.separator()
@ -920,6 +1011,7 @@ class TOPBAR_PT_name_marker(Panel):
classes = (
TOPBAR_HT_tool_bar,
TOPBAR_HT_upper_bar,
TOPBAR_MT_file_context_menu,
TOPBAR_MT_workspace_menu,

View File

@ -1140,14 +1140,16 @@ static int screen_global_header_size()
static void screen_global_topbar_area_refresh(wmWindow *win, bScreen *screen)
{
const short size = screen_global_header_size();
const short size_min = screen_global_header_size();
const short size_max = size_min * 2;
const short size = (screen->flag & SCREEN_SHOW_TOPTOOLBAR) ? size_min : size_max;
rcti rect;
BLI_rcti_init(&rect, 0, WM_window_pixels_x(win) - 1, 0, WM_window_pixels_y(win) - 1);
rect.ymin = rect.ymax - size;
rect.ymin = rect.ymax - size_max;
screen_global_area_refresh(
win, screen, SPACE_TOPBAR, GLOBAL_AREA_ALIGN_TOP, &rect, size, size, size);
win, screen, SPACE_TOPBAR, GLOBAL_AREA_ALIGN_TOP, &rect, size, size_min, size_max);
}
static void screen_global_statusbar_area_refresh(wmWindow *win, bScreen *screen)

View File

@ -545,6 +545,7 @@ enum {
enum {
SCREEN_DEPRECATED = 1,
SCREEN_COLLAPSE_STATUSBAR = 2,
SCREEN_SHOW_TOPTOOLBAR = 4,
};
/** #bScreen.state */

View File

@ -687,6 +687,11 @@ static void rna_def_screen(BlenderRNA *brna)
RNA_def_property_boolean_funcs(prop, "rna_Screen_fullscreen_get", nullptr);
RNA_def_property_ui_text(prop, "Maximize", "An area is maximized, filling this screen");
prop = RNA_def_property(srna, "show_toptoolbar", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SCREEN_SHOW_TOPTOOLBAR);
RNA_def_property_ui_text(prop, "Show Top Buttons", "Show Top Button Bar");
RNA_def_property_update(prop, 0, "rna_Screen_bar_update");
/* Status Bar. */
prop = RNA_def_property(srna, "show_statusbar", PROP_BOOLEAN, PROP_NONE);