labnag: add details border color and margin options

Adds --details-border-color and --details-margin command line options to configure the border color and margin of the details pane.
This commit is contained in:
stormshadow 2026-04-24 06:16:23 +05:30 committed by Johan Malm
parent de3870246a
commit 91d89f71ce
2 changed files with 38 additions and 5 deletions

View file

@ -46,6 +46,7 @@ struct conf {
uint32_t button_text; uint32_t button_text;
uint32_t button_background; uint32_t button_background;
uint32_t details_background; uint32_t details_background;
uint32_t details_border_color;
uint32_t background; uint32_t background;
uint32_t text; uint32_t text;
uint32_t button_border; uint32_t button_border;
@ -60,6 +61,7 @@ struct conf {
ssize_t button_gap_close; ssize_t button_gap_close;
ssize_t button_margin_right; ssize_t button_margin_right;
ssize_t button_padding; ssize_t button_padding;
ssize_t details_margin;
}; };
struct pointer { struct pointer {
@ -343,8 +345,9 @@ render_detailed(cairo_t *cairo, struct nag *nag, uint32_t y)
uint32_t width = nag->width; uint32_t width = nag->width;
int border = nag->conf->details_border_thickness; int border = nag->conf->details_border_thickness;
int margin = nag->conf->details_margin;
int padding = nag->conf->message_padding; int padding = nag->conf->message_padding;
int decor = padding + border; int decor = margin + border;
nag->details.x = decor; nag->details.x = decor;
nag->details.y = y + decor; nag->details.y = y + decor;
@ -401,6 +404,8 @@ render_detailed(cairo_t *cairo, struct nag *nag, uint32_t y)
nag->details.visible_lines = pango_layout_get_line_count(layout); nag->details.visible_lines = pango_layout_get_line_count(layout);
int border_rect_height = nag->details.height + 2 * border;
if (show_buttons) { if (show_buttons) {
nag->details.button_up.x = nag->details.x + nag->details.width; nag->details.button_up.x = nag->details.x + nag->details.width;
nag->details.button_up.y = nag->details.y; nag->details.button_up.y = nag->details.y;
@ -416,6 +421,11 @@ render_detailed(cairo_t *cairo, struct nag *nag, uint32_t y)
render_details_scroll_button(cairo, nag, &nag->details.button_down); render_details_scroll_button(cairo, nag, &nag->details.button_down);
} }
cairo_set_source_u32(cairo, nag->conf->details_border_color);
cairo_rectangle(cairo, margin, nag->details.y - border,
nag->details.width + 2 * border, border_rect_height);
cairo_fill(cairo);
cairo_set_source_u32(cairo, nag->conf->details_background); cairo_set_source_u32(cairo, nag->conf->details_background);
cairo_rectangle(cairo, nag->details.x, nag->details.y, cairo_rectangle(cairo, nag->details.x, nag->details.y,
nag->details.width, nag->details.height); nag->details.width, nag->details.height);
@ -1464,14 +1474,16 @@ conf_init(struct conf *conf)
conf->keyboard_focus = ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE; conf->keyboard_focus = ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE;
conf->bar_border_thickness = 2; conf->bar_border_thickness = 2;
conf->message_padding = 8; conf->message_padding = 8;
conf->details_border_thickness = 3;
conf->button_border_thickness = 3; conf->button_border_thickness = 3;
conf->button_gap = 20; conf->button_gap = 20;
conf->button_gap_close = 15; conf->button_gap_close = 15;
conf->button_margin_right = 2; conf->button_margin_right = 2;
conf->button_padding = 3; conf->button_padding = 3;
conf->button_background = 0x680A0AFF; conf->button_background = 0x680A0AFF;
conf->details_margin = 11;
conf->details_border_thickness = 3;
conf->details_background = 0x680A0AFF; conf->details_background = 0x680A0AFF;
conf->details_border_color = 0x680A0AFF;
conf->background = 0x900000FF; conf->background = 0x900000FF;
conf->text = 0xFFFFFFFF; conf->text = 0xFFFFFFFF;
conf->button_text = 0xFFFFFFFF; conf->button_text = 0xFFFFFFFF;
@ -1551,16 +1563,18 @@ nag_parse_options(int argc, char **argv, struct nag *nag,
TO_COLOR_BORDER_BOTTOM, TO_COLOR_BORDER_BOTTOM,
TO_COLOR_BUTTON_BG, TO_COLOR_BUTTON_BG,
TO_COLOR_DETAILS, TO_COLOR_DETAILS,
TO_COLOR_DETAILS_BORDER,
TO_COLOR_TEXT, TO_COLOR_TEXT,
TO_COLOR_BUTTON_TEXT, TO_COLOR_BUTTON_TEXT,
TO_THICK_BAR_BORDER, TO_THICK_BAR_BORDER,
TO_PADDING_MESSAGE, TO_PADDING_MESSAGE,
TO_THICK_DET_BORDER, TO_THICK_DETAILS_BORDER,
TO_THICK_BTN_BORDER, TO_THICK_BTN_BORDER,
TO_GAP_BTN, TO_GAP_BTN,
TO_GAP_BTN_DISMISS, TO_GAP_BTN_DISMISS,
TO_MARGIN_BTN_RIGHT, TO_MARGIN_BTN_RIGHT,
TO_PADDING_BTN, TO_PADDING_BTN,
TO_MARGIN_DETAILS,
}; };
static const struct option opts[] = { static const struct option opts[] = {
@ -1587,8 +1601,10 @@ nag_parse_options(int argc, char **argv, struct nag *nag,
{"button-text-color", required_argument, NULL, TO_COLOR_BUTTON_TEXT}, {"button-text-color", required_argument, NULL, TO_COLOR_BUTTON_TEXT},
{"border-bottom-size", required_argument, NULL, TO_THICK_BAR_BORDER}, {"border-bottom-size", required_argument, NULL, TO_THICK_BAR_BORDER},
{"message-padding", required_argument, NULL, TO_PADDING_MESSAGE}, {"message-padding", required_argument, NULL, TO_PADDING_MESSAGE},
{"details-border-size", required_argument, NULL, TO_THICK_DET_BORDER}, {"details-border-size", required_argument, NULL, TO_THICK_DETAILS_BORDER},
{"details-background-color", required_argument, NULL, TO_COLOR_DETAILS}, {"details-background-color", required_argument, NULL, TO_COLOR_DETAILS},
{"details-border-color", required_argument, NULL, TO_COLOR_DETAILS_BORDER},
{"details-margin", required_argument, NULL, TO_MARGIN_DETAILS},
{"button-border-size", required_argument, NULL, TO_THICK_BTN_BORDER}, {"button-border-size", required_argument, NULL, TO_THICK_BTN_BORDER},
{"button-gap", required_argument, NULL, TO_GAP_BTN}, {"button-gap", required_argument, NULL, TO_GAP_BTN},
{"button-dismiss-gap", required_argument, NULL, TO_GAP_BTN_DISMISS}, {"button-dismiss-gap", required_argument, NULL, TO_GAP_BTN_DISMISS},
@ -1633,6 +1649,9 @@ nag_parse_options(int argc, char **argv, struct nag *nag,
" --details-border-size size Thickness for the details border.\n" " --details-border-size size Thickness for the details border.\n"
" --details-background-color RRGGBB[AA]\n" " --details-background-color RRGGBB[AA]\n"
" Details background color.\n" " Details background color.\n"
" --details-border-color RRGGBB[AA]\n"
" Details border color.\n"
" --details-margin margin Margin for the details.\n"
" --button-border-size size Thickness for the button border.\n" " --button-border-size size Thickness for the button border.\n"
" --button-gap gap Size of the gap between buttons\n" " --button-gap gap Size of the gap between buttons\n"
" --button-dismiss-gap gap Size of the gap for dismiss button.\n" " --button-dismiss-gap gap Size of the gap for dismiss button.\n"
@ -1769,6 +1788,11 @@ nag_parse_options(int argc, char **argv, struct nag *nag,
fprintf(stderr, "Invalid details background color: %s\n", optarg); fprintf(stderr, "Invalid details background color: %s\n", optarg);
} }
break; break;
case TO_COLOR_DETAILS_BORDER:
if (!parse_color(optarg, &conf->details_border_color)) {
fprintf(stderr, "Invalid details border color: %s\n", optarg);
}
break;
case TO_COLOR_TEXT: /* Text color */ case TO_COLOR_TEXT: /* Text color */
if (!parse_color(optarg, &conf->text)) { if (!parse_color(optarg, &conf->text)) {
fprintf(stderr, "Invalid text color: %s\n", optarg); fprintf(stderr, "Invalid text color: %s\n", optarg);
@ -1785,7 +1809,7 @@ nag_parse_options(int argc, char **argv, struct nag *nag,
case TO_PADDING_MESSAGE: /* Message padding */ case TO_PADDING_MESSAGE: /* Message padding */
conf->message_padding = strtol(optarg, NULL, 0); conf->message_padding = strtol(optarg, NULL, 0);
break; break;
case TO_THICK_DET_BORDER: /* Details border thickness */ case TO_THICK_DETAILS_BORDER: /* Details border thickness */
conf->details_border_thickness = strtol(optarg, NULL, 0); conf->details_border_thickness = strtol(optarg, NULL, 0);
break; break;
case TO_THICK_BTN_BORDER: /* Button border thickness */ case TO_THICK_BTN_BORDER: /* Button border thickness */
@ -1803,6 +1827,9 @@ nag_parse_options(int argc, char **argv, struct nag *nag,
case TO_PADDING_BTN: /* Padding for the button text */ case TO_PADDING_BTN: /* Padding for the button text */
conf->button_padding = strtol(optarg, NULL, 0); conf->button_padding = strtol(optarg, NULL, 0);
break; break;
case TO_MARGIN_DETAILS:
conf->details_margin = strtol(optarg, NULL, 0);
break;
default: /* Help or unknown flag */ default: /* Help or unknown flag */
fprintf(c == 'h' ? stdout : stderr, "%s", usage); fprintf(c == 'h' ? stdout : stderr, "%s", usage);
return LAB_EXIT_FAILURE; return LAB_EXIT_FAILURE;

View file

@ -95,6 +95,12 @@ _labnag_ [options...]
*--details-border-size* <size> *--details-border-size* <size>
Set the thickness for the details border. Set the thickness for the details border.
*--details-border-color* <RRGGBB[AA]>
Set the color of the details border.
*--details-margin* <margin>
Set the margin for the details.
*--button-border-size* <size> *--button-border-size* <size>
Set the thickness for the button border. Set the thickness for the button border.