UI: tweak status bar layout to make it less jumpy.

Keymap on the left, messages and jobs in the middle, stats on the right.
This commit is contained in:
Brecht Van Lommel 2018-06-27 19:48:54 +02:00
parent 0e304ca8f5
commit d3b814e9ec
4 changed files with 34 additions and 52 deletions

View File

@ -25,34 +25,14 @@ class STATUSBAR_HT_header(Header):
bl_space_type = 'STATUSBAR'
def draw(self, context):
area = context.area
region = context.region
if region.alignment == 'RIGHT':
if region == area.regions[0]:
self.draw_right(context)
else:
self.draw_center(context)
else:
self.draw_left(context)
def draw_left(self, context):
layout = self.layout
# input status
layout.template_input_status()
def draw_center(self, context):
layout = self.layout
layout.separator_spacer()
scene = context.scene
view_layer = context.view_layer
layout.label(text=scene.statistics(view_layer), translate=False)
def draw_right(self, context):
layout = self.layout
layout.template_running_jobs()
# messages
layout.template_reports_banner()
row = layout.row(align=True)
@ -66,7 +46,16 @@ class STATUSBAR_HT_header(Header):
# include last so text doesn't push buttons out of the header
row.label(bpy.app.autoexec_fail_message)
return
layout.template_running_jobs()
layout.separator_spacer()
# stats
scene = context.scene
view_layer = context.view_layer
layout.label(text=scene.statistics(view_layer), translate=False)
classes = (

View File

@ -4310,14 +4310,20 @@ void uiTemplateInputStatus(uiLayout *layout, struct bContext *C)
/* Otherwise should cursor keymap status. */
for (int i = 0; i < 3; i++) {
uiLayout *box = uiLayoutRow(layout, true);
for (int j = 0; j < 2; j++) {
const char *msg = WM_window_cursor_keymap_status_get(win, i, j);
if ((j == 0) || (msg != NULL)) {
uiItemL(box, msg, j == 0 ? (ICON_MOUSE_LMB + i) : ICON_MOUSE_DRAG);
const char *msg = WM_window_cursor_keymap_status_get(win, i, 0);
const char *msg_drag = WM_window_cursor_keymap_status_get(win, i, 1);
if (msg || msg_drag) {
uiItemL(box, msg ? msg : "", (ICON_MOUSE_LMB + i));
if (msg_drag) {
uiItemL(box, msg_drag, ICON_MOUSE_DRAG);
}
if (i != 2) {
uiItemS(layout);
}
}
if (i != 2) {
uiItemSpacer(layout);
}
}
}

View File

@ -471,7 +471,9 @@ static void stats_string(ViewLayer *view_layer)
s = stats->infostr;
ofs = 0;
ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, "%s | ", versionstr);
if (ob) {
ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, "%s | ", ob->id.name + 2);
}
if (obedit) {
if (BKE_keyblock_from_object(obedit))
@ -505,15 +507,13 @@ static void stats_string(ViewLayer *view_layer)
}
else {
ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs,
IFACE_("Verts:%s | Faces:%s | Tris:%s | Objects:%s/%s | Lamps:%s/%s%s%s"),
IFACE_("Verts:%s | Faces:%s | Tris:%s | Objects:%s/%s%s%s"),
stats_fmt.totvert, stats_fmt.totface,
stats_fmt.tottri, stats_fmt.totobjsel,
stats_fmt.totobj, stats_fmt.totlampsel,
stats_fmt.totlamp, memstr, gpumemstr);
stats_fmt.totobj, memstr, gpumemstr);
}
if (ob)
BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, " | %s", ob->id.name + 2);
ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, " | %s", versionstr);
#undef MAX_INFO_MEM_LEN
}

View File

@ -56,21 +56,8 @@ static SpaceLink *statusbar_new(const ScrArea *UNUSED(area), const Scene *UNUSED
sstatusbar = MEM_callocN(sizeof(*sstatusbar), "init statusbar");
sstatusbar->spacetype = SPACE_STATUSBAR;
/* header regions */
/* *** NOTE: ***
* Python layout code (space_statusbar.py) depends on the list order of
* these! Not nice at all, but the only way to identify the correct header
* to draw to is using alignment + list position. It can't use alignment
* only since code below has to set two right aligned regions - XXX. */
ar = MEM_callocN(sizeof(*ar), "right aligned header for statusbar");
BLI_addtail(&sstatusbar->regionbase, ar);
ar->regiontype = RGN_TYPE_HEADER;
ar->alignment = RGN_ALIGN_RIGHT;
ar = MEM_callocN(sizeof(*ar), "center header for statusbar");
BLI_addtail(&sstatusbar->regionbase, ar);
ar->regiontype = RGN_TYPE_HEADER;
ar->alignment = RGN_ALIGN_RIGHT; /* Right aligned too, so region layout code scales it correctly. */
ar = MEM_callocN(sizeof(*ar), "left aligned header for statusbar");
/* header region */
ar = MEM_callocN(sizeof(*ar), "header for statusbar");
BLI_addtail(&sstatusbar->regionbase, ar);
ar->regiontype = RGN_TYPE_HEADER;
ar->alignment = RGN_ALIGN_NONE;