Skip to content

Commit 1605d56

Browse files
docs(shell): documents for self drawn border & shadpw
1 parent de7108b commit 1605d56

File tree

4 files changed

+80
-13
lines changed

4 files changed

+80
-13
lines changed

CONFIG.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,16 @@ Breeze Shell 配置文件的 JSON Schema 位于
9898
"submenu_bg": {
9999
...
100100
}
101-
}
101+
},
102+
// 使用自绘边框、阴影(需关闭 dwm 边框)
103+
"use_self_drawn_border": true,
104+
// 自定义边框示例配置
105+
"border_width": 2.5,
106+
// 支持渐变 [linear-gradient(angle, color1, color2) / radial-gradient(radius, color1, color2)]
107+
"border_color_dark": "linear-gradient(30, #DE73DF, #E5C07B)",
108+
"shadow_size": 20,
109+
"shadow_color_dark_from": "#ff000033",
110+
"shadow_color_dark_to": "#00ff0000"
102111
},
103112
// 启用垂直同步
104113
"vsync": true,
@@ -144,7 +153,7 @@ Breeze Shell 配置文件的 JSON Schema 位于
144153
```json
145154
{
146155
"default_animation": {
147-
"easing": "mutation"
148-
}
156+
"easing": "mutation"
157+
}
149158
}
150159
```

resources/schema.json

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,70 @@
125125
"type": "integer"
126126
},
127127
"acrylic_color_light": {
128-
"type": "string"
128+
"type": "string",
129+
"description": "Color string supporting formats like #RRGGBBAA, #RRGGBB, rgba(R, G, B, A), rgb(R, G, B), linear-gradient(angle, color1, color2), radial-gradient(radius, color1, color2), solid(color)."
129130
},
130131
"acrylic_color_dark": {
131-
"type": "string"
132+
"type": "string",
133+
"description": "Color string supporting formats like #RRGGBBAA, #RRGGBB, rgba(R, G, B, A), rgb(R, G, B), linear-gradient(angle, color1, color2), radial-gradient(radius, color1, color2), solid(color)."
132134
},
133135
"acrylic_opacity": {
134136
"type": "number"
135137
},
136138
"animation": {
137139
"$ref": "#/definitions/Animation"
140+
},
141+
"use_self_drawn_border": {
142+
"type": "boolean",
143+
"description": "Whether to use a self-drawn border instead of the system default."
144+
},
145+
"border_color_light": {
146+
"type": "string",
147+
"description": "Color of the border in light mode. Supports formats like #RRGGBBAA, #RRGGBB, rgba(R, G, B, A), rgb(R, G, B), linear-gradient(angle, color1, color2), radial-gradient(radius, color1, color2), solid(color)."
148+
},
149+
"border_color_dark": {
150+
"type": "string",
151+
"description": "Color of the border in dark mode. Supports formats like #RRGGBBAA, #RRGGBB, rgba(R, G, B, A), rgb(R, G, B), linear-gradient(angle, color1, color2), radial-gradient(radius, color1, color2), solid(color)."
152+
},
153+
"shadow_color_light_from": {
154+
"type": "string"
155+
},
156+
"shadow_color_light_to": {
157+
"type": "string"
158+
},
159+
"shadow_color_dark_from": {
160+
"type": "string"
161+
},
162+
"shadow_color_dark_to": {
163+
"type": "string"
164+
},
165+
"shadow_blur": {
166+
"type": "number",
167+
"description": "The blur radius of the shadow."
168+
},
169+
"shadow_offset_x": {
170+
"type": "number",
171+
"description": "The horizontal offset of the shadow."
172+
},
173+
"shadow_offset_y": {
174+
"type": "number",
175+
"description": "The vertical offset of the shadow."
176+
},
177+
"shadow_opacity": {
178+
"type": "number",
179+
"description": "The opacity of the shadow (0.0 to 1.0)."
180+
},
181+
"shadow_size": {
182+
"type": "number",
183+
"description": "The size of the shadow."
184+
},
185+
"border_width": {
186+
"type": "number",
187+
"description": "The width of the self-drawn border."
188+
},
189+
"inset_border": {
190+
"type": "boolean",
191+
"description": "Whether the self-drawn border should be inset."
138192
}
139193
},
140194
"required": [],
@@ -218,4 +272,4 @@
218272
"title": "Bg"
219273
}
220274
}
221-
}
275+
}

src/shell/config.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ struct config {
9898
std::string acrylic_color_light = "#fefefe00";
9999
std::string acrylic_color_dark = "#28282800";
100100

101-
bool use_self_drawn_border = false;
101+
bool use_self_drawn_border = true;
102102
// These values are used when use_self_drawn_border is true
103103
paint_color border_color_light = paint_color::from_string("#00000022");
104104
paint_color border_color_dark = paint_color::from_string("#ffffff22");
@@ -111,8 +111,8 @@ struct config {
111111
float shadow_offset_y = 0;
112112
float shadow_opacity = 0.2;
113113
float shadow_size = 10;
114-
float border_width = 1;
115-
bool inset_border = false;
114+
float border_width = 1.5;
115+
bool inset_border = true;
116116

117117
// unused, only for backward compatibility
118118
float acrylic_opacity = 0.1;

src/shell/contextmenu/menu_widget.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,13 @@ void mb_shell::menu_widget::render(ui::nanovg_context ctx) {
328328
auto &theme = config::current->context_menu.theme;
329329
bool light = menu_render::current.value()->light_color;
330330

331-
float boarder_width =
332-
theme.use_self_drawn_border ? theme.border_width : 0.0f;
331+
bool use_dwm = config::current->context_menu.theme.use_dwm_if_available
332+
? is_win11_or_later()
333+
: false;
334+
bool use_self_drawn_border = theme.use_self_drawn_border && !use_dwm;
333335

334-
if (theme.use_self_drawn_border) {
336+
float boarder_width = use_self_drawn_border ? theme.border_width : 0.0f;
337+
if (use_self_drawn_border) {
335338
float shadow_size = theme.shadow_size,
336339
shadow_offset_x = theme.shadow_offset_x,
337340
shadow_offset_y = theme.shadow_offset_y;
@@ -361,7 +364,8 @@ void mb_shell::menu_widget::render(ui::nanovg_context ctx) {
361364
ctx.beginPath();
362365

363366
if (theme.inset_border) {
364-
ctx.roundedRect(*bg->x + boarder_width / 2, *bg->y + boarder_width / 2,
367+
ctx.roundedRect(*bg->x + boarder_width / 2,
368+
*bg->y + boarder_width / 2,
365369
*bg->width - boarder_width,
366370
*bg->height - boarder_width, corner_radius);
367371
} else {

0 commit comments

Comments
 (0)