Add highlight/shadow controls for beveled items

This commit is contained in:
Jack Zeal 2026-04-06 20:09:51 -07:00
parent 6dffb80d6a
commit b2803b8f4d
14 changed files with 173 additions and 19 deletions

View file

@ -6,9 +6,7 @@
# make sure all other lines are commented out or deleted.
# general
border.width: 6
border.beveled: yes
border.bevel_width:2
border.width: 1
#
# The global padding.{width,height} of openbox are not supported because

View file

@ -15,6 +15,8 @@ struct lab_scene_rect_options {
int height;
enum border_type border_type;
int bevel_width;
int highlight;
int shadow;
};
struct lab_scene_rect {

View file

@ -60,6 +60,8 @@ struct theme_background {
enum border_type border_type;
int border_width;
int bevel_width;
int highlight;
int shadow;
bool exclusive;
};
@ -102,12 +104,16 @@ struct theme {
int button_bevel_width;
float button_border_color[4];
float button_hover_border_color[4];
int button_highlight;
int button_shadow;
float border_color[4];
float toggled_keybinds_color[4];
float label_text_color[4];
enum border_type border_type;
int bevel_width;
int highlight;
int shadow;
/* window drop-shadows */
int shadow_size;
@ -156,6 +162,8 @@ struct theme {
float menu_border_color[4];
enum border_type menu_border_type;
int menu_bevel_width;
int menu_highlight;
int menu_shadow;
int menu_items_padding_x;
int menu_items_padding_y;
@ -165,10 +173,16 @@ struct theme {
float menu_items_active_text_color[4];
enum border_type menu_items_border_type;
int menu_items_bevel_width;
int menu_items_highlight;
int menu_items_shadow;
enum border_type menu_title_border_type;
int menu_title_bevel_width;
int menu_title_highlight;
int menu_title_shadow;
enum border_type menu_items_active_border_type;
int menu_items_active_bevel_width;
int menu_items_active_highlight;
int menu_items_active_shadow;
int menu_separator_line_thickness;
int menu_separator_padding_width;
@ -186,6 +200,8 @@ struct theme {
float osd_label_text_color[4];
enum border_type osd_border_type;
int osd_border_bevel_width;
int osd_highlight;
int osd_shadow;
struct window_switcher_classic_theme {
int width;

View file

@ -59,7 +59,8 @@ lab_scene_rect_create(struct wlr_scene_tree *parent,
(uint32_t)(g*255) << 8 |
(uint32_t)(b*255);
struct borderset *renderedborders = get_borders(colour32, bw,
opts->border_type, opts->bevel_width, 128, 64);
opts->border_type, opts->bevel_width,
opts->highlight, opts->shadow);
border->textured_borders = generate_bufferset(border->tree,
renderedborders, bw);
} else {

View file

@ -38,7 +38,9 @@ update_preview_outlines(struct view *view)
.nr_borders = 3,
.border_width = theme->osd_window_switcher_preview_border_width,
.border_type = theme->osd_border_type,
.bevel_width = theme->osd_border_bevel_width
.bevel_width = theme->osd_border_bevel_width,
.highlight = theme->osd_highlight,
.shadow = theme->osd_shadow
};
rect = lab_scene_rect_create(&server.scene->tree, &opts);
wlr_scene_node_place_above(&rect->tree->node,

View file

@ -121,7 +121,9 @@ cycle_osd_classic_init(struct cycle_osd_output *osd_output)
.width = w,
.height = h,
.border_type = theme->osd_border_type,
.bevel_width = theme->osd_border_bevel_width
.bevel_width = theme->osd_border_bevel_width,
.highlight = theme->osd_highlight,
.shadow = theme->osd_shadow
};
lab_scene_rect_create(osd_output->tree, &bg_opts);
@ -205,7 +207,9 @@ cycle_osd_classic_init(struct cycle_osd_output *osd_output)
.width = w - 2 * padding,
.height = switcher_theme->item_height,
.border_type = theme->osd_border_type,
.bevel_width = theme->osd_border_bevel_width
.bevel_width = theme->osd_border_bevel_width,
.highlight = theme->osd_highlight,
.shadow = theme->osd_shadow
};
struct lab_scene_rect *highlight_rect = lab_scene_rect_create(
item->active_tree, &highlight_opts);

View file

@ -40,7 +40,9 @@ cycle_osd_scroll_init(struct cycle_osd_output *osd_output, struct wlr_box bar_ar
.width = bar_area.width,
.height = bar_area.height * nr_visible_rows / nr_rows,
.border_type = theme->osd_border_type,
.bevel_width = theme->osd_border_bevel_width
.bevel_width = theme->osd_border_bevel_width,
.highlight = theme->osd_highlight,
.shadow = theme->osd_shadow
};
scroll->bar = lab_scene_rect_create(scroll->bar_tree, &scrollbar_opts);
}

View file

@ -151,7 +151,9 @@ create_item_scene(struct wlr_scene_tree *parent, struct view *view,
.width = switcher_theme->item_width,
.height = switcher_theme->item_height,
.border_type = theme->osd_border_type,
.bevel_width = theme->osd_border_bevel_width
.bevel_width = theme->osd_border_bevel_width,
.highlight = theme->osd_highlight,
.shadow = theme->osd_shadow
};
item->active_bg = lab_scene_rect_create(tree, &opts);
@ -285,7 +287,9 @@ cycle_osd_thumbnail_init(struct cycle_osd_output *osd_output)
.width = items_width + 2 * padding,
.height = items_height + 2 * padding,
.border_type = theme->osd_border_type,
.bevel_width = theme->osd_border_bevel_width
.bevel_width = theme->osd_border_bevel_width,
.highlight = theme->osd_highlight,
.shadow = theme->osd_shadow
};
struct lab_scene_rect *bg =
lab_scene_rect_create(osd_output->tree, &bg_opts);

View file

@ -207,7 +207,9 @@ item_create_scene_for_state(struct menuitem *item, float *text_color,
(uint32_t)(b*255);
struct borderset *renderedborders = get_borders(colour32, bw,
rc.theme->menu_items_active_border_type,
rc.theme->menu_items_active_bevel_width, 128, 64);
rc.theme->menu_items_active_bevel_width,
rc.theme->menu_items_active_highlight,
rc.theme->menu_items_active_shadow);
bufferset = generate_bufferset(tree, renderedborders, bw);
} else if (rc.theme->menu_items_border_type && !state) {
float r = bg_color[0];
@ -221,7 +223,9 @@ item_create_scene_for_state(struct menuitem *item, float *text_color,
(uint32_t)(b*255);
struct borderset *renderedborders = get_borders(colour32, bw,
rc.theme->menu_items_border_type,
rc.theme->menu_items_bevel_width, 128, 64);
rc.theme->menu_items_bevel_width,
rc.theme->menu_items_highlight,
rc.theme->menu_items_shadow);
bufferset = generate_bufferset(tree, renderedborders, bw);
}
@ -410,7 +414,9 @@ title_create_scene(struct menuitem *menuitem, int *item_y)
(uint32_t)(b*255);
struct borderset *renderedborders = get_borders(colour32, bw,
rc.theme->menu_title_border_type,
rc.theme->menu_title_bevel_width, 128, 64);
rc.theme->menu_title_bevel_width,
rc.theme->menu_title_highlight,
rc.theme->menu_title_shadow);
bufferset = generate_bufferset(menuitem->tree, renderedborders, bw);
}
@ -519,7 +525,9 @@ menu_create_scene(struct menu *menu)
.width = menu->size.width,
.height = menu->size.height,
.border_type = theme->menu_border_type,
.bevel_width = theme->menu_bevel_width
.bevel_width = theme->menu_bevel_width,
.highlight = theme->menu_highlight,
.shadow = theme->menu_shadow
};
struct lab_scene_rect *bg_rect =
lab_scene_rect_create(menu->scene_tree, &opts);

