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

#include <aurore/views/label.hpp>

Inheritance diagram for aurore::Label:
aurore::View

Public Member Functions

 Label ()
 An empty label in the default font, size and colour.
 
 ~Label () override
 
void draw (NVGcontext *vg, float x, float y, float width, float height, Style style, FrameContext *ctx) override
 
void onLayout () override
 
void onFocusGained () override
 
void onFocusLost () override
 
void onParentFocusGained (View *focusedView) override
 
void onParentFocusLost (View *focusedView) override
 
virtual void setText (const std::string &text)
 
void setHorizontalAlign (HorizontalAlign align)
 
void setVerticalAlign (VerticalAlign align)
 
void setFontSize (float value)
 The font size asked, in layout units (drawn times the font scale).
 
void setFontScaled (bool scaled)
 false: this label keeps its size whatever the font scale.
 
void setFontScaleMax (float max)
 
void setShrinkToFit (bool shrink)
 
bool isShrinkingToFit ()
 See setShrinkToFit().
 
void setShrinkToFitMin (float size)
 
float getDrawnFontSize ()
 
float getFullFontSize ()
 
void setFontQuality (float value)
 nanovg's quality for the glyphs (1 by default).
 
void setLineHeight (float value)
 The height of a line, as a multiple of the font size.
 
void setTextColor (NVGcolor color)
 The text's colour (setThemeColor follows a theme key instead).
 
void setFont (int font)
 
bool setFontFamily (const std::string &name)
 
int getFont ()
 The font id the label draws with.
 
float getFontSize ()
 The font size asked, before the font scale.
 
float getFontQuality ()
 
float getLineHeight ()
 
NVGcolor getTextColor ()
 
std::string getFullText ()
 The whole text, as set (not cut to fit).
 
bool getStyleProperty (const std::string &name, StyleValue *value) override
 
bool setStyleProperty (const std::string &name, const StyleValue &value) override
 
bool setBoundText (const std::string &text) override
 
void onTextScaleChanged () override
 
void bindText (Observable< std::string > &text)
 
bool isTruncated ()
 The text as laid out does not fit: it is drawn cut, with an ellipsis.
 
void setRequiredWidth (float requiredWidth)
 Set by the measure function: the width the text needs on one line.
 
void setEllipsisWidth (float ellipsisWidth)
 Set by the measure function: the width of the ellipsis.
 
void setAnimated (bool animated)
 
void setAutoAnimate (bool autoAnimate)
 
void setSingleLine (bool singleLine)
 
bool isSingleLine ()
 See setSingleLine().
 
void setIsWrapping (bool isWrapping)
 
void setCursor (int cursor)
 Draws a blinking edit cursor before the byte cursor (CursorPosition::END: at the end; UNSET: none).
 
- Public Member Functions inherited from aurore::View
void setScale (float scale)
 
void setScaleX (float scale)
 
void setScaleY (float scale)
 
float getScaleX () const
 
float getScaleY () const
 
 View ()
 
virtual ~View ()
 
void setBackground (ViewBackground background)
 How the view's background is drawn: none, the sidebar's, the backdrop, a plain colour or a gradient.
 
void setBackgroundLinearGradient (NVGcolor start, NVGcolor end, ViewBackground direction=ViewBackground::VERTICAL_LINEAR)
 
void shakeHighlight (FocusDirection direction)
 Shakes the focus highlight towards direction: there is nothing to go to there.
 
Rect getFrame ()
 The view's position and size on the screen, after layout (getX(), getY(), getWidth(), getHeight()).
 
float getX ()
 The position on the screen, in layout units: the parents' positions and translations added.
 
float getY ()
 
Rect getLocalFrame ()
 The position and size in the parent, as laid out by Yoga.
 
float getLocalX ()
 
float getLocalY ()
 
float getWidth ()
 The size as laid out by Yoga; the height without the collapse when includeCollapse is false.
 
float getHeight (bool includeCollapse=true)
 
virtual void invalidate ()
 
virtual 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 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 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)
 
void keepSubscription (Subscription &&subscription)
 
bool bind (const std::string &spec)
 
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)
 
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 setFontScale (float scale)
 
static float getFontScale ()
 See setFontScale().
 
static View * create ()
 Makes a label for XML (<aurore:Label>).
 
static std::string STConverter (const std::string &text)
 
- Static Public Member Functions inherited from aurore::View
static void setHighlightGlide (bool glide)
 
static View * createFromXMLString (std::string_view xml)
 
static View * createFromXMLElement (tinyxml2::XMLElement *element)
 
static View * createFromXMLFile (std::string path)
 
static View * createFromXMLResource (std::string name)
 
static std::shared_ptr< tinyxml2::XMLDocument > getXMLCache (std::string_view path)
 
static void forgetXMLCache (const std::string &path)
 
static std::string describeXMLError (tinyxml2::XMLDocument *document, const std::string &source="")
 
static std::string describeXMLLocation (const tinyxml2::XMLElement *element)
 
static void fatalXML (const std::string &message)
 
static std::string closestXMLName (const std::string &name, const std::vector< std::string > &known)
 
template<typename T >
static std::string listXMLValues (const std::unordered_map< std::string, T > &values)
 An enumeration's values, sorted, for an error message.
 
static std::string getStringXMLAttributeValue (std::string value)
 
static std::string getFilePathXMLAttributeValue (std::string value)
 

Static Public Attributes

static bool OPENCC_ON = true
 STConverter() applied to Traditional Chinese text.
 
static float FONT_SCALE = 1.0f
 
- Static Public Attributes inherited from aurore::View
static constexpr float AUTO = NAN
 A size or position left to the layout (auto in XML).
 
static std::string CUSTOM_RESOURCES_PATH
 
static std::string currentXMLResource
 

Protected Member Functions

AccessibilityRole getDefaultAccessibilityRole () override
 
std::string getDefaultAccessibilityLabel () override
 
float textWidth ()
 the text's width as drawn
 
void stopScrollingAnimation ()
 
void resetScrollingAnimation ()
 
void startScrollTimer ()
 
void onScrollTimerFinished ()
 
enum NVGalign getNVGHorizontalAlign ()
 
enum NVGalign getNVGVerticalAlign ()
 
- Protected Member Functions inherited from aurore::View
NVGcolor a (NVGcolor color)
 Helper functions to apply this view's alpha to a color.
 
NVGpaint a (NVGpaint paint)
 
NVGcolor RGB (unsigned r, unsigned g, unsigned b)
 
NVGcolor RGBA (unsigned r, unsigned g, unsigned b, unsigned a)
 
NVGcolor RGBf (float r, float g, float b)
 
NVGcolor RGBAf (float r, float g, float b, float a)
 
NVGcolor shadowColor (NVGcolor color, float opacity)
 
virtual bool animateHint ()
 
virtual std::string getDefaultAccessibilityValue ()
 
virtual bool getDefaultAccessibilitySelected ()
 
bool transitionStyle (const char *name, const StyleValue &to)
 

Protected Attributes

std::string truncatedText
 
std::string fullText
 
int font
 
float fontSize
 
bool fontScaled = true
 
float fontScaleMax = 1e6f
 
bool shrinkToFit = false
 
float shrinkMin = 0
 setShrinkToFitMin
 
float fitScale = 1.0f
 from onLayout, when shrinkToFit
 
float fittedWidth = 0
 the text's width at that scale
 
float lineHeight
 
float fontQuality
 
NVGcolor textColor
 
float requiredWidth = 0
 
unsigned ellipsisWidth = 0
 
size_t stringLength = 0
 
bool singleLine = false
 
bool isWrapping = false
 
bool autoAnimate = true
 
bool animated = false
 should it animate?
 
bool animating = false
 currently animating?
 
int cursor = -2
 
Time cursor_blink = 0
 
Timer scrollingTimer
 
Animatable scrollingAnimation
 
HorizontalAlign horizontalAlign = HorizontalAlign::LEFT
 
VerticalAlign verticalAlign = VerticalAlign::CENTER
 
- Protected Attributes inherited from aurore::View
Animatable collapseState = 1.0f
 
bool focused = false
 
Activity * parentActivity = nullptr
 
Box * parent = nullptr
 
GenericEvent focusEvent
 
GenericEvent focusLostEvent
 
YGNode * ygNode
 
std::string id = ""
 

Additional Inherited Members

- Public Types inherited from aurore::View
typedef std::vector< std::shared_ptr< Action > >::iterator ActionIterator
 
- Public Attributes inherited from aurore::View
Animatable alpha = 1.0f
 

Detailed Description

Some text. The Label will automatically grow as much as possible. If there is enough space, the label dimensions will fit the text. If there is not enough horizontal space available, it will wrap and expand its height. If there is not enough vertical space available to wrap, the text will be truncated instead. The truncated text will animate if the Label or one of its parents is focused. Animation will be disabled if the alignment is other than LEFT. Warning: to wrap, the label width MUST be constrained

Constructor & Destructor Documentation

◆ Label()

aurore::Label::Label ( )

An empty label in the default font, size and colour.

◆ ~Label()

aurore::Label::~Label ( )
override

Member Function Documentation

◆ bindText()

void aurore::Label::bindText ( Observable< std::string > &  text)

Its own Observable: the label shows its value, now and at each change, as long as it lives.

◆ create()

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

Makes a label for XML (<aurore:Label>).

◆ draw()

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

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

Implements aurore::View.

◆ getDefaultAccessibilityLabel()

std::string aurore::Label::getDefaultAccessibilityLabel ( )
inlineoverrideprotectedvirtual

Reimplemented from aurore::View.

◆ getDefaultAccessibilityRole()

AccessibilityRole aurore::Label::getDefaultAccessibilityRole ( )
inlineoverrideprotectedvirtual

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

Reimplemented from aurore::View.

◆ getDrawnFontSize()

float aurore::Label::getDrawnFontSize ( )

The size it is drawn at, and the same before any shrinking to fit (what the text is measured at).

◆ getFont()

int aurore::Label::getFont ( )

The font id the label draws with.

◆ getFontQuality()

float aurore::Label::getFontQuality ( )

◆ getFontScale()

static float aurore::Label::getFontScale ( )
static

◆ getFontSize()

float aurore::Label::getFontSize ( )

The font size asked, before the font scale.

◆ getFullFontSize()

float aurore::Label::getFullFontSize ( )

◆ getFullText()

std::string aurore::Label::getFullText ( )

The whole text, as set (not cut to fit).

◆ getLineHeight()

float aurore::Label::getLineHeight ( )

◆ getNVGHorizontalAlign()

enum NVGalign aurore::Label::getNVGHorizontalAlign ( )
protected

◆ getNVGVerticalAlign()

enum NVGalign aurore::Label::getNVGVerticalAlign ( )
protected

◆ getStyleProperty()

bool aurore::Label::getStyleProperty ( const std::string &  name,
StyleValue *  value 
)
overridevirtual

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

◆ getTextColor()

NVGcolor aurore::Label::getTextColor ( )

◆ isShrinkingToFit()

bool aurore::Label::isShrinkingToFit ( )

◆ isSingleLine()

bool aurore::Label::isSingleLine ( )

◆ isTruncated()

bool aurore::Label::isTruncated ( )

The text as laid out does not fit: it is drawn cut, with an ellipsis.

◆ onFocusGained()

void aurore::Label::onFocusGained ( )
overridevirtual

Fired when focus is gained.

Reimplemented from aurore::View.

◆ onFocusLost()

void aurore::Label::onFocusLost ( )
overridevirtual

Fired when focus is lost.

Reimplemented from aurore::View.

◆ onLayout()

void aurore::Label::onLayout ( )
overridevirtual

Called when a layout pass ends on that view.

Reimplemented from aurore::View.

◆ onParentFocusGained()

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

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

Reimplemented from aurore::View.

◆ onParentFocusLost()

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

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

Reimplemented from aurore::View.

◆ onScrollTimerFinished()

void aurore::Label::onScrollTimerFinished ( )
protected

◆ onTextScaleChanged()

void aurore::Label::onTextScaleChanged ( )
overridevirtual

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

Reimplemented from aurore::View.

◆ resetScrollingAnimation()

void aurore::Label::resetScrollingAnimation ( )
protected

◆ setAnimated()

void aurore::Label::setAnimated ( bool  animated)

If an "animated" label is too large to fit its bounds, the full text will be displayed in a scrolling animation instead of being truncated with an ellipsis ("...").

Unless the autoAnimate flag is set to false, a label will automatically be set to "animated" if it is focused or if one of its parent is.

◆ setAutoAnimate()

void aurore::Label::setAutoAnimate ( bool  autoAnimate)

Controls whether focus changes automatically animates the label or not. Doesn't stop the ongoing animation should there be one.

◆ setBoundText()

bool aurore::Label::setBoundText ( const std::string &  text)
overridevirtual

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

Reimplemented from aurore::View.

◆ setCursor()

void aurore::Label::setCursor ( int  cursor)

Draws a blinking edit cursor before the byte cursor (CursorPosition::END: at the end; UNSET: none).

◆ setEllipsisWidth()

void aurore::Label::setEllipsisWidth ( float  ellipsisWidth)

Set by the measure function: the width of the ellipsis.

◆ setFont()

void aurore::Label::setFont ( int  font)

The font this label is drawn with (the app's default one unless set): by its id, or by the name it was loaded under (Application::loadFont*). A name not loaded leaves the font as it was. XML: fontFamily="name".

◆ setFontFamily()

bool aurore::Label::setFontFamily ( const std::string &  name)

◆ setFontQuality()

void aurore::Label::setFontQuality ( float  value)

nanovg's quality for the glyphs (1 by default).

◆ setFontScale()

static void aurore::Label::setFontScale ( float  scale)
static

Every label drawn scale times its size (1 by default), but those that keep theirs (setFontScaled(false)). It can change at any time: the labels then need laying out again (their nodes marked dirty). getFontSize() gives the size asked. Application::setTextScale does both.

◆ setFontScaled()

void aurore::Label::setFontScaled ( bool  scaled)

false: this label keeps its size whatever the font scale.

◆ setFontScaleMax()

void aurore::Label::setFontScaleMax ( float  max)

This label drawn at most max times its size, whatever the scale (with a scale of 1, as asked: nothing changes).

◆ setFontSize()

void aurore::Label::setFontSize ( float  value)

The font size asked, in layout units (drawn times the font scale).

◆ setHorizontalAlign()

void aurore::Label::setHorizontalAlign ( HorizontalAlign  align)

Sets the alignment of the text inside the view. Will not move the view, only the text inside.

Default is CENTER.

◆ setIsWrapping()

void aurore::Label::setIsWrapping ( bool  isWrapping)

Internal flag set by the measure function.

◆ setLineHeight()

void aurore::Label::setLineHeight ( float  value)

The height of a line, as a multiple of the font size.

◆ setRequiredWidth()

void aurore::Label::setRequiredWidth ( float  requiredWidth)

Set by the measure function: the width the text needs on one line.

◆ setShrinkToFit()

void aurore::Label::setShrinkToFit ( bool  shrink)

A single line its box is too narrow for, at a scale above 1: drawn smaller until it fits, never below the size asked (then cut as before), rather than wrapped. Nothing changes at a scale of 1.

◆ setShrinkToFitMin()

void aurore::Label::setShrinkToFitMin ( float  size)

With shrinkToFit: drawn as small as size, under the size asked and at any scale, before being cut (0, the default: the size asked).

◆ setSingleLine()

void aurore::Label::setSingleLine ( bool  singleLine)

A single-line label will not wrap and increase its height, even if the remaining vertical space allows it.

Instead, it will always be truncated (if too large) to fit the horizontal space.

◆ setStyleProperty()

bool aurore::Label::setStyleProperty ( const std::string &  name,
const StyleValue &  value 
)
overridevirtual

Reimplemented from aurore::View.

◆ setText()

virtual void aurore::Label::setText ( const std::string &  text)
virtual

Sets the text of the label.

◆ setTextColor()

void aurore::Label::setTextColor ( NVGcolor  color)

The text's colour (setThemeColor follows a theme key instead).

◆ setVerticalAlign()

void aurore::Label::setVerticalAlign ( VerticalAlign  align)

Sets the alignment of the text inside the view. Will not move the view, only the text inside.

Only applies to single-line labels.

Default is CENTER.

◆ startScrollTimer()

void aurore::Label::startScrollTimer ( )
protected

◆ STConverter()

static std::string aurore::Label::STConverter ( const std::string &  text)
static

Simplified Chinese to Traditional Chinese

◆ stopScrollingAnimation()

void aurore::Label::stopScrollingAnimation ( )
protected

◆ textWidth()

float aurore::Label::textWidth ( )
protected

the text's width as drawn

Member Data Documentation

◆ animated

bool aurore::Label::animated = false
protected

should it animate?

◆ animating

bool aurore::Label::animating = false
protected

currently animating?

◆ autoAnimate

bool aurore::Label::autoAnimate = true
protected

◆ cursor

int aurore::Label::cursor = -2
protected

◆ cursor_blink

Time aurore::Label::cursor_blink = 0
protected

◆ ellipsisWidth

unsigned aurore::Label::ellipsisWidth = 0
protected

◆ fitScale

float aurore::Label::fitScale = 1.0f
protected

from onLayout, when shrinkToFit

◆ fittedWidth

float aurore::Label::fittedWidth = 0
protected

the text's width at that scale

◆ font

int aurore::Label::font
protected

◆ FONT_SCALE

float aurore::Label::FONT_SCALE = 1.0f
inlinestatic

The font scale (setFontScale())

◆ fontQuality

float aurore::Label::fontQuality
protected

◆ fontScaled

bool aurore::Label::fontScaled = true
protected

◆ fontScaleMax

float aurore::Label::fontScaleMax = 1e6f
protected

◆ fontSize

float aurore::Label::fontSize
protected

◆ fullText

std::string aurore::Label::fullText
protected

◆ horizontalAlign

HorizontalAlign aurore::Label::horizontalAlign = HorizontalAlign::LEFT
protected

◆ isWrapping

bool aurore::Label::isWrapping = false
protected

◆ lineHeight

float aurore::Label::lineHeight
protected

◆ OPENCC_ON

bool aurore::Label::OPENCC_ON = true
inlinestatic

STConverter() applied to Traditional Chinese text.

◆ requiredWidth

float aurore::Label::requiredWidth = 0
protected

◆ scrollingAnimation

Animatable aurore::Label::scrollingAnimation
protected

◆ scrollingTimer

Timer aurore::Label::scrollingTimer
protected

◆ shrinkMin

float aurore::Label::shrinkMin = 0
protected

setShrinkToFitMin

◆ shrinkToFit

bool aurore::Label::shrinkToFit = false
protected

◆ singleLine

bool aurore::Label::singleLine = false
protected

◆ stringLength

size_t aurore::Label::stringLength = 0
protected

◆ textColor

NVGcolor aurore::Label::textColor
protected

◆ truncatedText

std::string aurore::Label::truncatedText
protected

◆ verticalAlign

VerticalAlign aurore::Label::verticalAlign = VerticalAlign::CENTER
protected

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