Aurore
A Switch-like interface for your app, on every screen
Loading...
Searching...
No Matches
aurore::Box Class Reference

Generic FlexBox layout. More...

#include <aurore/core/box.hpp>

Inheritance diagram for aurore::Box:
aurore::View VersionBadge aurore::AccountWidget aurore::AppletFrame aurore::BatteryWidget aurore::BottomBar aurore::Button aurore::ContextMenu aurore::ContextMenuItem aurore::DebugLayer aurore::Dialog aurore::Dropdown aurore::EditTextDialog aurore::HScrollingFrame aurore::Header aurore::Hint aurore::Hints aurore::Notification aurore::NotificationManager aurore::RecyclerCell aurore::RecyclerContentBox aurore::RecyclingGridContentBox aurore::RecyclingGridItem aurore::ScrollingFrame aurore::SidebarItem aurore::Slider aurore::TabFrame aurore::WirelessWidget cadran::Card cadran::kit::Chip

Public Member Functions

 Box (Axis flexDirection)
 An empty box laying its children out along flexDirection.
 
 Box ()
 An empty row.
 
 ~Box ()
 Deletes the children (those a ptrLock() holds go to the deletion pool).
 
void draw (NVGcontext *vg, float x, float y, float width, float height, Style style, FrameContext *ctx) override
 
View * getDefaultFocus () override
 
View * hitTest (Point point) override
 
View * getNextFocus (FocusDirection direction, View *currentView) override
 
void willAppear (bool resetState) override
 
void willDisappear (bool resetState) override
 
void onWindowSizeChanged () override
 
void onThemeChanged () override
 
void onFocusGained () override
 
void onFocusLost () override
 
void onParentFocusGained (View *focusedView) override
 
void onParentFocusLost (View *focusedView) override
 
bool applyXMLAttribute (std::string name, std::string value) override
 
virtual View * getParentNavigationDecision (View *from, View *newFocus, FocusDirection direction)
 
virtual void addView (View *view)
 
virtual void addView (View *view, size_t position)
 
virtual void removeView (View *view, bool free=true)
 
virtual void clearViews (bool free=true)
 
virtual void setPadding (float padding)
 
virtual void setPadding (float top, float right, float bottom, float left)
 
virtual void setPaddingTop (float top)
 
float getPaddingTop ()
 
virtual void setPaddingRight (float right)
 
float getPaddingRight ()
 
virtual void setPaddingBottom (float bottom)
 
float getPaddingBottom ()
 
virtual void setPaddingLeft (float left)
 
float getPaddingLeft ()
 
virtual void setGap (float gap)
 
float getGap ()
 
void setRowGap (float gap)
 
float getRowGap ()
 
void setColumnGap (float gap)
 
float getColumnGap ()
 
void setJustifyContent (JustifyContent justify)
 
void setAlignItems (AlignItems alignment)
 
void setDirection (Direction direction)
 
void setAxis (Axis axis)
 The axis the children are laid out along.
 
Axis getAxis () const
 
void setWrap (Wrap wrap)
 
Wrap getWrap () const
 
std::vector< View * > & getChildren ()
 The children, in order. The box owns them: it deletes them with itself.
 
virtual void getCullingBounds (float *top, float *right, float *bottom, float *left)
 
void forwardXMLAttribute (std::string attributeName, View *target)
 
void forwardXMLAttribute (std::string attributeName, View *target, std::string targetAttributeName)
 
virtual void onChildFocusGained (View *directChild, View *focusedView)
 
virtual void onChildFocusLost (View *directChild, View *focusedView)
 
View * getView (std::string id) override
 
void setLastFocusedView (View *view)
 The child the focus goes back to when the box gets it again.
 
void setDefaultFocusedIndex (int index)
 The child that takes the focus first (negative values are ignored).
 
size_t getDefaultFocusedIndex () const
 
View * getLastFocusedView () const
 See setLastFocusedView().
 
virtual bool isChildFocused ()
 Whether the focus is on one of the children, at any depth.
 
- Public Member Functions inherited from aurore::View
void setScale (float scale)
 
void setScaleX (float scale)
 
void setScaleY (float scale)
 
float getScaleX () const
 
float getScaleY () const
 
 View ()
 
virtual ~View ()
 
void setBackground (ViewBackground background)
 How the view's background is drawn: none, the sidebar's, the backdrop, a plain colour or a gradient.
 
void setBackgroundLinearGradient (NVGcolor start, NVGcolor end, ViewBackground direction=ViewBackground::VERTICAL_LINEAR)
 
void shakeHighlight (FocusDirection direction)
 Shakes the focus highlight towards direction: there is nothing to go to there.
 
Rect getFrame ()
 The view's position and size on the screen, after layout (getX(), getY(), getWidth(), getHeight()).
 
float getX ()
 The position on the screen, in layout units: the parents' positions and translations added.
 
float getY ()
 
Rect getLocalFrame ()
 The position and size in the parent, as laid out by Yoga.
 
float getLocalX ()
 
float getLocalY ()
 
float getWidth ()
 The size as laid out by Yoga; the height without the collapse when includeCollapse is false.
 
float getHeight (bool includeCollapse=true)
 
virtual void invalidate ()
 
virtual void onLayout ()
 
void setWidth (float width)
 
void setHeight (float height)
 
void setSize (Size size)
 
void setDimensions (float width, float height)
 
void setWidthPercentage (float percentage)
 
void setHeightPercentage (float percentage)
 
void setMinWidth (float minWidth)
 
void setMinHeight (float minHeight)
 
void setMinWidthPercentage (float percentage)
 
void setMinHeightPercentage (float percentage)
 
void setMaxWidth (float maxWidth)
 
void setMaxHeight (float maxHeight)
 
void setMaxWidthPercentage (float percentage)
 
void setMaxHeightPercentage (float percentage)
 
void setGrow (float grow)
 
void setShrink (float shrink)
 
void setMargins (float top, float right, float bottom, float left)
 
void setMarginTop (float top)
 
void setMarginRight (float right)
 
float getMarginRight ()
 
float getMarginLeft ()
 
void setMarginBottom (float right)
 
void setMarginLeft (float left)
 
void setVisibility (Visibility visibility)
 
Visibility getVisibility ()
 
void setPositionTop (float pos)
 
void setPositionRight (float pos)
 
void setPositionBottom (float pos)
 
void setPositionLeft (float pos)
 
void setPositionTopPercentage (float percentage)
 
void setPositionRightPercentage (float percentage)
 
void setPositionBottomPercentage (float percentage)
 
void setPositionLeftPercentage (float percentage)
 
void setPositionType (PositionType type)
 
void setId (std::string id)
 
const std::string & getId () const
 
void setAlignSelf (AlignSelf align)
 
void setBoxSizing (BoxSizing sizing)
 
void setLineColor (NVGcolor color)
 
void setLineTop (float thickness)
 
void setLineRight (float thickness)
 
void setLineBottom (float thickness)
 
void setLineLeft (float thickness)
 
void setBackgroundColor (NVGcolor color)
 
void setBorderColor (NVGcolor color)
 
ViewBackground getBackground () const
 
NVGcolor getBackgroundColor () const
 
NVGcolor getBorderColor () const
 
void setBorderThickness (float thickness)
 
float getBorderThickness ()
 
void setCornerRadius (float radius)
 
void setCornerRadius (float topLeft, float topRight, float bottomRight, float bottomLeft)
 
float getCornerRadius ()
 
void setThemeArea (ThemeArea area)
 
ThemeArea getThemeArea () const
 
void setShadowType (ShadowType type)
 
void setShadowVisibility (bool visible)
 
void setHideHighlightBackground (bool hide)
 
void setHideHighlightBorder (bool hide)
 
void setHideHighlight (bool hide)
 
void setHideClickAnimation (bool hide)
 No click animation when the view is clicked.
 
void setHighlightPadding (float padding)
 
void setHighlightCornerRadius (float radius)
 
virtual View * getNearestView (std::string id)
 
virtual void applyXMLAttributes (tinyxml2::XMLElement *element)
 
void registerAutoXMLAttribute (std::string name, AutoAttributeHandler handler)
 
void registerPercentageXMLAttribute (std::string name, FloatAttributeHandler handler)
 
void registerFloatXMLAttribute (std::string name, FloatAttributeHandler handler)
 
void registerStringXMLAttribute (std::string name, StringAttributeHandler handler)
 
void registerColorXMLAttribute (std::string name, ColorAttributeHandler handler)
 
void registerBoolXMLAttribute (std::string name, BoolAttributeHandler handler)
 
void registerFilePathXMLAttribute (std::string name, FilePathAttributeHandler handler)
 
bool isXMLAttributeValid (std::string attributeName)
 
void setMaximumAllowedXMLElements (unsigned max)
 
unsigned getMaximumAllowedXMLElements ()
 
void setInFadeAnimation (bool translucent)
 
void setFocusable (bool focusable)
 
bool isFocusable ()
 Whether the view takes the focus: focusable, and visible.
 
void removeFromSuperView (bool free=true)
 
void setFocusSound (enum Sound sound)
 
virtual enum Sound getFocusSound ()
 
void detach ()
 
bool isDetached ()
 See detach().
 
void setDetachedPosition (float x, float y)
 
void setDetachedPositionX (float x)
 
void setDetachedPositionY (float y)
 
Point getDetachedPosition () const
 
void setParent (Box *parent, void *parentUserdata=nullptr)
 The box this view is in (Box::addView sets it; parentUserdata is the box's own).
 
Box * getParent ()
 
bool hasParent ()
 
void * getParentUserData ()
 
template<class ButtonType >
ActionIterator getAction (ButtonType button)
 
ActionIterator getAction (ActionIdentifier identifier)
 The action registered under identifier, or getActions().end().
 
template<class ButtonType , class ActionType >
ActionIdentifier registerAction (const std::string &hintText, ButtonType button, const ActionListener &actionListener, bool hidden=false, bool allowRepeating=false, enum Sound sound=SOUND_NONE)
 
ActionIdentifier registerAction (const std::string &hintText, ControllerButton button, const ActionListener &actionListener, bool hidden=false, bool allowRepeating=false, enum Sound sound=SOUND_NONE)
 The same, on a controller button.
 
ActionIdentifier registerAction (AuroreKeyCombination key, const ActionListener &actionListener, bool allowRepeating=false)
 An action on a keyboard key (a combination with modifiers): no hint, no sound.
 
void func (AuroreKeyCombination key)
 
void unregisterAction (ActionIdentifier identifier)
 
void registerClickAction (const ActionListener &actionListener)
 
void updateActionHint (enum ControllerButton button, const std::string &hintText)
 Changes the hint of the action on button.
 
void setActionAvailable (enum ControllerButton button, bool available)
 Turns the action on button on or off (an action off runs nothing and shows no hint).
 
void setActionsAvailable (bool available) const
 The same for every action of the view.
 
void setActionHidden (enum ControllerButton button, bool hidden)
 
void resetClickAnimation ()
 
void playClickAnimation (bool reverse=false, bool animateBack=true, bool force=false)
 Plays the click animation (the flash over the view).
 
std::string getClassString () const
 The view's class name ("Label", "Box"…).
 
std::string describe () const
 The class name and the id, for logs: Label (id="title").
 
YGNode * getYGNode ()
 The view's Yoga node.
 
const std::vector< std::shared_ptr< Action > > & getActions ()
 The actions registered on the view.
 
const std::vector< GestureRecognizer * > & getGestureRecognizers ()
 
void interruptGestures (bool onlyIfUnsureState)
 
void addGestureRecognizer (GestureRecognizer *recognizer)
 
bool removeGestureRecognizer (GestureRecognizer *recognizer)
 
Sound gestureRecognizerRequest (TouchState touch, MouseState mouse, View *firstResponder)
 
virtual void frame (FrameContext *ctx)
 
void frameHighlight (FrameContext *ctx)
 
virtual void onShowAnimationEnd ()
 
virtual void show (std::function< void(void)> cb)
 
virtual void show (std::function< void(void)> cb, bool animate, float animationDuration)
 
virtual float getShowAnimationDuration (TransitionAnimation animation)
 
void collapse (bool animated=true)
 
bool isCollapsed ()
 Whether collapse() hid the view.
 
void setAlpha (float alpha)
 The view's opacity, 0 to 1 (a transition when its style has one).
 
void expand (bool animated=true)
 
virtual void hide (std::function< void(void)> cb)
 
virtual void hide (std::function< void(void)> cb, bool animate, float animationDuration)
 
bool isHidden ()
 Whether hide() hid the view.
 
virtual bool isTranslucent ()
 
bool isFocused ()
 Whether the view has the focus.
 
void setCustomNavigationRoute (FocusDirection direction, View *target)
 
void setCustomNavigationRoute (FocusDirection direction, std::string targetId)
 
bool hasCustomNavigationRouteByPtr (FocusDirection direction)
 
bool hasCustomNavigationRouteById (FocusDirection direction)
 
View * getCustomNavigationRoutePtr (FocusDirection direction)
 
std::string getCustomNavigationRouteId (FocusDirection direction)
 
GenericEvent * getFocusEvent ()
 Fired with the view when it gains the focus.
 
GenericEvent * getFocusLostEvent ()
 Fired with the view when it loses the focus.
 
virtual float getAlpha (bool child=false)
 The opacity drawn: the view's alpha times its parents'.
 
float getClickAlpha ()
 
void overrideTheme (Theme *newTheme)
 
void setCulled (bool culled)
 
bool isCulled ()
 
void setAspectRatio (float value)
 The width over the height, kept by the layout (values <= 0 are ignored).
 
float getAspectRatio ()
 
void setBackgroundCornerRadii (float topLeft, float topRight, float bottomRight, float bottomLeft)
 
void setTranslationY (float translateY)
 
void setTranslationX (float translateX)
 
void setWireframeEnabled (bool wireframe)
 
bool isWireframeEnabled ()
 
AppletFrameItem * getAppletFrameItem ()
 
void updateAppletFrameItem ()
 
bool getClipsToBounds () const
 Whether the children are clipped to the view's frame when drawn.
 
void setClipsToBounds (bool value)
 
virtual AppletFrame * getAppletFrame ()
 The AppletFrame the view is in, or nullptr.
 
void present (View *view)
 Pushes view as the content of the view's AppletFrame (a page inside the frame).
 
virtual void dismiss (std::function< void(void)> cb=[] {})
 Pops the AppletFrame's content back to the one before, then runs cb.
 
std::weak_ptr< void > aliveToken ()
 
void ptrLock ()
 
void ptrUnlock ()
 
bool isPtrLocked ()
 Whether a ptrLock() holds the view.
 
void freeView ()
 Deletes the view at the end of the frame (Application::addToFreeQueue).
 
Activity * getParentActivity ()
 The activity the view is in, through its parents; nullptr when none.
 
void setParentActivity (Activity *activity)
 
bool setStateStyle (StyleState state, const std::string &property, const std::string &value)
 
void setStyleState (StyleState state, bool on)
 
bool hasStyleState (StyleState state)
 
bool setTransition (const std::string &spec)
 
virtual bool getStyleProperty (const std::string &name, StyleValue *value)
 
virtual bool setStyleProperty (const std::string &name, const StyleValue &value)
 
void keepSubscription (Subscription &&subscription)
 
bool bind (const std::string &spec)
 
virtual bool setBoundText (const std::string &text)
 
void setAccessibilityRole (AccessibilityRole role)
 
AccessibilityRole getAccessibilityRole ()
 See setAccessibilityRole().
 
void setAccessibilityLabel (const std::string &label)
 
std::string getAccessibilityLabel ()
 
void setAccessibilityValue (const std::string &value)
 
std::string getAccessibilityValue ()
 
void setAccessibilitySelected (bool selected)
 
bool isAccessibilitySelected ()
 
virtual bool getAccessibilityPosition (int *index, int *count)
 
virtual std::string getAccessibilityDescription ()
 
std::string getAccessibilityText ()
 
void announceAccessibilityValue ()
 
void resolveBindings (Activity *activity=nullptr)
 
virtual void onTextScaleChanged ()
 
bool setThemeColor (const std::string &property, const std::string &key)
 
std::string getThemeColor (const std::string &property)
 

Static Public Member Functions

static View * create ()
 
- Static Public Member Functions inherited from aurore::View
static void setHighlightGlide (bool glide)
 
static View * createFromXMLString (std::string_view xml)
 
static View * createFromXMLElement (tinyxml2::XMLElement *element)
 
static View * createFromXMLFile (std::string path)
 
static View * createFromXMLResource (std::string name)
 
static std::shared_ptr< tinyxml2::XMLDocument > getXMLCache (std::string_view path)
 
static void forgetXMLCache (const std::string &path)
 
static std::string describeXMLError (tinyxml2::XMLDocument *document, const std::string &source="")
 
static std::string describeXMLLocation (const tinyxml2::XMLElement *element)
 
static void fatalXML (const std::string &message)
 
static std::string closestXMLName (const std::string &name, const std::vector< std::string > &known)
 
template<typename T >
static std::string listXMLValues (const std::unordered_map< std::string, T > &values)
 An enumeration's values, sorted, for an error message.
 
static std::string getStringXMLAttributeValue (std::string value)
 
static std::string getFilePathXMLAttributeValue (std::string value)
 

Protected Member Functions

std::string getDefaultAccessibilityLabel () override
 A focusable box says the texts shown in it (getAccessibilityText).
 
void inflateFromXMLString (std::string_view xml)
 
void inflateFromXMLElement (tinyxml2::XMLElement *element)
 
void inflateFromXMLRes (const std::string &res)
 
void inflateFromXMLFile (const std::string &path)
 
void handleXMLElement (tinyxml2::XMLElement *element) override
 
- Protected Member Functions inherited from aurore::View
NVGcolor a (NVGcolor color)
 Helper functions to apply this view's alpha to a color.
 
NVGpaint a (NVGpaint paint)
 
NVGcolor RGB (unsigned r, unsigned g, unsigned b)
 
NVGcolor RGBA (unsigned r, unsigned g, unsigned b, unsigned a)
 
NVGcolor RGBf (float r, float g, float b)
 
NVGcolor RGBAf (float r, float g, float b, float a)
 
NVGcolor shadowColor (NVGcolor color, float opacity)
 
virtual bool animateHint ()
 
virtual AccessibilityRole getDefaultAccessibilityRole ()
 
virtual std::string getDefaultAccessibilityValue ()
 
virtual bool getDefaultAccessibilitySelected ()
 
bool transitionStyle (const char *name, const StyleValue &to)
 

Additional Inherited Members

- Public Types inherited from aurore::View
typedef std::vector< std::shared_ptr< Action > >::iterator ActionIterator
 
- Public Attributes inherited from aurore::View
Animatable alpha = 1.0f
 
- Static Public Attributes inherited from aurore::View
static constexpr float AUTO = NAN
 A size or position left to the layout (auto in XML).
 
static std::string CUSTOM_RESOURCES_PATH
 
static std::string currentXMLResource
 
- Protected Attributes inherited from aurore::View
Animatable collapseState = 1.0f
 
bool focused = false
 
Activity * parentActivity = nullptr
 
Box * parent = nullptr
 
GenericEvent focusEvent
 
GenericEvent focusLostEvent
 
YGNode * ygNode
 
std::string id = ""
 

Detailed Description

Generic FlexBox layout.

Constructor & Destructor Documentation

◆ Box() [1/2]

aurore::Box::Box ( Axis  flexDirection)

An empty box laying its children out along flexDirection.

◆ Box() [2/2]

aurore::Box::Box ( )

An empty row.

◆ ~Box()

aurore::Box::~Box ( )

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

Member Function Documentation

◆ addView() [1/2]

virtual void aurore::Box::addView ( View *  view)
virtual

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

Reimplemented in aurore::HScrollingFrame, and aurore::ScrollingFrame.

◆ addView() [2/2]

virtual void aurore::Box::addView ( View *  view,
size_t  position 
)
virtual

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

◆ applyXMLAttribute()

bool aurore::Box::applyXMLAttribute ( std::string  name,
std::string  value 
)
overridevirtual

Applies the given attribute to the view.

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

Reimplemented from aurore::View.

Reimplemented in aurore::IconButton.

◆ clearViews()

virtual void aurore::Box::clearViews ( bool  free = true)
virtual

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

◆ create()

static View * aurore::Box::create ( )
static

◆ draw()

void aurore::Box::draw ( NVGcontext *  vg,
float  x,
float  y,
float  width,
float  height,
Style  style,
FrameContext *  ctx 
)
overridevirtual

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

Implements aurore::View.

Reimplemented in cadran::Card, FooterHints, ScrollView, aurore::ContextMenu, aurore::HScrollingFrame, aurore::IconButton, aurore::RecyclerFrame, aurore::RecyclingGrid, aurore::HRecyclerFrame, aurore::ScrollingFrame, aurore::Slider, and aurore::WirelessWidget.

◆ forwardXMLAttribute() [1/2]

void aurore::Box::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.

◆ forwardXMLAttribute() [2/2]

void aurore::Box::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.

◆ getAxis()

Axis aurore::Box::getAxis ( ) const

◆ getChildren()

std::vector< View * > & aurore::Box::getChildren ( )

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

◆ getColumnGap()

float aurore::Box::getColumnGap ( )

◆ getCullingBounds()

virtual void aurore::Box::getCullingBounds ( float *  top,
float *  right,
float *  bottom,
float *  left 
)
virtual

Returns the bounds used for culling children.

◆ getDefaultAccessibilityLabel()

std::string aurore::Box::getDefaultAccessibilityLabel ( )
overrideprotectedvirtual

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

Reimplemented from aurore::View.

Reimplemented in aurore::Button, aurore::DetailCell, aurore::RadioCell, aurore::Dialog, aurore::Dropdown, aurore::SidebarItem, and aurore::Slider.

◆ getDefaultFocus()

View * aurore::Box::getDefaultFocus ( )
overridevirtual

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

Reimplemented from aurore::View.

Reimplemented in ScrollView, aurore::SliderCell, aurore::ContextMenu, aurore::HScrollingFrame, aurore::RecyclingGrid, aurore::HRecyclerFrame, aurore::ScrollingFrame, and aurore::Slider.

◆ getDefaultFocusedIndex()

size_t aurore::Box::getDefaultFocusedIndex ( ) const

◆ getGap()

float aurore::Box::getGap ( )

Returns the current gap between child elements inside this view.

◆ getLastFocusedView()

View * aurore::Box::getLastFocusedView ( ) const

◆ getNextFocus()

View * aurore::Box::getNextFocus ( FocusDirection  direction,
View *  currentView 
)
overridevirtual

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

Reimplemented from aurore::View.

Reimplemented in ScrollView, aurore::HScrollingFrame, aurore::RecyclerContentBox, aurore::RecyclingGridContentBox, and aurore::ScrollingFrame.

◆ getPaddingBottom()

float aurore::Box::getPaddingBottom ( )

◆ getPaddingLeft()

float aurore::Box::getPaddingLeft ( )

◆ getPaddingRight()

float aurore::Box::getPaddingRight ( )

◆ getPaddingTop()

float aurore::Box::getPaddingTop ( )

◆ getParentNavigationDecision()

virtual View * aurore::Box::getParentNavigationDecision ( View *  from,
View *  newFocus,
FocusDirection  direction 
)
virtual

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.

Reimplemented in aurore::Dropdown, aurore::HScrollingFrame, and aurore::ScrollingFrame.

◆ getRowGap()

float aurore::Box::getRowGap ( )

◆ getView()

View * aurore::Box::getView ( std::string  id)
overridevirtual

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.

Reimplemented from aurore::View.

◆ getWrap()

Wrap aurore::Box::getWrap ( ) const

Returns the wrapping behavior for the children inside this view.

◆ handleXMLElement()

void aurore::Box::handleXMLElement ( tinyxml2::XMLElement *  element)
overrideprotectedvirtual

Handles a child XML element.

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

Reimplemented from aurore::View.

Reimplemented in aurore::TabFrame.

◆ hitTest()

View * aurore::Box::hitTest ( Point  point)
overridevirtual

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.

Reimplemented from aurore::View.

◆ inflateFromXMLElement()

void aurore::Box::inflateFromXMLElement ( tinyxml2::XMLElement *  element)
protected

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.

◆ inflateFromXMLFile()

void aurore::Box::inflateFromXMLFile ( const std::string &  path)
protected

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.

◆ inflateFromXMLRes()

void aurore::Box::inflateFromXMLRes ( const std::string &  res)
protected

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.

◆ inflateFromXMLString()

void aurore::Box::inflateFromXMLString ( std::string_view  xml)
protected

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.

◆ isChildFocused()

virtual bool aurore::Box::isChildFocused ( )
virtual

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

◆ onChildFocusGained()

virtual void aurore::Box::onChildFocusGained ( View *  directChild,
View *  focusedView 
)
virtual

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.

Reimplemented in ScrollView, aurore::HScrollingFrame, and aurore::ScrollingFrame.

◆ onChildFocusLost()

virtual void aurore::Box::onChildFocusLost ( View *  directChild,
View *  focusedView 
)
virtual

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

Reimplemented in aurore::HScrollingFrame, and aurore::ScrollingFrame.

◆ onFocusGained()

void aurore::Box::onFocusGained ( )
overridevirtual

Fired when focus is gained.

Reimplemented from aurore::View.

Reimplemented in aurore::Button, aurore::HScrollingFrame, aurore::RecyclerCell, aurore::ScrollingFrame, and aurore::SidebarItem.

◆ onFocusLost()

void aurore::Box::onFocusLost ( )
overridevirtual

Fired when focus is lost.

Reimplemented from aurore::View.

Reimplemented in ScrollView, aurore::Button, aurore::RecyclerCell, and aurore::SidebarItem.

◆ onParentFocusGained()

void aurore::Box::onParentFocusGained ( View *  focusedView)
overridevirtual

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

Reimplemented from aurore::View.

◆ onParentFocusLost()

void aurore::Box::onParentFocusLost ( View *  focusedView)
overridevirtual

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

Reimplemented from aurore::View.

◆ onThemeChanged()

void aurore::Box::onThemeChanged ( )
overridevirtual

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.

Reimplemented from aurore::View.

Reimplemented in aurore::ContextMenu, aurore::RecyclerFrame, aurore::RecyclingGrid, and aurore::HRecyclerFrame.

◆ onWindowSizeChanged()

void aurore::Box::onWindowSizeChanged ( )
overridevirtual

Fired when the window size changes, after updating layout.

Reimplemented from aurore::View.

◆ removeView()

virtual void aurore::Box::removeView ( View *  view,
bool  free = true 
)
virtual

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

Reimplemented in aurore::HScrollingFrame, and aurore::ScrollingFrame.

◆ setAlignItems()

void aurore::Box::setAlignItems ( AlignItems  alignment)

Sets the children alignment along the Box cross axis.

Default is AUTO.

◆ setAxis()

void aurore::Box::setAxis ( Axis  axis)

The axis the children are laid out along.

◆ setColumnGap()

void aurore::Box::setColumnGap ( float  gap)

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

◆ setDefaultFocusedIndex()

void aurore::Box::setDefaultFocusedIndex ( int  index)

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

◆ setDirection()

void aurore::Box::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.

◆ setGap()

virtual void aurore::Box::setGap ( float  gap)
virtual

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

◆ setJustifyContent()

void aurore::Box::setJustifyContent ( JustifyContent  justify)

Sets the children alignment along the Box axis.

Default is FLEX_START.

◆ setLastFocusedView()

void aurore::Box::setLastFocusedView ( View *  view)

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

◆ setPadding() [1/2]

virtual void aurore::Box::setPadding ( float  padding)
virtual

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.

Reimplemented in aurore::RecyclerFrame, aurore::RecyclingGrid, and aurore::HRecyclerFrame.

◆ setPadding() [2/2]

virtual void aurore::Box::setPadding ( float  top,
float  right,
float  bottom,
float  left 
)
virtual

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.

Reimplemented in aurore::HScrollingFrame, aurore::RecyclerFrame, aurore::RecyclingGrid, aurore::HRecyclerFrame, and aurore::ScrollingFrame.

◆ setPaddingBottom()

virtual void aurore::Box::setPaddingBottom ( float  bottom)
virtual

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

Reimplemented in aurore::HScrollingFrame, aurore::RecyclerFrame, aurore::RecyclingGrid, aurore::HRecyclerFrame, and aurore::ScrollingFrame.

◆ setPaddingLeft()

virtual void aurore::Box::setPaddingLeft ( float  left)
virtual

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

Reimplemented in aurore::HScrollingFrame, aurore::RecyclerFrame, aurore::RecyclingGrid, aurore::HRecyclerFrame, and aurore::ScrollingFrame.

◆ setPaddingRight()

virtual void aurore::Box::setPaddingRight ( float  right)
virtual

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

Reimplemented in aurore::HScrollingFrame, aurore::RecyclerFrame, aurore::RecyclingGrid, aurore::HRecyclerFrame, and aurore::ScrollingFrame.

◆ setPaddingTop()

virtual void aurore::Box::setPaddingTop ( float  top)
virtual

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

Reimplemented in aurore::HScrollingFrame, aurore::RecyclerFrame, aurore::RecyclingGrid, aurore::HRecyclerFrame, and aurore::ScrollingFrame.

◆ setRowGap()

void aurore::Box::setRowGap ( float  gap)

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

◆ setWrap()

void aurore::Box::setWrap ( Wrap  wrap)

Sets the wrapping behavior for the children inside this view.

◆ willAppear()

void aurore::Box::willAppear ( bool  resetState)
overridevirtual

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

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

Reimplemented from aurore::View.

Reimplemented in ScrollView, aurore::HScrollingFrame, and aurore::ScrollingFrame.

◆ willDisappear()

void aurore::Box::willDisappear ( bool  resetState)
overridevirtual

Called when the view will disappear from the screen.

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

Reimplemented from aurore::View.


The documentation for this class was generated from the following file: