Topbar: visual tweaks

* Make bottom half of topbar a bit higher
* Make tabs higher and put them closer together
* Remove screen layouts dropdown, we'll have one layout per window
* Hide action zones from topbar
* Don't change topbar background color when activating
This commit is contained in:
Brecht Van Lommel 2018-04-21 10:06:12 +02:00
parent 04fe5edba3
commit e89fefdc69
Notes: blender-bot 2023-08-18 12:18:28 +02:00
Referenced by issue #94148, Top bar and Status bar have hardcoded color offset
4 changed files with 30 additions and 21 deletions

View File

@ -46,6 +46,8 @@ class TOPBAR_HT_upper_bar(Header):
if not screen.show_fullscreen:
layout.template_ID_tabs(window, "workspace", new="workspace.workspace_add_menu", unlink="workspace.workspace_delete")
else:
layout.operator("screen.back_to_previous", icon='SCREEN_BACK', text="Back to Previous")
layout.separator()
@ -71,8 +73,11 @@ class TOPBAR_HT_upper_bar(Header):
layout = self.layout
window = context.window
scene = window.scene
# Active workspace view-layer is retrieved through window, not through workspace.
layout.template_ID(window, "scene", new="scene.new", unlink="scene.delete")
layout.template_search(window, "view_layer", scene, "view_layers")
class TOPBAR_HT_lower_bar(Header):
@ -103,17 +108,8 @@ class TOPBAR_HT_lower_bar(Header):
def draw_right(self, context):
layout = self.layout
window = context.window
workspace = context.workspace
scene = context.scene
screen = context.screen
if screen.show_fullscreen:
layout.operator("screen.back_to_previous", icon='SCREEN_BACK', text="Back to Previous")
else:
layout.template_search_preview(window, "screen", workspace, "screens", new="screen.new", unlink="screen.delete", rows=2, cols=6)
# Active workspace view-layer is retrieved through window, not through workspace.
layout.template_search(window, "view_layer", scene, "view_layers")
# Placeholder
layout.operator("ed.undo_history", text="...")
class TOPBAR_MT_editor_menus(Menu):

View File

@ -574,7 +574,8 @@ static const char *template_id_context(StructRNA *type)
static uiBut *template_id_def_new_but(
uiBlock *block, const ID *id, const TemplateID *template_ui, StructRNA *type,
const char * const newop, const bool editable, const bool id_open, const bool use_tab_but)
const char * const newop, const bool editable, const bool id_open, const bool use_tab_but,
int but_height)
{
ID *idfrom = template_ui->ptr.id.data;
uiBut *but;
@ -613,12 +614,12 @@ static uiBut *template_id_def_new_but(
if (newop) {
but = uiDefIconTextButO(block, but_type, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN,
(id) ? "" : CTX_IFACE_(template_id_context(type), "New"), 0, 0, w, UI_UNIT_Y, NULL);
(id) ? "" : CTX_IFACE_(template_id_context(type), "New"), 0, 0, w, but_height, NULL);
UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
}
else {
but = uiDefIconTextBut(block, but_type, 0, ICON_ZOOMIN, (id) ? "" : CTX_IFACE_(template_id_context(type), "New"),
0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
0, 0, w, but_height, NULL, 0, 0, 0, 0, NULL);
UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
}
@ -735,7 +736,7 @@ static void template_ID(
}
if (flag & UI_ID_ADD_NEW) {
template_id_def_new_but(block, id, template_ui, type, newop, editable, flag & UI_ID_OPEN, false);
template_id_def_new_but(block, id, template_ui, type, newop, editable, flag & UI_ID_OPEN, false, UI_UNIT_X);
}
/* Due to space limit in UI - skip the "open" icon for packed data, and allow to unpack.
@ -811,6 +812,7 @@ static void template_ID_tabs(
const ARegion *region = CTX_wm_region(C);
const PointerRNA active_ptr = RNA_property_pointer_get(&template->ptr, template->prop);
const int but_align = (region->alignment == RGN_ALIGN_TOP) ? UI_BUT_ALIGN_DOWN : UI_BUT_ALIGN_TOP;
const int but_height = UI_UNIT_Y * 1.1;
uiBlock *block = uiLayoutGetBlock(layout);
uiStyle *style = UI_style_get_dpi();
@ -824,7 +826,7 @@ static void template_ID_tabs(
uiButTab *tab;
tab = (uiButTab *)uiDefButR_prop(
block, UI_BTYPE_TAB, 0, "", 0, 0, but_width, UI_UNIT_Y,
block, UI_BTYPE_TAB, 0, "", 0, 0, but_width, UI_UNIT_Y * 1.1,
&template->ptr, template->prop, 0, 0.0f,
sizeof(id->name) - 2, 0.0f, 0.0f, "");
UI_but_funcN_set(&tab->but, template_ID_set_property_cb, MEM_dupallocN(template), id);
@ -845,7 +847,7 @@ static void template_ID_tabs(
type = active_ptr.type;
}
but = template_id_def_new_but(block, active_ptr.data, template, type, newop, editable, flag & UI_ID_OPEN, true);
but = template_id_def_new_but(block, active_ptr.data, template, type, newop, editable, flag & UI_ID_OPEN, true, but_height);
UI_but_drawflag_enable(but, but_align);
}
}
@ -896,7 +898,7 @@ static void ui_template_id(
*/
if (template_ui->idlb) {
if (use_tabs) {
uiLayoutRow(layout, false);
uiLayoutRow(layout, true);
template_ID_tabs(C, layout, template_ui, type, flag, newop, openop, unlinkop);
}
else {

View File

@ -753,6 +753,10 @@ static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea
return;
}
if (ED_area_is_global(sa)) {
return;
}
/* can't click on bottom corners on OS X, already used for resizing */
#ifdef __APPLE__
if (!(sa->totrct.xmin == 0 && sa->totrct.ymin == 0) || WM_window_is_fullscreen(win))
@ -1881,9 +1885,16 @@ int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco)
static ThemeColorID region_background_color_id(const bContext *C, const ARegion *region)
{
ScrArea *area = CTX_wm_area(C);
switch (region->regiontype) {
case RGN_TYPE_HEADER:
return ED_screen_area_active(C) ? TH_HEADER : TH_HEADERDESEL;
if (ED_screen_area_active(C) || ED_area_is_global(area)) {
return TH_HEADER;
}
else {
return TH_HEADERDESEL;
}
case RGN_TYPE_PREVIEW:
return TH_PREVIEW_BACK;
default:
@ -2187,7 +2198,7 @@ void ED_region_header(const bContext *C, ARegion *ar)
UI_view2d_view_ortho(&ar->v2d);
xco = maxco = start_ofs;
yco = headery - floor(0.2f * UI_UNIT_Y);
yco = headery + (ar->winy - headery)/2 - floor(0.2f * UI_UNIT_Y);
/* XXX workaround for 1 px alignment issue. Not sure what causes it... Would prefer a proper fix - Julian */
if (CTX_wm_area(C)->spacetype == SPACE_TOPBAR) {

View File

@ -1123,7 +1123,7 @@ void ED_screen_global_topbar_area_create(wmWindow *win, const bScreen *screen)
SpaceType *st = BKE_spacetype_from_id(SPACE_TOPBAR);
SpaceLink *sl = st->new(NULL);
ScrArea *sa;
const short size_y = 2 * HEADERY;
const short size_y = 2.25 * HEADERY;
const int minx = 0, maxx = WM_window_pixels_x(win) - 1;
const int maxy = WM_window_pixels_y(win) - 1, miny = maxy - size_y;