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

#include <aurore/core/view.hpp>

Inheritance diagram for aurore::View:
CadranDigits CadranIcon CadranSwatch HeaderSetting LoadingBar QrView TabBadge aurore::Box aurore::CheckBox aurore::Image aurore::Label aurore::Padding aurore::ProgressSpinner aurore::Rectangle aurore::SidebarSeparator cadran::Switch cadran::kit::Bar cadran::kit::Mark

Public Types

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

Public Member Functions

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 ()
 
virtual View * getView (std::string id)
 
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 handleXMLElement (tinyxml2::XMLElement *element)
 
virtual void applyXMLAttributes (tinyxml2::XMLElement *element)
 
virtual bool applyXMLAttribute (std::string name, std::string value)
 
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 draw (NVGcontext *vg, float x, float y, float width, float height, Style style, FrameContext *ctx)=0
 
virtual void willAppear (bool resetState=false)
 
virtual void willDisappear (bool resetState=false)
 
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.
 
virtual View * getDefaultFocus ()
 
virtual View * hitTest (Point point)
 
virtual View * getNextFocus (FocusDirection direction, View *currentView)
 
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)
 
virtual void onFocusGained ()
 
virtual void onFocusLost ()
 
virtual void onParentFocusGained (View *focusedView)
 
virtual void onParentFocusLost (View *focusedView)
 
virtual void onWindowSizeChanged ()
 
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)
 
virtual void onThemeChanged ()
 

Static Public Member Functions

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)
 

Public Attributes

Animatable alpha = 1.0f
 

Static Public Attributes

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 Member Functions

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 getDefaultAccessibilityLabel ()
 
virtual std::string getDefaultAccessibilityValue ()
 
virtual bool getDefaultAccessibilitySelected ()
 
bool transitionStyle (const char *name, const StyleValue &to)
 

Protected Attributes

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

Friends

class Application
 

Detailed 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)

Member Typedef Documentation

◆ ActionIterator

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

Constructor & Destructor Documentation

◆ View()

aurore::View::View ( )

◆ ~View()

virtual aurore::View::~View ( )
virtual

Member Function Documentation

◆ a() [1/2]

NVGcolor aurore::View::a ( NVGcolor  color)
protected

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

◆ a() [2/2]

NVGpaint aurore::View::a ( NVGpaint  paint)
protected

◆ addGestureRecognizer()

void aurore::View::addGestureRecognizer ( GestureRecognizer *  recognizer)

Add new gesture recognizer on this view.

◆ aliveToken()

std::weak_ptr< void > aurore::View::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.

◆ animateHint()

virtual bool aurore::View::animateHint ( )
inlineprotectedvirtual

Should the hint alpha be animated when pushing the view?

◆ announceAccessibilityValue()

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

◆ applyXMLAttribute()

virtual bool aurore::View::applyXMLAttribute ( std::string  name,
std::string  value 
)
virtual

Applies the given attribute to the view.

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

Reimplemented in aurore::Box, and aurore::IconButton.

◆ applyXMLAttributes()

virtual void aurore::View::applyXMLAttributes ( tinyxml2::XMLElement *  element)
virtual

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.

◆ bind()

bool aurore::View::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="…".

◆ closestXMLName()

static std::string aurore::View::closestXMLName ( const std::string &  name,
const std::vector< std::string > &  known 
)
static

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

◆ collapse()

void aurore::View::collapse ( bool  animated = true)

Hides the view in a collapse animation

◆ createFromXMLElement()

static View * aurore::View::createFromXMLElement ( tinyxml2::XMLElement *  element)
static

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.

◆ createFromXMLFile()

static View * aurore::View::createFromXMLFile ( std::string  path)
static

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.

◆ createFromXMLResource()

static View * aurore::View::createFromXMLResource ( std::string  name)
static

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.

◆ createFromXMLString()

static View * aurore::View::createFromXMLString ( std::string_view  xml)
static

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.

◆ describe()

std::string aurore::View::describe ( ) const

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

◆ describeXMLError()

static std::string aurore::View::describeXMLError ( tinyxml2::XMLDocument *  document,
const std::string &  source = "" 
)
static

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.

◆ describeXMLLocation()

static std::string aurore::View::describeXMLLocation ( const tinyxml2::XMLElement *  element)
static

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

◆ detach()

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

◆ dismiss()

virtual void aurore::View::dismiss ( std::function< void(void)>  cb = [] {})
virtual

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

◆ draw()

◆ expand()

void aurore::View::expand ( bool  animated = true)

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

◆ fatalXML()

static void aurore::View::fatalXML ( const std::string &  message)
static

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

◆ forgetXMLCache()

static void aurore::View::forgetXMLCache ( const std::string &  path)
static

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.

◆ frame()

virtual void aurore::View::frame ( FrameContext *  ctx)
virtual

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

Reimplemented in cadran::kit::Chip.

◆ frameHighlight()

void aurore::View::frameHighlight ( FrameContext *  ctx)

Called each frame

◆ freeView()

void aurore::View::freeView ( )

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

◆ func()

void aurore::View::func ( AuroreKeyCombination  key)

◆ gestureRecognizerRequest()

Sound aurore::View::gestureRecognizerRequest ( TouchState  touch,
MouseState  mouse,
View *  firstResponder 
)

Called each frame when touch is registered.

Returns
sound to play invoked by touch recognizers.

◆ getAccessibilityDescription()

virtual std::string aurore::View::getAccessibilityDescription ( )
virtual

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").

◆ getAccessibilityLabel()

std::string aurore::View::getAccessibilityLabel ( )

◆ getAccessibilityPosition()

virtual bool aurore::View::getAccessibilityPosition ( int *  index,
int *  count 
)
virtual

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).

◆ getAccessibilityRole()

AccessibilityRole aurore::View::getAccessibilityRole ( )

◆ getAccessibilityText()

std::string aurore::View::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.

◆ getAccessibilityValue()

std::string aurore::View::getAccessibilityValue ( )

◆ getAction() [1/2]

ActionIterator aurore::View::getAction ( ActionIdentifier  identifier)

The action registered under identifier, or getActions().end().

◆ getAction() [2/2]

template<class ButtonType >
ActionIterator aurore::View::getAction ( ButtonType  button)

◆ getActions()

const std::vector< std::shared_ptr< Action > > & aurore::View::getActions ( )

The actions registered on the view.

◆ getAlpha()

virtual float aurore::View::getAlpha ( bool  child = false)
virtual

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

◆ getAppletFrame()

virtual AppletFrame * aurore::View::getAppletFrame ( )
virtual

The AppletFrame the view is in, or nullptr.

Reimplemented in aurore::Dialog, and aurore::Dropdown.

◆ getAppletFrameItem()

AppletFrameItem * aurore::View::getAppletFrameItem ( )
inline

◆ getAspectRatio()

float aurore::View::getAspectRatio ( )

◆ getBackground()

ViewBackground aurore::View::getBackground ( ) const
inline

◆ getBackgroundColor()

NVGcolor aurore::View::getBackgroundColor ( ) const
inline

◆ getBorderColor()

NVGcolor aurore::View::getBorderColor ( ) const
inline

◆ getBorderThickness()

float aurore::View::getBorderThickness ( )
inline

◆ getClassString()

std::string aurore::View::getClassString ( ) const

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

◆ getClickAlpha()

float aurore::View::getClickAlpha ( )
inline

◆ getClipsToBounds()

bool aurore::View::getClipsToBounds ( ) const
inline

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

◆ getCornerRadius()

float aurore::View::getCornerRadius ( )
inline

◆ getCustomNavigationRouteId()

std::string aurore::View::getCustomNavigationRouteId ( FocusDirection  direction)

◆ getCustomNavigationRoutePtr()

View * aurore::View::getCustomNavigationRoutePtr ( FocusDirection  direction)

◆ getDefaultAccessibilityLabel()

virtual std::string aurore::View::getDefaultAccessibilityLabel ( )
inlineprotectedvirtual

◆ getDefaultAccessibilityRole()

virtual AccessibilityRole aurore::View::getDefaultAccessibilityRole ( )
inlineprotectedvirtual

◆ getDefaultAccessibilitySelected()

virtual bool aurore::View::getDefaultAccessibilitySelected ( )
inlineprotectedvirtual

Reimplemented in aurore::RadioCell, and aurore::SidebarItem.

◆ getDefaultAccessibilityValue()

virtual std::string aurore::View::getDefaultAccessibilityValue ( )
inlineprotectedvirtual

◆ getDefaultFocus()

virtual View * aurore::View::getDefaultFocus ( )
virtual

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 in ScrollView, aurore::Box, aurore::SliderCell, aurore::ContextMenu, aurore::HScrollingFrame, aurore::RecyclingGrid, aurore::HRecyclerFrame, aurore::ScrollingFrame, and aurore::Slider.

◆ getDetachedPosition()

Point aurore::View::getDetachedPosition ( ) const
inline

Gets detached position of the view.

◆ getFilePathXMLAttributeValue()

static std::string aurore::View::getFilePathXMLAttributeValue ( std::string  value)
static

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: "".

◆ getFocusEvent()

GenericEvent * aurore::View::getFocusEvent ( )

Fired with the view when it gains the focus.

◆ getFocusLostEvent()

GenericEvent * aurore::View::getFocusLostEvent ( )

Fired with the view when it loses the focus.

◆ getFocusSound()

virtual enum Sound aurore::View::getFocusSound ( )
virtual

◆ getFrame()

Rect aurore::View::getFrame ( )

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

◆ getGestureRecognizers()

const std::vector< GestureRecognizer * > & aurore::View::getGestureRecognizers ( )

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

◆ getHeight()

float aurore::View::getHeight ( bool  includeCollapse = true)

◆ getId()

const std::string & aurore::View::getId ( ) const
inline

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

◆ getLocalFrame()

Rect aurore::View::getLocalFrame ( )

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

◆ getLocalX()

float aurore::View::getLocalX ( )

◆ getLocalY()

float aurore::View::getLocalY ( )

◆ getMarginLeft()

float aurore::View::getMarginLeft ( )

◆ getMarginRight()

float aurore::View::getMarginRight ( )

◆ getMaximumAllowedXMLElements()

unsigned aurore::View::getMaximumAllowedXMLElements ( )

◆ getNearestView()

virtual View * aurore::View::getNearestView ( std::string  id)
virtual

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.

◆ getNextFocus()

virtual View * aurore::View::getNextFocus ( FocusDirection  direction,
View *  currentView 
)
virtual

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 in ScrollView, aurore::Box, aurore::HScrollingFrame, aurore::RecyclerContentBox, aurore::RecyclingGridContentBox, and aurore::ScrollingFrame.

◆ getParent()

Box * aurore::View::getParent ( )

◆ getParentActivity()

Activity * aurore::View::getParentActivity ( )

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

◆ getParentUserData()

void * aurore::View::getParentUserData ( )

◆ getScaleX()

float aurore::View::getScaleX ( ) const
inline

◆ getScaleY()

float aurore::View::getScaleY ( ) const
inline

◆ getShowAnimationDuration()

virtual float aurore::View::getShowAnimationDuration ( TransitionAnimation  animation)
virtual

Returns the duration of the view show / hide animation.

Reimplemented in aurore::Dropdown.

◆ getStringXMLAttributeValue()

static std::string aurore::View::getStringXMLAttributeValue ( std::string  value)
static

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.

◆ getStyleProperty()

virtual bool aurore::View::getStyleProperty ( const std::string &  name,
StyleValue *  value 
)
virtual

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.

Reimplemented in CadranDigits, CadranIcon, aurore::Button, aurore::Label, aurore::ProgressSpinner, and aurore::Rectangle.

◆ getThemeArea()

ThemeArea aurore::View::getThemeArea ( ) const
inline

◆ getThemeColor()

std::string aurore::View::getThemeColor ( const std::string &  property)

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

◆ getView()

virtual View * aurore::View::getView ( std::string  id)
virtual

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

◆ getVisibility()

Visibility aurore::View::getVisibility ( )

Gets the visibility of the view.

◆ getWidth()

float aurore::View::getWidth ( )

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

◆ getX()

float aurore::View::getX ( )

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

◆ getXMLCache()

static std::shared_ptr< tinyxml2::XMLDocument > aurore::View::getXMLCache ( std::string_view  path)
static

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

◆ getY()

float aurore::View::getY ( )

◆ getYGNode()

YGNode * aurore::View::getYGNode ( )

The view's Yoga node.

◆ handleXMLElement()

virtual void aurore::View::handleXMLElement ( tinyxml2::XMLElement *  element)
virtual

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).

Reimplemented in aurore::Box, aurore::AppletFrame, and aurore::TabFrame.

◆ hasCustomNavigationRouteById()

bool aurore::View::hasCustomNavigationRouteById ( FocusDirection  direction)

◆ hasCustomNavigationRouteByPtr()

bool aurore::View::hasCustomNavigationRouteByPtr ( FocusDirection  direction)

◆ hasParent()

bool aurore::View::hasParent ( )

◆ hasStyleState()

bool aurore::View::hasStyleState ( StyleState  state)

◆ hide() [1/2]

virtual void aurore::View::hide ( std::function< void(void)>  cb)
virtual

Hides the view with a fade out animation.

◆ hide() [2/2]

virtual void aurore::View::hide ( std::function< void(void)>  cb,
bool  animate,
float  animationDuration 
)
virtual

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

Reimplemented in aurore::Dropdown.

◆ hitTest()

virtual View * aurore::View::hitTest ( Point  point)
virtual

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 in HeaderSetting, and aurore::Box.

◆ interruptGestures()

void aurore::View::interruptGestures ( bool  onlyIfUnsureState)

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

◆ invalidate()

virtual void aurore::View::invalidate ( )
virtual

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.

◆ isAccessibilitySelected()

bool aurore::View::isAccessibilitySelected ( )

◆ isCollapsed()

bool aurore::View::isCollapsed ( )

Whether collapse() hid the view.

◆ isCulled()

bool aurore::View::isCulled ( )
inline

◆ isDetached()

bool aurore::View::isDetached ( )

See detach().

◆ isFocusable()

bool aurore::View::isFocusable ( )

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

◆ isFocused()

bool aurore::View::isFocused ( )

Whether the view has the focus.

◆ isHidden()

bool aurore::View::isHidden ( )

Whether hide() hid the view.

◆ isPtrLocked()

bool aurore::View::isPtrLocked ( )

Whether a ptrLock() holds the view.

◆ isTranslucent()

virtual bool aurore::View::isTranslucent ( )
virtual

Is this view translucent?

If you override it please return

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

Reimplemented in aurore::ContextMenu, aurore::Dialog, aurore::Dropdown, and aurore::EditTextDialog.

◆ isWireframeEnabled()

bool aurore::View::isWireframeEnabled ( )

◆ isXMLAttributeValid()

bool aurore::View::isXMLAttributeValid ( std::string  attributeName)

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

◆ keepSubscription()

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

◆ listXMLValues()

template<typename T >
static std::string aurore::View::listXMLValues ( const std::unordered_map< std::string, T > &  values)
inlinestatic

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

◆ onFocusGained()

virtual void aurore::View::onFocusGained ( )
virtual

◆ onFocusLost()

virtual void aurore::View::onFocusLost ( )
virtual

Fired when focus is lost.

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

◆ onLayout()

virtual void aurore::View::onLayout ( )
inlinevirtual

◆ onParentFocusGained()

virtual void aurore::View::onParentFocusGained ( View *  focusedView)
virtual

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

Reimplemented in aurore::Box, and aurore::Label.

◆ onParentFocusLost()

virtual void aurore::View::onParentFocusLost ( View *  focusedView)
virtual

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

Reimplemented in aurore::Box, and aurore::Label.

◆ onShowAnimationEnd()

virtual void aurore::View::onShowAnimationEnd ( )
inlinevirtual

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

◆ onTextScaleChanged()

virtual void aurore::View::onTextScaleChanged ( )
inlinevirtual

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

Reimplemented in CadranDigits, aurore::Label, and aurore::RecyclerCell.

◆ onThemeChanged()

virtual void aurore::View::onThemeChanged ( )
virtual

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 in aurore::Box, aurore::ContextMenu, aurore::RecyclerFrame, aurore::RecyclingGrid, aurore::HRecyclerFrame, and aurore::BatteryWidget.

◆ onWindowSizeChanged()

virtual void aurore::View::onWindowSizeChanged ( )
inlinevirtual

Fired when the window size changes, after updating layout.

Reimplemented in aurore::Box.

◆ overrideTheme()

void aurore::View::overrideTheme ( Theme *  newTheme)

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

◆ playClickAnimation()

void aurore::View::playClickAnimation ( bool  reverse = false,
bool  animateBack = true,
bool  force = false 
)

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

◆ present()

void aurore::View::present ( View *  view)

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

◆ ptrLock()

void aurore::View::ptrLock ( )

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

◆ ptrUnlock()

void aurore::View::ptrUnlock ( )

◆ registerAction() [1/3]

ActionIdentifier aurore::View::registerAction ( AuroreKeyCombination  key,
const ActionListener &  actionListener,
bool  allowRepeating = false 
)

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

◆ registerAction() [2/3]

template<class ButtonType , class ActionType >
ActionIdentifier aurore::View::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.

◆ registerAction() [3/3]

ActionIdentifier aurore::View::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.

◆ registerAutoXMLAttribute()

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

◆ registerBoolXMLAttribute()

void aurore::View::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").

◆ registerClickAction()

void aurore::View::registerClickAction ( const ActionListener &  actionListener)

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

◆ registerColorXMLAttribute()

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

◆ registerFilePathXMLAttribute()

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

◆ registerFloatXMLAttribute()

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

◆ registerPercentageXMLAttribute()

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

◆ registerStringXMLAttribute()

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

◆ removeFromSuperView()

void aurore::View::removeFromSuperView ( bool  free = true)

Removes view from it's parent

◆ removeGestureRecognizer()

bool aurore::View::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.

◆ resetClickAnimation()

void aurore::View::resetClickAnimation ( )

◆ resolveBindings()

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

◆ RGB()

NVGcolor aurore::View::RGB ( unsigned  r,
unsigned  g,
unsigned  b 
)
inlineprotected

◆ RGBA()

NVGcolor aurore::View::RGBA ( unsigned  r,
unsigned  g,
unsigned  b,
unsigned  a 
)
inlineprotected

◆ RGBAf()

NVGcolor aurore::View::RGBAf ( float  r,
float  g,
float  b,
float  a 
)
inlineprotected

◆ RGBf()

NVGcolor aurore::View::RGBf ( float  r,
float  g,
float  b 
)
inlineprotected

◆ setAccessibilityLabel()

void aurore::View::setAccessibilityLabel ( const std::string &  label)

◆ setAccessibilityRole()

void aurore::View::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/…".

◆ setAccessibilitySelected()

void aurore::View::setAccessibilitySelected ( bool  selected)

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

◆ setAccessibilityValue()

void aurore::View::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="…".

◆ setActionAvailable()

void aurore::View::setActionAvailable ( enum ControllerButton  button,
bool  available 
)

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

◆ setActionHidden()

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

◆ setActionsAvailable()

void aurore::View::setActionsAvailable ( bool  available) const

The same for every action of the view.

◆ setAlignSelf()

void aurore::View::setAlignSelf ( AlignSelf  align)

Overrides align items of the parent box.

Default is AUTO.

◆ setAlpha()

void aurore::View::setAlpha ( float  alpha)

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

◆ setAspectRatio()

void aurore::View::setAspectRatio ( float  value)

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

◆ setBackground()

void aurore::View::setBackground ( ViewBackground  background)

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

◆ setBackgroundColor()

void aurore::View::setBackgroundColor ( NVGcolor  color)
inline

Sets the view shape background color.

◆ setBackgroundCornerRadii()

void aurore::View::setBackgroundCornerRadii ( float  topLeft,
float  topRight,
float  bottomRight,
float  bottomLeft 
)
inline

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

◆ setBackgroundLinearGradient()

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

◆ setBorderColor()

void aurore::View::setBorderColor ( NVGcolor  color)
inline

Sets the view shape border color.

◆ setBorderThickness()

void aurore::View::setBorderThickness ( float  thickness)
inline

Sets the view shape border thickness.

◆ setBoundText()

virtual bool aurore::View::setBoundText ( const std::string &  text)
inlinevirtual

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

Reimplemented in aurore::Button, aurore::DetailCell, aurore::RadioCell, and aurore::Label.

◆ setBoxSizing()

void aurore::View::setBoxSizing ( BoxSizing  sizing)

Sets what the width and height of the view measure.

Default is BORDER_BOX.

◆ setClipsToBounds()

void aurore::View::setClipsToBounds ( bool  value)
inline

◆ setCornerRadius() [1/2]

void aurore::View::setCornerRadius ( float  radius)
inline

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

◆ setCornerRadius() [2/2]

void aurore::View::setCornerRadius ( float  topLeft,
float  topRight,
float  bottomRight,
float  bottomLeft 
)
inline

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

◆ setCulled()

void aurore::View::setCulled ( bool  culled)
inline

Enables / disable culling for that view.

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

◆ setCustomNavigationRoute() [1/2]

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

◆ setCustomNavigationRoute() [2/2]

void aurore::View::setCustomNavigationRoute ( FocusDirection  direction,
View *  target 
)

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

◆ setDetachedPosition()

void aurore::View::setDetachedPosition ( float  x,
float  y 
)

Sets the position of the view, if detached.

◆ setDetachedPositionX()

void aurore::View::setDetachedPositionX ( float  x)

Sets the position X of the view, if detached.

◆ setDetachedPositionY()

void aurore::View::setDetachedPositionY ( float  y)

Sets the position Y of the view, if detached.

◆ setDimensions()

void aurore::View::setDimensions ( float  width,
float  height 
)

Shortcut to setWidth + setHeight.

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

◆ setFocusable()

void aurore::View::setFocusable ( bool  focusable)
inline

Sets the view to be focusable.

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

◆ setFocusSound()

void aurore::View::setFocusSound ( enum Sound  sound)
inline

Sets the sound to play when this view gets focused.

◆ setGrow()

void aurore::View::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;

◆ setHeight()

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

◆ setHeightPercentage()

void aurore::View::setHeightPercentage ( float  percentage)

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

◆ setHideClickAnimation()

void aurore::View::setHideClickAnimation ( bool  hide)
inline

No click animation when the view is clicked.

◆ setHideHighlight()

void aurore::View::setHideHighlight ( bool  hide)
inline

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

◆ setHideHighlightBackground()

void aurore::View::setHideHighlightBackground ( bool  hide)
inline

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).

◆ setHideHighlightBorder()

void aurore::View::setHideHighlightBorder ( bool  hide)
inline

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

◆ setHighlightCornerRadius()

void aurore::View::setHighlightCornerRadius ( float  radius)
inline

Sets the highlight rectangle corner radius.

◆ setHighlightGlide()

static void aurore::View::setHighlightGlide ( bool  glide)
static

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.

◆ setHighlightPadding()

void aurore::View::setHighlightPadding ( float  padding)
inline

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.

◆ setId()

void aurore::View::setId ( std::string  id)

Sets the id of the view.

◆ setInFadeAnimation()

void aurore::View::setInFadeAnimation ( bool  translucent)

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

◆ setLineBottom()

void aurore::View::setLineBottom ( float  thickness)
inline

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

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

◆ setLineColor()

void aurore::View::setLineColor ( NVGcolor  color)
inline

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

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

◆ setLineLeft()

void aurore::View::setLineLeft ( float  thickness)
inline

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

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

◆ setLineRight()

void aurore::View::setLineRight ( float  thickness)
inline

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

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

◆ setLineTop()

void aurore::View::setLineTop ( float  thickness)
inline

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

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

◆ setMarginBottom()

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

◆ setMarginLeft()

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

◆ setMarginRight()

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

◆ setMargins()

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

◆ setMarginTop()

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

◆ setMaxHeight()

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

◆ setMaxHeightPercentage()

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

◆ setMaximumAllowedXMLElements()

void aurore::View::setMaximumAllowedXMLElements ( unsigned  max)

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

◆ setMaxWidth()

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

◆ setMaxWidthPercentage()

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

◆ setMinHeight()

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

◆ setMinHeightPercentage()

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

◆ setMinWidth()

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

◆ setMinWidthPercentage()

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

◆ setParent()

void aurore::View::setParent ( Box *  parent,
void *  parentUserdata = nullptr 
)

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

◆ setParentActivity()

void aurore::View::setParentActivity ( Activity *  activity)

◆ setPositionBottom()

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

◆ setPositionBottomPercentage()

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

◆ setPositionLeft()

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

◆ setPositionLeftPercentage()

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

◆ setPositionRight()

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

◆ setPositionRightPercentage()

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

◆ setPositionTop()

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

◆ setPositionTopPercentage()

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

◆ setPositionType()

void aurore::View::setPositionType ( PositionType  type)

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

Default is RELATIVE.

◆ setScale()

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

◆ setScaleX()

void aurore::View::setScaleX ( float  scale)

◆ setScaleY()

void aurore::View::setScaleY ( float  scale)

◆ setShadowType()

void aurore::View::setShadowType ( ShadowType  type)
inline

Sets the view shape shadow type. Default is NONE.

◆ setShadowVisibility()

void aurore::View::setShadowVisibility ( bool  visible)
inline

Sets the shadow visibility.

◆ setShrink()

void aurore::View::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;

◆ setSize()

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

◆ setStateStyle()

bool aurore::View::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.

◆ setStyleProperty()

virtual bool aurore::View::setStyleProperty ( const std::string &  name,
const StyleValue &  value 
)
virtual

◆ setStyleState()

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

◆ setThemeArea()

void aurore::View::setThemeArea ( ThemeArea  area)
inline

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.

◆ setThemeColor()

bool aurore::View::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.

◆ setTransition()

bool aurore::View::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.

◆ setTranslationX()

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

◆ setTranslationY()

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

◆ setVisibility()

void aurore::View::setVisibility ( Visibility  visibility)

Sets the visibility of the view.

◆ setWidth()

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

◆ setWidthPercentage()

void aurore::View::setWidthPercentage ( float  percentage)

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

◆ setWireframeEnabled()

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

◆ shadowColor()

NVGcolor aurore::View::shadowColor ( NVGcolor  color,
float  opacity 
)
protected

◆ shakeHighlight()

void aurore::View::shakeHighlight ( FocusDirection  direction)

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

◆ show() [1/2]

virtual void aurore::View::show ( std::function< void(void)>  cb)
virtual

Shows the view with a fade in animation.

◆ show() [2/2]

virtual void aurore::View::show ( std::function< void(void)>  cb,
bool  animate,
float  animationDuration 
)
virtual

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

Reimplemented in aurore::Dropdown.

◆ transitionStyle()

bool aurore::View::transitionStyle ( const char *  name,
const StyleValue &  to 
)
inlineprotected

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.

◆ unregisterAction()

void aurore::View::unregisterAction ( ActionIdentifier  identifier)

Unregisters an action with the given identifier.

◆ updateActionHint()

void aurore::View::updateActionHint ( enum ControllerButton  button,
const std::string &  hintText 
)

Changes the hint of the action on button.

◆ updateAppletFrameItem()

void aurore::View::updateAppletFrameItem ( )

◆ willAppear()

virtual void aurore::View::willAppear ( bool  resetState = false)
inlinevirtual

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 in ScrollView, aurore::Box, aurore::HScrollingFrame, aurore::ScrollingFrame, and aurore::ProgressSpinner.

◆ willDisappear()

virtual void aurore::View::willDisappear ( bool  resetState = false)
inlinevirtual

Called when the view will disappear from the screen.

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

Reimplemented in aurore::Box, and aurore::ProgressSpinner.

Friends And Related Symbol Documentation

◆ Application

friend class Application
friend

Member Data Documentation

◆ alpha

Animatable aurore::View::alpha = 1.0f

◆ AUTO

constexpr float aurore::View::AUTO = NAN
staticconstexpr

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

◆ collapseState

Animatable aurore::View::collapseState = 1.0f
protected

◆ currentXMLResource

std::string aurore::View::currentXMLResource
static

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

◆ CUSTOM_RESOURCES_PATH

std::string aurore::View::CUSTOM_RESOURCES_PATH
inlinestatic

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.

◆ focused

bool aurore::View::focused = false
protected

◆ focusEvent

GenericEvent aurore::View::focusEvent
protected

◆ focusLostEvent

GenericEvent aurore::View::focusLostEvent
protected

◆ id

std::string aurore::View::id = ""
protected

◆ parent

Box* aurore::View::parent = nullptr
protected

◆ parentActivity

Activity* aurore::View::parentActivity = nullptr
protected

◆ ygNode

YGNode* aurore::View::ygNode
protected

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