|
| 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 | +|  |  |  | |
| 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