Skip to main content

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.

NameValue
TypeUnknown0
TypeRoot1
TypeText2
TypeRect3
TypeGrid4
TypeGroup5
TypePanel6
TypeDialog7
TypeWindow8
TypeCheck9
TypeCombo10
TypeButton11
TypeSlider12
TypeScroll13
TypeSplit14
TypeArea15
TypeTree16
TypeEdit17
NumTypes18

State

Control states.

NameValue
StateUnknown0
StateNormal1
StateFocused2
StatePressed3
StateDisabled4
NumStates5

Mesh

Control meshes.

NameValue
MeshCheck0
MeshButton1
MeshSliderLine2
MeshHScrollLine3
MeshVScrollLine4
MeshSliderHandle5
MeshHScrollHandle6
MeshVScrollHandle7
MeshBackground8
MeshSelection9
MeshBorder10
MeshFrame11
NumMeshes12

Align

Control alignments.

NameValue
AlignNone0
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)
NumAligns11

Button

Control buttons.

NameValue
ButtonNone0
ButtonLeft(1 << 0)
ButtonLeft2(1 << 1)
ButtonRight(1 << 2)
ButtonRight2(1 << 3)
ButtonMiddle(1 << 4)
ButtonMiddle2(1 << 5)
NumButtons6

Axis

Control axes.

NameValue
AxisUnknown0
AxisX1
AxisY2
AxisZ3
AxisW4
NumAxes5

Key

Control keys.

NameValue
KeyNone128
KeyTab129
KeyBackspace130
KeyDelete131
KeyInsert132
KeyReturn133
KeyPrior134
KeyNext135
KeyEnd136
KeyHome137
KeyUp138
KeyDown139
KeyLeft140
KeyRight141
KeyShift142
KeyCtrl143
KeyAlt144
KeyCmd145
NumKeys146
KeyOptionKeyCmd
KeyOptionKeyCtrl