30 GuiItem() : growWeight(0),
hasAlignH(false), hasAlignV(false),
35 GuiItem& grow(
float weight = 1.0f) { growWeight = weight;
return *
this; }
49 GuiItem& background() { isBackground =
true;
return *
this; }
60 GuiLayout&
add(
GuiElement* e,
const GuiItem& item = GuiItem());
63 GuiLayout&
add(
GuiElement& e,
const GuiItem& item = GuiItem()) {
return add(&e, item); }
86 GuiLayout& gap(
float x,
float y) {
return setSpacing(x, y); }
87 GuiLayout& pad(
float all) {
return setPadding(all); }
88 GuiLayout& pad(
float horizontal,
float vertical) {
return setPadding(horizontal, vertical); }
89 GuiLayout& pad(
float left,
float top,
float right,
float bottom) {
return setPadding(left, top, right, bottom); }
100 void update(InputController * c)
override;
118 haveAssigned(false), lastW(-1),
lastH(-1), lastVisible(true) {}
137 std::vector<Entry> entries;
138 std::vector<Entry*> visibleScratch;
139 int userFixedW, userFixedH;
140 int assignedW, assignedH;
141 int naturalW, naturalH;
153 GuiRow(
int w = 0,
int h = 0);
178 GuiGrid(
int columns,
int w = 0,
int h = 0);
GuiColumn(int w=0, int h=0)
GuiLayoutResult solve(const std::vector< Entry * > &visible, float fixedW, float fixedH) override
Works out the container size and each visible entry's rectangle (what a subclass does)
bool visible
Visibility of the element.
GuiLayoutResult solve(const std::vector< Entry * > &visible, float fixedW, float fixedH) override
Works out the container size and each visible entry's rectangle (what a subclass does)
GuiGrid(int columns, int w=0, int h=0)
Base of the layout containers. Not used directly; see GuiRow, GuiColumn, GuiGrid, GuiOverlay.
void clear()
Removes every child.
void remove(GuiElement *e) override
Removes the specified child.
GuiLayout & add(GuiElement &e, const GuiItem &item=GuiItem())
Adds a child by reference, so a builder can pass it straight in: row.add(ui.label("Hi"))
GuiLayout & add(GuiElement *e, const GuiItem &item=GuiItem())
Adds a child. Children are laid out in the order they are added.
void collectNavigable(std::vector< GuiElement * > &out) override
Appends the elements that selection can move between (default: this element; layout containers add th...
GuiLayout & size(int w, int h)
Short names for the setters above, for reading a layout top to bottom: ui.row().size(568,...
void layout() override
Brings the element's own layout up to date.
GuiLayout & addSpace(float weight=1.0f)
Adds flexible empty space that takes a share of what is left over, for example to push one child to e...
GuiLayout & setFixedSize(int w, int h)
Fixes the container's size (0 on an axis = fit the content)
GuiLayout & setSpacing(float s)
Sets the gap between neighbouring children (a grid uses both numbers)
void getNaturalSize(int &w, int &h) override
Layout protocol: how a layout container (GuiRow, GuiColumn, GuiGrid, GuiOverlay) asks about and arran...
GuiLayout & setAlignItems(LAYOUT_ALIGN a)
Sets the default alignment of children across the main axis.
void update(InputController *c) override
Called constantly to allow the element to respond to the current input data.
void draw() override
Called constantly to redraw the element.
void invalidate()
Forces layout to run again.
GuiLayout & addGap(float size)
Adds a fixed gap along a row's width or a column's height.
GuiLayout & setPadding(float all)
Sets the space between the container's edge and its children.
virtual GuiLayoutResult solve(const std::vector< Entry * > &visible, float fixedW, float fixedH)=0
Works out the container size and each visible entry's rectangle (what a subclass does)
GuiLayout & setJustify(LAYOUT_JUSTIFY j)
Sets how leftover space along the main axis is spent when no child grows.
void setLayoutSize(int w, int h) override
Gives the element a size chosen by a container (default: sets width and height)
GuiOverlay(int w=0, int h=0)
GuiLayoutResult solve(const std::vector< Entry * > &visible, float fixedW, float fixedH) override
Works out the container size and each visible entry's rectangle (what a subclass does)
GuiLayoutResult solve(const std::vector< Entry * > &visible, float fixedW, float fixedH) override
Works out the container size and each visible entry's rectangle (what a subclass does)
bool hasAlignH
Per-child options passed to GuiLayout::add().
LAYOUT_ALIGN
How an item sits across the main direction of a stack, or inside a grid cell.
LAYOUT_JUSTIFY
How leftover space along a stack's main direction is spent (when no item grows).
@ STRETCH
Fills the available space.
Space around the inside edge of a container.
The solver's answer: the container's size and each item's rectangle.
int natH
Natural size, as measured this pass.
int baseH
Natural size before layout resized it.
int assignedH
Size layout last gave it.
float gapSize
Fixed size of a gap.
int lastH
Natural size at the last layout, to spot changes.
GuiElement * e
The child; null for a gap or flexible space.