Donner SVG main
0.8.0 ยท 382bd0190.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
AttachedNumericStepper.h File Reference
Include dependency graph for AttachedNumericStepper.h:

Classes

struct  donner::editor::AttachedNumericStepperResult
 One pair of compact step buttons joined to the right edge of a numeric field. More...
struct  donner::editor::NumericPresetPopupPlacement
 Where a numeric preset popup opens relative to the control it belongs to. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Functions

AttachedNumericStepperResult donner::editor::RenderAttachedNumericStepper (const char *id, const ImVec2 &fieldMin, const ImVec2 &fieldMax, const EditorTheme &theme)
 Draw two vertically stacked step buttons with the exact height of the preceding field.
NumericPresetPopupPlacement donner::editor::PlaceNumericPresetPopup (const Box2d &control, double preferredHeight, double width, const Box2d &bounds, double gap)
 Choose a preset popup position that never overlaps the control it belongs to.
bool donner::editor::BeginHybridNumericPresetPopup (const char *popupId, const ImVec2 &fieldMin, const ImVec2 &fieldMax, bool fieldActivated, float maximumHeight)
 Open a preset popup next to a focused numeric input without stealing its typing focus.

Variables

constexpr float donner::editor::kAttachedNumericStepperWidth = 22.0f
 Logical width of the stepper pair attached to a numeric input.

Function Documentation

◆ BeginHybridNumericPresetPopup()

bool donner::editor::BeginHybridNumericPresetPopup ( const char * popupId,
const ImVec2 & fieldMin,
const ImVec2 & fieldMax,
bool fieldActivated,
float maximumHeight )
nodiscard

Open a preset popup next to a focused numeric input without stealing its typing focus.

Call after rendering the input and its attached stepper. The caller must pair a true return with ImGui::EndPopup(). Single-click activation keeps the field editable while expanding the preset choices. Its width matches the numeric field plus attached stepper. It opens below the field when the list fits there, otherwise above, and never covers the field (see donner::editor::PlaceNumericPresetPopup).

Parameters
popupIdStable ImGui popup ID in the caller's current ID scope.
fieldMinMinimum screen-space corner of the numeric input.
fieldMaxMaximum screen-space corner of the numeric input.
fieldActivatedTrue only on the input's focus-acquisition frame.
maximumHeightMaximum popup height before its contents scroll.
Returns
True when the popup is open and BeginPopup succeeded.

◆ PlaceNumericPresetPopup()

NumericPresetPopupPlacement donner::editor::PlaceNumericPresetPopup ( const Box2d & control,
double preferredHeight,
double width,
const Box2d & bounds,
double gap )
nodiscard

Choose a preset popup position that never overlaps the control it belongs to.

The popup opens below the control when its preferred height fits there, otherwise above when it fits there, otherwise on the side with more room with its height reduced so the list scrolls. Horizontally it follows the control's left edge, shifted only to stay inside the bounds when it fits within them.

Parameters
controlScreen-space rectangle of the numeric field plus its attached stepper.
preferredHeightHeight the popup needs to show all choices, capped by the caller's limit.
widthPopup width.
boundsScreen-space rectangle the popup must stay within.
gapVertical spacing kept between the control and the popup.

◆ RenderAttachedNumericStepper()

AttachedNumericStepperResult donner::editor::RenderAttachedNumericStepper ( const char * id,
const ImVec2 & fieldMin,
const ImVec2 & fieldMax,
const EditorTheme & theme )
nodiscard

Draw two vertically stacked step buttons with the exact height of the preceding field.

Call immediately after an ImGui numeric input. The pair has no horizontal gap, shares a single outer frame with the input, and keeps its hit boxes independent of the field's value.

Parameters
idStable ImGui ID scope for this pair.
fieldMinMinimum screen-space corner of the preceding numeric field.
fieldMaxMaximum screen-space corner of the preceding numeric field.
themeActive editor colors and corner radius.
Returns
Activated step plus both screen-space hit boxes.