View file

@ -51,7 +51,8 @@ resize_indicator_reconfigure_view(struct resize_indicator *indicator)
(uint32_t)(g*255) << 8 |
(uint32_t)(b*255);
struct borderset *renderedborders = get_borders(colour32, bw,
theme->osd_border_type, theme->osd_border_bevel_width, 128, 64);
theme->osd_border_type, theme->osd_border_bevel_width,
theme->osd_highlight, theme->osd_shadow);
indicator->textured_borders = generate_bufferset(indicator->tree,
renderedborders, bw);
}

View file

@ -57,7 +57,9 @@ ssd_border_create(struct ssd *ssd)
(uint32_t)(b*255);
struct borderset *renderedborders = get_borders(colour32, bw,
theme->window[active].border_type,
theme->window[active].bevel_width, 128, 64);
theme->window[active].bevel_width,
theme->window[active].highlight,
theme->window[active].shadow);
subtree->textured_borders = generate_bufferset(subtree->tree,
renderedborders, bw);
} else {

View file

@ -70,7 +70,8 @@ ssd_titlebar_create(struct ssd *ssd)
theme->window[active].title_bg.border_width,
theme->window[active].title_bg.border_type,
theme->window[active].title_bg.bevel_width,
128, 64);
theme->window[active].title_bg.highlight,
theme->window[active].title_bg.shadow);
subtree->textured_borders = generate_bufferset(subtree->tree,
renderedborders, theme->window[active].title_bg.border_width);

