Skip to content

SplitPane

splitPane · Containers · interactive

Two panes and a divider the reader can drag.

Import

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

Example

Nothing is downloaded until you press it.

cpp
SplitPaneResult splitPane(Ui& ui, const Interaction& input, std::string_view id, float position, const std::function<void(Ui&)>& leading, const std::function<void(Ui&)>& trailing, const SplitPaneOptions& options = {});

Draws leading, a divider, and trailing. position is the share the leading pane asks for, 0 to 1. It is a request: the minimums win over it, so a container too narrow for both gives each what it needs and the fraction stops being reachable — which is the right answer and the one a caller does not have to write.

API

SplitPaneOptions

OptionTypeDefaultWhat it does
orientationSplitOrientation
Horizontal · Vertical
SplitOrientation::HorizontalWhich way the panes sit, and therefore which pair of arrow keys moves the divider.
minLeadingfloat120.0fThe smallest each pane may become, in pixels. Enforced by the layout rather than by the drag, which is what makes it hold when the window shrinks as well as when the divider moves — the case a clamp in the drag handler silently misses.
minTrailingfloat120.0fAs above, for the other one.
dividerWidthfloat7.0fHow wide the grab strip is. Wider than the hairline drawn in it: a one-pixel target is a target nobody hits.
namestd::string_viewWhat the divider is called. "Sidebar width" says more than "Resize", and it is the only thing a reader has to know which of two panes the arrow keys are about to change.
leadingLabelstd::string_viewWhat each side is, announced as a group around it. Empty leaves the pane's own contents to speak for it.
trailingLabelstd::string_viewAs above, for the other one.
widthfloatkAuto
heightfloatkAuto
growfloat1.0f

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