mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
overlay: add theme settings for colors and border width
adds theme settings like: snapping.overlay.[region|edge].bg.color: #8080b380 snapping.overlay.[region|edge].border.color: #ffffff,#000000,#ffffff snapping.overlay.[region|edge].border.width: 1
This commit is contained in:
parent
50fd65416f
commit
3b13f4cdcd
5 changed files with 123 additions and 10 deletions
|
|
@ -208,6 +208,34 @@ elements are not listed here, but are supported.
|
|||
Otherwise, an outlined rectangle is shown instead.
|
||||
If software rendering is used, an outlined rectangle is always shown.
|
||||
|
||||
*snapping.preview.region.bg.color*
|
||||
Color of a filled rectangle shown as the preview when a window is snapped to
|
||||
a region. Default is #8080b380.
|
||||
|
||||
*snapping.preview.edge.bg.color*
|
||||
Color of a filled rectangle shown as the preview when a window is snapped to
|
||||
an edge. Default is #8080b380.
|
||||
|
||||
*snapping.preview.region.border.width*
|
||||
Border width of an outlined rectangle shown as the preview when a window is
|
||||
snapped to a region. Inherits `osd.border.width` if not set.
|
||||
|
||||
*snapping.preview.edge.border.width*
|
||||
Border width of an outlined rectangle shown as the preview when a window is
|
||||
snapped to an edge. Inherits `osd.border.width` if not set.
|
||||
|
||||
*snapping.preview.region.border.color*
|
||||
Color(s) of an outlined rectangle shown as the preview when a window is
|
||||
snapped to a region. Possible value is a color or up to 3 colors separated
|
||||
by commas (e.g. "#ffffff,#000000,#ffffff"). When multiple colors are
|
||||
specified, a multi-line rectangle with each line having the specified color
|
||||
is drawn. If not set, this inherits the on-screen-display theme
|
||||
("[*osd.bg.color*],[*osd.label.text.color*],[*osd.bg.color*]").
|
||||
|
||||
*snapping.preview.edge.border.color*
|
||||
Color(s) of an outlined rectangle shown as the preview when a window is
|
||||
snapped to an edge. See *snapping.preview.region.border.color* for details.
|
||||
|
||||
*border.color*
|
||||
Set both *window.active.border.color* and *window.inactive.border.color*.
|
||||
This is obsolete, but supported for backward compatibility as some themes
|
||||
|
|
|
|||
|
|
@ -74,3 +74,9 @@ osd.workspace-switcher.boxes.height: 20
|
|||
|
||||
snapping.preview.region.fill: yes
|
||||
snapping.preview.edge.fill: yes
|
||||
snapping.preview.region.bg.color: #8080b380
|
||||
snapping.preview.edge.bg.color: #8080b380
|
||||
snapping.preview.region.border.width: 1
|
||||
snapping.preview.edge.border.width: 1
|
||||
snapping.preview.region.border.color: #dddda6,#000000,#dddda6
|
||||
snapping.preview.edge.border.color: #dddda6,#000000,#dddda6
|
||||
|
|
|
|||
|
|
@ -83,6 +83,14 @@ struct theme {
|
|||
bool snapping_preview_region_fill;
|
||||
bool snapping_preview_edge_fill;
|
||||
|
||||
float snapping_preview_region_bg_color[4];
|
||||
float snapping_preview_edge_bg_color[4];
|
||||
|
||||
int snapping_preview_region_border_width;
|
||||
int snapping_preview_edge_border_width;
|
||||
float snapping_preview_region_border_color[3][4];
|
||||
float snapping_preview_edge_border_color[3][4];
|
||||
|
||||
/* textures */
|
||||
struct lab_data_buffer *button_close_active_unpressed;
|
||||
struct lab_data_buffer *button_maximize_active_unpressed;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@
|
|||
#include "view.h"
|
||||
|
||||
static void
|
||||
create_overlay_rect(struct seat *seat, struct overlay_rect *rect, int fill)
|
||||
create_overlay_rect(struct seat *seat, struct overlay_rect *rect, int fill,
|
||||
float bg_color[4], int border_width, float border_colors[3][4])
|
||||
{
|
||||
struct server *server = seat->server;
|
||||
|
||||
|
|
@ -18,20 +19,18 @@ create_overlay_rect(struct seat *seat, struct overlay_rect *rect, int fill)
|
|||
|
||||
if (rect->fill) {
|
||||
/* Create a filled rectangle */
|
||||
float color[4] = { 0.25, 0.25, 0.35, 0.5 };
|
||||
rect->scene_rect = wlr_scene_rect_create(&server->scene->tree,
|
||||
0, 0, color);
|
||||
0, 0, bg_color);
|
||||
rect->node = &rect->scene_rect->node;
|
||||
} else {
|
||||
/* Create outlines */
|
||||
int line_width = server->theme->osd_border_width;
|
||||
float *colors[3] = {
|
||||
server->theme->osd_bg_color,
|
||||
server->theme->osd_label_text_color,
|
||||
server->theme->osd_bg_color
|
||||
border_colors[0],
|
||||
border_colors[1],
|
||||
border_colors[2],
|
||||
};
|
||||
rect->pixman_rect = multi_rect_create(&server->scene->tree,
|
||||
colors, line_width);
|
||||
colors, border_width);
|
||||
rect->node = &rect->pixman_rect->tree->node;
|
||||
}
|
||||
|
||||
|
|
@ -49,9 +48,15 @@ void overlay_reconfigure(struct seat *seat)
|
|||
|
||||
struct theme *theme = seat->server->theme;
|
||||
create_overlay_rect(seat, &seat->overlay.region_rect,
|
||||
theme->snapping_preview_region_fill);
|
||||
theme->snapping_preview_region_fill,
|
||||
theme->snapping_preview_region_bg_color,
|
||||
theme->snapping_preview_region_border_width,
|
||||
theme->snapping_preview_region_border_color);
|
||||
create_overlay_rect(seat, &seat->overlay.edge_rect,
|
||||
theme->snapping_preview_edge_fill);
|
||||
theme->snapping_preview_edge_fill,
|
||||
theme->snapping_preview_edge_bg_color,
|
||||
theme->snapping_preview_edge_border_width,
|
||||
theme->snapping_preview_edge_border_color);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
66
src/theme.c
66
src/theme.c
|
|
@ -428,6 +428,16 @@ parse_hexstr(const char *hex, float *rgba)
|
|||
rgba[2] *= rgba[3];
|
||||
}
|
||||
|
||||
static void
|
||||
parse_hexstrs(const char *hexes, float colors[3][4])
|
||||
{
|
||||
gchar **elements = g_strsplit(hexes, ",", -1);
|
||||
for (int i = 0; elements[i] && i < 3; i++) {
|
||||
parse_hexstr(elements[i], colors[i]);
|
||||
}
|
||||
g_strfreev(elements);
|
||||
}
|
||||
|
||||
static enum lab_justification
|
||||
parse_justification(const char *str)
|
||||
{
|
||||
|
|
@ -524,6 +534,19 @@ theme_builtin(struct theme *theme)
|
|||
|
||||
theme->snapping_preview_region_fill = true;
|
||||
theme->snapping_preview_edge_fill = true;
|
||||
|
||||
parse_hexstr("#8080b380", theme->snapping_preview_region_bg_color);
|
||||
parse_hexstr("#8080b380", theme->snapping_preview_edge_bg_color);
|
||||
|
||||
/* inherit settings in post_processing() if not set elsewhere */
|
||||
theme->snapping_preview_region_border_width = INT_MIN;
|
||||
theme->snapping_preview_edge_border_width = INT_MIN;
|
||||
memset(theme->snapping_preview_region_border_color, 0,
|
||||
sizeof(theme->snapping_preview_region_border_color));
|
||||
theme->snapping_preview_region_border_color[0][0] = FLT_MIN;
|
||||
memset(theme->snapping_preview_edge_border_color, 0,
|
||||
sizeof(theme->snapping_preview_edge_border_color));
|
||||
theme->snapping_preview_edge_border_color[0][0] = FLT_MIN;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -725,6 +748,24 @@ entry(struct theme *theme, const char *key, const char *value)
|
|||
if (match_glob(key, "snapping.preview.edge.fill")) {
|
||||
theme->snapping_preview_edge_fill = parse_bool(value, true);
|
||||
}
|
||||
if (match_glob(key, "snapping.preview.region.bg.color")) {
|
||||
parse_hexstr(value, theme->snapping_preview_region_bg_color);
|
||||
}
|
||||
if (match_glob(key, "snapping.preview.edge.bg.color")) {
|
||||
parse_hexstr(value, theme->snapping_preview_edge_bg_color);
|
||||
}
|
||||
if (match_glob(key, "snapping.preview.region.border.width")) {
|
||||
theme->snapping_preview_region_border_width = atoi(value);
|
||||
}
|
||||
if (match_glob(key, "snapping.preview.edge.border.width")) {
|
||||
theme->snapping_preview_edge_border_width = atoi(value);
|
||||
}
|
||||
if (match_glob(key, "snapping.preview.region.border.color")) {
|
||||
parse_hexstrs(value, theme->snapping_preview_region_border_color);
|
||||
}
|
||||
if (match_glob(key, "snapping.preview.edge.border.color")) {
|
||||
parse_hexstrs(value, theme->snapping_preview_edge_border_color);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -982,6 +1023,14 @@ create_corners(struct theme *theme)
|
|||
theme->corner_top_right_inactive_normal = rounded_rect(&ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
fill_colors_with_osd_theme(struct theme *theme, float colors[3][4])
|
||||
{
|
||||
memcpy(colors[0], theme->osd_bg_color, sizeof(colors[0]));
|
||||
memcpy(colors[1], theme->osd_label_text_color, sizeof(colors[1]));
|
||||
memcpy(colors[2], theme->osd_bg_color, sizeof(colors[2]));
|
||||
}
|
||||
|
||||
static void
|
||||
post_processing(struct theme *theme)
|
||||
{
|
||||
|
|
@ -1043,6 +1092,23 @@ post_processing(struct theme *theme)
|
|||
theme->osd_window_switcher_width =
|
||||
MIN(theme->osd_window_switcher_width, 100);
|
||||
}
|
||||
|
||||
if (theme->snapping_preview_region_border_width == INT_MIN) {
|
||||
theme->snapping_preview_region_border_width =
|
||||
theme->osd_border_width;
|
||||
}
|
||||
if (theme->snapping_preview_edge_border_width == INT_MIN) {
|
||||
theme->snapping_preview_edge_border_width =
|
||||
theme->osd_border_width;
|
||||
}
|
||||
if (theme->snapping_preview_region_border_color[0][0] == FLT_MIN) {
|
||||
fill_colors_with_osd_theme(theme,
|
||||
theme->snapping_preview_region_border_color);
|
||||
}
|
||||
if (theme->snapping_preview_edge_border_color[0][0] == FLT_MIN) {
|
||||
fill_colors_with_osd_theme(theme,
|
||||
theme->snapping_preview_edge_border_color);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue