mirror of
https://github.com/labwc/labwc.git
synced 2026-06-13 14:33:18 -04:00
Realign with codesniffer rules
This commit is contained in:
parent
5846a95f98
commit
987b2c2a89
15 changed files with 486 additions and 466 deletions
158
src/theme.c
158
src/theme.c
|
|
@ -91,7 +91,7 @@ draw_hover_overlay_on_button(cairo_t *cairo, int w, int h)
|
|||
cairo_fill(cairo);
|
||||
}
|
||||
|
||||
static void draw_beveled_border_on_button(cairo_t* cairo, int w, int h, int active, int hover)
|
||||
static void draw_beveled_border_on_button(cairo_t *cairo, int w, int h, int active, int hover)
|
||||
{
|
||||
if (rc.theme->window[active].button_border_type) {
|
||||
int bw = rc.theme->window[active].button_border_width;
|
||||
|
|
@ -108,9 +108,13 @@ static void draw_beveled_border_on_button(cairo_t* cairo, int w, int h, int acti
|
|||
a = rc.theme->window[active].button_hover_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);
|
||||
struct borderset * renderedborders = getBorders(colour32, bw, rc.theme->window[active].button_border_type, rc.theme->window[active].button_bevel_width);
|
||||
|
||||
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->window[active].button_border_type,
|
||||
rc.theme->window[active].button_bevel_width);
|
||||
|
||||
cairo_set_source_surface(cairo, renderedborders->top->surface, 0, 0);
|
||||
cairo_pattern_set_extend(cairo_get_source(cairo), CAIRO_EXTEND_REPEAT);
|
||||
|
|
@ -122,21 +126,16 @@ static void draw_beveled_border_on_button(cairo_t* cairo, int w, int h, int acti
|
|||
cairo_rectangle(cairo, bw, h-bw, w-bw*2, bw);
|
||||
cairo_fill(cairo);
|
||||
|
||||
|
||||
|
||||
cairo_set_source_surface(cairo, renderedborders->left->surface, 0, 0);
|
||||
cairo_pattern_set_extend(cairo_get_source(cairo), CAIRO_EXTEND_REPEAT);
|
||||
cairo_rectangle(cairo, 0, bw, bw, h-bw*2);
|
||||
cairo_fill(cairo);
|
||||
|
||||
|
||||
cairo_set_source_surface(cairo, renderedborders->right->surface, w-bw, bw);
|
||||
cairo_pattern_set_extend(cairo_get_source(cairo), CAIRO_EXTEND_REPEAT);
|
||||
cairo_rectangle(cairo, w-bw, bw, bw, h-bw*2);
|
||||
cairo_fill(cairo);
|
||||
|
||||
|
||||
|
||||
cairo_set_source_surface(cairo, renderedborders->tl->surface, 0, 0);
|
||||
cairo_rectangle(cairo, 0, 0, bw, bw);
|
||||
cairo_fill(cairo);
|
||||
|
|
@ -175,8 +174,6 @@ static void draw_nonhover_inactive_border_on_button(cairo_t *cairo, int w, int h
|
|||
draw_beveled_border_on_button(cairo, w, h, SSD_INACTIVE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Round the buffer for the leftmost button in the titlebar */
|
||||
static void
|
||||
round_left_corner_button(cairo_t *cairo, int w, int h)
|
||||
|
|
@ -308,16 +305,15 @@ load_button(struct theme *theme, struct button *b, enum ssd_active_state active)
|
|||
draw_hover_overlay_on_button);
|
||||
}
|
||||
|
||||
|
||||
if (theme->window[active].button_border_type) {
|
||||
if (active) {
|
||||
if (b->state_set & LAB_BS_HOVERED) {
|
||||
if (b->state_set & LAB_BS_HOVERED) {
|
||||
lab_img_add_modifier(*img, draw_hover_active_border_on_button);
|
||||
} else {
|
||||
lab_img_add_modifier(*img, draw_nonhover_active_border_on_button);
|
||||
}
|
||||
} else {
|
||||
if (b->state_set & LAB_BS_HOVERED) {
|
||||
if (b->state_set & LAB_BS_HOVERED) {
|
||||
lab_img_add_modifier(*img, draw_hover_inactive_border_on_button);
|
||||
} else {
|
||||
lab_img_add_modifier(*img, draw_nonhover_inactive_border_on_button);
|
||||
|
|
@ -552,16 +548,24 @@ parse_hexstrs(const char *hexes, float colors[3][4])
|
|||
g_strfreev(elements);
|
||||
}
|
||||
|
||||
static enum border_type parse_border_type(const char *str) {
|
||||
static enum border_type parse_border_type(const char *str)
|
||||
{
|
||||
char *lower = g_ascii_strdown(str, -1);
|
||||
enum border_type border_type;
|
||||
if (strstr(lower, "doublesunken")) border_type = BORDER_DOUBLE_INSET;
|
||||
else if (strstr(lower, "sunken")) border_type = BORDER_INSET;
|
||||
else if (strstr(lower, "doubleraised")) border_type = BORDER_DOUBLE;
|
||||
else if (strstr(lower, "raised")) border_type = BORDER_SINGLE;
|
||||
else if (strstr(lower, "flat")) border_type = BORDER_FLAT;
|
||||
else border_type = BORDER_NONE;
|
||||
|
||||
if (strstr(lower, "doublesunken")) {
|
||||
border_type = BORDER_DOUBLE_INSET;
|
||||
} else if (strstr(lower, "sunken")) {
|
||||
border_type = BORDER_INSET;
|
||||
} else if (strstr(lower, "doubleraised")) {
|
||||
border_type = BORDER_DOUBLE;
|
||||
} else if (strstr(lower, "raised")) {
|
||||
border_type = BORDER_SINGLE;
|
||||
} else if (strstr(lower, "flat")) {
|
||||
border_type = BORDER_FLAT;
|
||||
} else {
|
||||
border_type = BORDER_NONE;
|
||||
}
|
||||
|
||||
g_free(lower);
|
||||
return border_type;
|
||||
}
|
||||
|
|
@ -678,17 +682,16 @@ theme_builtin(struct theme *theme)
|
|||
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_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_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_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_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_border_color[0] = FLT_MIN;
|
||||
theme->window[SSD_INACTIVE].button_hover_border_color[0] = FLT_MIN;
|
||||
|
||||
|
||||
parse_hexstr("#000000", theme->window[SSD_ACTIVE].label_text_color);
|
||||
parse_hexstr("#000000", theme->window[SSD_INACTIVE].label_text_color);
|
||||
|
|
@ -844,7 +847,7 @@ entry(struct theme *theme, const char *key, const char *value)
|
|||
theme->border_width = get_int_if_positive(
|
||||
value, "border.width");
|
||||
}
|
||||
|
||||
|
||||
if (match_glob(key, "window.titlebar.padding.width")) {
|
||||
theme->window_titlebar_padding_width = get_int_if_positive(
|
||||
value, "window.titlebar.padding.width");
|
||||
|
|
@ -859,39 +862,43 @@ entry(struct theme *theme, const char *key, const char *value)
|
|||
if (match_glob(key, "padding.height")) {
|
||||
wlr_log(WLR_INFO, "padding.height is no longer supported");
|
||||
}
|
||||
|
||||
|
||||
if (match_glob(key, "window.active.title.bg") && parse_border_type(value)) {
|
||||
theme->window[SSD_ACTIVE].title_bg.border_type= parse_border_type(value);
|
||||
theme->window[SSD_ACTIVE].title_bg.border_type = parse_border_type(value);
|
||||
}
|
||||
if (match_glob(key, "window.active.title.bg.width")) {
|
||||
theme->window[SSD_ACTIVE].title_bg.border_width = get_int_if_positive(value, "window.active.title.bg.width");
|
||||
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.exclusive")) {
|
||||
set_bool(value, &theme->window[SSD_ACTIVE].title_bg.exclusive);
|
||||
}
|
||||
if (match_glob(key, "window.active.title.bg.bevel-width")) {
|
||||
theme->window[SSD_ACTIVE].title_bg.bevel_width = get_int_if_positive(value, "window.active.title.bg.bevel-width");
|
||||
theme->window[SSD_ACTIVE].title_bg.bevel_width =
|
||||
get_int_if_positive(value, "window.active.title.bg.bevel-width");
|
||||
}
|
||||
if (match_glob(key, "window.active.border.color")) {
|
||||
parse_color(value, theme->window[SSD_ACTIVE].border_color);
|
||||
}
|
||||
|
||||
|
||||
if (match_glob(key, "window.active.border.type")) {
|
||||
theme->window[SSD_ACTIVE].border_type = parse_border_type(value);
|
||||
}
|
||||
if (match_glob(key, "window.active.border.bevel-width")) {
|
||||
theme->window[SSD_ACTIVE].bevel_width = get_int_if_positive(value, "window.active.border.bevel-width");
|
||||
theme->window[SSD_ACTIVE].bevel_width =
|
||||
get_int_if_positive(value, "window.active.border.bevel-width");
|
||||
}
|
||||
|
||||
|
||||
if (match_glob(key, "window.inactive.border.color")) {
|
||||
parse_color(value, theme->window[SSD_INACTIVE].border_color);
|
||||
}
|
||||
|
||||
|
||||
if (match_glob(key, "window.inactive.border.bevel-width")) {
|
||||
theme->window[SSD_INACTIVE].bevel_width = get_int_if_positive(value, "window.inactive.border.bevel-width");
|
||||
theme->window[SSD_INACTIVE].bevel_width =
|
||||
get_int_if_positive(value, "window.inactive.border.bevel-width");
|
||||
}
|
||||
|
||||
|
||||
if (match_glob(key, "window.inactive.border.type")) {
|
||||
theme->window[SSD_INACTIVE].border_type = parse_border_type(value);
|
||||
}
|
||||
|
|
@ -908,22 +915,22 @@ entry(struct theme *theme, const char *key, const char *value)
|
|||
if (match_glob(key, "window.active.title.bg")) {
|
||||
theme->window[SSD_ACTIVE].title_bg.gradient = parse_gradient(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);
|
||||
theme->window[SSD_INACTIVE].title_bg.border_type = parse_border_type(value);
|
||||
}
|
||||
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");
|
||||
theme->window[SSD_INACTIVE].title_bg.border_width =
|
||||
get_int_if_positive(value, "window.inactive.title.bg.width");
|
||||
}
|
||||
if (match_glob(key, "window.inactive.title.bg.bevel-width")) {
|
||||
theme->window[SSD_INACTIVE].title_bg.bevel_width = get_int_if_positive(value, "window.inactive.title.bg.bevel-width");
|
||||
theme->window[SSD_INACTIVE].title_bg.bevel_width =
|
||||
get_int_if_positive(value, "window.inactive.title.bg.bevel-width");
|
||||
}
|
||||
if (match_glob(key, "window.inactive.title.bg.exclusive")) {
|
||||
set_bool(value, &theme->window[SSD_INACTIVE].title_bg.exclusive);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (match_glob(key, "window.inactive.title.bg")) {
|
||||
theme->window[SSD_INACTIVE].title_bg.gradient = parse_gradient(value);
|
||||
}
|
||||
|
|
@ -984,43 +991,45 @@ 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);
|
||||
theme->window[SSD_INACTIVE].button_border_type = parse_border_type(value);
|
||||
}
|
||||
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");
|
||||
theme->window[SSD_INACTIVE].button_border_width =
|
||||
get_int_if_positive(value, "window.inactive.button.bg.width");
|
||||
}
|
||||
if (match_glob(key, "window.inactive.button.bg.bevel-width")) {
|
||||
theme->window[SSD_INACTIVE].button_bevel_width = get_int_if_positive(value, "window.inactive.button.bg.bevel-width");
|
||||
theme->window[SSD_INACTIVE].button_bevel_width =
|
||||
get_int_if_positive(value, "window.inactive.button.bg.bevel-width");
|
||||
}
|
||||
|
||||
|
||||
if (match_glob(key, "window.inactive.button.bg.border-color")) {
|
||||
parse_color(value, theme->window[SSD_INACTIVE].button_border_color);
|
||||
}
|
||||
|
||||
|
||||
if (match_glob(key, "window.inactive.button.bg.border-hover-color")) {
|
||||
parse_color(value, theme->window[SSD_INACTIVE].button_hover_border_color);
|
||||
}
|
||||
|
||||
|
||||
if (match_glob(key, "window.active.button.bg") && parse_border_type(value)) {
|
||||
theme->window[SSD_ACTIVE].button_border_type= parse_border_type(value);
|
||||
theme->window[SSD_ACTIVE].button_border_type = parse_border_type(value);
|
||||
}
|
||||
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");
|
||||
theme->window[SSD_ACTIVE].button_border_width =
|
||||
get_int_if_positive(value, "window.active.button.bg.width");
|
||||
}
|
||||
if (match_glob(key, "window.inactive.button.bg.bevel-width")) {
|
||||
theme->window[SSD_ACTIVE].button_bevel_width = get_int_if_positive(value, "window.active.button.bg.bevel-width");
|
||||
theme->window[SSD_ACTIVE].button_bevel_width =
|
||||
get_int_if_positive(value, "window.active.button.bg.bevel-width");
|
||||
}
|
||||
|
||||
|
||||
if (match_glob(key, "window.active.button.bg.border-color")) {
|
||||
parse_color(value, theme->window[SSD_ACTIVE].button_border_color);
|
||||
}
|
||||
|
||||
|
||||
if (match_glob(key, "window.active.button.bg.border-hover-color")) {
|
||||
parse_color(value, theme->window[SSD_ACTIVE].button_hover_border_color);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* botton hover overlay */
|
||||
if (match_glob(key, "window.button.hover.bg.color")) {
|
||||
parse_color(value, theme->window_button_hover_bg_color);
|
||||
|
|
@ -1142,10 +1151,10 @@ entry(struct theme *theme, const char *key, const char *value)
|
|||
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");
|
||||
theme->menu_bevel_width =
|
||||
get_int_if_positive(value, "menu.bg.bevel-width");
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (match_glob(key, "menu.items.padding.x")) {
|
||||
theme->menu_items_padding_x = get_int_if_positive(
|
||||
value, "menu.items.padding.x");
|
||||
|
|
@ -1161,9 +1170,10 @@ entry(struct theme *theme, const char *key, const char *value)
|
|||
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");
|
||||
theme->menu_items_bevel_width =
|
||||
get_int_if_positive(value, "menu.items.bg.bevel-width");
|
||||
}
|
||||
|
||||
|
||||
if (match_glob(key, "menu.items.text.color")) {
|
||||
parse_color(value, theme->menu_items_text_color);
|
||||
}
|
||||
|
|
@ -1173,14 +1183,14 @@ entry(struct theme *theme, const char *key, const char *value)
|
|||
if (match_glob(key, "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");
|
||||
theme->menu_items_active_bevel_width =
|
||||
get_int_if_positive(value, "menu.items.active.bg.bevel-width");
|
||||
}
|
||||
|
||||
|
||||
if (match_glob(key, "menu.separator.width")) {
|
||||
theme->menu_separator_line_thickness = get_int_if_positive(
|
||||
|
|
@ -1207,14 +1217,14 @@ entry(struct theme *theme, const char *key, const char *value)
|
|||
if (match_glob(key, "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");
|
||||
theme->menu_title_bevel_width =
|
||||
get_int_if_positive(value, "menu.title.bg.bevel-width");
|
||||
}
|
||||
|
||||
|
||||
if (match_glob(key, "osd.bg.color")) {
|
||||
parse_color(value, theme->osd_bg_color);
|
||||
|
|
@ -1226,7 +1236,7 @@ entry(struct theme *theme, const char *key, const char *value)
|
|||
if (match_glob(key, "osd.border.color")) {
|
||||
parse_color(value, theme->osd_border_color);
|
||||
}
|
||||
|
||||
|
||||
if (match_glob(key, "osd.bg")) {
|
||||
theme->osd_border_type = parse_border_type(value);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue