Class · aurore

aurore::Box

Generic FlexBox layout.

On this page
aurore/core/box.hpp
#include <aurore/core/box.hpp>

class aurore::Box : public aurore::View

Constructors 3

Box(Axis flexDirection)

An empty box laying its children out along flexDirection.

box.hpp:77
Box()

An empty row.

box.hpp:79
~Box()

Deletes the children (those a ptrLock() holds go to the deletion pool).

box.hpp:81

Functions 53

virtual void draw(NVGcontext *vg,float x,float y,float width,float height,Style style,FrameContext *ctx) override

Called by frame() to draw the view onscreen. Views should not draw outside of their bounds (they may be clipped if they do so).

Overrides aurore::View::draw

box.hpp:83
virtual View * getDefaultFocus() override

Returns the default view to focus when focusing this view Typically the view itself or one of its children.

Returning nullptr means that the view is not focusable (and neither are its children)

By default, a view is focusable if the flag is set to true with setFocusable() and if the view is visible.

When pressing a key, the flow is :

  1. starting from the currently focused view's parent, traverse the tree upwards and repeatedly call getNextFocus() on every view until we find a next view to focus or meet the end of the tree
  2. if a view is found, getNextFocus() will internally call getDefaultFocus() for the selected child
  3. give focus to the result, if it exists

Overrides aurore::View::getDefaultFocus

box.hpp:84
virtual View * hitTest(Point point) override

Returns the view to focus with the corresponding screen coordinates in the view or its children, or nullptr if it hasn't been found.

Research is done recursively by traversing the tree starting from this view. This view's parents are not traversed.

Overrides aurore::View::hitTest

box.hpp:85
virtual View * getNextFocus(FocusDirection direction,View *currentView) override

Returns the next view to focus given the requested direction and the currently focused view (as parent user data)

Returning nullptr means that there is no next view to focus in that direction - getNextFocus will then be called on our parent if any

Overrides aurore::View::getNextFocus

box.hpp:86
virtual void willAppear(bool resetState) override

Called when the view will appear on screen, before or after layout().

Can be called if the view has already appeared, so be careful.

Overrides aurore::View::willAppear

box.hpp:87
virtual void willDisappear(bool resetState) override

Called when the view will disappear from the screen.

Can be called if the view has already disappeared, so be careful.

Overrides aurore::View::willDisappear

box.hpp:88
virtual void onWindowSizeChanged() override

Fired when the window size changes, after updating layout.

Overrides aurore::View::onWindowSizeChanged

box.hpp:89
virtual void onThemeChanged() override

Called on every view of the screens when the theme changes (Application::getThemeChangedEvent): the colours given by key (setThemeColor) take their new values, the state styles read their "@theme/" values again. A view that keeps other colours of its own looks them up again here, then calls the base. A Box goes on to its children.

Overrides aurore::View::onThemeChanged

box.hpp:90
virtual void onFocusGained() override

Fired when focus is gained.

Overrides aurore::View::onFocusGained

box.hpp:91
virtual void onFocusLost() override

Fired when focus is lost.

Overrides aurore::View::onFocusLost

box.hpp:92
virtual void onParentFocusGained(View *focusedView) override

Fired when focus is gained on this view's parent, or the parent of the parent...

Overrides aurore::View::onParentFocusGained

box.hpp:93
virtual void onParentFocusLost(View *focusedView) override

Fired when focus is lost on one of this view's parents. Works similarly to onParentFocusGained().

Overrides aurore::View::onParentFocusLost

box.hpp:94
virtual bool applyXMLAttribute(std::string name, std::string value) override

Applies the given attribute to the view.

You can add your own attributes to by calling registerXMLAttribute() in the view constructor.

Overrides aurore::View::applyXMLAttribute

box.hpp:95
virtual View * getParentNavigationDecision(View *from,View *newFocus,FocusDirection direction)

The focus about to move from from to newFocus: a box may give another view instead. Asked of every parent up the tree; returns newFocus by default.

box.hpp:101
virtual void addView(View *view)

Adds a view to this Box. Returns the position the view was added at.

box.hpp:107
virtual void addView(View *view, size_t position)

Adds a view to this Box at the given position. Returns the position the view was added at.

box.hpp:113
virtual void removeView(View *view, bool free = true)

Removes the given view from the Box. It will be freed.

box.hpp:118
virtual void clearViews(bool free = true)

Removes all views from the Box. Them will be freed.

box.hpp:123
virtual void setPadding(float padding)

Sets the padding of the view, aka the internal space to give between this view boundaries and its children.

Only does one layout pass instead of four when using the four methods separately.

box.hpp:131
virtual void setPadding(float top,float right,float bottom,float left)

Sets the padding of the view, aka the internal space to give between this view boundaries and its children.

Only does one layout pass instead of four when using the four methods separately.

box.hpp:139
virtual void setPaddingTop(float top)

Sets the padding of the view, aka the internal space to give between this view boundaries and its children.

box.hpp:145
float getPaddingTop()
virtual void setPaddingRight(float right)

Sets the padding of the view, aka the internal space to give between this view boundaries and its children.

box.hpp:153
float getPaddingRight()
virtual void setPaddingBottom(float bottom)

Sets the padding of the view, aka the internal space to give between this view boundaries and its children.

box.hpp:161
float getPaddingBottom()
virtual void setPaddingLeft(float left)

Sets the padding of the view, aka the internal space to give between this view boundaries and its children.

box.hpp:169
float getPaddingLeft()
virtual void setGap(float gap)

Sets the gap between child elements inside this view. This is typically used in layouts like grids or lists.

box.hpp:177
float getGap()

Returns the current gap between child elements inside this view.

box.hpp:182
void setRowGap(float gap)

Sets the gap between two lines of children (wrapped rows, or the children of a column), overriding setGap() on that axis.

box.hpp:188
float getRowGap()
void setColumnGap(float gap)

Sets the gap between two children along a row (or between wrapped columns), overriding setGap() on that axis.

box.hpp:195
float getColumnGap()
void setJustifyContent(JustifyContent justify)

Sets the children alignment along the Box axis.

Default is FLEX_START.

box.hpp:203
void setAlignItems(AlignItems alignment)

Sets the children alignment along the Box cross axis.

Default is AUTO.

box.hpp:210
void setDirection(Direction direction)

Sets the direction of the box, aka place the views left to right or right to left (flips the children).

Default is INHERIT.

box.hpp:218
void setAxis(Axis axis)

The axis the children are laid out along.

box.hpp:221
Axis getAxis() const
void setWrap(Wrap wrap)

Sets the wrapping behavior for the children inside this view.

box.hpp:227
Wrap getWrap() const

Returns the wrapping behavior for the children inside this view.

box.hpp:232
std::vector< View * > & getChildren()

The children, in order. The box owns them: it deletes them with itself.

box.hpp:235
virtual void getCullingBounds(float *top,float *right,float *bottom,float *left)

Returns the bounds used for culling children.

box.hpp:240
void forwardXMLAttribute(std::string attributeName, View *target)

Registers an XML attribute to be forwarded to the given view. Works regardless of the target attribute type. Useful to expose attributes of children views in the parent box without copy pasting them individually.

The forwarded attribute value will override the value of the regular attribute if it already exists in the target view.

box.hpp:248
void forwardXMLAttribute(std::string attributeName,View *target,std::string targetAttributeName)

Registers an XML attribute to be forwarded to the given view, while changing the target attribute name. Works regardless of the target attribute type. Useful to expose attributes of children views in the parent box without copy pasting them individually, but with a different name.

The forwarded attribute value will override the value of the regular attribute if it already exists in the target view.

box.hpp:257
virtual void onChildFocusGained(View *directChild, View *focusedView)

Fired when focus is gained on one of this view's children, or one of the children of the children...

directChild is guaranteed to be one of your children. It may not be the view that has been focused.

If focusedView == directChild, then the child of yours has been focused. Otherwise, focusedView is a child of directChild.

box.hpp:269
virtual void onChildFocusLost(View *directChild, View *focusedView)

Fired when focus is lost on one of this view's children. Works similarly to onChildFocusGained().

box.hpp:275
virtual View * getView(std::string id) override

Returns the view with the corresponding id in the view or its children, or nullptr if it hasn't been found.

Research is done recursively by traversing the tree starting from this view. This view's parents are not traversed.

Overrides aurore::View::getView

box.hpp:277
void setLastFocusedView(View *view)

The child the focus goes back to when the box gets it again.

box.hpp:280
void setDefaultFocusedIndex(int index)

The child that takes the focus first (negative values are ignored).

box.hpp:283
size_t getDefaultFocusedIndex() const
View * getLastFocusedView() const
virtual bool isChildFocused()

Whether the focus is on one of the children, at any depth.

box.hpp:291

Also the functions of aurore::View (221).

Static functions 1

static View * create()

Protected functions 6

virtual std::string getDefaultAccessibilityLabel() override

A focusable box says the texts shown in it (getAccessibilityText).

Overrides aurore::View::getDefaultAccessibilityLabel

box.hpp:305
void inflateFromXMLString(std::string_view xml)

Inflates the Box with the given XML string.

The root element MUST be a aurore::Box, corresponding to the inflated Box itself. Its attributes will be applied to the Box.

Each child node in the root aurore::Box will be treated as a view and added as a child of the Box.

box.hpp:316
void inflateFromXMLElement(tinyxml2::XMLElement *element)

Inflates the Box with the given XML element.

The root element MUST be a aurore::Box, corresponding to the inflated Box itself. Its attributes will be applied to the Box.

Each child node in the root aurore::Box will be treated as a view and added as a child of the Box.

box.hpp:327
void inflateFromXMLRes(const std::string &res)

Inflates the Box with the given XML resource.

The root element MUST be a aurore::Box, corresponding to the inflated Box itself. Its attributes will be applied to the Box.

Each child node in the root aurore::Box will be treated as a view and added as a child of the Box.

box.hpp:338
void inflateFromXMLFile(const std::string &path)

Inflates the Box with the given XML file path.

The root element MUST be a aurore::Box, corresponding to the inflated Box itself. Its attributes will be applied to the Box.

Each child node in the root aurore::Box will be treated as a view and added as a child of the Box.

box.hpp:349
virtual void handleXMLElement(tinyxml2::XMLElement *element) override

Handles a child XML element.

By default, calls createFromXMLElement() and adds the result to the children of the Box.

Overrides aurore::View::handleXMLElement

box.hpp:357

Read from Aurore's headers by Doxygen at each build · library/include