Drawer
drawer · Overlays · interactive
A panel that comes in from an edge.
Import
cpp
#include "gbui/widgets/drawer.hpp"Example
cpp
Drawer drawer(Ui& ui, const Interaction& input, std::string_view id, std::string_view title, bool open, const DrawerOptions& options = {});A panel from an edge. bool showFilters = …; auto sheet = drawer(ui, input, "filters", "Filters", showFilters); if (sheet.result.dismissed) showFilters = false; { // contents, written into sheet.body like any other container } The call sits unconditionally in the frame, the way tooltip does. Closed and finished leaving, body is a zero-sized clipped box out of the flow, so whatever the caller writes into it costs a few nodes and draws nothing — rather than landing in whichever container happened to be current.
API
DrawerOptions
| Option | Type | Default | What it does |
|---|---|---|---|
side | DrawerSideLeft · Right · Top · Bottom | DrawerSide::Right | Which edge it comes in from, and therefore which way it slides. |
size | float | 320.0f | How far across the window it reaches, in pixels. Clamped to the window, so a 400-pixel drawer on a 320-pixel window is a 320-pixel drawer rather than one with its close button off the edge. |
modal | bool | true | Blocks the window: a backdrop behind it and the keyboard trapped inside. On, because a panel that arrives over the content and leaves the content usable is an unusual thing to want and a confusing thing to meet. Off is the desktop inspector — a pane beside the work rather than in front of it. |
backdrop | bool | true | Dims what is behind it. Only meaningful when modal; a non-modal drawer with a backdrop would dim a window it does not block. |
header | bool | true | The title bar. Off leaves the whole panel to the caller, which is what a drawer holding its own toolbar wants. |
closeButton | bool | true | The × in the header. A drawer with no other way out should keep it. |
icon optional | std::optional<Icon> | Beside the title. | |
dismissOnBackdrop | bool | true | A press on the backdrop puts it away. Only when modal — without a backdrop there is nothing that press could mean. |
dismissOnEscape | bool | true | |
duration | float | 0.22f | How long the slide takes, in seconds. Needs an animator; without one it simply appears, which is what every animated thing here does. |
bounds | Rect | The window. Empty means the viewport the last layout used. |