Compare commits

...

2 Commits

Author SHA1 Message Date
Přemysl Eric Janouch 58eb7edfd5
Make the scroll wheel act on the gauge and volume 2023-07-23 15:51:22 +02:00
Přemysl Eric Janouch 48fc9bdb19
Add vertical padding to the status bar as well
For symmetry, if for nothing else.
2023-07-23 15:36:37 +02:00
1 changed files with 38 additions and 15 deletions

View File

@ -1148,8 +1148,8 @@ pulse_volume_status (struct pulse *self, struct str *s)
// Widget identification, mostly for mouse events.
enum
{
WIDGET_NONE = 0, WIDGET_BUTTON, WIDGET_GAUGE, WIDGET_TAB, WIDGET_SPECTRUM,
WIDGET_LIST, WIDGET_SCROLLBAR, WIDGET_MESSAGE,
WIDGET_NONE = 0, WIDGET_BUTTON, WIDGET_GAUGE, WIDGET_VOLUME,
WIDGET_TAB, WIDGET_SPECTRUM, WIDGET_LIST, WIDGET_SCROLLBAR, WIDGET_MESSAGE,
};
struct layout
@ -1616,7 +1616,7 @@ app_append_layout (struct layout *l, struct layout *dest)
{
// Assuming there is no unclaimed vertical space.
LIST_FOR_EACH (struct widget, w, l->head)
widget_move (w, 0, last->y + last->height - w->y);
widget_move (w, 0, last->y + last->height);
last->next = l->head;
l->head->prev = last;
@ -1866,7 +1866,8 @@ app_layout_status (struct layout *out)
if (volume.len)
{
app_push (&l, g.ui->padding (attrs[0], 1, 1));
app_push (&l, g.ui->label (attrs[0], volume.str));
app_push (&l, g.ui->label (attrs[0], volume.str))
->id = WIDGET_VOLUME;
}
str_free (&volume);
@ -1913,20 +1914,22 @@ app_layout_tabs (struct layout *out)
app_flush_layout (&l, out);
}
static void
app_layout_padding (chtype attrs, struct layout *out)
{
struct layout l = {};
app_push_fill (&l, g.ui->padding (attrs, 0, 0.125));
app_flush_layout (&l, out);
}
static void
app_layout_header (struct layout *out)
{
if (g.client.state == MPD_CONNECTED)
{
struct layout lt = {};
app_push_fill (&lt, g.ui->padding (APP_ATTR (NORMAL), 0, 0.125));
app_flush_layout (&lt, out);
app_layout_padding (APP_ATTR (NORMAL), out);
app_layout_status (out);
struct layout lb = {};
app_push_fill (&lb, g.ui->padding (APP_ATTR (NORMAL), 0, 0.125));
app_flush_layout (&lb, out);
app_layout_padding (APP_ATTR (NORMAL), out);
}
app_layout_tabs (out);
@ -2136,8 +2139,10 @@ app_layout_mpd_status (struct layout *out)
static void
app_layout_statusbar (struct layout *out)
{
struct layout l = {};
chtype attrs[2] = { APP_ATTR (NORMAL), APP_ATTR (HIGHLIGHT) };
app_layout_padding (attrs[0], out);
struct layout l = {};
if (g.message)
{
app_push (&l, g.ui->padding (attrs[0], 0.25, 1));
@ -2167,6 +2172,8 @@ app_layout_statusbar (struct layout *out)
app_layout_text ("Connecting to MPD...", attrs[0], out);
else if (g.client.state == MPD_DISCONNECTED)
app_layout_text ("Disconnected", attrs[0], out);
app_layout_padding (attrs[0], out);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -2848,12 +2855,28 @@ app_process_mouse (termo_mouse_event_t type, int x, int y, int button,
g.ui_dragging = target->id;
return app_process_left_mouse_click (target, x, y, modifiers);
case 4:
if (target->id == WIDGET_LIST)
switch (target->id)
{
case WIDGET_LIST:
return app_process_action (ACTION_SCROLL_UP);
case WIDGET_VOLUME:
return app_process_action (g.pulse_control_requested
? ACTION_PULSE_VOLUME_UP : ACTION_MPD_VOLUME_UP);
case WIDGET_GAUGE:
return app_process_action (ACTION_MPD_FORWARD);
}
break;
case 5:
if (target->id == WIDGET_LIST)
switch (target->id)
{
case WIDGET_LIST:
return app_process_action (ACTION_SCROLL_DOWN);
case WIDGET_VOLUME:
return app_process_action (g.pulse_control_requested
? ACTION_PULSE_VOLUME_DOWN : ACTION_MPD_VOLUME_DOWN);
case WIDGET_GAUGE:
return app_process_action (ACTION_MPD_BACKWARD);
}
break;
}
return false;