mirror of
https://github.com/labwc/labwc.git
synced 2026-03-11 05:33:49 -04:00
theme: replace *.hover.bg.shape with *.hover.bg.corner-radius
This commit is contained in:
parent
1f1ac27bf5
commit
fe6b3c1c35
4 changed files with 31 additions and 36 deletions
|
|
@ -126,9 +126,13 @@ labwc-config(5).
|
||||||
Space between titlebar buttons, in pixels.
|
Space between titlebar buttons, in pixels.
|
||||||
Default is 0.
|
Default is 0.
|
||||||
|
|
||||||
*window.button.hover.bg.shape*
|
*window.button.hover.bg.corner-radius*
|
||||||
The shape of the hover effect of a titlebar button: "rectangle" or "circle".
|
Radius of the hover effect of a titlebar button, in pixels.
|
||||||
Default is "rectangle".
|
Default is 0.
|
||||||
|
|
||||||
|
Note: for a circular hover effect, set *window.button.width* and
|
||||||
|
*window.button.height* equal and *window.button.hover.bg.corner-radius* half
|
||||||
|
of them.
|
||||||
|
|
||||||
*window.active.button.unpressed.image.color*
|
*window.active.button.unpressed.image.color*
|
||||||
Color of the images in titlebar buttons in their default, unpressed,
|
Color of the images in titlebar buttons in their default, unpressed,
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ window.button.width: 26
|
||||||
window.button.spacing: 0
|
window.button.spacing: 0
|
||||||
|
|
||||||
# window button hover effect
|
# window button hover effect
|
||||||
window.button.hover.bg.shape: rectangle
|
window.button.hover.bg.corner-radius: 0
|
||||||
|
|
||||||
# window buttons
|
# window buttons
|
||||||
window.active.button.unpressed.image.color: #000000
|
window.active.button.unpressed.image.color: #000000
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,6 @@ enum lab_justification {
|
||||||
LAB_JUSTIFY_RIGHT,
|
LAB_JUSTIFY_RIGHT,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum lab_shape {
|
|
||||||
LAB_RECTANGLE,
|
|
||||||
LAB_CIRCLE,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct theme_snapping_overlay {
|
struct theme_snapping_overlay {
|
||||||
bool bg_enabled;
|
bool bg_enabled;
|
||||||
bool border_enabled;
|
bool border_enabled;
|
||||||
|
|
@ -72,8 +67,8 @@ struct theme {
|
||||||
int window_button_height;
|
int window_button_height;
|
||||||
int window_button_spacing;
|
int window_button_spacing;
|
||||||
|
|
||||||
/* the shape of the hover effect */
|
/* the corner radius of the hover effect */
|
||||||
enum lab_shape window_button_hover_bg_shape;
|
int window_button_hover_bg_corner_radius;
|
||||||
|
|
||||||
int menu_item_padding_x;
|
int menu_item_padding_x;
|
||||||
int menu_item_padding_y;
|
int menu_item_padding_y;
|
||||||
|
|
|
||||||
46
src/theme.c
46
src/theme.c
|
|
@ -147,18 +147,19 @@ create_hover_fallback(struct theme *theme,
|
||||||
/* Overlay (pre-multiplied alpha) */
|
/* Overlay (pre-multiplied alpha) */
|
||||||
float overlay_color[4] = { 0.15f, 0.15f, 0.15f, 0.3f};
|
float overlay_color[4] = { 0.15f, 0.15f, 0.15f, 0.3f};
|
||||||
set_cairo_color(cairo, overlay_color);
|
set_cairo_color(cairo, overlay_color);
|
||||||
int radius = MIN(width, height) / 2;
|
int radius = theme->window_button_hover_bg_corner_radius;
|
||||||
|
|
||||||
switch (theme->window_button_hover_bg_shape) {
|
|
||||||
case LAB_CIRCLE:
|
|
||||||
cairo_arc(cairo, width / 2, height / 2, radius, 0 * deg, 360 * deg);
|
|
||||||
break;
|
|
||||||
case LAB_RECTANGLE:
|
|
||||||
cairo_rectangle(cairo, 0, 0, width, height);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
cairo_new_sub_path(cairo);
|
||||||
|
cairo_arc(cairo, radius, radius, radius, 180 * deg, 270 * deg);
|
||||||
|
cairo_line_to(cairo, width - radius, 0);
|
||||||
|
cairo_arc(cairo, width - radius, radius, radius, -90 * deg, 0 * deg);
|
||||||
|
cairo_line_to(cairo, width, height - radius);
|
||||||
|
cairo_arc(cairo, width - radius, height - radius, radius, 0 * deg, 90 * deg);
|
||||||
|
cairo_line_to(cairo, radius, height);
|
||||||
|
cairo_arc(cairo, radius, height - radius, radius, 90 * deg, 180 * deg);
|
||||||
|
cairo_close_path(cairo);
|
||||||
cairo_fill(cairo);
|
cairo_fill(cairo);
|
||||||
|
|
||||||
cairo_surface_flush(cairo_get_target(cairo));
|
cairo_surface_flush(cairo_get_target(cairo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -542,18 +543,6 @@ parse_justification(const char *str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum lab_shape
|
|
||||||
parse_shape(const char *str)
|
|
||||||
{
|
|
||||||
if (!strcasecmp(str, "Rectangle")) {
|
|
||||||
return LAB_RECTANGLE;
|
|
||||||
} else if (!strcasecmp(str, "Circle")) {
|
|
||||||
return LAB_CIRCLE;
|
|
||||||
} else {
|
|
||||||
return LAB_RECTANGLE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We generally use Openbox defaults, but if no theme file can be found it's
|
* We generally use Openbox defaults, but if no theme file can be found it's
|
||||||
* better to populate the theme variables with some sane values as no-one
|
* better to populate the theme variables with some sane values as no-one
|
||||||
|
|
@ -592,7 +581,7 @@ theme_builtin(struct theme *theme, struct server *server)
|
||||||
theme->window_button_width = 26;
|
theme->window_button_width = 26;
|
||||||
theme->window_button_height = 26;
|
theme->window_button_height = 26;
|
||||||
theme->window_button_spacing = 0;
|
theme->window_button_spacing = 0;
|
||||||
theme->window_button_hover_bg_shape = LAB_RECTANGLE;
|
theme->window_button_hover_bg_corner_radius = 0;
|
||||||
|
|
||||||
for (enum ssd_part_type type = LAB_SSD_BUTTON_FIRST;
|
for (enum ssd_part_type type = LAB_SSD_BUTTON_FIRST;
|
||||||
type <= LAB_SSD_BUTTON_LAST; type++) {
|
type <= LAB_SSD_BUTTON_LAST; type++) {
|
||||||
|
|
@ -785,8 +774,9 @@ entry(struct theme *theme, const char *key, const char *value)
|
||||||
theme->window_button_spacing = get_int_if_positive(
|
theme->window_button_spacing = get_int_if_positive(
|
||||||
value, "window.button.spacing");
|
value, "window.button.spacing");
|
||||||
}
|
}
|
||||||
if (match_glob(key, "window.button.hover.bg.shape")) {
|
if (match_glob(key, "window.button.hover.bg.corner-radius")) {
|
||||||
theme->window_button_hover_bg_shape = parse_shape(value);
|
theme->window_button_hover_bg_corner_radius = get_int_if_positive(
|
||||||
|
value, "window.button.hover.bg.corner-radius");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* universal button */
|
/* universal button */
|
||||||
|
|
@ -1491,6 +1481,12 @@ post_processing(struct theme *theme)
|
||||||
rc.corner_radius = theme->title_height - 1;
|
rc.corner_radius = theme->title_height - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int min_button_hover_radius =
|
||||||
|
MIN(theme->window_button_width, theme->window_button_height) / 2;
|
||||||
|
if (theme->window_button_hover_bg_corner_radius > min_button_hover_radius) {
|
||||||
|
theme->window_button_hover_bg_corner_radius = min_button_hover_radius;
|
||||||
|
}
|
||||||
|
|
||||||
if (theme->menu_max_width < theme->menu_min_width) {
|
if (theme->menu_max_width < theme->menu_min_width) {
|
||||||
wlr_log(WLR_ERROR,
|
wlr_log(WLR_ERROR,
|
||||||
"Adjusting menu.width.max: .max (%d) lower than .min (%d)",
|
"Adjusting menu.width.max: .max (%d) lower than .min (%d)",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue