xF: improve layouting
This commit is contained in:
@@ -2365,11 +2365,14 @@ app_label (enum app_attribute attribute, const char *text)
|
||||
}
|
||||
|
||||
static struct widget *
|
||||
app_button (enum app_attribute attribute, const char *text, enum action action)
|
||||
app_button (chtype extra_attrs, const char *text, enum action action)
|
||||
{
|
||||
const struct xui_icon_point *icon =
|
||||
action == ACTION_RECONNECT ? app_icon_reconnect : NULL;
|
||||
struct widget *w = g_xui.ui->symbol (g_attrs[attribute].attrs, text, icon);
|
||||
|
||||
// We need to add in the attributes before the widget gets measured.
|
||||
struct widget *w = g_xui.ui->symbol
|
||||
(g_attrs[ATTRIBUTE_CHROME].attrs | extra_attrs, text, icon);
|
||||
w->widget_id = WIDGET_BUTTON;
|
||||
w->userdata = action;
|
||||
return w;
|
||||
@@ -2550,7 +2553,7 @@ app_append_line_items (struct layout *row, chtype base,
|
||||
|
||||
// We don't want the "hitbox" of links to extend until the end of line.
|
||||
if (!line->items_tail
|
||||
|| line->items_tail->style & BUFFER_LINE_ITEM_LINK)
|
||||
|| (line->items_tail->style & BUFFER_LINE_ITEM_LINK))
|
||||
app_push_fill (row, app_label_attrs (base, 0, ""));
|
||||
}
|
||||
|
||||
@@ -2624,19 +2627,20 @@ app_make_activity_indicator (void)
|
||||
static struct widget *
|
||||
app_make_title (void)
|
||||
{
|
||||
struct layout title = {};
|
||||
if (g.buffer_current)
|
||||
app_append_line_items (&title, g_attrs[ATTRIBUTE_CHROME].attrs,
|
||||
&g.buffer_current->topic);
|
||||
if (!title.head)
|
||||
app_push_fill (&title, app_label (ATTRIBUTE_CHROME, ""));
|
||||
|
||||
struct layout row = {};
|
||||
app_push (&row, app_padding (ATTRIBUTE_CHROME, 0.25));
|
||||
if (g.buffer_current && g.buffer_current->topic.items)
|
||||
app_append_line_items (&row, g_attrs[ATTRIBUTE_CHROME].attrs,
|
||||
&g.buffer_current->topic);
|
||||
else
|
||||
app_push_fill (&row, app_label (ATTRIBUTE_CHROME, ""));
|
||||
|
||||
app_push_fill (&row, xui_hbox (title.head));
|
||||
app_push (&row, app_padding (ATTRIBUTE_CHROME, 0.5));
|
||||
app_push (&row, app_make_activity_indicator ());
|
||||
app_push (&row, app_padding (ATTRIBUTE_CHROME, 0.5));
|
||||
app_push (&row, app_button (ATTRIBUTE_CHROME, "@", ACTION_RECONNECT))
|
||||
->attrs |= A_BOLD;
|
||||
app_push (&row, app_button (A_BOLD, "@", ACTION_RECONNECT));
|
||||
app_push (&row, app_padding (ATTRIBUTE_CHROME, 0.25));
|
||||
return xui_hbox (row.head);
|
||||
}
|
||||
@@ -3165,20 +3169,17 @@ app_make_status (void)
|
||||
app_push (&row, app_label (ATTRIBUTE_CHROME, "↓"));
|
||||
}
|
||||
app_push (&row, app_padding (ATTRIBUTE_CHROME, 0.5));
|
||||
app_push (&row, app_button (ATTRIBUTE_CHROME, "B", ACTION_FORMAT_BOLD))
|
||||
->attrs |= A_BOLD;
|
||||
app_push (&row, app_button (A_BOLD, "B", ACTION_FORMAT_BOLD));
|
||||
app_push (&row, app_padding (ATTRIBUTE_CHROME, 0.5));
|
||||
#ifdef A_ITALIC
|
||||
app_push (&row, app_button (ATTRIBUTE_CHROME, "I", ACTION_FORMAT_ITALIC))
|
||||
->attrs |= A_ITALIC;
|
||||
app_push (&row, app_button (A_ITALIC, "I", ACTION_FORMAT_ITALIC));
|
||||
#else
|
||||
app_push (&row, app_button (ATTRIBUTE_CHROME, "I", ACTION_FORMAT_ITALIC));
|
||||
app_push (&row, app_button (0, "I", ACTION_FORMAT_ITALIC));
|
||||
#endif
|
||||
app_push (&row, app_padding (ATTRIBUTE_CHROME, 0.5));
|
||||
app_push (&row, app_button (ATTRIBUTE_CHROME, "U", ACTION_FORMAT_UNDERLINE))
|
||||
->attrs |= A_UNDERLINE;
|
||||
app_push (&row, app_button (A_UNDERLINE, "U", ACTION_FORMAT_UNDERLINE));
|
||||
app_push (&row, app_padding (ATTRIBUTE_CHROME, 0.5));
|
||||
app_push (&row, app_button (ATTRIBUTE_CHROME,
|
||||
app_push (&row, app_button (0,
|
||||
g.log.visible ? "Hide log" : "Log", ACTION_LOG));
|
||||
app_push (&row, app_padding (ATTRIBUTE_CHROME, 0.25));
|
||||
str_free (&status);
|
||||
|
||||
Reference in New Issue
Block a user