View file

@ -114,7 +114,9 @@ static void draw_beveled_border_on_button(cairo_t *cairo, int w, int h, int acti
(uint32_t)(b*255);
struct borderset *renderedborders = get_borders(colour32, bw,
rc.theme->window[active].button_border_type,
rc.theme->window[active].button_bevel_width, 128, 64);
rc.theme->window[active].button_bevel_width,
rc.theme->window[active].button_highlight,
rc.theme->window[active].button_shadow);
cairo_set_source_surface(cairo, renderedborders->top->surface, 0, 0);
cairo_pattern_set_extend(cairo_get_source(cairo), CAIRO_EXTEND_REPEAT);
@ -672,24 +674,36 @@ theme_builtin(struct theme *theme)
theme->window[SSD_INACTIVE].title_bg.color_to_split_to[0] = FLT_MIN;
theme->window[SSD_ACTIVE].bevel_width = 0;
theme->window[SSD_ACTIVE].border_type = BORDER_NONE;
theme->window[SSD_ACTIVE].highlight = 128;
theme->window[SSD_ACTIVE].shadow = 64;
theme->window[SSD_ACTIVE].title_bg.bevel_width = 0;
theme->window[SSD_ACTIVE].title_bg.border_width = 0;
theme->window[SSD_ACTIVE].title_bg.exclusive = FALSE;
theme->window[SSD_ACTIVE].title_bg.border_type = BORDER_NONE;
theme->window[SSD_ACTIVE].title_bg.highlight = 128;
theme->window[SSD_ACTIVE].title_bg.shadow = 64;
theme->window[SSD_INACTIVE].bevel_width = 0;
theme->window[SSD_INACTIVE].border_type = BORDER_NONE;
theme->window[SSD_INACTIVE].highlight = 128;
theme->window[SSD_INACTIVE].shadow = 64;
theme->window[SSD_INACTIVE].title_bg.bevel_width = 0;
theme->window[SSD_INACTIVE].title_bg.border_width = 0;
theme->window[SSD_INACTIVE].title_bg.exclusive = FALSE;
theme->window[SSD_INACTIVE].title_bg.border_type = BORDER_NONE;
theme->window[SSD_INACTIVE].title_bg.highlight = 128;
theme->window[SSD_INACTIVE].title_bg.shadow = 64;
theme->window[SSD_ACTIVE].button_border_type = BORDER_NONE;
theme->window[SSD_ACTIVE].button_border_width = 0;
theme->window[SSD_ACTIVE].button_bevel_width = 0;
theme->window[SSD_ACTIVE].button_highlight = 128;
theme->window[SSD_ACTIVE].button_shadow = 64;
theme->window[SSD_ACTIVE].button_border_color[0] = FLT_MIN;
theme->window[SSD_ACTIVE].button_hover_border_color[0] = FLT_MIN;
theme->window[SSD_INACTIVE].button_border_type = BORDER_NONE;
theme->window[SSD_INACTIVE].button_border_width = 0;
theme->window[SSD_INACTIVE].button_bevel_width = 0;
theme->window[SSD_INACTIVE].button_highlight = 128;
theme->window[SSD_INACTIVE].button_shadow = 64;
theme->window[SSD_INACTIVE].button_border_color[0] = FLT_MIN;
theme->window[SSD_INACTIVE].button_hover_border_color[0] = FLT_MIN;
@ -724,6 +738,8 @@ theme_builtin(struct theme *theme)
theme->menu_border_width = INT_MIN;
theme->menu_border_color[0] = FLT_MIN;
theme->menu_border_type = BORDER_NONE;
theme->menu_highlight = 128;
theme->menu_shadow = 64;
theme->menu_bevel_width = 0;
theme->menu_items_padding_x = 7;
@ -734,10 +750,16 @@ theme_builtin(struct theme *theme)
parse_hexstr("#000000", theme->menu_items_active_text_color);
theme->menu_items_border_type = BORDER_NONE;
theme->menu_items_bevel_width = 0;
theme->menu_items_highlight = 128;
theme->menu_items_shadow = 64;
theme->menu_title_border_type = BORDER_NONE;
theme->menu_title_bevel_width = 0;
theme->menu_title_highlight = 128;
theme->menu_title_shadow = 64;
theme->menu_items_active_border_type = BORDER_NONE;
theme->menu_items_active_bevel_width = 0;
theme->menu_items_active_highlight = 128;
theme->menu_items_active_shadow = 64;
theme->menu_separator_line_thickness = 1;
theme->menu_separator_padding_width = 6;
@ -785,6 +807,8 @@ theme_builtin(struct theme *theme)
theme->osd_label_text_color[0] = FLT_MIN;
theme->osd_border_type = BORDER_NONE;
theme->osd_border_bevel_width = 0;
theme->osd_highlight = 128;
theme->osd_shadow = 64;
if (wlr_renderer_is_pixman(server.renderer)) {
/* Draw only outlined overlay by default to save CPU resource */
@ -870,6 +894,14 @@ entry(struct theme *theme, const char *key, const char *value)
theme->window[SSD_ACTIVE].title_bg.border_width =
get_int_if_positive(value, "window.active.title.bg.width");
}
if (match_glob(key, "window.active.title.bg.highlight")) {
theme->window[SSD_ACTIVE].title_bg.highlight =
get_int_if_positive(value, "window.active.title.bg.highlight");
}
if (match_glob(key, "window.active.title.bg.shadow")) {
theme->window[SSD_ACTIVE].title_bg.shadow =
get_int_if_positive(value, "window.active.title.bg.shadow");
}
if (match_glob(key, "window.active.title.bg.exclusive")) {
set_bool(value, &theme->window[SSD_ACTIVE].title_bg.exclusive);
@ -889,6 +921,14 @@ entry(struct theme *theme, const char *key, const char *value)
theme->window[SSD_ACTIVE].bevel_width =
get_int_if_positive(value, "window.active.border.bevel-width");
}
if (match_glob(key, "window.active.border.highlight")) {
theme->window[SSD_ACTIVE].highlight =
get_int_if_positive(value, "window.active.border.highlight");
}
if (match_glob(key, "window.active.border.shadow")) {
theme->window[SSD_ACTIVE].shadow =
get_int_if_positive(value, "window.active.border.shadow");
}
if (match_glob(key, "window.inactive.border.color")) {
parse_color(value, theme->window[SSD_INACTIVE].border_color);
@ -902,6 +942,15 @@ entry(struct theme *theme, const char *key, const char *value)
if (match_glob(key, "window.inactive.border.type")) {
theme->window[SSD_INACTIVE].border_type = parse_border_type(value);
}
if (match_glob(key, "window.inactive.border.highlight")) {
theme->window[SSD_INACTIVE].highlight =
get_int_if_positive(value, "window.inactive.border.highlight");
}
if (match_glob(key, "window.inactive.border.shadow")) {
theme->window[SSD_INACTIVE].shadow =
get_int_if_positive(value, "window.inactive.border.shadow");
}
/* border.color is obsolete, but handled for backward compatibility */
if (match_glob(key, "border.color")) {
parse_color(value, theme->window[SSD_ACTIVE].border_color);
@ -919,6 +968,14 @@ entry(struct theme *theme, const char *key, const char *value)
if (match_glob(key, "window.inactive.title.bg") && parse_border_type(value)) {
theme->window[SSD_INACTIVE].title_bg.border_type = parse_border_type(value);
}
if (match_glob(key, "window.inactive.title.bg.highlight")) {
theme->window[SSD_INACTIVE].title_bg.highlight =
get_int_if_positive(value, "window.inactive.title.bg.highlight");
}
if (match_glob(key, "window.inactive.title.bg.shadow")) {
theme->window[SSD_INACTIVE].title_bg.shadow =
get_int_if_positive(value, "window.inactive.title.bg.shadow");
}
if (match_glob(key, "window.inactive.title.bg.width")) {
theme->window[SSD_INACTIVE].title_bg.border_width =
get_int_if_positive(value, "window.inactive.title.bg.width");
@ -993,6 +1050,14 @@ entry(struct theme *theme, const char *key, const char *value)
if (match_glob(key, "window.inactive.button.bg") && parse_border_type(value)) {
theme->window[SSD_INACTIVE].button_border_type = parse_border_type(value);
}
if (match_glob(key, "window.inactive.button.bg.highlight")) {
theme->window[SSD_INACTIVE].button_highlight =
get_int_if_positive(value, "window.inactive.button.bg.highlight");
}
if (match_glob(key, "window.inactive.button.bg.shadow")) {
theme->window[SSD_INACTIVE].button_shadow =
get_int_if_positive(value, "window.inactive.button.bg.shadow");
}
if (match_glob(key, "window.inactive.button.bg.width")) {
theme->window[SSD_INACTIVE].button_border_width =
get_int_if_positive(value, "window.inactive.button.bg.width");
@ -1013,6 +1078,14 @@ entry(struct theme *theme, const char *key, const char *value)
if (match_glob(key, "window.active.button.bg") && parse_border_type(value)) {
theme->window[SSD_ACTIVE].button_border_type = parse_border_type(value);
}
if (match_glob(key, "window.active.button.bg.highlight")) {
theme->window[SSD_ACTIVE].button_highlight =
get_int_if_positive(value, "window.active.button.bg.highlight");
}
if (match_glob(key, "window.active.button.bg.shadow")) {
theme->window[SSD_ACTIVE].button_shadow =
get_int_if_positive(value, "window.active.button.bg.shadow");
}
if (match_glob(key, "window.active.button.bg.width")) {
theme->window[SSD_ACTIVE].button_border_width =
get_int_if_positive(value, "window.active.button.bg.width");
@ -1154,6 +1227,14 @@ entry(struct theme *theme, const char *key, const char *value)
theme->menu_bevel_width =
get_int_if_positive(value, "menu.bg.bevel-width");
}
if (match_glob(key, "menu.bg.highlight")) {
theme->menu_highlight =
get_int_if_positive(value, "menu.bg.highlight");
}
if (match_glob(key, "menu.bg.shadow")) {
theme->menu_shadow =
get_int_if_positive(value, "menu.bg.shadow");
}
if (match_glob(key, "menu.items.padding.x")) {
theme->menu_items_padding_x = get_int_if_positive(
@ -1169,6 +1250,14 @@ entry(struct theme *theme, const char *key, const char *value)
if (match_glob(key, "menu.items.bg")) {
theme->menu_items_border_type = parse_border_type(value);
}
if (match_glob(key, "menu.items.bg.highlight")) {
theme->menu_items_highlight =
get_int_if_positive(value, "menu.items.bg.highlight");
}
if (match_glob(key, "menu.items.bg.shadow")) {
theme->menu_items_shadow =
get_int_if_positive(value, "menu.items.bg.shadow");
}
if (match_glob(key, "menu.items.bg.bevel-width")) {
theme->menu_items_bevel_width =
get_int_if_positive(value, "menu.items.bg.bevel-width");
@ -1186,6 +1275,14 @@ entry(struct theme *theme, const char *key, const char *value)
if (match_glob(key, "menu.items.active.bg")) {
theme->menu_items_active_border_type = parse_border_type(value);
}
if (match_glob(key, "menu.items.active.bg.highlight")) {
theme->menu_items_active_highlight =
get_int_if_positive(value, "menu.items.active,bg.highlight");
}
if (match_glob(key, "menu.items.active.bg.shadow")) {
theme->menu_items_active_shadow =
get_int_if_positive(value, "menu.items.active.bg.shadow");
}
if (match_glob(key, "menu.items.active.bg.bevel-width")) {
theme->menu_items_active_bevel_width =
@ -1220,6 +1317,14 @@ entry(struct theme *theme, const char *key, const char *value)
if (match_glob(key, "menu.title.bg")) {
theme->menu_title_border_type = parse_border_type(value);
}
if (match_glob(key, "menu.title.bg.highlight")) {
theme->menu_title_highlight =
get_int_if_positive(value, "menu.title.bg.highlight");
}
if (match_glob(key, "menu.title.bg.shadow")) {
theme->menu_title_shadow =
get_int_if_positive(value, "menu.title.bg.shadow");
}
if (match_glob(key, "menu.title.bg.bevel-width")) {
theme->menu_title_bevel_width =
@ -1239,6 +1344,14 @@ entry(struct theme *theme, const char *key, const char *value)
if (match_glob(key, "osd.bg")) {
theme->osd_border_type = parse_border_type(value);
}
if (match_glob(key, "osd.bg.highlight")) {
theme->osd_highlight =
get_int_if_positive(value, "osd.bg.highlight");
}
if (match_glob(key, "osd.bg.shadow")) {
theme->osd_shadow =
get_int_if_positive(value, "osd.bg.shadow");
}
if (match_glob(key, "osd.bg.bevel-width")) {
theme->osd_border_bevel_width = get_int_if_positive(value, "osd.bg.bevel-width");

View file

@ -116,7 +116,7 @@ _osd_update(void)
(uint32_t)(b*255);
struct borderset *renderedborders = get_borders(colour32, bw,
theme->osd_border_type, theme->osd_border_bevel_width,
128, 64);
theme->osd_highlight, theme->osd_shadow);
cairo_set_source_surface(cairo, renderedborders->top->surface, 0, 0);
cairo_pattern_set_extend(cairo_get_source(cairo), CAIRO_EXTEND_REPEAT);