Skip to content

Layout & Control Widgets ​

This page covers the smaller, purpose-built widgets. Each setter that returns the concrete widget reference is marked (chainable, returns X&).


Divider ​

cpp
class Divider : public Container;
enum class DividerOrientation { kHorizontal, kVertical };

A thin separator line. Header: <neoflux/widgets/divider.h>.

MethodSignatureNotes
ctorDivider() / explicit Divider(float thickness)
SetColorDivider& SetColor(const Color&)(chainable)
SetThicknessDivider& SetThickness(float)px, default 1.0. (chainable)
SetOrientationDivider& SetOrientation(DividerOrientation)default horizontal. (chainable)
cpp
std::make_shared<Divider>(1.0F)
    ->SetColor({220, 220, 220, 255})
    .build();

Padding ​

cpp
class Padding : public Container;

A single-child widget that insets its child by fixed edge insets. Header: <neoflux/widgets/padding.h>. No setters; child + insets are supplied up front.

MethodSignature
ctorexplicit Padding(float all, std::shared_ptr<Widget> child = nullptr)
ctorPadding(const EdgeInsets& insets, std::shared_ptr<Widget> child = nullptr)
cpp
std::make_shared<Padding>(16.0F, label);  // uniform 16px all edges

Center ​

cpp
class Center : public Container;

Fills its parent and centers the child on both axes (flex-grow=1, centered justify/align). Header: <neoflux/widgets/center.h>.

MethodSignature
ctorexplicit Center(std::shared_ptr<Widget> child = nullptr)
cpp
std::make_shared<Center>(spinner);

Align ​

cpp
class Align : public Container;

Like Center but for an arbitrary corner/alignment. Equivalent to Align(kCenter, kCenter) being Center. Header: <neoflux/widgets/align.h>.

MethodSignatureNotes
ctorAlign(HAlign h, VAlign v, std::shared_ptr<Widget> child = nullptr)
SetHorizontalAlign& SetHorizontal(HAlign)(chainable)
SetVerticalAlign& SetVertical(VAlign)(chainable)
cpp
std::make_shared<Align>(HAlign::kRight, VAlign::kTop, closeButton);

Card ​

cpp
class Card : public Container;

A rounded, padded surface panel framing a single child. Adapted (design-level) from EUI-NEO, Apache-2.0. Header: <neoflux/widgets/card.h>.

MethodSignatureNotes
ctorexplicit Card(std::shared_ptr<Widget> child = nullptr)
SetCardColorCard& SetCardColor(const Color&)(chainable)
SetCardRadiusCard& SetCardRadius(float)px. (chainable)
SetCardPaddingCard& SetCardPadding(float)uniform inner padding. (chainable)
cpp
std::make_shared<Card>(body)
    ->SetCardColor({255, 255, 255, 255})
    .SetCardRadius(10.0F)
    .SetCardPadding(14.0F)
    .build();

ProgressIndicator ​

cpp
class ProgressIndicator : public Widget;

A determinate horizontal progress bar (rounded track + filled portion). Adapted from EUI-NEO, Apache-2.0. Header: <neoflux/widgets/progress_indicator.h>.

MethodSignatureNotes
ctorProgressIndicator()
SetValueProgressIndicator& SetValue(float)clamped to [0,1]. (chainable)
GetValuefloat GetValue() const noexceptcurrent clamped value.
SetTrackColorProgressIndicator& SetTrackColor(const Color&)background. (chainable)
SetFillColorProgressIndicator& SetFillColor(const Color&)filled portion. (chainable)
SetThicknessProgressIndicator& SetThickness(float)track height px. (chainable)
cpp
bar->SetValue(0.6F).SetFillColor({40, 140, 255, 255});

Switch ​

cpp
class Switch : public Widget;
using OnChanged = std::function<void(bool checked)>;

A pill toggle. Clicking toggles state and fires the callback. Adapted from EUI-NEO, Apache-2.0. Header: <neoflux/widgets/switch.h>.

MethodSignatureNotes
ctorSwitch() / explicit Switch(bool checked)
SetCheckedSwitch& SetChecked(bool)programmatic; does NOT fire callback. (chainable)
IsCheckedbool IsChecked() const noexcept
SetOnChangedSwitch& SetOnChanged(OnChanged)fired on user toggle. (chainable)
SetLabelSwitch& SetLabel(std::string)trailing label. (chainable)
SetOnColorSwitch& SetOnColor(const Color&)track when on. (chainable)
SetOffColorSwitch& SetOffColor(const Color&)track when off. (chainable)
cpp
auto sw = std::make_shared<Switch>(false);
sw->SetLabel("Dark mode")
  .SetOnChanged([](bool on) { /* ... */ });

Checkbox ​

cpp
class Checkbox : public Widget;
using OnChanged = std::function<void(bool checked)>;

A checked/unchecked box with optional trailing label. The check mark is drawn as a filled block (the command buffer exposes rects only). Adapted from EUI-NEO, Apache-2.0. Header: <neoflux/widgets/checkbox.h>.

MethodSignatureNotes
ctorCheckbox() / explicit Checkbox(bool checked)
SetCheckedCheckbox& SetChecked(bool)programmatic; does NOT fire callback. (chainable)
IsCheckedbool IsChecked() const noexcept
SetOnChangedCheckbox& SetOnChanged(OnChanged)fired on toggle. (chainable)
SetLabelCheckbox& SetLabel(std::string)trailing label. (chainable)
SetCheckedColorCheckbox& SetCheckedColor(const Color&)box color when checked. (chainable)
cpp
auto cb = std::make_shared<Checkbox>();
cb->SetLabel("Remember me")
  .SetOnChanged([](bool on) { /* ... */ });

Comments

Released under the GPL-3.0 License.