Skip to content

Drawer

drawer · Overlays · interactive

A panel that comes in from an edge.

Import

cpp
#include "gbui/widgets/drawer.hpp"

Example

Nothing is downloaded until you press it.

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

OptionTypeDefaultWhat it does
sideDrawerSide
Left · Right · Top · Bottom
DrawerSide::RightWhich edge it comes in from, and therefore which way it slides.
sizefloat320.0fHow 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.
modalbooltrueBlocks 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.
backdropbooltrueDims what is behind it. Only meaningful when modal; a non-modal drawer with a backdrop would dim a window it does not block.
headerbooltrueThe title bar. Off leaves the whole panel to the caller, which is what a drawer holding its own toolbar wants.
closeButtonbooltrueThe × in the header. A drawer with no other way out should keep it.
icon optionalstd::optional<Icon>Beside the title.
dismissOnBackdropbooltrueA press on the backdrop puts it away. Only when modal — without a backdrop there is nothing that press could mean.
dismissOnEscapebooltrue
durationfloat0.22fHow long the slide takes, in seconds. Needs an animator; without one it simply appears, which is what every animated thing here does.
boundsRectThe window. Empty means the viewport the last layout used.

Released under the LGPL-3.0-or-later licence.