forked from Dynamitos/Seele
Compare commits
4
Commits
master
..
e0c396b533
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0c396b533 | ||
|
|
167bbce163 | ||
|
|
1bb36333e6 | ||
|
|
d33533474c |
No files matched your search
@@ -7,7 +7,6 @@ target_sources(Engine
|
|||||||
FlexLayout.cpp
|
FlexLayout.cpp
|
||||||
System.h
|
System.h
|
||||||
System.cpp
|
System.cpp
|
||||||
Widgets.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_sources(Engine
|
target_sources(Engine
|
||||||
@@ -17,7 +16,6 @@ target_sources(Engine
|
|||||||
Element.h
|
Element.h
|
||||||
FlexLayout.h
|
FlexLayout.h
|
||||||
System.h
|
System.h
|
||||||
Widgets.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
add_subdirectory(Style/)
|
add_subdirectory(Style/)
|
||||||
|
|||||||
@@ -1,90 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "UI/Element/Div.h"
|
|
||||||
#include "UI/Element/Text.h"
|
|
||||||
#include "UI/Style/Class.h"
|
|
||||||
|
|
||||||
namespace Seele {
|
|
||||||
namespace UI {
|
|
||||||
// An accordion: a collapsible section with a header that toggles the body.
|
|
||||||
// HTML analog: <details><summary>
|
|
||||||
//
|
|
||||||
// The Accordion is a vertical container with a header (a clickable label)
|
|
||||||
// and a body (arbitrary children). The body's visibility is toggled by the
|
|
||||||
// owning view in response to the header's onClick. The Accordion itself does
|
|
||||||
// not track open/closed state — the view does.
|
|
||||||
//
|
|
||||||
// Usage:
|
|
||||||
// auto* header = new Text<Font_Arial, Text_SM>("Section Title");
|
|
||||||
// auto* body = new Div<FlexCol>(UI::Attributes{});
|
|
||||||
// auto* acc = new Accordion<>(UI::Attributes{}, OElement(header), OElement(body));
|
|
||||||
// // The view owns the "open" state and toggles body's visibility:
|
|
||||||
// // if (clicked) { bodyVisible = !bodyVisible; acc->setBodyVisible(bodyVisible); }
|
|
||||||
template<StyleClass... classes>
|
|
||||||
class Accordion : public Div<classes...> {
|
|
||||||
public:
|
|
||||||
using Div<classes...>::attr;
|
|
||||||
using Div<classes...>::style;
|
|
||||||
using Div<classes...>::markDirty;
|
|
||||||
using Div<classes...>::getTheme;
|
|
||||||
using Div<classes...>::children;
|
|
||||||
|
|
||||||
Accordion(Attributes attr, OElement header, OElement body)
|
|
||||||
: Div<classes...>(std::move(attr), std::initializer_list<OElement>{}) {
|
|
||||||
_header = PElement(header);
|
|
||||||
_body = PElement(body);
|
|
||||||
|
|
||||||
children.add(std::move(header));
|
|
||||||
children.add(std::move(body));
|
|
||||||
if (children.size() >= 2) {
|
|
||||||
children.back()->setParent(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
style.backgroundColor = Vector(0.10f, 0.10f, 0.12f);
|
|
||||||
style.gap = 0;
|
|
||||||
|
|
||||||
if (_header != nullptr) {
|
|
||||||
auto* h = _header.getHandle();
|
|
||||||
if (h != nullptr) {
|
|
||||||
auto& hs = h->getStyle();
|
|
||||||
hs.backgroundColor = Vector(0.14f, 0.14f, 0.16f);
|
|
||||||
hs.paddingLeft = 12;
|
|
||||||
hs.paddingRight = 12;
|
|
||||||
hs.paddingTop = 8;
|
|
||||||
hs.paddingBottom = 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
virtual ~Accordion() override {}
|
|
||||||
|
|
||||||
void setBodyVisible(bool visible) {
|
|
||||||
if (_body != nullptr) {
|
|
||||||
auto* b = _body.getHandle();
|
|
||||||
if (b != nullptr) {
|
|
||||||
b->getStyle().display = visible ? Display::Flex : Display::Hidden;
|
|
||||||
b->markDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bool isBodyVisible() const {
|
|
||||||
if (_body == nullptr) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
auto* b = _body.getHandle();
|
|
||||||
return b != nullptr && b->getStyle().display == Display::Flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
PElement getHeader() const { return _header; }
|
|
||||||
PElement getBody() const { return _body; }
|
|
||||||
|
|
||||||
void applyStyle(Style parentStyle, const Theme& theme) override {
|
|
||||||
Div<classes...>::applyStyle(parentStyle, theme);
|
|
||||||
style.backgroundColor = Vector(0.10f, 0.10f, 0.12f);
|
|
||||||
style.gap = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
PElement _header;
|
|
||||||
PElement _body;
|
|
||||||
};
|
|
||||||
} // namespace UI
|
|
||||||
} // namespace Seele
|
|
||||||
@@ -4,17 +4,6 @@ target_sources(Engine
|
|||||||
Text.h
|
Text.h
|
||||||
Button.h
|
Button.h
|
||||||
Panel.h
|
Panel.h
|
||||||
Checkbox.h
|
|
||||||
ToggleSwitch.h
|
|
||||||
Radio.h
|
|
||||||
SelectBox.h
|
|
||||||
InputField.h
|
|
||||||
Slider.h
|
|
||||||
Progressbar.h
|
|
||||||
TabBar.h
|
|
||||||
Tooltip.h
|
|
||||||
Accordion.h
|
|
||||||
HR.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_sources(Engine
|
target_sources(Engine
|
||||||
@@ -24,15 +13,4 @@ target_sources(Engine
|
|||||||
Text.h
|
Text.h
|
||||||
Button.h
|
Button.h
|
||||||
Panel.h
|
Panel.h
|
||||||
Checkbox.h
|
|
||||||
ToggleSwitch.h
|
|
||||||
Radio.h
|
|
||||||
SelectBox.h
|
|
||||||
InputField.h
|
|
||||||
Slider.h
|
|
||||||
Progressbar.h
|
|
||||||
TabBar.h
|
|
||||||
Tooltip.h
|
|
||||||
Accordion.h
|
|
||||||
HR.h
|
|
||||||
)
|
)
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "UI/Element/Div.h"
|
|
||||||
#include "UI/Style/Class.h"
|
|
||||||
|
|
||||||
namespace Seele {
|
|
||||||
namespace UI {
|
|
||||||
// A checkbox: a square indicator + optional label.
|
|
||||||
// HTML analog: <input type="checkbox">
|
|
||||||
//
|
|
||||||
// Usage:
|
|
||||||
// auto* cb = new Checkbox<>();
|
|
||||||
// // per-frame: cb->setChecked(viewState.flag)
|
|
||||||
//
|
|
||||||
// Pure display widget. The view drives checked state via setChecked().
|
|
||||||
// The checkbox does NOT handle its own onClick — the view wires the
|
|
||||||
// toggle logic via attr.onClick on the owning container.
|
|
||||||
template<StyleClass... classes>
|
|
||||||
class Checkbox : public Div<classes...> {
|
|
||||||
public:
|
|
||||||
using Div<classes...>::attr;
|
|
||||||
using Div<classes...>::style;
|
|
||||||
using Div<classes...>::markDirty;
|
|
||||||
using Div<classes...>::getTheme;
|
|
||||||
using Div<classes...>::children;
|
|
||||||
|
|
||||||
Checkbox(Attributes attr = Attributes{}, std::initializer_list<OElement> children = {})
|
|
||||||
: Div<classes...>(std::move(attr), children) {
|
|
||||||
style.height = 20;
|
|
||||||
style.width = 20;
|
|
||||||
}
|
|
||||||
virtual ~Checkbox() override {}
|
|
||||||
|
|
||||||
void setChecked(bool checked) {
|
|
||||||
_checked = checked;
|
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
bool isChecked() const { return _checked; }
|
|
||||||
|
|
||||||
void setHovered(bool hovered) override { _hovered = hovered; }
|
|
||||||
void setFocused(bool focused) override { _focused = focused; }
|
|
||||||
bool isFocusable() const override { return attr.focusable; }
|
|
||||||
|
|
||||||
void applyStyle(Style parentStyle, const Theme& theme) override {
|
|
||||||
Div<classes...>::applyStyle(parentStyle, theme);
|
|
||||||
}
|
|
||||||
|
|
||||||
// The System calls applyOverrides() during style() after applyStyle.
|
|
||||||
// We use it to reflect checked/hover/focus in the background color.
|
|
||||||
void applyOverrides() override {
|
|
||||||
const Theme& th = getTheme();
|
|
||||||
if (_checked) {
|
|
||||||
style.backgroundColor = th.color(ColorToken::Green);
|
|
||||||
} else if (_hovered) {
|
|
||||||
style.backgroundColor = Vector(0.22f, 0.24f, 0.28f);
|
|
||||||
} else if (_focused) {
|
|
||||||
style.backgroundColor = Vector(0.20f, 0.22f, 0.26f);
|
|
||||||
} else {
|
|
||||||
style.backgroundColor = Vector(0.14f, 0.14f, 0.16f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool _checked = false;
|
|
||||||
bool _hovered = false;
|
|
||||||
bool _focused = false;
|
|
||||||
};
|
|
||||||
} // namespace UI
|
|
||||||
} // namespace Seele
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "UI/Element/Div.h"
|
|
||||||
#include "UI/Style/Class.h"
|
|
||||||
|
|
||||||
namespace Seele {
|
|
||||||
namespace UI {
|
|
||||||
// A horizontal rule: a thin decorative divider line.
|
|
||||||
// HTML analog: <hr>
|
|
||||||
//
|
|
||||||
// A simple 1px tall element with a subtle background color. No interactivity.
|
|
||||||
template<StyleClass... classes>
|
|
||||||
class HR : public Div<classes...> {
|
|
||||||
public:
|
|
||||||
using Div<classes...>::attr;
|
|
||||||
using Div<classes...>::style;
|
|
||||||
|
|
||||||
HR(Attributes attr = Attributes{}, std::initializer_list<OElement> children = {})
|
|
||||||
: Div<classes...>(std::move(attr), children) {
|
|
||||||
style.height = 1;
|
|
||||||
style.backgroundColor = Vector(0.25f, 0.25f, 0.28f);
|
|
||||||
style.marginTop = 8;
|
|
||||||
style.marginBottom = 8;
|
|
||||||
}
|
|
||||||
virtual ~HR() override {}
|
|
||||||
|
|
||||||
void applyStyle(Style parentStyle, const Theme& theme) override {
|
|
||||||
Div<classes...>::applyStyle(parentStyle, theme);
|
|
||||||
style.height = 1;
|
|
||||||
style.backgroundColor = Vector(0.25f, 0.25f, 0.28f);
|
|
||||||
style.marginTop = 8;
|
|
||||||
style.marginBottom = 8;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace UI
|
|
||||||
} // namespace Seele
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "UI/Element/Div.h"
|
|
||||||
#include "UI/Element/Text.h"
|
|
||||||
#include "UI/Style/Class.h"
|
|
||||||
|
|
||||||
namespace Seele {
|
|
||||||
namespace UI {
|
|
||||||
// A text input field: a box that displays a placeholder (when empty) or a
|
|
||||||
// text value (when non-empty). The actual text editing (key handling, cursor,
|
|
||||||
// IME) is the owning view's responsibility — the view intercepts key events
|
|
||||||
// and calls setValue() with the updated text.
|
|
||||||
//
|
|
||||||
// HTML analog: <input type="text">
|
|
||||||
//
|
|
||||||
// Usage:
|
|
||||||
// auto* field = new InputField<Font_Arial, Text_SM>(UI::Attributes{}, "Enter name...");
|
|
||||||
// // per-frame: field->setValue(viewState.inputText);
|
|
||||||
template<StyleClass... classes>
|
|
||||||
class InputField : public Div<classes...> {
|
|
||||||
public:
|
|
||||||
using Div<classes...>::attr;
|
|
||||||
using Div<classes...>::style;
|
|
||||||
using Div<classes...>::markDirty;
|
|
||||||
using Div<classes...>::getTheme;
|
|
||||||
using Div<classes...>::children;
|
|
||||||
|
|
||||||
InputField(Attributes attr, std::string placeholder = "")
|
|
||||||
: Div<classes...>(std::move(attr), std::initializer_list<OElement>{}) {
|
|
||||||
attr.focusable = true;
|
|
||||||
_placeholder = std::move(placeholder);
|
|
||||||
|
|
||||||
auto* t = new Text<classes...>(_placeholder);
|
|
||||||
children.add(OElement(t));
|
|
||||||
children.back()->setParent(this);
|
|
||||||
_text = PElement(t);
|
|
||||||
|
|
||||||
style.paddingLeft = 12;
|
|
||||||
style.paddingRight = 12;
|
|
||||||
style.paddingTop = 8;
|
|
||||||
style.paddingBottom = 8;
|
|
||||||
style.backgroundColor = Vector(0.10f, 0.10f, 0.12f);
|
|
||||||
}
|
|
||||||
virtual ~InputField() override {}
|
|
||||||
|
|
||||||
void setValue(std::string value) {
|
|
||||||
_value = std::move(value);
|
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
std::string getValue() const { return _value; }
|
|
||||||
std::string getPlaceholder() const { return _placeholder; }
|
|
||||||
|
|
||||||
void setFocused(bool focused) override {
|
|
||||||
_focused = focused;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setHovered(bool hovered) override { _hovered = hovered; }
|
|
||||||
bool isFocusable() const override { return attr.focusable; }
|
|
||||||
|
|
||||||
void applyStyle(Style parentStyle, const Theme& theme) override {
|
|
||||||
Div<classes...>::applyStyle(parentStyle, theme);
|
|
||||||
}
|
|
||||||
|
|
||||||
void applyOverrides() override {
|
|
||||||
const Theme& th = getTheme();
|
|
||||||
if (_focused) {
|
|
||||||
style.backgroundColor = Vector(0.14f, 0.15f, 0.18f);
|
|
||||||
} else if (_hovered) {
|
|
||||||
style.backgroundColor = Vector(0.12f, 0.12f, 0.14f);
|
|
||||||
} else {
|
|
||||||
style.backgroundColor = Vector(0.10f, 0.10f, 0.12f);
|
|
||||||
}
|
|
||||||
// Switch between placeholder (dimmed) and value (full color) display.
|
|
||||||
if (_text == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto* t = dynamic_cast<Text<classes...>*>(_text.getHandle());
|
|
||||||
if (t == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_value.empty()) {
|
|
||||||
t->setText(_placeholder);
|
|
||||||
style.textColor = th.color(ColorToken::Gray600);
|
|
||||||
} else {
|
|
||||||
t->setText(_value);
|
|
||||||
style.textColor = th.color(ColorToken::White);
|
|
||||||
}
|
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string _placeholder;
|
|
||||||
std::string _value;
|
|
||||||
bool _focused = false;
|
|
||||||
bool _hovered = false;
|
|
||||||
PElement _text;
|
|
||||||
};
|
|
||||||
} // namespace UI
|
|
||||||
} // namespace Seele
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "UI/Element/Div.h"
|
|
||||||
#include "UI/Style/Class.h"
|
|
||||||
|
|
||||||
namespace Seele {
|
|
||||||
namespace UI {
|
|
||||||
// A progress bar: a horizontal bar that fills proportionally to a 0.0-1.0 value.
|
|
||||||
// HTML analog: <progress>
|
|
||||||
//
|
|
||||||
// Usage:
|
|
||||||
// auto* bar = new Progressbar<>();
|
|
||||||
// // per-frame: bar->setValue(fraction) // 0.0 - 1.0
|
|
||||||
//
|
|
||||||
// Pure display widget. The bar's background is a lerp between a dimmed
|
|
||||||
// "empty" color and an accent "full" color, giving a visual fill effect.
|
|
||||||
template<StyleClass... classes>
|
|
||||||
class Progressbar : public Div<classes...> {
|
|
||||||
public:
|
|
||||||
using Div<classes...>::attr;
|
|
||||||
using Div<classes...>::style;
|
|
||||||
using Div<classes...>::markDirty;
|
|
||||||
using Div<classes...>::getTheme;
|
|
||||||
|
|
||||||
Progressbar(Attributes attr = Attributes{}, std::initializer_list<OElement> children = {})
|
|
||||||
: Div<classes...>(std::move(attr), children) {
|
|
||||||
style.height = 8;
|
|
||||||
}
|
|
||||||
virtual ~Progressbar() override {}
|
|
||||||
|
|
||||||
void setValue(float value) {
|
|
||||||
_value = value < 0.0f ? 0.0f : (value > 1.0f ? 1.0f : value);
|
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
float getValue() const { return _value; }
|
|
||||||
|
|
||||||
void applyStyle(Style parentStyle, const Theme& theme) override {
|
|
||||||
Div<classes...>::applyStyle(parentStyle, theme);
|
|
||||||
}
|
|
||||||
|
|
||||||
void applyOverrides() override {
|
|
||||||
const Theme& th = getTheme();
|
|
||||||
// Lerp between empty (dimmed) and full (green) based on value.
|
|
||||||
Vector empty(0.14f, 0.14f, 0.16f);
|
|
||||||
Vector full = th.color(ColorToken::Green);
|
|
||||||
float v = _value;
|
|
||||||
style.backgroundColor = Vector(
|
|
||||||
empty.x + (full.x - empty.x) * v,
|
|
||||||
empty.y + (full.y - empty.y) * v,
|
|
||||||
empty.z + (full.z - empty.z) * v);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
float _value = 0.0f;
|
|
||||||
};
|
|
||||||
} // namespace UI
|
|
||||||
} // namespace Seele
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "UI/Element/Div.h"
|
|
||||||
#include "UI/Style/Class.h"
|
|
||||||
|
|
||||||
namespace Seele {
|
|
||||||
namespace UI {
|
|
||||||
// A radio button: a circular indicator + optional label.
|
|
||||||
// HTML analog: <input type="radio">
|
|
||||||
//
|
|
||||||
// Usage:
|
|
||||||
// auto* r1 = new Radio<>();
|
|
||||||
// auto* r2 = new Radio<>();
|
|
||||||
// // per-frame: r1->setSelected(viewState.choice == 0)
|
|
||||||
// // r2->setSelected(viewState.choice == 1)
|
|
||||||
//
|
|
||||||
// Pure display widget. The view owns the selection state and drives
|
|
||||||
// setSelected() on each radio in the group.
|
|
||||||
template<StyleClass... classes>
|
|
||||||
class Radio : public Div<classes...> {
|
|
||||||
public:
|
|
||||||
using Div<classes...>::attr;
|
|
||||||
using Div<classes...>::style;
|
|
||||||
using Div<classes...>::markDirty;
|
|
||||||
using Div<classes...>::getTheme;
|
|
||||||
|
|
||||||
Radio(Attributes attr = Attributes{}, std::initializer_list<OElement> children = {})
|
|
||||||
: Div<classes...>(std::move(attr), children) {
|
|
||||||
style.height = 20;
|
|
||||||
style.width = 20;
|
|
||||||
}
|
|
||||||
virtual ~Radio() override {}
|
|
||||||
|
|
||||||
void setSelected(bool selected) {
|
|
||||||
_selected = selected;
|
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
bool isSelected() const { return _selected; }
|
|
||||||
|
|
||||||
void setHovered(bool hovered) override { _hovered = hovered; }
|
|
||||||
void setFocused(bool focused) override { _focused = focused; }
|
|
||||||
bool isFocusable() const override { return attr.focusable; }
|
|
||||||
|
|
||||||
void applyStyle(Style parentStyle, const Theme& theme) override {
|
|
||||||
Div<classes...>::applyStyle(parentStyle, theme);
|
|
||||||
}
|
|
||||||
|
|
||||||
void applyOverrides() override {
|
|
||||||
const Theme& th = getTheme();
|
|
||||||
if (_selected) {
|
|
||||||
style.backgroundColor = th.color(ColorToken::Blue);
|
|
||||||
} else if (_hovered) {
|
|
||||||
style.backgroundColor = Vector(0.22f, 0.24f, 0.28f);
|
|
||||||
} else if (_focused) {
|
|
||||||
style.backgroundColor = Vector(0.20f, 0.22f, 0.26f);
|
|
||||||
} else {
|
|
||||||
style.backgroundColor = Vector(0.14f, 0.14f, 0.16f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool _selected = false;
|
|
||||||
bool _hovered = false;
|
|
||||||
bool _focused = false;
|
|
||||||
};
|
|
||||||
} // namespace UI
|
|
||||||
} // namespace Seele
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "UI/Element/Div.h"
|
|
||||||
#include "UI/Element/Text.h"
|
|
||||||
#include "UI/Style/Class.h"
|
|
||||||
|
|
||||||
namespace Seele {
|
|
||||||
namespace UI {
|
|
||||||
// A select box (dropdown): a clickable box that displays the current selection.
|
|
||||||
// HTML analog: <select>
|
|
||||||
//
|
|
||||||
// The dropdown list is a SEPARATE element tree managed by the owning view.
|
|
||||||
// The SelectBox is the trigger: it displays the current selection and an
|
|
||||||
// arrow indicator. The view toggles the dropdown list's visibility in
|
|
||||||
// response to onClick and updates the selection when the user picks an item.
|
|
||||||
//
|
|
||||||
// Usage (pass the font/size classes via the template pack):
|
|
||||||
// auto* sel = new SelectBox<Font_Arial, Text_SM>(UI::Attributes{}, "Option A");
|
|
||||||
// // per-frame: sel->setSelection("Option B"); sel->setOpen(true/false)
|
|
||||||
template<StyleClass... classes>
|
|
||||||
class SelectBox : public Div<classes...> {
|
|
||||||
public:
|
|
||||||
using Div<classes...>::attr;
|
|
||||||
using Div<classes...>::style;
|
|
||||||
using Div<classes...>::markDirty;
|
|
||||||
using Div<classes...>::getTheme;
|
|
||||||
using Div<classes...>::children;
|
|
||||||
|
|
||||||
SelectBox(Attributes attr, std::string selection = "")
|
|
||||||
: Div<classes...>(std::move(attr), std::initializer_list<OElement>{}) {
|
|
||||||
attr.focusable = true;
|
|
||||||
_selection = std::move(selection);
|
|
||||||
|
|
||||||
// Display text: the current selection + a down-arrow indicator.
|
|
||||||
auto* t = new Text<classes...>(_selection + " ▾");
|
|
||||||
children.add(OElement(t));
|
|
||||||
children.back()->setParent(this);
|
|
||||||
_text = PElement(t);
|
|
||||||
|
|
||||||
style.paddingLeft = 12;
|
|
||||||
style.paddingRight = 12;
|
|
||||||
style.paddingTop = 8;
|
|
||||||
style.paddingBottom = 8;
|
|
||||||
style.backgroundColor = Vector(0.14f, 0.14f, 0.16f);
|
|
||||||
}
|
|
||||||
virtual ~SelectBox() override {}
|
|
||||||
|
|
||||||
void setSelection(std::string selection) {
|
|
||||||
_selection = std::move(selection);
|
|
||||||
if (_text != nullptr) {
|
|
||||||
if (auto* t = dynamic_cast<Text<classes...>*>(_text.getHandle())) {
|
|
||||||
t->setText(_selection + " ▾");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
std::string getSelection() const { return _selection; }
|
|
||||||
|
|
||||||
void setOpen(bool open) {
|
|
||||||
_open = open;
|
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
bool isOpen() const { return _open; }
|
|
||||||
|
|
||||||
void setHovered(bool hovered) override { _hovered = hovered; }
|
|
||||||
void setFocused(bool focused) override { _focused = focused; }
|
|
||||||
bool isFocusable() const override { return attr.focusable; }
|
|
||||||
|
|
||||||
void applyStyle(Style parentStyle, const Theme& theme) override {
|
|
||||||
Div<classes...>::applyStyle(parentStyle, theme);
|
|
||||||
}
|
|
||||||
|
|
||||||
void applyOverrides() override {
|
|
||||||
const Theme& th = getTheme();
|
|
||||||
if (_open) {
|
|
||||||
style.backgroundColor = Vector(0.18f, 0.19f, 0.22f);
|
|
||||||
style.textColor = th.color(ColorToken::White);
|
|
||||||
} else if (_hovered) {
|
|
||||||
style.backgroundColor = Vector(0.18f, 0.19f, 0.22f);
|
|
||||||
style.textColor = th.color(ColorToken::Gray400);
|
|
||||||
} else if (_focused) {
|
|
||||||
style.backgroundColor = Vector(0.16f, 0.17f, 0.20f);
|
|
||||||
style.textColor = th.color(ColorToken::Gray500);
|
|
||||||
} else {
|
|
||||||
style.backgroundColor = Vector(0.14f, 0.14f, 0.16f);
|
|
||||||
style.textColor = th.color(ColorToken::Gray400);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string _selection;
|
|
||||||
bool _open = false;
|
|
||||||
bool _hovered = false;
|
|
||||||
bool _focused = false;
|
|
||||||
PElement _text;
|
|
||||||
};
|
|
||||||
} // namespace UI
|
|
||||||
} // namespace Seele
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "UI/Element/Div.h"
|
|
||||||
#include "UI/Style/Class.h"
|
|
||||||
|
|
||||||
namespace Seele {
|
|
||||||
namespace UI {
|
|
||||||
// A slider: a horizontal track with a fill bar that reflects a 0.0-1.0 value.
|
|
||||||
// HTML analog: <input type="range">
|
|
||||||
//
|
|
||||||
// Usage:
|
|
||||||
// auto* slider = new Slider<>();
|
|
||||||
// // per-frame: slider->setValue(viewState.volume) // 0.0 - 1.0
|
|
||||||
//
|
|
||||||
// Pure display widget. The slider's background is a lerp between a dimmed
|
|
||||||
// "track" color and an accent "fill" color based on the value, giving a
|
|
||||||
// visual fill effect. Mouse drag handling is the owning view's job.
|
|
||||||
template<StyleClass... classes>
|
|
||||||
class Slider : public Div<classes...> {
|
|
||||||
public:
|
|
||||||
using Div<classes...>::attr;
|
|
||||||
using Div<classes...>::style;
|
|
||||||
using Div<classes...>::markDirty;
|
|
||||||
using Div<classes...>::getTheme;
|
|
||||||
|
|
||||||
Slider(Attributes attr = Attributes{}, std::initializer_list<OElement> children = {})
|
|
||||||
: Div<classes...>(std::move(attr), children) {
|
|
||||||
attr.focusable = true;
|
|
||||||
style.height = 8;
|
|
||||||
}
|
|
||||||
virtual ~Slider() override {}
|
|
||||||
|
|
||||||
void setValue(float value) {
|
|
||||||
_value = value < 0.0f ? 0.0f : (value > 1.0f ? 1.0f : value);
|
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
float getValue() const { return _value; }
|
|
||||||
|
|
||||||
void setHovered(bool hovered) override { _hovered = hovered; }
|
|
||||||
void setFocused(bool focused) override { _focused = focused; }
|
|
||||||
bool isFocusable() const override { return attr.focusable; }
|
|
||||||
|
|
||||||
void applyStyle(Style parentStyle, const Theme& theme) override {
|
|
||||||
Div<classes...>::applyStyle(parentStyle, theme);
|
|
||||||
}
|
|
||||||
|
|
||||||
void applyOverrides() override {
|
|
||||||
const Theme& th = getTheme();
|
|
||||||
if (_focused || _hovered) {
|
|
||||||
style.backgroundColor = th.color(ColorToken::Blue);
|
|
||||||
} else {
|
|
||||||
// Lerp between track (dimmed) and accent (blue) for fill effect.
|
|
||||||
Vector track(0.18f, 0.18f, 0.20f);
|
|
||||||
Vector accent = th.color(ColorToken::Blue);
|
|
||||||
float v = _value;
|
|
||||||
style.backgroundColor = Vector(
|
|
||||||
track.x + (accent.x - track.x) * v,
|
|
||||||
track.y + (accent.y - track.y) * v,
|
|
||||||
track.z + (accent.z - track.z) * v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
float _value = 0.0f;
|
|
||||||
bool _hovered = false;
|
|
||||||
bool _focused = false;
|
|
||||||
};
|
|
||||||
} // namespace UI
|
|
||||||
} // namespace Seele
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "UI/Element/Div.h"
|
|
||||||
#include "UI/Element/Button.h"
|
|
||||||
#include "UI/Style/Class.h"
|
|
||||||
|
|
||||||
namespace Seele {
|
|
||||||
namespace UI {
|
|
||||||
// A tab bar: a horizontal row of tab buttons. One tab is highlighted as active.
|
|
||||||
// HTML analog: <ul role="tablist">
|
|
||||||
//
|
|
||||||
// Usage:
|
|
||||||
// auto* tab1 = new Button<>(UI::Attributes{});
|
|
||||||
// auto* tab2 = new Button<>(UI::Attributes{});
|
|
||||||
// auto* tabs = new TabBar<>(UI::Attributes{}, {OElement(tab1), OElement(tab2)});
|
|
||||||
// // per-frame: tabs->setActiveTab(0)
|
|
||||||
//
|
|
||||||
// The tab bar takes a fixed set of Button children at construction (the
|
|
||||||
// fixed-children constraint). The active tab gets an accent color; the
|
|
||||||
// others get a dimmed color. The view handles onClick on each button to
|
|
||||||
// change the active tab.
|
|
||||||
template<StyleClass... classes>
|
|
||||||
class TabBar : public Div<classes...> {
|
|
||||||
public:
|
|
||||||
using Div<classes...>::attr;
|
|
||||||
using Div<classes...>::style;
|
|
||||||
using Div<classes...>::markDirty;
|
|
||||||
using Div<classes...>::getTheme;
|
|
||||||
using Div<classes...>::children;
|
|
||||||
|
|
||||||
TabBar(Attributes attr, std::initializer_list<OElement> tabs)
|
|
||||||
: Div<classes...>(std::move(attr), tabs) {
|
|
||||||
style.direction = FlexDirection::Row;
|
|
||||||
style.gap = 4;
|
|
||||||
}
|
|
||||||
virtual ~TabBar() override {}
|
|
||||||
|
|
||||||
void setActiveTab(int index) {
|
|
||||||
_activeTab = index;
|
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
int getActiveTab() const { return _activeTab; }
|
|
||||||
|
|
||||||
void applyStyle(Style parentStyle, const Theme& theme) override {
|
|
||||||
Div<classes...>::applyStyle(parentStyle, theme);
|
|
||||||
style.direction = FlexDirection::Row;
|
|
||||||
style.gap = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
void applyOverrides() override {
|
|
||||||
const Theme& th = getTheme();
|
|
||||||
int i = 0;
|
|
||||||
for (auto& child : children) {
|
|
||||||
if (child == nullptr) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
auto& cs = child->getStyle();
|
|
||||||
if (i == _activeTab) {
|
|
||||||
cs.backgroundColor = th.color(ColorToken::Blue);
|
|
||||||
cs.textColor = th.color(ColorToken::White);
|
|
||||||
} else {
|
|
||||||
cs.backgroundColor = Vector(0.14f, 0.14f, 0.16f);
|
|
||||||
cs.textColor = th.color(ColorToken::Gray500);
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
int _activeTab = 0;
|
|
||||||
};
|
|
||||||
} // namespace UI
|
|
||||||
} // namespace Seele
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "UI/Element/Div.h"
|
|
||||||
#include "UI/Element/Text.h"
|
|
||||||
#include "UI/Style/Class.h"
|
|
||||||
|
|
||||||
namespace Seele {
|
|
||||||
namespace UI {
|
|
||||||
// A toggle switch: a pill-shaped on/off switch with an optional label.
|
|
||||||
// HTML analog: <input type="checkbox"> styled as a switch (iOS-style)
|
|
||||||
//
|
|
||||||
// Usage:
|
|
||||||
// auto* toggle = new ToggleSwitch<Font_Arial, Text_SM>(UI::Attributes{}, "Wi-Fi");
|
|
||||||
// // per-frame: toggle->setOn(viewState.wifi)
|
|
||||||
//
|
|
||||||
// The toggle is a Div containing a label Text and an indicator pill.
|
|
||||||
// The pill's background shifts between off (dimmed) and on (green) based
|
|
||||||
// on the `on` state. The knob is a child div positioned to the left (off)
|
|
||||||
// or right (on).
|
|
||||||
template<StyleClass... classes>
|
|
||||||
class ToggleSwitch : public Div<classes...> {
|
|
||||||
public:
|
|
||||||
using Div<classes...>::attr;
|
|
||||||
using Div<classes...>::style;
|
|
||||||
using Div<classes...>::markDirty;
|
|
||||||
using Div<classes...>::getTheme;
|
|
||||||
using Div<classes...>::children;
|
|
||||||
|
|
||||||
ToggleSwitch(Attributes attr = Attributes{}, std::string label = "")
|
|
||||||
: Div<classes...>(std::move(attr), std::initializer_list<OElement>{}) {
|
|
||||||
// Build the label (if any)
|
|
||||||
if (!label.empty()) {
|
|
||||||
auto* lbl = new Text<classes...>(label);
|
|
||||||
children.add(OElement(lbl));
|
|
||||||
children.back()->setParent(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build the toggle pill: a rounded indicator (60x28)
|
|
||||||
auto* pill = new Div<>(UI::Attributes{});
|
|
||||||
{
|
|
||||||
auto& ps = pill->getStyle();
|
|
||||||
ps.width = 60;
|
|
||||||
ps.height = 28;
|
|
||||||
ps.backgroundColor = Vector(0.20f, 0.20f, 0.22f);
|
|
||||||
}
|
|
||||||
_pill = PElement(pill);
|
|
||||||
children.add(OElement(pill));
|
|
||||||
children.back()->setParent(this);
|
|
||||||
|
|
||||||
// Build the knob: a circle inside the pill (20x20)
|
|
||||||
auto* knob = new Div<>(UI::Attributes{});
|
|
||||||
{
|
|
||||||
auto& ks = knob->getStyle();
|
|
||||||
ks.width = 20;
|
|
||||||
ks.height = 20;
|
|
||||||
ks.backgroundColor = Vector(0.70f, 0.70f, 0.72f);
|
|
||||||
ks.left = 4;
|
|
||||||
ks.position = Position::Absolute;
|
|
||||||
}
|
|
||||||
_knob = PElement(knob);
|
|
||||||
children.add(OElement(knob));
|
|
||||||
children.back()->setParent(this);
|
|
||||||
|
|
||||||
style.height = 28;
|
|
||||||
}
|
|
||||||
virtual ~ToggleSwitch() override {}
|
|
||||||
|
|
||||||
void setOn(bool on) {
|
|
||||||
_on = on;
|
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
bool isOn() const { return _on; }
|
|
||||||
|
|
||||||
void setHovered(bool hovered) override { _hovered = hovered; }
|
|
||||||
|
|
||||||
void applyStyle(Style parentStyle, const Theme& theme) override {
|
|
||||||
Div<classes...>::applyStyle(parentStyle, theme);
|
|
||||||
}
|
|
||||||
|
|
||||||
void applyOverrides() override {
|
|
||||||
const Theme& th = getTheme();
|
|
||||||
if (_pill != nullptr) {
|
|
||||||
auto* p = _pill.getHandle();
|
|
||||||
if (p != nullptr) {
|
|
||||||
if (_on) {
|
|
||||||
p->getStyle().backgroundColor = th.color(ColorToken::Green);
|
|
||||||
} else {
|
|
||||||
p->getStyle().backgroundColor = Vector(0.20f, 0.20f, 0.22f);
|
|
||||||
}
|
|
||||||
p->markDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (_knob != nullptr) {
|
|
||||||
auto* k = _knob.getHandle();
|
|
||||||
if (k != nullptr) {
|
|
||||||
k->getStyle().left = _on ? 36 : 4;
|
|
||||||
k->markDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool _on = false;
|
|
||||||
bool _hovered = false;
|
|
||||||
PElement _pill;
|
|
||||||
PElement _knob;
|
|
||||||
};
|
|
||||||
} // namespace UI
|
|
||||||
} // namespace Seele
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "UI/Element/Div.h"
|
|
||||||
#include "UI/Element/Text.h"
|
|
||||||
#include "UI/Style/Class.h"
|
|
||||||
|
|
||||||
namespace Seele {
|
|
||||||
namespace UI {
|
|
||||||
// A tooltip: an element that shows a tooltip bubble when hovered.
|
|
||||||
// HTML analog: title="..." attribute / CSS :hover tooltip
|
|
||||||
//
|
|
||||||
// The Tooltip wraps a child element and, when the child is hovered, shows
|
|
||||||
// a floating label with the tooltip text. The tooltip is rendered as a
|
|
||||||
// child element (a Text with a dark background) that is hidden until hover.
|
|
||||||
//
|
|
||||||
// Usage:
|
|
||||||
// auto* target = new Button<>(UI::Attributes{});
|
|
||||||
// auto* tip = new Tooltip<>(UI::Attributes{}, OElement(target), "Helpful info");
|
|
||||||
//
|
|
||||||
// NOTE: the tooltip child is added to the tree at construction. Its position
|
|
||||||
// is set by the view (absolute positioning) — the Tooltip itself does not
|
|
||||||
// compute the tooltip's position.
|
|
||||||
template<StyleClass... classes>
|
|
||||||
class Tooltip : public Div<classes...> {
|
|
||||||
public:
|
|
||||||
using Div<classes...>::attr;
|
|
||||||
using Div<classes...>::style;
|
|
||||||
using Div<classes...>::markDirty;
|
|
||||||
using Div<classes...>::getTheme;
|
|
||||||
using Div<classes...>::children;
|
|
||||||
|
|
||||||
Tooltip(Attributes attr, OElement target, std::string text)
|
|
||||||
: Div<classes...>(std::move(attr), std::initializer_list<OElement>{}) {
|
|
||||||
// Wrap the target
|
|
||||||
children.add(std::move(target));
|
|
||||||
if (children.size() > 0) {
|
|
||||||
children.back()->setParent(this);
|
|
||||||
}
|
|
||||||
_tipText = std::move(text);
|
|
||||||
|
|
||||||
// Build the tooltip bubble: a dark panel with the text
|
|
||||||
auto* bubble = new Text<classes...>(_tipText);
|
|
||||||
{
|
|
||||||
auto& bs = bubble->getStyle();
|
|
||||||
bs.backgroundColor = Vector(0.05f, 0.05f, 0.06f);
|
|
||||||
bs.paddingLeft = 8;
|
|
||||||
bs.paddingRight = 8;
|
|
||||||
bs.paddingTop = 4;
|
|
||||||
bs.paddingBottom = 4;
|
|
||||||
bs.display = Display::Hidden;
|
|
||||||
}
|
|
||||||
_bubble = PElement(bubble);
|
|
||||||
children.add(OElement(bubble));
|
|
||||||
children.back()->setParent(this);
|
|
||||||
}
|
|
||||||
virtual ~Tooltip() override {}
|
|
||||||
|
|
||||||
void setText(std::string text) {
|
|
||||||
_tipText = std::move(text);
|
|
||||||
if (_bubble != nullptr) {
|
|
||||||
if (auto* t = dynamic_cast<Text<classes...>*>(_bubble.getHandle())) {
|
|
||||||
t->setText(_tipText);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setHovered(bool hovered) override {
|
|
||||||
_hovered = hovered;
|
|
||||||
if (_bubble != nullptr) {
|
|
||||||
if (auto* b = dynamic_cast<Element*>(_bubble.getHandle())) {
|
|
||||||
if (b != nullptr) {
|
|
||||||
b->getStyle().display = hovered ? Display::Flex : Display::Hidden;
|
|
||||||
b->markDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void applyStyle(Style parentStyle, const Theme& theme) override {
|
|
||||||
Div<classes...>::applyStyle(parentStyle, theme);
|
|
||||||
}
|
|
||||||
|
|
||||||
void applyOverrides() override {
|
|
||||||
const Theme& th = getTheme();
|
|
||||||
if (_bubble != nullptr) {
|
|
||||||
if (auto* b = dynamic_cast<Text<classes...>*>(_bubble.getHandle())) {
|
|
||||||
if (b != nullptr) {
|
|
||||||
b->getStyle().textColor = th.color(ColorToken::White);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string _tipText;
|
|
||||||
PElement _bubble;
|
|
||||||
bool _hovered = false;
|
|
||||||
};
|
|
||||||
} // namespace UI
|
|
||||||
} // namespace Seele
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
// Seele UI: reusable component library.
|
|
||||||
//
|
|
||||||
// HTML-analog widgets built on the existing Element/Div/Text/Button base.
|
|
||||||
// All components are header-only template classes (matching the existing
|
|
||||||
// Button/Text/Div/Panel pattern). No .cpp files are needed.
|
|
||||||
//
|
|
||||||
// Design constraint: "children fixed at construction" — the UI tree's
|
|
||||||
// structure is immutable at runtime. Dynamic content (dropdown options,
|
|
||||||
// tab pages, scrollable items) is pre-allocated as a fixed pool at
|
|
||||||
// construction and driven per-frame by the owning view via setter methods
|
|
||||||
// (setText, setValue, setChecked, setVisible, etc.).
|
|
||||||
//
|
|
||||||
// Interaction model: the only sanctioned input path is Element::attr.onClick
|
|
||||||
// (delivered by System::processInput on click-release). Components that
|
|
||||||
// need to react to clicks expose the Button/Div onClick handler; the owning
|
|
||||||
// view reads state in its per-frame update() and calls the component's
|
|
||||||
// setters to reflect the new state.
|
|
||||||
|
|
||||||
// Form controls
|
|
||||||
#include "UI/Element/Checkbox.h"
|
|
||||||
#include "UI/Element/ToggleSwitch.h"
|
|
||||||
#include "UI/Element/Radio.h"
|
|
||||||
#include "UI/Element/SelectBox.h"
|
|
||||||
#include "UI/Element/InputField.h"
|
|
||||||
#include "UI/Element/Slider.h"
|
|
||||||
|
|
||||||
// Display / navigation
|
|
||||||
#include "UI/Element/Progressbar.h"
|
|
||||||
#include "UI/Element/TabBar.h"
|
|
||||||
#include "UI/Element/Tooltip.h"
|
|
||||||
#include "UI/Element/Accordion.h"
|
|
||||||
#include "UI/Element/HR.h"
|
|
||||||
@@ -1,162 +0,0 @@
|
|||||||
// Syntax-check TU for the new UI widget components.
|
|
||||||
// Instantiates each component with template args to force full template
|
|
||||||
// instantiation, then references key members to ensure they exist.
|
|
||||||
#include "UI/Widgets.h"
|
|
||||||
#include "UI/Element/Button.h"
|
|
||||||
#include "UI/Element/Div.h"
|
|
||||||
#include "UI/Element/Text.h"
|
|
||||||
#include "UI/Style/Fonts.h"
|
|
||||||
|
|
||||||
using namespace Seele;
|
|
||||||
using namespace Seele::UI;
|
|
||||||
|
|
||||||
// A translation-unit-level function that exercises every new widget type.
|
|
||||||
// The compiler must fully instantiate each template here.
|
|
||||||
void widget_smoke_test() {
|
|
||||||
// --- Checkbox ---
|
|
||||||
{
|
|
||||||
auto* cb = new Checkbox<Font_Arial, Text_SM>();
|
|
||||||
cb->setChecked(true);
|
|
||||||
(void)cb->isChecked();
|
|
||||||
cb->setHovered(true);
|
|
||||||
cb->setFocused(true);
|
|
||||||
cb->applyOverrides();
|
|
||||||
(void)cb->style;
|
|
||||||
(void)cb->attr;
|
|
||||||
(void)cb->children;
|
|
||||||
cb->markDirty();
|
|
||||||
delete cb;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- ToggleSwitch ---
|
|
||||||
{
|
|
||||||
auto* ts = new ToggleSwitch<Font_Arial, Text_SM>(UI::Attributes{}, "Wi-Fi");
|
|
||||||
ts->setOn(true);
|
|
||||||
(void)ts->isOn();
|
|
||||||
ts->setHovered(true);
|
|
||||||
ts->applyOverrides();
|
|
||||||
(void)ts->style;
|
|
||||||
(void)ts->attr;
|
|
||||||
(void)ts->children;
|
|
||||||
ts->markDirty();
|
|
||||||
delete ts;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Radio ---
|
|
||||||
{
|
|
||||||
auto* r1 = new Radio<Font_Arial, Text_SM>();
|
|
||||||
r1->setSelected(true);
|
|
||||||
(void)r1->isSelected();
|
|
||||||
r1->applyOverrides();
|
|
||||||
(void)r1->style;
|
|
||||||
(void)r1->attr;
|
|
||||||
r1->markDirty();
|
|
||||||
delete r1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- SelectBox ---
|
|
||||||
{
|
|
||||||
auto* sel = new SelectBox<Font_Arial, Text_SM>(UI::Attributes{}, "Option A");
|
|
||||||
sel->setSelection("Option B");
|
|
||||||
(void)sel->getSelection();
|
|
||||||
sel->setOpen(true);
|
|
||||||
(void)sel->isOpen();
|
|
||||||
sel->applyOverrides();
|
|
||||||
(void)sel->style;
|
|
||||||
(void)sel->attr;
|
|
||||||
(void)sel->children;
|
|
||||||
sel->markDirty();
|
|
||||||
delete sel;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- InputField ---
|
|
||||||
{
|
|
||||||
auto* input = new InputField<Font_Arial, Text_SM>(UI::Attributes{}, "Enter name...");
|
|
||||||
input->setValue("hello");
|
|
||||||
(void)input->getValue();
|
|
||||||
(void)input->getPlaceholder();
|
|
||||||
input->setFocused(true);
|
|
||||||
input->applyOverrides();
|
|
||||||
(void)input->style;
|
|
||||||
(void)input->attr;
|
|
||||||
(void)input->children;
|
|
||||||
input->markDirty();
|
|
||||||
delete input;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Slider ---
|
|
||||||
{
|
|
||||||
auto* slider = new Slider<Font_Arial, Text_SM>();
|
|
||||||
slider->setValue(0.75f);
|
|
||||||
(void)slider->getValue();
|
|
||||||
slider->applyOverrides();
|
|
||||||
(void)slider->style;
|
|
||||||
(void)slider->attr;
|
|
||||||
slider->markDirty();
|
|
||||||
delete slider;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Progressbar ---
|
|
||||||
{
|
|
||||||
auto* bar = new Progressbar<Font_Arial, Text_SM>();
|
|
||||||
bar->setValue(0.5f);
|
|
||||||
(void)bar->getValue();
|
|
||||||
bar->applyOverrides();
|
|
||||||
(void)bar->style;
|
|
||||||
(void)bar->attr;
|
|
||||||
bar->markDirty();
|
|
||||||
delete bar;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- TabBar ---
|
|
||||||
{
|
|
||||||
auto* tab1 = new Button<Font_Arial, Text_SM>(UI::Attributes{});
|
|
||||||
auto* tab2 = new Button<Font_Arial, Text_SM>(UI::Attributes{});
|
|
||||||
auto* tabs = new TabBar<>(UI::Attributes{}, {OElement(tab1), OElement(tab2)});
|
|
||||||
tabs->setActiveTab(0);
|
|
||||||
(void)tabs->getActiveTab();
|
|
||||||
tabs->applyOverrides();
|
|
||||||
(void)tabs->style;
|
|
||||||
(void)tabs->attr;
|
|
||||||
(void)tabs->children;
|
|
||||||
tabs->markDirty();
|
|
||||||
delete tabs;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Tooltip ---
|
|
||||||
{
|
|
||||||
auto* target = new Button<Font_Arial, Text_SM>(UI::Attributes{});
|
|
||||||
auto* tip = new Tooltip<Font_Arial, Text_SM>(UI::Attributes{}, OElement(target), "Helpful");
|
|
||||||
tip->setHovered(true);
|
|
||||||
tip->applyOverrides();
|
|
||||||
(void)tip->style;
|
|
||||||
(void)tip->attr;
|
|
||||||
(void)tip->children;
|
|
||||||
tip->markDirty();
|
|
||||||
delete tip;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Accordion ---
|
|
||||||
{
|
|
||||||
auto* header = new Text<Font_Arial, Text_SM>("Section");
|
|
||||||
auto* body = new Div<>(UI::Attributes{});
|
|
||||||
auto* acc = new Accordion<>(UI::Attributes{}, OElement(header), OElement(body));
|
|
||||||
acc->setBodyVisible(false);
|
|
||||||
(void)acc->isBodyVisible();
|
|
||||||
(void)acc->getHeader();
|
|
||||||
(void)acc->getBody();
|
|
||||||
(void)acc->style;
|
|
||||||
(void)acc->attr;
|
|
||||||
(void)acc->children;
|
|
||||||
acc->markDirty();
|
|
||||||
delete acc;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- HR ---
|
|
||||||
{
|
|
||||||
auto* hr = new HR<Font_Arial, Text_SM>();
|
|
||||||
(void)hr->style;
|
|
||||||
(void)hr->attr;
|
|
||||||
delete hr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user