mirror of
https://github.com/labwc/labwc.git
synced 2026-04-07 08:21:20 -04:00
Pull menu bevels from theme
This commit is contained in:
parent
362c3e1b47
commit
e7b53c5d28
6 changed files with 78 additions and 25 deletions
|
|
@ -61,8 +61,6 @@ struct theme_background {
|
||||||
|
|
||||||
struct theme {
|
struct theme {
|
||||||
int border_width;
|
int border_width;
|
||||||
bool beveled_border;
|
|
||||||
int border_bevel_width;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* the space between title bar border and
|
* the space between title bar border and
|
||||||
|
|
@ -147,6 +145,8 @@ struct theme {
|
||||||
int menu_max_width;
|
int menu_max_width;
|
||||||
int menu_border_width;
|
int menu_border_width;
|
||||||
float menu_border_color[4];
|
float menu_border_color[4];
|
||||||
|
enum border_type menu_border_type;
|
||||||
|
int menu_bevel_width;
|
||||||
|
|
||||||
int menu_items_padding_x;
|
int menu_items_padding_x;
|
||||||
int menu_items_padding_y;
|
int menu_items_padding_y;
|
||||||
|
|
@ -154,6 +154,12 @@ struct theme {
|
||||||
float menu_items_text_color[4];
|
float menu_items_text_color[4];
|
||||||
float menu_items_active_bg_color[4];
|
float menu_items_active_bg_color[4];
|
||||||
float menu_items_active_text_color[4];
|
float menu_items_active_text_color[4];
|
||||||
|
enum border_type menu_items_border_type;
|
||||||
|
int menu_items_bevel_width;
|
||||||
|
enum border_type menu_title_border_type;
|
||||||
|
int menu_title_bevel_width;
|
||||||
|
enum border_type menu_items_active_border_type;
|
||||||
|
int menu_items_active_bevel_width;
|
||||||
|
|
||||||
int menu_separator_line_thickness;
|
int menu_separator_line_thickness;
|
||||||
int menu_separator_padding_width;
|
int menu_separator_padding_width;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,11 @@ struct borderset * getBorders(uint32_t id, int size, enum border_type type, int
|
||||||
type = BORDER_SINGLE;
|
type = BORDER_SINGLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type == BORDER_DOUBLE_INSET && (bevelSize > size/2)) {
|
||||||
|
type = BORDER_INSET;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Anything with a size of 0 is converted to a 1-pixel flat border so as to prevent empty allocations
|
// Anything with a size of 0 is converted to a 1-pixel flat border so as to prevent empty allocations
|
||||||
|
|
||||||
if (size < 1) {
|
if (size < 1) {
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ item_create_scene_for_state(struct menuitem *item, float *text_color,
|
||||||
{
|
{
|
||||||
struct menu *menu = item->parent;
|
struct menu *menu = item->parent;
|
||||||
struct theme *theme = rc.theme;
|
struct theme *theme = rc.theme;
|
||||||
struct bufferset * bufferset;
|
struct bufferset * bufferset = NULL;
|
||||||
|
|
||||||
/* Tree to hold background and label buffers */
|
/* Tree to hold background and label buffers */
|
||||||
struct wlr_scene_tree *tree = lab_wlr_scene_tree_create(item->tree);
|
struct wlr_scene_tree *tree = lab_wlr_scene_tree_create(item->tree);
|
||||||
|
|
@ -195,7 +195,7 @@ item_create_scene_for_state(struct menuitem *item, float *text_color,
|
||||||
lab_wlr_scene_rect_create(tree, bg_width, theme->menu_item_height, bg_color);
|
lab_wlr_scene_rect_create(tree, bg_width, theme->menu_item_height, bg_color);
|
||||||
|
|
||||||
int bw = theme->menu_border_width;
|
int bw = theme->menu_border_width;
|
||||||
if (rc.theme->beveled_border && state) {
|
if (rc.theme->menu_items_active_border_type && state) {
|
||||||
float r = bg_color[0];
|
float r = bg_color[0];
|
||||||
float g = bg_color[1];
|
float g = bg_color[1];
|
||||||
float b = bg_color[2];
|
float b = bg_color[2];
|
||||||
|
|
@ -203,7 +203,17 @@ item_create_scene_for_state(struct menuitem *item, float *text_color,
|
||||||
|
|
||||||
|
|
||||||
uint32_t colour32 = (uint32_t)(a*255) << 24 | (uint32_t)(r*255) << 16 | (uint32_t)(g*255) << 8 | (uint32_t)(b*255);
|
uint32_t colour32 = (uint32_t)(a*255) << 24 | (uint32_t)(r*255) << 16 | (uint32_t)(g*255) << 8 | (uint32_t)(b*255);
|
||||||
struct borderset * renderedborders = getBorders(colour32, bw, BORDER_INSET, 0);
|
struct borderset * renderedborders = getBorders(colour32, bw, rc.theme->menu_items_active_border_type, rc.theme->menu_items_active_bevel_width);
|
||||||
|
bufferset = generateBufferset(tree, renderedborders, bw);
|
||||||
|
} else if (rc.theme->menu_items_border_type && !state) {
|
||||||
|
float r = bg_color[0];
|
||||||
|
float g = bg_color[1];
|
||||||
|
float b = bg_color[2];
|
||||||
|
float a = bg_color[3];
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t colour32 = (uint32_t)(a*255) << 24 | (uint32_t)(r*255) << 16 | (uint32_t)(g*255) << 8 | (uint32_t)(b*255);
|
||||||
|
struct borderset * renderedborders = getBorders(colour32, bw, rc.theme->menu_items_border_type, rc.theme->menu_items_bevel_width);
|
||||||
bufferset = generateBufferset(tree, renderedborders, bw);
|
bufferset = generateBufferset(tree, renderedborders, bw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -240,7 +250,7 @@ item_create_scene_for_state(struct menuitem *item, float *text_color,
|
||||||
wlr_scene_node_set_position(&label_buffer->scene_buffer->node, x, y);
|
wlr_scene_node_set_position(&label_buffer->scene_buffer->node, x, y);
|
||||||
|
|
||||||
|
|
||||||
if (rc.theme->beveled_border && state) {
|
if (bufferset != NULL) {
|
||||||
renderBufferset(bufferset, bg_width, theme->menu_item_height, 0);
|
renderBufferset(bufferset, bg_width, theme->menu_item_height, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -387,7 +397,7 @@ title_create_scene(struct menuitem *menuitem, int *item_y)
|
||||||
|
|
||||||
|
|
||||||
int bw = theme->menu_border_width;
|
int bw = theme->menu_border_width;
|
||||||
if (rc.theme->beveled_border) {
|
if (rc.theme->menu_title_border_type) {
|
||||||
float r = bg_color[0];
|
float r = bg_color[0];
|
||||||
float g = bg_color[1];
|
float g = bg_color[1];
|
||||||
float b = bg_color[2];
|
float b = bg_color[2];
|
||||||
|
|
@ -395,7 +405,7 @@ title_create_scene(struct menuitem *menuitem, int *item_y)
|
||||||
|
|
||||||
|
|
||||||
uint32_t colour32 = (uint32_t)(a*255) << 24 | (uint32_t)(r*255) << 16 | (uint32_t)(g*255) << 8 | (uint32_t)(b*255);
|
uint32_t colour32 = (uint32_t)(a*255) << 24 | (uint32_t)(r*255) << 16 | (uint32_t)(g*255) << 8 | (uint32_t)(b*255);
|
||||||
struct borderset * renderedborders = getBorders(colour32, bw, BORDER_SINGLE, 0);
|
struct borderset * renderedborders = getBorders(colour32, bw, rc.theme->menu_title_border_type, rc.theme->menu_title_bevel_width);
|
||||||
bufferset = generateBufferset(menuitem->tree, renderedborders, bw);
|
bufferset = generateBufferset(menuitem->tree, renderedborders, bw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -429,7 +439,7 @@ title_create_scene(struct menuitem *menuitem, int *item_y)
|
||||||
wlr_scene_node_set_position(&title_font_buffer->scene_buffer->node,
|
wlr_scene_node_set_position(&title_font_buffer->scene_buffer->node,
|
||||||
title_x, title_y);
|
title_x, title_y);
|
||||||
|
|
||||||
if (rc.theme->beveled_border) {
|
if (rc.theme->menu_title_border_type) {
|
||||||
renderBufferset(bufferset, bg_width, theme->menu_item_height, 0);
|
renderBufferset(bufferset, bg_width, theme->menu_item_height, 0);
|
||||||
}
|
}
|
||||||
error:
|
error:
|
||||||
|
|
@ -504,7 +514,8 @@ menu_create_scene(struct menu *menu)
|
||||||
.border_width = theme->menu_border_width,
|
.border_width = theme->menu_border_width,
|
||||||
.width = menu->size.width,
|
.width = menu->size.width,
|
||||||
.height = menu->size.height,
|
.height = menu->size.height,
|
||||||
//.beveled = true,
|
.border_type = theme->menu_border_type,
|
||||||
|
.bevel_width = theme->menu_bevel_width
|
||||||
};
|
};
|
||||||
struct lab_scene_rect *bg_rect =
|
struct lab_scene_rect *bg_rect =
|
||||||
lab_scene_rect_create(menu->scene_tree, &opts);
|
lab_scene_rect_create(menu->scene_tree, &opts);
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ resize_indicator_init(struct view *view)
|
||||||
indicator->background = lab_wlr_scene_rect_create(
|
indicator->background = lab_wlr_scene_rect_create(
|
||||||
indicator->tree, 0, 0, rc.theme->osd_bg_color);
|
indicator->tree, 0, 0, rc.theme->osd_bg_color);
|
||||||
|
|
||||||
if (rc.theme->beveled_border) {
|
if (rc.theme->osd_border_type) {
|
||||||
float r = rc.theme->osd_border_color[0];
|
float r = rc.theme->osd_border_color[0];
|
||||||
float g = rc.theme->osd_border_color[1];
|
float g = rc.theme->osd_border_color[1];
|
||||||
float b = rc.theme->osd_border_color[2];
|
float b = rc.theme->osd_border_color[2];
|
||||||
|
|
@ -61,7 +61,7 @@ resize_indicator_init(struct view *view)
|
||||||
int bw = rc.theme->osd_border_width;
|
int bw = rc.theme->osd_border_width;
|
||||||
|
|
||||||
uint32_t colour32 = (uint32_t)(a*255) << 24 | (uint32_t)(r*255) << 16 | (uint32_t)(g*255) << 8 | (uint32_t)(b*255);
|
uint32_t colour32 = (uint32_t)(a*255) << 24 | (uint32_t)(r*255) << 16 | (uint32_t)(g*255) << 8 | (uint32_t)(b*255);
|
||||||
struct borderset * renderedborders = getBorders(colour32, bw, BORDER_SINGLE, 0);
|
struct borderset * renderedborders = getBorders(colour32, bw, rc.theme->osd_border_type, rc.theme->osd_border_bevel_width);
|
||||||
indicator->texturedBorders = generateBufferset(indicator->tree, renderedborders, bw);
|
indicator->texturedBorders = generateBufferset(indicator->tree, renderedborders, bw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,7 +135,7 @@ resize_indicator_set_size(struct resize_indicator *indicator, int width)
|
||||||
indicator->width - 2 * rc.theme->osd_border_width,
|
indicator->width - 2 * rc.theme->osd_border_width,
|
||||||
indicator->height - 2 * rc.theme->osd_border_width);
|
indicator->height - 2 * rc.theme->osd_border_width);
|
||||||
|
|
||||||
if (rc.theme->beveled_border) {
|
if (rc.theme->osd_border_type) {
|
||||||
renderBufferset(indicator->texturedBorders, indicator->width, indicator->height, 0);
|
renderBufferset(indicator->texturedBorders, indicator->width, indicator->height, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
49
src/theme.c
49
src/theme.c
|
|
@ -544,8 +544,6 @@ static void
|
||||||
theme_builtin(struct theme *theme)
|
theme_builtin(struct theme *theme)
|
||||||
{
|
{
|
||||||
theme->border_width = 1;
|
theme->border_width = 1;
|
||||||
theme->beveled_border = false;
|
|
||||||
theme->border_bevel_width=0;
|
|
||||||
theme->window_titlebar_padding_height = 0;
|
theme->window_titlebar_padding_height = 0;
|
||||||
theme->window_titlebar_padding_width = 0;
|
theme->window_titlebar_padding_width = 0;
|
||||||
|
|
||||||
|
|
@ -599,6 +597,8 @@ theme_builtin(struct theme *theme)
|
||||||
theme->menu_max_width = 200;
|
theme->menu_max_width = 200;
|
||||||
theme->menu_border_width = INT_MIN;
|
theme->menu_border_width = INT_MIN;
|
||||||
theme->menu_border_color[0] = FLT_MIN;
|
theme->menu_border_color[0] = FLT_MIN;
|
||||||
|
theme->menu_border_type = BORDER_FLAT;
|
||||||
|
theme->menu_bevel_width = 0;
|
||||||
|
|
||||||
theme->menu_items_padding_x = 7;
|
theme->menu_items_padding_x = 7;
|
||||||
theme->menu_items_padding_y = 4;
|
theme->menu_items_padding_y = 4;
|
||||||
|
|
@ -606,6 +606,12 @@ theme_builtin(struct theme *theme)
|
||||||
parse_hexstr("#000000", theme->menu_items_text_color);
|
parse_hexstr("#000000", theme->menu_items_text_color);
|
||||||
parse_hexstr("#e1dedb", theme->menu_items_active_bg_color);
|
parse_hexstr("#e1dedb", theme->menu_items_active_bg_color);
|
||||||
parse_hexstr("#000000", theme->menu_items_active_text_color);
|
parse_hexstr("#000000", theme->menu_items_active_text_color);
|
||||||
|
theme->menu_items_border_type = BORDER_FLAT;
|
||||||
|
theme->menu_items_bevel_width = 0;
|
||||||
|
theme->menu_title_border_type = BORDER_FLAT;
|
||||||
|
theme->menu_title_bevel_width = 0;
|
||||||
|
theme->menu_items_active_border_type = BORDER_FLAT;
|
||||||
|
theme->menu_items_active_bevel_width = 0;
|
||||||
|
|
||||||
theme->menu_separator_line_thickness = 1;
|
theme->menu_separator_line_thickness = 1;
|
||||||
theme->menu_separator_padding_width = 6;
|
theme->menu_separator_padding_width = 6;
|
||||||
|
|
@ -715,13 +721,7 @@ entry(struct theme *theme, const char *key, const char *value)
|
||||||
theme->border_width = get_int_if_positive(
|
theme->border_width = get_int_if_positive(
|
||||||
value, "border.width");
|
value, "border.width");
|
||||||
}
|
}
|
||||||
if (match_glob(key, "border.beveled")) {
|
|
||||||
set_bool(value, &theme->beveled_border);
|
|
||||||
}
|
|
||||||
if (match_glob(key, "border.bevel_width")) {
|
|
||||||
theme->border_bevel_width = get_int_if_positive(
|
|
||||||
value, "border.bevel_width");
|
|
||||||
}
|
|
||||||
if (match_glob(key, "window.titlebar.padding.width")) {
|
if (match_glob(key, "window.titlebar.padding.width")) {
|
||||||
theme->window_titlebar_padding_width = get_int_if_positive(
|
theme->window_titlebar_padding_width = get_int_if_positive(
|
||||||
value, "window.titlebar.padding.width");
|
value, "window.titlebar.padding.width");
|
||||||
|
|
@ -948,6 +948,14 @@ entry(struct theme *theme, const char *key, const char *value)
|
||||||
parse_color(value, theme->menu_border_color);
|
parse_color(value, theme->menu_border_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (match_glob(key, "menu.bg")) {
|
||||||
|
theme->menu_border_type = parse_border_type(value);
|
||||||
|
}
|
||||||
|
if (match_glob(key, "menu.bg.bevel-width")) {
|
||||||
|
theme->menu_bevel_width = get_int_if_positive(value, "menu.bg.bevel-width");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (match_glob(key, "menu.items.padding.x")) {
|
if (match_glob(key, "menu.items.padding.x")) {
|
||||||
theme->menu_items_padding_x = get_int_if_positive(
|
theme->menu_items_padding_x = get_int_if_positive(
|
||||||
value, "menu.items.padding.x");
|
value, "menu.items.padding.x");
|
||||||
|
|
@ -959,6 +967,13 @@ entry(struct theme *theme, const char *key, const char *value)
|
||||||
if (match_glob(key, "menu.items.bg.color")) {
|
if (match_glob(key, "menu.items.bg.color")) {
|
||||||
parse_color(value, theme->menu_items_bg_color);
|
parse_color(value, theme->menu_items_bg_color);
|
||||||
}
|
}
|
||||||
|
if (match_glob(key, "menu.items.bg")) {
|
||||||
|
theme->menu_items_border_type = parse_border_type(value);
|
||||||
|
}
|
||||||
|
if (match_glob(key, "menu.items.bg.bevel-width")) {
|
||||||
|
theme->menu_items_bevel_width = get_int_if_positive(value, "menu.items.bg.bevel-width");
|
||||||
|
}
|
||||||
|
|
||||||
if (match_glob(key, "menu.items.text.color")) {
|
if (match_glob(key, "menu.items.text.color")) {
|
||||||
parse_color(value, theme->menu_items_text_color);
|
parse_color(value, theme->menu_items_text_color);
|
||||||
}
|
}
|
||||||
|
|
@ -969,6 +984,14 @@ entry(struct theme *theme, const char *key, const char *value)
|
||||||
parse_color(value, theme->menu_items_active_text_color);
|
parse_color(value, theme->menu_items_active_text_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.bevel-width")) {
|
||||||
|
theme->menu_items_active_bevel_width = get_int_if_positive(value, "menu.items.active.bg.bevel-width");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (match_glob(key, "menu.separator.width")) {
|
if (match_glob(key, "menu.separator.width")) {
|
||||||
theme->menu_separator_line_thickness = get_int_if_positive(
|
theme->menu_separator_line_thickness = get_int_if_positive(
|
||||||
value, "menu.separator.width");
|
value, "menu.separator.width");
|
||||||
|
|
@ -995,6 +1018,14 @@ entry(struct theme *theme, const char *key, const char *value)
|
||||||
parse_color(value, theme->menu_title_text_color);
|
parse_color(value, theme->menu_title_text_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (match_glob(key, "menu.title.bg")) {
|
||||||
|
theme->menu_title_border_type = parse_border_type(value);
|
||||||
|
}
|
||||||
|
if (match_glob(key, "menu.title.bg.bevel-width")) {
|
||||||
|
theme->menu_title_bevel_width = get_int_if_positive(value, "menu.title.bg.bevel-width");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (match_glob(key, "osd.bg.color")) {
|
if (match_glob(key, "osd.bg.color")) {
|
||||||
parse_color(value, theme->osd_bg_color);
|
parse_color(value, theme->osd_bg_color);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,14 +104,14 @@ _osd_update(void)
|
||||||
cairo_fill(cairo);
|
cairo_fill(cairo);
|
||||||
|
|
||||||
/* Border */
|
/* Border */
|
||||||
if (theme->beveled_border) {
|
if (theme->osd_border_type) {
|
||||||
float r = theme->osd_border_color[0];
|
float r = theme->osd_border_color[0];
|
||||||
float g = theme->osd_border_color[1];
|
float g = theme->osd_border_color[1];
|
||||||
float b = theme->osd_border_color[2];
|
float b = theme->osd_border_color[2];
|
||||||
float a = theme->osd_border_color[3];
|
float a = theme->osd_border_color[3];
|
||||||
|
|
||||||
uint32_t colour32 = (uint32_t)(a*255) << 24 | (uint32_t)(r*255) << 16 | (uint32_t)(g*255) << 8 | (uint32_t)(b*255);
|
uint32_t colour32 = (uint32_t)(a*255) << 24 | (uint32_t)(r*255) << 16 | (uint32_t)(g*255) << 8 | (uint32_t)(b*255);
|
||||||
struct borderset * renderedborders = getBorders(colour32, bw, BORDER_SINGLE, 0);
|
struct borderset * renderedborders = getBorders(colour32, bw, theme->osd_border_type, theme->osd_border_bevel_width);
|
||||||
|
|
||||||
cairo_set_source_surface(cairo, renderedborders->top->surface, 0, 0);
|
cairo_set_source_surface(cairo, renderedborders->top->surface, 0, 0);
|
||||||
cairo_pattern_set_extend(cairo_get_source(cairo), CAIRO_EXTEND_REPEAT);
|
cairo_pattern_set_extend(cairo_get_source(cairo), CAIRO_EXTEND_REPEAT);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue