mirror of
https://github.com/labwc/labwc.git
synced 2026-04-06 07:15:40 -04:00
add window.*.border.type and window.*.border.bevel-width options
This commit is contained in:
parent
b07165f154
commit
773996f1ee
5 changed files with 40 additions and 7 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#include <stdint.h>
|
||||
#include <wlr/types/wlr_scene.h>
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#ifndef LABWC_BORDERSET_H
|
||||
#define LABWC_BORDERSET_H
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include <cairo.h>
|
||||
#include <stdbool.h>
|
||||
#include "common/node-type.h"
|
||||
#include "common/borderset.h"
|
||||
|
||||
struct lab_img;
|
||||
|
||||
|
|
@ -98,6 +99,8 @@ struct theme {
|
|||
float border_color[4];
|
||||
float toggled_keybinds_color[4];
|
||||
float label_text_color[4];
|
||||
enum border_type border_type;
|
||||
int bevel_width;
|
||||
|
||||
/* window drop-shadows */
|
||||
int shadow_size;
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ struct borderset * createBuffer(uint32_t id, int size, enum border_type type, i
|
|||
newBorderset->bevelSize = bevelSize;
|
||||
|
||||
|
||||
|
||||
// Use ID as a AARRGGBB colour
|
||||
uint8_t a = id >> 24 & 255;
|
||||
uint8_t r = id >> 16 & 255;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ ssd_border_create(struct ssd *ssd)
|
|||
struct wlr_scene_tree *parent = subtree->tree;
|
||||
wlr_scene_node_set_enabled(&parent->node, active);
|
||||
float *color = theme->window[active].border_color;
|
||||
if (theme->beveled_border) {
|
||||
if (theme->window[active].border_type) {
|
||||
|
||||
// These will otherwise get left under the window when we reload
|
||||
|
||||
|
|
@ -51,10 +51,6 @@ ssd_border_create(struct ssd *ssd)
|
|||
subtree->bottom = lab_wlr_scene_rect_create(parent, 1, 1, color);
|
||||
|
||||
subtree->top = lab_wlr_scene_rect_create(parent, 1, 1, color);
|
||||
|
||||
|
||||
|
||||
int bevelSize = theme->border_bevel_width;
|
||||
|
||||
/* From Pull request 3382 */
|
||||
float r = color[0];
|
||||
|
|
@ -63,7 +59,7 @@ ssd_border_create(struct ssd *ssd)
|
|||
float a = 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, BORDER_DOUBLE, bevelSize);
|
||||
struct borderset * renderedborders = getBorders(colour32, bw, theme->window[active].border_type, theme->window[active].bevel_width);
|
||||
subtree->texturedBorders = generateBufferset(subtree->tree, renderedborders, bw);
|
||||
} else {
|
||||
subtree->left = lab_wlr_scene_rect_create(parent,
|
||||
|
|
@ -172,7 +168,7 @@ ssd_border_update(struct ssd *ssd)
|
|||
struct ssd_border_subtree *subtree = &ssd->border.subtrees[active];
|
||||
|
||||
|
||||
if (theme->beveled_border) {
|
||||
if (theme->window[active].border_type) {
|
||||
renderBufferset(subtree->texturedBorders, full_width, side_height+(ssd->titlebar.height + 2*theme->border_width), -ssd->titlebar.height-theme->border_width);
|
||||
} else {
|
||||
wlr_scene_rect_set_size(subtree->left,
|
||||
|
|
|
|||
32
src/theme.c
32
src/theme.c
|
|
@ -450,6 +450,18 @@ parse_hexstrs(const char *hexes, float colors[3][4])
|
|||
g_strfreev(elements);
|
||||
}
|
||||
|
||||
static enum border_type parse_border_type(const char *str) {
|
||||
char *lower = g_ascii_strdown(str, -1);
|
||||
if (strstr(lower, "doublesunken")) return BORDER_DOUBLE_INSET;
|
||||
if (strstr(lower, "sunken")) return BORDER_INSET;
|
||||
if (strstr(lower, "doubleraised")) return BORDER_DOUBLE;
|
||||
if (strstr(lower, "raised")) return BORDER_SINGLE;
|
||||
return BORDER_FLAT;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
parse_color(const char *str, float *rgba)
|
||||
{
|
||||
|
|
@ -552,6 +564,10 @@ theme_builtin(struct theme *theme)
|
|||
theme->window[SSD_INACTIVE].title_bg.color_to[0] = FLT_MIN;
|
||||
theme->window[SSD_ACTIVE].title_bg.color_to_split_to[0] = FLT_MIN;
|
||||
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_FLAT;
|
||||
theme->window[SSD_INACTIVE].bevel_width = 0;
|
||||
theme->window[SSD_INACTIVE].border_type = BORDER_FLAT;
|
||||
|
||||
parse_hexstr("#000000", theme->window[SSD_ACTIVE].label_text_color);
|
||||
parse_hexstr("#000000", theme->window[SSD_INACTIVE].label_text_color);
|
||||
|
|
@ -722,9 +738,25 @@ entry(struct theme *theme, const char *key, const char *value)
|
|||
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");
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
if (match_glob(key, "window.inactive.border.type")) {
|
||||
theme->window[SSD_INACTIVE].border_type = parse_border_type(value);
|
||||
}
|
||||
/* border.color is obsolete, but handled for backward compatibility */
|
||||
if (match_glob(key, "border.color")) {
|
||||
parse_color(value, theme->window[SSD_ACTIVE].border_color);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue