HoverRace  2.0
Classes | Public Member Functions | Private Types | Private Attributes | List of all members
HoverRace::Display::Label Class Reference

A static text label. More...

#include <Label.h>

+ Inheritance diagram for HoverRace::Display::Label:

Classes

struct  Props
 

Public Member Functions

 Label (const std::string &text, const UiFont &font, const Color color, uiLayoutFlags_t layoutFlags=0)
 Constructor for automatically-sized label. More...
 
 Label (double wrapWidth, const std::string &text, const UiFont &font, const Color color, uiLayoutFlags_t layoutFlags=0)
 Constructor for fixed-width label. More...
 
virtual ~Label ()
 
void AttachView (Display &disp) override
 
double GetScale () const
 Gets the scaling of this label. More...
 
double GetWrapWidth () const
 Returns the set width, if a fixed width is set. More...
 
bool IsAutoWidth () const
 Check if automatic width sizing is enabled. More...
 
void SetAutoWidth ()
 Automatically determine the width of the text. More...
 
void SetScale (const double scale)
 
void SetWrapWidth (double wrapWidth)
 Set a fixed width for the label. More...
 
- Public Member Functions inherited from HoverRace::Display::BaseText
 BaseText (const std::string &text, const UiFont &font, const Color color, uiLayoutFlags_t layoutFlags=0)
 Constructor for automatically-sized widget. More...
 
virtual ~BaseText ()
 
const Color GetColor () const
 
const UiFontGetFont () const
 
const std::string & GetText () const
 
bool IsFixedScale () const
 Check if the scaling is fixed (i.e., ignores user text scale config). More...
 
void SetColor (const Color color)
 
void SetFixedScale (bool fixedScale)
 
void SetFont (const UiFont &font)
 
void SetText (const std::string &text)
 
- Public Member Functions inherited from HoverRace::Display::UiViewModel
 UiViewModel (uiLayoutFlags_t layoutFlags=0)
 
virtual ~UiViewModel ()
 
virtual void DropFocus ()
 Force this widget to give up focus, if it is currently focused. More...
 
Vec2 GetAlignedPos (const Vec2 &pos, double w, double h) const
 Retrieve an arbitrary position adjusted by the current alignment. More...
 
Vec2 GetAlignedPos (double w, double h) const
 Retrieve the position adjusted by the current alignment. More...
 
Alignment GetAlignment () const
 Retrieve the alignment of the component. More...
 
focusRelinquishedSignal_tGetFocusRelinquishedSignal ()
 
focusRequestedSignal_tGetFocusRequestedSignal ()
 
uiLayoutFlags_t GetLayoutFlags () const
 Retrieve the layout flags. More...
 
const Vec2GetPos () const
 Get the position of the component. More...
 
const Vec2GetTranslation () const
 Retrieves the position translation. More...
 
bool IsFocused () const
 Check if this widget currently has input focus. More...
 
uiLayoutFlags_t IsLayoutFloating () const
 
uiLayoutFlags_t IsLayoutUnscaled () const
 
virtual bool OnAction ()
 
virtual bool OnMouseMoved (const Vec2 &)
 
virtual bool OnMousePressed (const Control::Mouse::Click &)
 
virtual bool OnMouseReleased (const Control::Mouse::Click &)
 
virtual bool OnMouseScrolled (const Control::Mouse::Scroll &)
 
virtual bool OnNavigate (const Control::Nav &)
 
void RequestFocus ()
 Attempt to hand over the input focus to this widget. More...
 
void SetAlignment (Alignment alignment)
 Set the alignment of the component. More...
 
void SetPos (const Vec2 &pos)
 Set the position of the component. More...
 
void SetPos (double x, double y)
 Convenience function for SetPos(const Vec2&). More...
 
void SetTranslation (const Vec2 &translation)
 Sets the position translation. More...
 
void SetTranslation (double x, double y)
 Convenience function for SetTranslation(const Vec2&). More...
 
virtual bool TryFocus (const Control::Nav &nav=Control::Nav::NEUTRAL)
 Attempts to give this widget focus. More...
 
- Public Member Functions inherited from HoverRace::Display::ViewModel
 ViewModel ()
 
virtual ~ViewModel ()
 
ViewGetView () const
 
virtual Vec3 Measure ()
 Calculate the size of the component. More...
 
void PrepareRender ()
 
void Render ()
 
void SetView (std::unique_ptr< View > &&view)
 

Private Types

using SUPER = BaseText
 

Private Attributes

double scale
 
double wrapWidth
 

Additional Inherited Members

- Public Types inherited from HoverRace::Display::UiViewModel
enum  Alignment {
  Alignment::NW, Alignment::N, Alignment::NE, Alignment::E,
  Alignment::SE, Alignment::S, Alignment::SW, Alignment::W,
  Alignment::CENTER
}
 Imagine the component pinned to the container with a thumbtack. More...
 
using focusRelinquishedSignal_t = boost::signals2::signal< void(UiViewModel &, const Control::Nav &)>
 
using focusRequestedSignal_t = boost::signals2::signal< void(UiViewModel &)>
 
- Protected Member Functions inherited from HoverRace::Display::UiViewModel
void RelinquishFocus (const Control::Nav &nav)
 Voluntarily give up input focus, passing it on to the next widget. More...
 
void SetFocused (bool focused)
 Set the focused state. More...
 
- Protected Member Functions inherited from HoverRace::Display::ViewModel
template<class T >
void AttachViewDynamic (Display &disp, T *self)
 
virtual void FireModelUpdate (int prop)
 Indicate that a model property has changed. More...
 
virtual void Layout ()
 Adjust the size and position of any child elements. More...
 
void RequestLayout ()
 Indicate that the current layout is out-of-date and needs to be adjusted. More...
 

Detailed Description

A static text label.

This is intended for text elements that rarely change over time, aside from visibility.

Author
Michael Imamura

Member Typedef Documentation

Constructor & Destructor Documentation

HoverRace::Display::Label::Label ( const std::string &  text,
const UiFont font,
const Color  color,
uiLayoutFlags_t  layoutFlags = 0 
)

Constructor for automatically-sized label.

Parameters
textThe text.
fontThe font.
colorThe text foreground color (including alpha).
layoutFlagsOptional layout flags.
HoverRace::Display::Label::Label ( double  wrapWidth,
const std::string &  text,
const UiFont font,
const Color  color,
uiLayoutFlags_t  layoutFlags = 0 
)

Constructor for fixed-width label.

Parameters
wrapWidthThe width of the label.
textThe text.
fontThe font.
colorThe text foreground color (including alpha).
layoutFlagsOptional layout flags.
virtual HoverRace::Display::Label::~Label ( )
inlinevirtual

Member Function Documentation

void HoverRace::Display::Label::AttachView ( Display disp)
inlineoverridevirtual
double HoverRace::Display::Label::GetScale ( ) const
inline

Gets the scaling of this label.

Returns
The scale.
double HoverRace::Display::Label::GetWrapWidth ( ) const
inline

Returns the set width, if a fixed width is set.

Returns
The width. If auto-width is enabled, the result is undefined (always check IsAutoWidth() first).
bool HoverRace::Display::Label::IsAutoWidth ( ) const
inline

Check if automatic width sizing is enabled.

Returns
true if the width is determined by the longest line in the text, or false if the text is wrapped to fit a specific width.
void HoverRace::Display::Label::SetAutoWidth ( )

Automatically determine the width of the text.

The width will be the longest line in the text.

void HoverRace::Display::Label::SetScale ( const double  scale)
void HoverRace::Display::Label::SetWrapWidth ( double  wrapWidth)

Set a fixed width for the label.

Text will be wrapped to fit the width. Single words which are longer than will fit in the width will be clipped.

Parameters
wrapWidthThe fixed width.

Member Data Documentation

double HoverRace::Display::Label::scale
private
double HoverRace::Display::Label::wrapWidth
private

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