Class · aurore

aurore::View

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

class aurore::View

Description

Superclass for all the other views Lifecycle of a view is : new -> [willAppear -> willDisappear] -> delete

Users have do to the new, the rest of the lifecycle is taken care of by the library

willAppear and willDisappear can be called zero or multiple times before deletion (in case of a TabLayout for instance)

Types 1

typedef std::vector< std::shared_ptr< Action > >::iterator ActionIterator

Constructors 2

View()
virtual ~View()

Functions 221

void setScale(float scale)

Draws the view (its background, content and highlight) scaled around its centre, without laying anything out again: a pressed or focused view grown or shrunk a little. Touch hit-testing keeps the unscaled frame. XML: scale="1.05".

view.hpp:415
void setScaleX(float scale)
void setScaleY(float scale)
float getScaleX() const
float getScaleY() const
void setBackground(ViewBackground background)

How the view's background is drawn: none, the sidebar's, the backdrop, a plain colour or a gradient.

view.hpp:433
void setBackgroundLinearGradient(NVGcolor start,NVGcolor end,ViewBackground direction = ViewBackground::VERTICAL_LINEAR)

Sets a linear gradient background for the view, from start to end: top to bottom (VERTICAL_LINEAR) or left to right (HORIZONTAL_LINEAR).

view.hpp:439
void shakeHighlight(FocusDirection direction)

Shakes the focus highlight towards direction: there is nothing to go to there.

view.hpp:442
Rect getFrame()

The view's position and size on the screen, after layout (getX(), getY(), getWidth(), getHeight()).

view.hpp:445
float getX()

The position on the screen, in layout units: the parents' positions and translations added.

view.hpp:447
float getY()
Rect getLocalFrame()

The position and size in the parent, as laid out by Yoga.

view.hpp:451
float getLocalX()
float getLocalY()
float getWidth()

The size as laid out by Yoga; the height without the collapse when includeCollapse is false.

view.hpp:456
float getHeight(bool includeCollapse = true)
virtual void invalidate()

Triggers a layout of the whole view tree. Must be called after a yoga node property is changed.

Only methods that change yoga nodes properties should call this method.

view.hpp:466
virtual void onLayout()

Called when a layout pass ends on that view.

view.hpp:471
virtual View * getView(std::string id)

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.

view.hpp:480
void setWidth(float width)

Sets the preferred width of the view. Use aurore::View::AUTO to have the layout automatically resize the view.

If set to anything else than AUTO, the view is guaranteed to never shrink below the given width.

view.hpp:493
void setHeight(float height)

Sets the preferred height of the view. Use aurore::View::AUTO to have the layout automatically resize the view.

If set to anything else than AUTO, the view is guaranteed to never shrink below the given height.

view.hpp:502
void setSize(Size size)

Sets the preferred width and height of the view. Use aurore::View::AUTO to have the layout automatically resize the view.

If set to anything else than AUTO, the view is guaranteed to never shrink below the given height.

view.hpp:511
void setDimensions(float width, float height)

Shortcut to setWidth + setHeight.

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

view.hpp:518
void setWidthPercentage(float percentage)

Sets the preferred width of the view in percentage of the parent view width. Between 0.0f and 100.0f.

view.hpp:524
void setHeightPercentage(float percentage)

Sets the preferred height of the view in percentage of the parent view height. Between 0.0f and 100.0f.

view.hpp:530
void setMinWidth(float minWidth)

Sets the minimum width of the view, in pixels.

This constraint is stronger than the grow factor: the view is guaranteed to never be less than the given min width.

Use View::AUTO to disable the min width constraint.

view.hpp:540
void setMinHeight(float minHeight)

Sets the minimum height of the view, in pixels.

This constraint is stronger than the grow factor: the view is guaranteed to never be less than the given max height.

Use View::AUTO to disable the min height constraint.

view.hpp:550
void setMinWidthPercentage(float percentage)

Sets the minimum width of the view, in parent width percentage.

This constraint is stronger than the grow factor: the view is guaranteed to never be less than the given max width.

Use View::AUTO to disable the min width constraint.

view.hpp:560
void setMinHeightPercentage(float percentage)

Sets the minimum height of the view, in parent height percentage.

This constraint is stronger than the grow factor: the view is guaranteed to never be less than the given max height.

Use View::AUTO to disable the min height constraint.

view.hpp:570
void setMaxWidth(float maxWidth)

Sets the maximum width of the view, in pixels.

This constraint is stronger than the grow factor: the view is guaranteed to never be larger than the given max width.

Use View::AUTO to disable the max width constraint.

view.hpp:580
void setMaxHeight(float maxHeight)

Sets the maximum height of the view, in pixels.

This constraint is stronger than the grow factor: the view is guaranteed to never be larger than the given max height.

Use View::AUTO to disable the max height constraint.

view.hpp:590
void setMaxWidthPercentage(float percentage)

Sets the maximum width of the view, in parent width percentage.

This constraint is stronger than the grow factor: the view is guaranteed to never be larger than the given max width.

Use View::AUTO to disable the max width constraint.

view.hpp:600
void setMaxHeightPercentage(float percentage)

Sets the maximum height of the view, in parent height percentage.

This constraint is stronger than the grow factor: the view is guaranteed to never be larger than the given max height.

Use View::AUTO to disable the max height constraint.

view.hpp:610
void setGrow(float grow)

Sets the grow factor of the view, aka the percentage of remaining space to give this view, in the containing box axis. Opposite of shrink. Default is 0.0f;

view.hpp:618
void setShrink(float shrink)

Sets the shrink factor of the view, aka the percentage of space the view is allowed to shrink for if there is not enough space for everyone in the contaning box axis. Opposite of grow. Default is 1.0f;

view.hpp:626
void setMargins(float top, float right, float bottom, float left)

Sets the margin of the view, aka the space that separates this view and the surrounding ones in all 4 directions.

Use aurore::View::AUTO to have the layout automatically select the margin.

Only works with views that have parents - top level views that are pushed on the stack don't have parents.

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

view.hpp:640
void setMarginTop(float top)

Sets the top margin of the view, aka the space that separates this view and the surrounding ones.

Only works with views that have parents - top level views that are pushed on the stack don't have parents.

Use aurore::View::AUTO to have the layout automatically select the margin.

view.hpp:652
void setMarginRight(float right)

Sets the right margin of the view, aka the space that separates this view and the surrounding ones.

Only works with views that have parents - top level views that are pushed on the stack don't have parents.

Use aurore::View::AUTO to have the layout automatically select the margin.

view.hpp:664
float getMarginRight()
float getMarginLeft()
void setMarginBottom(float right)

Sets the bottom margin of the view, aka the space that separates this view and the surrounding ones.

Only works with views that have parents - top level views that are pushed on the stack don't have parents.

Use aurore::View::AUTO to have the layout automatically select the margin.

view.hpp:679
void setMarginLeft(float left)

Sets the right margin of the view, aka the space that separates this view and the surrounding ones.

Only works with views that have parents - top level views that are pushed on the stack don't have parents.

Use aurore::View::AUTO to have the layout automatically select the margin.

view.hpp:691
void setVisibility(Visibility visibility)

Sets the visibility of the view.

view.hpp:696
Visibility getVisibility()

Gets the visibility of the view.

view.hpp:701
void setPositionTop(float pos)

Sets the top position of the view, in pixels.

The behavior of this attribute changes depending on the position type of the view.

If relative, it will simply offset the view by the given amount.

If absolute, it will behave like the "display: absolute;" CSS property and move the view freely in its parent. Use 0 to snap to the parent top edge. Absolute positioning ignores padding.

Use View::AUTO to disable (not the same as 0).

view.hpp:717
void setPositionRight(float pos)

Sets the right position of the view, in pixels.

The behavior of this attribute changes depending on the position type of the view.

If relative, it will simply offset the view by the given amount.

If absolute, it will behave like the "display: absolute;" CSS property and move the view freely in its parent. Use 0 to snap to the parent right edge. Absolute positioning ignores padding.

Use View::AUTO to disable (not the same as 0).

view.hpp:733
void setPositionBottom(float pos)

Sets the bottom position of the view, in pixels.

The behavior of this attribute changes depending on the position type of the view.

If relative, it will simply offset the view by the given amount.

If absolute, it will behave like the "display: absolute;" CSS property and move the view freely in its parent. Use 0 to snap to the parent bottom edge. Absolute positioning ignores padding.

Use View::AUTO to disable (not the same as 0).

view.hpp:749
void setPositionLeft(float pos)

Sets the left position of the view, in pixels.

The behavior of this attribute changes depending on the position type of the view.

If relative, it will simply offset the view by the given amount.

If absolute, it will behave like the "display: absolute;" CSS property and move the view freely in its parent. Use 0 to snap to the parent left edge. Absolute positioning ignores padding.

Use View::AUTO to disable (not the same as 0).

view.hpp:765
void setPositionTopPercentage(float percentage)

Sets the top position of the view, in percents.

The behavior of this attribute changes depending on the position type of the view.

view.hpp:773
void setPositionRightPercentage(float percentage)

Sets the right position of the view, in percents.

The behavior of this attribute changes depending on the position type of the view.

view.hpp:781
void setPositionBottomPercentage(float percentage)

Sets the bottom position of the view, in percentage.

The behavior of this attribute changes depending on the position type of the view.

view.hpp:789
void setPositionLeftPercentage(float percentage)

Sets the left position of the view, in percents.

The behavior of this attribute changes depending on the position type of the view.

view.hpp:797
void setPositionType(PositionType type)

Sets the "position type" of the view, aka the behavior of the 4 position attributes.

Default is RELATIVE.

view.hpp:805
void setId(std::string id)

Sets the id of the view.

view.hpp:810
const std::string & getId() const

The view's id (setId, or the XML's id attribute), "" for none.

view.hpp:815
void setAlignSelf(AlignSelf align)

Overrides align items of the parent box.

Default is AUTO.

view.hpp:825
void setBoxSizing(BoxSizing sizing)

Sets what the width and height of the view measure.

Default is BORDER_BOX.

view.hpp:832
void setLineColor(NVGcolor color)

Sets the line color for the view. To be used with setLineTop(), setLineRight()...

The "line" is separate from the shape "border".

view.hpp:844
void setLineTop(float thickness)

Sets the top line thickness. Use setLineColor() to change the line color.

The "line" is separate from the shape "border".

view.hpp:857
void setLineRight(float thickness)

Sets the right line thickness. Use setLineColor() to change the line color.

The "line" is separate from the shape "border".

view.hpp:868
void setLineBottom(float thickness)

Sets the bottom line thickness. Use setLineColor() to change the line color.

The "line" is separate from the shape "border".

view.hpp:879
void setLineLeft(float thickness)

Sets the left line thickness. Use setLineColor() to change the line color.

The "line" is separate from the shape "border".

view.hpp:890
void setBackgroundColor(NVGcolor color)

Sets the view shape background color.

view.hpp:898
void setBorderColor(NVGcolor color)

Sets the view shape border color.

view.hpp:909
ViewBackground getBackground() const
NVGcolor getBackgroundColor() const
NVGcolor getBorderColor() const
void setBorderThickness(float thickness)

Sets the view shape border thickness.

view.hpp:923
float getBorderThickness()
void setCornerRadius(float radius)

Sets the view shape corner radius (uniform). 0 means no rounded corners.

view.hpp:939
void setCornerRadius(float topLeft,float topRight,float bottomRight,float bottomLeft)

Sets the view shape corner radii individually. Order: top-left, top-right, bottom-right, bottom-left.

view.hpp:954
float getCornerRadius()
void setThemeArea(ThemeArea area)

The area of the theme's decorations this view is (docs/themes.md, Decorations): HEADER, SIDEBAR or DIALOG. Its picture (backdrop.header, .sidebar, .dialog) is drawn over the view's background, under its content, in its corners. A DIALOG in a translucent colour over a theme's background image has that image drawn under it first, dimmed by aurore/backdrop, so that it does not show the screen behind it. A HEADER is drawn across the whole width of its parent (an AppletFrame), when that parent is a screen's (not in a dialog). NONE by default; the core's header, sidebar, dialogs and dropdowns are set.

view.hpp:979
ThemeArea getThemeArea() const
void setShadowType(ShadowType type)

Sets the view shape shadow type. Default is NONE.

view.hpp:986
void setShadowVisibility(bool visible)

Sets the shadow visibility.

view.hpp:994
void setHideHighlightBackground(bool hide)

If set to true, the highlight background will be hidden for this view (the white rectangle that goes behind the view, replacing the usual background shape).

view.hpp:1003
void setHideHighlightBorder(bool hide)

If set to true, the highlight border will be hidden for this view.

view.hpp:1011
void setHideHighlight(bool hide)

If set to true, the highlight will be hidden for this view.

view.hpp:1019
void setHideClickAnimation(bool hide)

No click animation when the view is clicked.

view.hpp:1025
void setHighlightPadding(float padding)

Sets the highlight padding of the view, aka the space between the highlight rectangle and the view. The highlight rect is enlarged, the view is untouched.

view.hpp:1034
void setHighlightCornerRadius(float radius)

Sets the highlight rectangle corner radius.

view.hpp:1042
virtual View * getNearestView(std::string id)

Returns the "nearest" view with the corresponding id, or nullptr if none has been found. "Nearest" means the closest in the vicinity of this view. The siblings are searched as well as its children.

Research is done by traversing the tree upwards, starting from this view. The current algorithm is very inefficient.

view.hpp:1057
virtual void handleXMLElement(tinyxml2::XMLElement *element)

Handles a child XML element.

You can redefine this method to handle child XML like as you want in your own views.

If left unimplemented, will throw an exception because raw views cannot handle child XML elements (Boxes can).

view.hpp:1115
virtual void applyXMLAttributes(tinyxml2::XMLElement *element)

Applies the attributes of the given XML element to the view.

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

view.hpp:1123
virtual bool applyXMLAttribute(std::string name, std::string value)

Applies the given attribute to the view.

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

view.hpp:1131
void registerAutoXMLAttribute(std::string name,AutoAttributeHandler handler)

Register a new XML attribute with the given name and handler method. You can have multiple attributes registered with the same name but different types / handlers, except if the type is string.

The method will be called if the attribute has the value "auto".

view.hpp:1140
void registerPercentageXMLAttribute(std::string name,FloatAttributeHandler handler)

Register a new XML attribute with the given name and handler method. You can have multiple attributes registered with the same name but different types / handlers, except if the type is string.

The method will be called if the attribute has a percentage value (an integer with "%" suffix). The given float value is guaranteed to be between 0.0f and 1.0f.

view.hpp:1150
void registerFloatXMLAttribute(std::string name,FloatAttributeHandler handler)

Register a new XML attribute with the given name and handler method. You can have multiple attributes registered with the same name but different types / handlers, except if the type is string.

The method will be called if the attribute has an integer, float, @style or "px" value.

view.hpp:1159
void registerStringXMLAttribute(std::string name,StringAttributeHandler handler)

Register a new XML attribute with the given name and handler method. You can have multiple attributes registered with the same name but different types / handlers, except if the type is string.

The method will be called if the attribute has a string or @i18n value.

If you use string as a type, you can only have one handler for the attribute.

view.hpp:1170
void registerColorXMLAttribute(std::string name,ColorAttributeHandler handler)

Register a new XML attribute with the given name and handler method. You can have multiple attributes registered with the same name but different types / handlers, except if the type is string.

The method will be called if the attribute has a color value ("#XXXXXX" or "#XXXXXXXX") or a @theme value.

view.hpp:1180
void registerBoolXMLAttribute(std::string name,BoolAttributeHandler handler)

Register a new XML attribute with the given name and handler method. You can have multiple attributes registered with the same name but different types / handlers, except if the type is string.

The method will be called if the attribute has a boolean value ("true" or "false").

view.hpp:1189
void registerFilePathXMLAttribute(std::string name,FilePathAttributeHandler handler)

Register a new XML attribute with the given name and handler method. You can have multiple attributes registered with the same name but different types / handlers, except if the type is string.

The method will be called if the attribute has a file path value ("@res/" or raw path).

view.hpp:1198
bool isXMLAttributeValid(std::string attributeName)

Returns if the given XML attribute name is valid for that view.

view.hpp:1215
void setMaximumAllowedXMLElements(unsigned max)

Sets the maximum number of allowed children XML elements when using a view of that class in an XML file.

view.hpp:1265
unsigned getMaximumAllowedXMLElements()
void setInFadeAnimation(bool translucent)

If set to true, will force the view to be translucent.

view.hpp:1272
void setFocusable(bool focusable)

Sets the view to be focusable.

Required to be able to use actions that need focus on that view (such as an A press).

view.hpp:1280
bool isFocusable()

Whether the view takes the focus: focusable, and visible.

view.hpp:1286
void removeFromSuperView(bool free = true)

Removes view from it's parent

view.hpp:1291
void setFocusSound(enum Sound sound)

Sets the sound to play when this view gets focused.

view.hpp:1296
virtual enum Sound getFocusSound()
void detach()

Sets the detached flag to true. This action is irreversible.

A detached view will, as the name suggests, not be attached to their parent Yoga node. That means that invalidation and layout need to be taken care of manually by the parent.

detach() must be called before adding the view to the parent.

view.hpp:1313
bool isDetached()
void setDetachedPosition(float x, float y)

Sets the position of the view, if detached.

view.hpp:1321
void setDetachedPositionX(float x)

Sets the position X of the view, if detached.

view.hpp:1326
void setDetachedPositionY(float y)

Sets the position Y of the view, if detached.

view.hpp:1331
Point getDetachedPosition() const

Gets detached position of the view.

view.hpp:1336
void setParent(Box *parent, void *parentUserdata = nullptr)

The box this view is in (Box::addView sets it; parentUserdata is the box's own).

view.hpp:1342
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().

view.hpp:1354
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)

Registers an action with the given parameters. The listener will be fired when the user presses the key when the view is focused.

The listener should return true if the action was consumed, false otherwise. The sound will only be played if the listener returned true.

A hidden action will not show up in the bottom-right hints.

Returns the identifier for the action, so it can be unregistered later on. Returns ACTION_NONE if the action was not registered.

view.hpp:1369
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.

view.hpp:1372
ActionIdentifier registerAction(AuroreKeyCombination key,const ActionListener &actionListener,bool allowRepeating = false)

An action on a keyboard key (a combination with modifiers): no hint, no sound.

view.hpp:1375
void func(AuroreKeyCombination key)
void unregisterAction(ActionIdentifier identifier)

Unregisters an action with the given identifier.

view.hpp:1382
void registerClickAction(const ActionListener &actionListener)

Shortcut to register a generic "A OK" click action.

view.hpp:1387
void updateActionHint(enum ControllerButton button,const std::string &hintText)

Changes the hint of the action on button.

view.hpp:1390
void setActionAvailable(enum ControllerButton button, bool available)

Turns the action on button on or off (an action off runs nothing and shows no hint).

view.hpp:1392
void setActionsAvailable(bool available) const

The same for every action of the view.

view.hpp:1394
void setActionHidden(enum ControllerButton button, bool hidden)

Shows or hides the hint of the action on button (the action still works), as registerAction's hidden but while the view lives.

view.hpp:1400
void resetClickAnimation()
void playClickAnimation(bool reverse = false,bool animateBack = true,bool force = false)

Plays the click animation (the flash over the view).

view.hpp:1404
std::string getClassString() const

The view's class name ("Label", "Box"…).

view.hpp:1407
std::string describe() const

The class name and the id, for logs: Label (id="title").

view.hpp:1410
YGNode * getYGNode()

The view's Yoga node.

view.hpp:1413
const std::vector< std::shared_ptr< Action > > & getActions()

The actions registered on the view.

view.hpp:1416
const std::vector< GestureRecognizer * > & getGestureRecognizers()

Get the vector of all gesture recognizers attached to that view.

view.hpp:1421
void interruptGestures(bool onlyIfUnsureState)

Interrupt every recognizer on this view. If onlyIfUnsureState == true, only recognizers with current state UNSURE will be interupted

view.hpp:1428
void addGestureRecognizer(GestureRecognizer *recognizer)

Add new gesture recognizer on this view.

view.hpp:1433
bool removeGestureRecognizer(GestureRecognizer *recognizer)

Removes a recognizer added with addGestureRecognizer and deletes it (false if the view did not have it). Not from one of its own callbacks: the gesture being handled still uses it.

view.hpp:1440
Sound gestureRecognizerRequest(TouchState touch,MouseState mouse,View *firstResponder)

Called each frame when touch is registered.

Returns

sound to play invoked by touch recognizers.

view.hpp:1447
virtual void frame(FrameContext *ctx)

Called each frame Do not override it to draw your view, override draw() instead

view.hpp:1454
void frameHighlight(FrameContext *ctx)

Called each frame

view.hpp:1459
virtual void draw(NVGcontext *vg,float x,float y,float width,float height,Style style,FrameContext *ctx) =0

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

view.hpp:1466
virtual void willAppear(bool resetState = false)

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

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

view.hpp:1475
virtual void willDisappear(bool resetState = false)

Called when the view will disappear from the screen.

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

view.hpp:1487
virtual void onShowAnimationEnd()

Called when the show() animation (fade in) ends

view.hpp:1496
virtual void show(std::function< void(void)> cb)

Shows the view with a fade in animation.

view.hpp:1501
virtual void show(std::function< void(void)> cb,bool animate,float animationDuration)

Shows the view with a fade in animation, or no animation at all.

view.hpp:1506
virtual float getShowAnimationDuration(TransitionAnimation animation)

Returns the duration of the view show / hide animation.

view.hpp:1511
void collapse(bool animated = true)

Hides the view in a collapse animation

view.hpp:1516
bool isCollapsed()

Whether collapse() hid the view.

view.hpp:1519
void setAlpha(float alpha)

The view's opacity, 0 to 1 (a transition when its style has one).

view.hpp:1522
void expand(bool animated = true)

Shows the view in a expand animation (opposite of collapse)

view.hpp:1528
virtual void hide(std::function< void(void)> cb)

Hides the view with a fade out animation.

view.hpp:1533
virtual void hide(std::function< void(void)> cb,bool animate,float animationDuration)

Hides the view with a fade out animation, or no animation at all.

view.hpp:1538
bool isHidden()

Whether hide() hid the view.

view.hpp:1541
virtual bool isTranslucent()

Is this view translucent?

If you override it please return

|| View::isTranslucent() to keep the fadeIn transition

view.hpp:1550
bool isFocused()

Whether the view has the focus.

view.hpp:1553
virtual View * getDefaultFocus()

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
view.hpp:1571
virtual View * hitTest(Point point)

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.

view.hpp:1580
virtual View * getNextFocus(FocusDirection direction,View *currentView)

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

view.hpp:1590
void setCustomNavigationRoute(FocusDirection direction, View *target)

Sets a custom navigation route from this view to the target one.

view.hpp:1595
void setCustomNavigationRoute(FocusDirection direction,std::string targetId)

Sets a custom navigation route from this view to the target one, by ID. The final target view will be the "nearest" with the given ID.

Resolution of the ID to View is made when the navigation event occurs, not when the route is registered.

view.hpp:1604
bool hasCustomNavigationRouteByPtr(FocusDirection direction)
bool hasCustomNavigationRouteById(FocusDirection direction)
View * getCustomNavigationRoutePtr(FocusDirection direction)
std::string getCustomNavigationRouteId(FocusDirection direction)
virtual void onFocusGained()

Fired when focus is gained.

view.hpp:1615
virtual void onFocusLost()

Fired when focus is lost.

view.hpp:1620
virtual void onParentFocusGained(View *focusedView)

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

view.hpp:1625
virtual void onParentFocusLost(View *focusedView)

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

view.hpp:1631
virtual void onWindowSizeChanged()

Fired when the window size changes, after updating layout.

view.hpp:1637
GenericEvent * getFocusEvent()

Fired with the view when it gains the focus.

view.hpp:1643
GenericEvent * getFocusLostEvent()

Fired with the view when it loses the focus.

view.hpp:1645
virtual float getAlpha(bool child = false)

The opacity drawn: the view's alpha times its parents'.

view.hpp:1650
float getClickAlpha()
void overrideTheme(Theme *newTheme)

Forces this view and its children to use the specified theme.

view.hpp:1658
void setCulled(bool culled)

Enables / disable culling for that view.

To disable culling for all child views of a Box use setCullingEnabled on the box.

view.hpp:1666
bool isCulled()
void setAspectRatio(float value)

The width over the height, kept by the layout (values <= 0 are ignored).

view.hpp:1677
float getAspectRatio()
void setBackgroundCornerRadii(float topLeft,float topRight,float bottomRight,float bottomLeft)

Sets the background corner radii of the view. Only for vertical linear style.

view.hpp:1684
void setTranslationY(float translateY)

Sets the Y translation of this view.

Translation is applied after the layout phase. Use relative position and setPosition methods if possible instead.

view.hpp:1695
void setTranslationX(float translateX)

Sets the X translation of this view.

Translation is applied after the layout phase. Use relative position and setPosition methods if possible instead.

view.hpp:1703
void setWireframeEnabled(bool wireframe)

Wireframe mode allows you to see the view size and margins (and padding if applicable) directly in your app.

Useful to diagnose views misplacements or display bugs.

view.hpp:1711
bool isWireframeEnabled()
AppletFrameItem * getAppletFrameItem()
void updateAppletFrameItem()
bool getClipsToBounds() const

Whether the children are clipped to the view's frame when drawn.

view.hpp:1737
void setClipsToBounds(bool value)
virtual AppletFrame * getAppletFrame()

The AppletFrame the view is in, or nullptr.

view.hpp:1748
void present(View *view)

Pushes view as the content of the view's AppletFrame (a page inside the frame).

view.hpp:1751
virtual void dismiss(std::function< void(void)> cb = [] {})

Pops the AppletFrame's content back to the one before, then runs cb.

view.hpp:1753
std::weak_ptr< void > aliveToken()

A token that expires when this view is deleted. A task that comes back to the view from another thread captures it by value and checks it on the UI thread, before it touches the view:

aurore::async([this, alive = aliveToken()] { auto result = work(); // not this: the view may be gone aurore::sync([this, alive, result] { if (alive.expired()) return; ... }); });

Checked on another thread it only says the view was alive then.

view.hpp:1771
void ptrLock()

Keeps the view from being deleted by the deletion pool while a pointer to it is in use (counted: one ptrUnlock() per ptrLock()).

view.hpp:1774
void ptrUnlock()
bool isPtrLocked()

Whether a ptrLock() holds the view.

view.hpp:1777
void freeView()

Deletes the view at the end of the frame (Application::addToFreeQueue).

view.hpp:1779
Activity * getParentActivity()

The activity the view is in, through its parents; nullptr when none.

view.hpp:1782
void setParentActivity(Activity *activity)
bool setStateStyle(StyleState state,const std::string &property,const std::string &value)

While state is on, the style property property takes value (as XML writes it: "#rrggbb", "rgba(…)", "@theme/…", "4", "@style/…"), and goes back to what it was when no state styles it any more. XML: focus:backgroundColor="@theme/aurore/accent", pressed:scale="0.96", disabled:alpha="0.4", hover:borderColor="#ffffff". A "@theme/" value is read when the state comes on, so it follows the theme. Returns false for a property the view does not have.

view.hpp:1799
void setStyleState(StyleState state, bool on)

Turns a style state on or off. FOCUS, PRESSED and HOVER follow the focus, the click animation and the mouse by themselves; DISABLED is the app's (a Button sets it from its ButtonState).

view.hpp:1806
bool hasStyleState(StyleState state)
bool setTransition(const std::string &spec)

Animates the changes of style properties instead of applying them at once, the state styles' as well as the setters' (setBackgroundColor…): "backgroundColor 150ms ease-out, scale 120ms" or "all 200ms". The easing is linear, ease, ease-in, ease-out, ease-in-out, or one of tweeny's (quadraticOut, backOut…). Skipped while the app asks for reduced motion (Application::getReduceMotion). An empty spec removes them. XML: transition="…". Returns false (and changes nothing) for a spec it cannot read.

view.hpp:1819
virtual bool getStyleProperty(const std::string &name,StyleValue *value)

The style properties the states and transitions work on, by name: backgroundColor, borderColor, lineColor (colours), borderThickness, cornerRadius, alpha, scale (numbers); a Label adds textColor, a Rectangle color, a Button textColor. Only properties that are drawn, never laid out. A subclass adds its own by overriding both and calling the base for the others.

view.hpp:1829
virtual bool setStyleProperty(const std::string &name,const StyleValue &value)
void keepSubscription(Subscription &&subscription)

Keeps subscription (an Observable's) as long as the view lives: what binds a view to an Observable ends with the view.

view.hpp:1836
bool bind(const std::string &spec)

Binds a property of the view to an observable of the data models (Application::registerModel, Activity::registerModel): "text: profile.name, visible: profile.online". Properties: text (a string, int or float observable; views that have a text: Label, Button, cells), visible (bool: VISIBLE or GONE), and every style property (float or NVGcolor). Returns false for a spec it cannot read; a model not registered yet is looked up again when the view joins an activity. XML: bind="…".

view.hpp:1848
virtual bool setBoundText(const std::string &text)

Sets the view's text, for bind="text: …"; false when it has none.

view.hpp:1853
void setAccessibilityRole(AccessibilityRole role)

What the view is and what it says, for the focus announcer (Application::setFocusAnnouncer). By default a Label says its text, a Button and the cells their title, a focusable Box the texts shown in it. XML: accessibilityRole="button", accessibilityLabel="@i18n/…".

view.hpp:1861
AccessibilityRole getAccessibilityRole()
void setAccessibilityLabel(const std::string &label)
std::string getAccessibilityLabel()
void setAccessibilityValue(const std::string &value)

What the view is set to, said after its role: a cell's detail, "on" or "off" for a BooleanCell, "40%" for a slider. XML: accessibilityValue="…".

view.hpp:1872
std::string getAccessibilityValue()
void setAccessibilitySelected(bool selected)

The chosen one of its kind (a picker's current row, a checked radio cell): "selected" is said after its value.

view.hpp:1879
bool isAccessibilitySelected()
virtual bool getAccessibilityPosition(int *index, int *count)

Where the view is among the rows it belongs to, from 1, said as "3 of 10": a recycler's cell its row in its section, a cell, a button or a tab among the focusable views of its parent. False when that says nothing (a view alone, a label).

view.hpp:1888
virtual std::string getAccessibilityDescription()

What is announced when the view takes the focus: its label, then its role, its value and state in the app's language and its place ("Wi-Fi, switch, on, 2 of 5"; "Save, button, disabled").

view.hpp:1895
std::string getAccessibilityText()

The texts shown in the view, for a label made of them: its own label for a view with no children, else the labels of the views under it (a focusable one left out: it speaks for itself), joined by ", ". Nothing for a hidden view.

view.hpp:1903
void announceAccessibilityValue()

Says the view's value and state again (Application::announce) when it has the focus and the user pressed or touched something in the last 2 s (not a value changing on its own): called by the views whose value changes in place (a toggle flipped, a slider moved, a detail changed).

view.hpp:1911
void resolveBindings(Activity *activity = nullptr)

Resolves the bindings left pending in this view and its children against activity's models (its own activity's when nullptr), then the application's. Called when a tree joins an activity.

view.hpp:1918
virtual void onTextScaleChanged()

Called on every view of the screens when the text scale changes (Application::setTextScale): a view that measures text marks itself dirty here.

view.hpp:1925
bool setThemeColor(const std::string &property, const std::string &key)

Draws the style property property (backgroundColor, textColor…, see getStyleProperty) in the theme colour key ("aurore/text"), now and again each time the theme changes (a theme file, the light or dark variant). XML does it for every "@theme/…" colour. A colour the app sets on the property afterwards (setTextColor…) replaces the key. An empty key only forgets the property's key (the colour stays). Returns false for a property the view does not have or an unknown key.

view.hpp:1936
std::string getThemeColor(const std::string &property)

The key setThemeColor gave property, "" when it has none.

view.hpp:1941
virtual void onThemeChanged()

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.

view.hpp:1951

Static functions 14

static void setHighlightGlide(bool glide)

Whether the highlight's border glides from the view that had the focus to the next one (140 ms), rather than jumping. On by default.

view.hpp:407
static View * createFromXMLString(std::string_view xml)

Creates a view from the given XML file content.

The method handleXMLElement() is executed for each child node in the XML.

Uses the internal lookup table to instantiate the views. Use registerXMLView() to add your own views to the table so that you can use them in your own XML files.

view.hpp:1068
static View * createFromXMLElement(tinyxml2::XMLElement *element)

Creates a view from the given XML element (node and attributes).

Elements nest at most 64 levels deep, the files aurore:View includes counted (a file including itself is an error, not a stack overflow).

The method handleXMLElement() is executed for each child node in the XML.

Uses the internal lookup table to instantiate the views. Use registerXMLView() to add your own views to the table so that you can use them in your own XML files.

view.hpp:1082
static View * createFromXMLFile(std::string path)

Creates a view from the given XML file path.

The method handleXMLElement() is executed for each child node in the XML.

Uses the internal lookup table to instantiate the views. Use registerXMLView() to add your own views to the table so that you can use them in your own XML files.

view.hpp:1093
static View * createFromXMLResource(std::string name)

Creates a view from the given XML resource file name.

The method handleXMLElement() is executed for each child node in the XML.

Uses the internal lookup table to instantiate the views. Use registerXMLView() to add your own views to the table so that you can use them in your own XML files.

view.hpp:1104
static std::shared_ptr< tinyxml2::XMLDocument > getXMLCache(std::string_view path)

Get the XML document for the XML file, creating a new one if none is cached.

view.hpp:1203
static void forgetXMLCache(const std::string &path)

Drops the cached document of an XML file, which is then read again (hot reload). The document stays in memory: views made from it may still point into it.

view.hpp:1210
static std::string describeXMLError(tinyxml2::XMLDocument *document,const std::string &source = "")

Describes the document's parse error for a fatal message: where it comes from (the path, or the resource being loaded), the line and tinyxml2's own text.

view.hpp:1222
static std::string describeXMLLocation(const tinyxml2::XMLElement *element)

Where an element is: "file:line" (the path or the resource it was loaded from), "line N" for an XML string.

view.hpp:1234
static void fatalXML(const std::string &message)

fatal() for an XML error, the message prefixed with where the element being read is ("file:line: <tag>: ").

view.hpp:1240
static std::string closestXMLName(const std::string &name,const std::vector< std::string > &known)

The known name closest to name (a typo's), or "" when none is close.

view.hpp:1245
template <typename T>static std::string listXMLValues(const std::unordered_map< std::string, T > &values)

An enumeration's values, sorted, for an error message.

view.hpp:1249
static std::string getStringXMLAttributeValue(std::string value)

Resolves the value of the given XML attribute string. Applies i18n if the value is an "@i18n/" string, returns the string as it is otherwise.

view.hpp:1720
static std::string getFilePathXMLAttributeValue(std::string value)

Resolves the value of the given XML attribute file path. Returns the full path of the resource if it starts with "@res/", returns the path as it is otherwise. A resource path with ".." is refused: "".

view.hpp:1727

Attributes 1

Animatable alpha = 1.0f

Static attributes 3

static constexpr constexpr float AUTO = NAN

A size or position left to the layout (auto in XML).

view.hpp:422
static std::string CUSTOM_RESOURCES_PATH

A folder whose xml/ files replace the built-in ones of the same name in createFromXMLResource(); one that cannot be read is logged, and the built-in one used.

view.hpp:427
static std::string currentXMLResource

The XML resource being loaded, named in the parse errors of a document given as a string.

view.hpp:1228

Protected functions 13

NVGcolor a(NVGcolor color)

Helper functions to apply this view's alpha to a color.

view.hpp:368
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()

Should the hint alpha be animated when pushing the view?

view.hpp:397
virtual AccessibilityRole getDefaultAccessibilityRole()

The view's own role and label when the app gave none.

view.hpp:1957
virtual std::string getDefaultAccessibilityLabel()
virtual std::string getDefaultAccessibilityValue()
virtual bool getDefaultAccessibilitySelected()
bool transitionStyle(const char *name, const StyleValue &to)

Called by a style property's setter before it changes the value: true when a transition takes the change over (the setter then returns without changing anything). Cheap for a view with no transition.

view.hpp:1967

Protected attributes 8

Animatable collapseState = 1.0f
bool focused = false
Activity * parentActivity = nullptr
Box * parent = nullptr
GenericEvent focusEvent
GenericEvent focusLostEvent
YGNode * ygNode
std::string id = ""

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