Skip to content

Commit 0651212

Browse files
committed
feat(docs): add decorations
1 parent 4dc1fe2 commit 0651212

7 files changed

Lines changed: 89 additions & 0 deletions

File tree

astro.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { defineConfig } from "astro/config";
33
import react from "@astrojs/react";
44
import starlight from "@astrojs/starlight";
55

6+
import starlightImageZoom from "starlight-image-zoom";
67
import starlightAutoSidebar from "starlight-auto-sidebar";
78
import starlightThemeRapide from "starlight-theme-rapide";
89

@@ -22,13 +23,15 @@ export default defineConfig({
2223
},
2324
sidebar: [
2425
{ label: "Getting Started", autogenerate: { directory: "/getting-started/" } },
26+
{ label: "Window", autogenerate: { directory: "/window/" } },
2527
{ label: "Webview", autogenerate: { directory: "/webview/" } },
2628
],
2729
components: {
2830
Hero: "./src/components/Hero.astro",
2931
SiteTitle: "./src/components/Title.astro",
3032
},
3133
plugins: [
34+
starlightImageZoom(),
3235
starlightAutoSidebar(),
3336
starlightThemeRapide(),
3437
],

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"react-dom": "^19.1.1",
2222
"sharp": "^0.34.2",
2323
"starlight-auto-sidebar": "^0.1.2",
24+
"starlight-image-zoom": "^0.13.0",
2425
"starlight-theme-rapide": "^0.5.1"
2526
},
2627
"devDependencies": {

pnpm-lock.yaml

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/assets/full.png

221 KB
Loading

src/assets/none.png

219 KB
Loading

src/assets/partial.png

233 KB
Loading
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
title: Decorations
3+
---
4+
5+
import { Icon } from "@astrojs/starlight/components";
6+
7+
> This page documents how window decorations work
8+
9+
Window Decorations are commonly defined as the non-client area parts of a window, so things like the Titlebar and Resize-Borders.
10+
Saucer offers an API to change Window Decorations to allow for custom titlebars, which you might've seen in other apps such as e.g. Spotify or Discord.
11+
12+
```cpp title="Example: Changing Window Decorations"
13+
window->set_decorations(saucer::window::decoration::partial);
14+
```
15+
16+
There are three decoration-types to choose from (`none`, `partial`, `full`). Each of them behave differently.
17+
Their differences are listed in the table below:
18+
19+
| Decoration | Titlebar | Resizable | Aero-Snap[^1] | Window Shadows | Note |
20+
| ---------- | ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | ---------------------------------------- |
21+
| `none` | <Icon name="close" color="red"/> | <Icon name="close" color="red"/> | <Icon name="close" color="red"/> | <Icon name="close" color="red"/> | Prefer `partial` decorations if possible |
22+
| `partial` | <Icon name="close" color="red"/> | <Icon name="approve-check" color="green"/> | <Icon name="approve-check" color="green"/> | <Icon name="approve-check" color="green"/> | - |
23+
| `full` | <Icon name="approve-check" color="green"/> | <Icon name="approve-check" color="green"/> | <Icon name="approve-check" color="green"/> | <Icon name="approve-check" color="green"/> | The default window decorations |
24+
25+
[^1]: Refers to Window-Snapping, e.g. when dragging the window to the top of the screen, the operating system will usually prompt to maximize the window.
26+
27+
## Gallery
28+
29+
| `decoration::none` | `decoration::partial` | `decoration::full` |
30+
| :-----------------------: | :--------------------------: | :-----------------------: |
31+
| ![](/src/assets/none.png) | ![](/src/assets/partial.png) | ![](/src/assets/full.png) |
32+
33+
## Webview Support
34+
35+
When the webview `attributes` (`saucer::webview::options{.attributes = true}`) setting is enabled (_the default_), you can use the following `data`-attributes to more easily implement a custom titlebar:
36+
37+
- `data-webview-close`
38+
39+
> When an element with this attribute is clicked, the window is closed
40+
41+
- `data-webview-minimize`
42+
43+
> When an element with this attribute is clicked, the window is minimized
44+
45+
- `data-webview-maximize`
46+
47+
> When an element with this attribute is clicked, the window is maximized or restored, depending on its current state
48+
49+
- `data-webview-drag`
50+
51+
> When an element with this attribute is held, the window will follow the mouse cursor
52+
53+
- `data-webview-resize="<edge>"`
54+
55+
> When an element with this attribute is held, the window will start resizing.
56+
> `<edge>` should be one (or a combination[^2]) of the following
57+
>
58+
> - `t` ≈ "top" window border
59+
> - `b` ≈ "bottom" window border
60+
> - `l` ≈ "left" window border
61+
> - `r` ≈ "right" window border
62+
63+
- `data-webview-ignore`
64+
> Add this to elements that trigger any kind of unwanted operation. This can happen when the parent of such an element has a `data-webview` attribute
65+
66+
[^2]: e.g. `data-webview-resize="tr"` to start resizing from the top right border.

0 commit comments

Comments
 (0)