Control
The Control class is a base class for UI controls such as buttons, sliders, and panels, providing methods to define their type, state, and alignment. It supports flexible parent-child relationships, allowing for the addition, removal, and organization of controls in a hierarchical layout. The class also manages control size, position, margins, and offsets, with the ability to enable or disable controls based on user interaction. It handles various control states, such as focused, pressed, or disabled, and allows for querying and modifying these states. Additionally, it provides functionality for managing interaction events, such as mouse clicks and key presses, making it essential for creating dynamic and interactive UI elements.
#include <interface/TellusimControls.h>
Constructors
Control()
explicit Control(Control *parent)
Control(Control *parent, float32_t width, float32_t height = 0.0f)
Methods
Control type.
Type getType() const
static const char *getTypeName(Type type)
const char *getTypeName() const
bool isUnknown() const
bool isRoot() const
bool isText() const
bool isRect() const
bool isGrid() const
bool isGroup() const
bool isPanel() const
bool isDialog() const
bool isWindow() const
bool isCheck() const
bool isCombo() const
bool isButton() const
bool isSlider() const
bool isScroll() const
bool isSplit() const
bool isArea() const
bool isTree() const
bool isEdit() const
Control alignment.
void setAlign(Align align)
Align getAlign() const
bool hasAlign(Align align) const
bool hasAligns(Align aligns) const
bool isSpacer() const
Control created.
void setCreated(bool created)
bool isCreated() const
Control enabled flag.
void setEnabled(bool enabled)
bool isEnabled() const
bool wasEnabled() const
bool wasUpdated() const
Control disabled flag.
void setDisabled(bool disabled)
bool isDisabled() const
Control canvas.
Canvas getCanvas() const
Control root.
const ControlRoot getRoot() const
ControlRoot getRoot()
Control panel.
const ControlPanel getPanel() const
ControlPanel getPanel()
Control parent.
uint32_t setParent(Control &parent)
const Control getParent() const
Control getParent()
bool isParentEnabled() const
bool isParentDisabled() const
Control children.
uint32_t addChild(Control &child)
Control setChild(uint32_t index, Control &child)
bool raiseChild(Control &child)
bool lowerChild(Control &child)
bool removeChild(Control &child)
void releaseChildren()
uint32_t findChild(const Control &child) const
bool isChild(const Control &child, bool hierarchy = false) const
uint32_t getNumChildren() const
const Array<Control> getChildren() const
Array<Control> getChildren()
const Control getChild(uint32_t index) const
Control getChild(uint32_t index)
Control size.
void setSize(Vector2f size)
void setSize(float32_t width, float32_t height)
const Vector2f getSize() const
float32_t getWidth() const
float32_t getHeight() const
Control position.
void setPosition(Vector3f position)
void setPosition(float32_t x, float32_t y, float32_t z = 0.0f)
const Vector3f getPosition() const
float32_t getPositionX() const
float32_t getPositionY() const
Control offset.
void setOffset(Vector3f offset)
void setOffset(float32_t x, float32_t y, float32_t z = 0.0f)
const Vector3f getOffset() const
float32_t getOffsetX() const
float32_t getOffsetY() const
Control margin.
void setMargin(float32_t value)
void setMargin(float32_t horizontal, float32_t vertical)
void setMargin(float32_t left, float32_t right, float32_t bottom, float32_t top)
void setMargin(Rect margin)
const Rect getMargin() const
Control rectangle.
const Rect getRect() const
Control state.
State getState() const
Enums
Type
Control types.
Name | Value |
---|---|
TypeUnknown | 0 |
TypeRoot | 1 |
TypeText | 2 |
TypeRect | 3 |
TypeGrid | 4 |
TypeGroup | 5 |
TypePanel | 6 |
TypeDialog | 7 |
TypeWindow | 8 |
TypeCheck | 9 |
TypeCombo | 10 |
TypeButton | 11 |
TypeSlider | 12 |
TypeScroll | 13 |
TypeSplit | 14 |
TypeArea | 15 |
TypeTree | 16 |
TypeEdit | 17 |
NumTypes | 18 |
State
Control states.
Name | Value |
---|---|
StateUnknown | 0 |
StateNormal | 1 |
StateFocused | 2 |
StatePressed | 3 |
StateDisabled | 4 |
NumStates | 5 |
Mesh
Control meshes.
Name | Value |
---|---|
MeshCheck | 0 |
MeshButton | 1 |
MeshSliderLine | 2 |
MeshHScrollLine | 3 |
MeshVScrollLine | 4 |
MeshSliderHandle | 5 |
MeshHScrollHandle | 6 |
MeshVScrollHandle | 7 |
MeshBackground | 8 |
MeshSelection | 9 |
MeshBorder | 10 |
MeshFrame | 11 |
NumMeshes | 12 |
Align
Control alignments.
Name | Value |
---|---|
AlignNone | 0 |
AlignLeft | (1 << 0) |
AlignRight | (1 << 1) |
AlignBottom | (1 << 2) |
AlignTop | (1 << 3) |
AlignCenterX | (1 << 4) |
AlignCenterY | (1 << 5) |
AlignExpandX | (1 << 6) |
AlignExpandY | (1 << 7) |
AlignOverlap | (1 << 8) |
AlignSpacer | (1 << 9) |
AlignAspect | (1 << 10) |
AlignLeftBottom | (AlignLeft | AlignBottom) |
AlignLeftTop | (AlignLeft | AlignTop) |
AlignRightBottom | (AlignRight | AlignBottom) |
AlignRightTop | (AlignRight | AlignTop) |
AlignCenter | (AlignCenterX | AlignCenterY) |
AlignExpand | (AlignExpandX | AlignExpandY) |
NumAligns | 11 |
Button
Control buttons.
Name | Value |
---|---|
ButtonNone | 0 |
ButtonLeft | (1 << 0) |
ButtonLeft2 | (1 << 1) |
ButtonRight | (1 << 2) |
ButtonRight2 | (1 << 3) |
ButtonMiddle | (1 << 4) |
ButtonMiddle2 | (1 << 5) |
NumButtons | 6 |
Axis
Control axes.
Name | Value |
---|---|
AxisUnknown | 0 |
AxisX | 1 |
AxisY | 2 |
AxisZ | 3 |
AxisW | 4 |
NumAxes | 5 |
Key
Control keys.
Name | Value |
---|---|
KeyNone | 128 |
KeyTab | 129 |
KeyBackspace | 130 |
KeyDelete | 131 |
KeyInsert | 132 |
KeyReturn | 133 |
KeyPrior | 134 |
KeyNext | 135 |
KeyEnd | 136 |
KeyHome | 137 |
KeyUp | 138 |
KeyDown | 139 |
KeyLeft | 140 |
KeyRight | 141 |
KeyShift | 142 |
KeyCtrl | 143 |
KeyAlt | 144 |
KeyCmd | 145 |
NumKeys | 146 |
KeyOption | KeyCmd |
KeyOption | KeyCtrl |