swaynag: add details background option

Adds a new config option for details background for swaynag

issue/#5673
This commit is contained in:
Mustafa Abdul-Kader 2020-09-08 21:43:35 -05:00 committed by Brian Ashworth
parent afa890e8e9
commit eb1c09030e
6 changed files with 24 additions and 2 deletions

View file

@ -11,6 +11,7 @@ struct swaynag_type {
// Colors
uint32_t button_text;
uint32_t button_background;
uint32_t details_background;
uint32_t background;
uint32_t text;
uint32_t border;

View file

@ -38,6 +38,7 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
TO_COLOR_BORDER,
TO_COLOR_BORDER_BOTTOM,
TO_COLOR_BUTTON,
TO_COLOR_DETAILS,
TO_COLOR_TEXT,
TO_COLOR_BUTTON_TEXT,
TO_THICK_BAR_BORDER,
@ -77,6 +78,7 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
{"border-bottom-size", required_argument, NULL, TO_THICK_BAR_BORDER},
{"message-padding", required_argument, NULL, TO_PADDING_MESSAGE},
{"details-border-size", required_argument, NULL, TO_THICK_DET_BORDER},
{"details-background", required_argument, NULL, TO_COLOR_DETAILS},
{"button-border-size", required_argument, NULL, TO_THICK_BTN_BORDER},
{"button-gap", required_argument, NULL, TO_GAP_BTN},
{"button-dismiss-gap", required_argument, NULL, TO_GAP_BTN_DISMISS},
@ -122,6 +124,7 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
" --border-bottom-size size Thickness of the bar border.\n"
" --message-padding padding Padding for the message.\n"
" --details-border-size size Thickness for the details border.\n"
" --details-background RRGGBB[AA] Details background color.\n"
" --button-border-size size Thickness for the button border.\n"
" --button-gap gap Size of the gap between buttons\n"
" --button-dismiss-gap gap Size of the gap for dismiss button.\n"
@ -253,6 +256,11 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
fprintf(stderr, "Invalid button background color: %s", optarg);
}
break;
case TO_COLOR_DETAILS: // Details background color
if (type && !parse_color(optarg, &type->details_background)) {
fprintf(stderr, "Invalid details background color: %s", optarg);
}
break;
case TO_COLOR_TEXT: // Text color
if (type && !parse_color(optarg, &type->text)) {
fprintf(stderr, "Invalid text color: %s", optarg);

View file

@ -37,7 +37,7 @@ static void render_details_scroll_button(cairo_t *cairo,
int border = swaynag->type->button_border_thickness * swaynag->scale;
int padding = swaynag->type->button_padding * swaynag->scale;
cairo_set_source_u32(cairo, swaynag->type->border);
cairo_set_source_u32(cairo, swaynag->type->details_background);
cairo_rectangle(cairo, button->x, button->y,
button->width, button->height);
cairo_fill(cairo);
@ -153,7 +153,7 @@ static uint32_t render_detailed(cairo_t *cairo, struct swaynag *swaynag,
&swaynag->details.button_down);
}
cairo_set_source_u32(cairo, swaynag->type->border);
cairo_set_source_u32(cairo, swaynag->type->details_background);
cairo_rectangle(cairo, swaynag->details.x, swaynag->details.y,
swaynag->details.width, swaynag->details.height);
cairo_fill(cairo);

View file

@ -106,6 +106,9 @@ _swaynag_ [options...]
*--message-padding* <padding>
Set the padding for the message.
*--details-background* <RRGGBB[AA]>
Set the color for the background for details.
*--details-border-size* <size>
Set the thickness for the details border.

View file

@ -53,6 +53,9 @@ The following sizing options can also be set:
*message-padding=<padding>*
Set the padding for the message.
*details-gackground=<color>*
The background color for the details.
*details-border-size=<size>*
Set the thickness for the details border.

View file

@ -36,6 +36,7 @@ void swaynag_types_add_default(list_t *types) {
| ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT
| ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
type_defaults->button_background = 0x333333FF;
type_defaults->details_background = 0x333333FF;
type_defaults->background = 0x323232FF;
type_defaults->text = 0xFFFFFFFF;
type_defaults->button_text = 0xFFFFFFFF;
@ -53,6 +54,7 @@ void swaynag_types_add_default(list_t *types) {
struct swaynag_type *type_error = swaynag_type_new("error");
type_error->button_background = 0x680A0AFF;
type_error->details_background = 0x680A0AFF;
type_error->background = 0x900000FF;
type_error->text = 0xFFFFFFFF;
type_error->button_text = 0xFFFFFFFF;
@ -62,6 +64,7 @@ void swaynag_types_add_default(list_t *types) {
struct swaynag_type *type_warning = swaynag_type_new("warning");
type_warning->button_background = 0xFFC100FF;
type_warning->details_background = 0xFFC100FF;
type_warning->background = 0xFFA800FF;
type_warning->text = 0x000000FF;
type_warning->button_text = 0x000000FF;
@ -102,6 +105,10 @@ void swaynag_type_merge(struct swaynag_type *dest, struct swaynag_type *src) {
dest->button_background = src->button_background;
}
if (src->details_background > 0) {
dest->details_background = src->details_background;
}
if (src->background > 0) {
dest->background = src->background;
}