HoverRace  2.0
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Private Attributes | List of all members
HoverRace::Display::Display Class Referenceabstract

Base class for display managers. More...

#include <Display.h>

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

Public Types

using displayConfigChangedSignal_t = boost::signals2::signal< void(int, int)>
 
using uiScaleChangedSignal_t = boost::signals2::signal< void(double)>
 

Public Member Functions

 Display ()
 
virtual ~Display ()
 
uiLayoutFlags_t AddUiLayoutFlags (uiLayoutFlags_t flags) noexcept
 Combine the current UI layout flags with new flags. More...
 
Vec2 AddUiOrigin (const Vec2 &vec) noexcept
 Shift the current UI origin coordinates by an offset. More...
 
void CleanTypeCaseCache ()
 Clean up the cache of TypeCase instances. More...
 
virtual void Flip ()=0
 Rendering for the frame has completed; update the screen. More...
 
displayConfigChangedSignal_tGetDisplayConfigChangedSignal ()
 
virtual VideoServices::VideoBufferGetLegacyDisplay () const =0
 Retrieve the legacy (8-bit) framebuffer. More...
 
std::shared_ptr< TypeCaseGetTypeCase (const UiFont &font)
 Retrieve or create the TypeCase for a particular font. More...
 
const Vec2GetUiOffset () const noexcept
 
const Vec2GetUiOrigin () const noexcept
 Retrieve the current UI origin coordinates. More...
 
double GetUiScale () const noexcept
 
uiScaleChangedSignal_tGetUiScaleChangedSignal ()
 
const Vec2GetUiScreenSize () const noexcept
 Retrieve the dimensions of the screen, in UI coordinates. More...
 
Vec2 LayoutUiPosition (const Vec2 &relPos, uiLayoutFlags_t layoutFlags=0) noexcept
 
virtual void OnDesktopModeChanged (int width, int height)=0
 Reconfigure the display when the desktop resolution has changed. More...
 
virtual void OnDisplayConfigChanged ()
 Reconfigure the display based on the new configuration. More...
 
virtual void Screenshot ()=0
 Take a screenshot. More...
 
void SetUiLayoutFlags (uiLayoutFlags_t flags) noexcept
 Explicitly set the current UI layout flags. More...
 
void SetUiOrigin (const Vec2 &vec) noexcept
 Explicitly set the UI origin coordinates. More...
 
- Public Member Functions inherited from HoverRace::Display::ViewAttacher< ActiveText >
virtual void AttachView (ActiveText &model)=0
 Attach the display-specific view. More...
 
- Public Member Functions inherited from HoverRace::Display::ViewAttacher< BaseContainer >
virtual void AttachView (BaseContainer &model)=0
 Attach the display-specific view. More...
 
- Public Member Functions inherited from HoverRace::Display::ViewAttacher< Button >
virtual void AttachView (Button &model)=0
 Attach the display-specific view. More...
 
- Public Member Functions inherited from HoverRace::Display::ViewAttacher< ClickRegion >
virtual void AttachView (ClickRegion &model)=0
 Attach the display-specific view. More...
 
- Public Member Functions inherited from HoverRace::Display::ViewAttacher< FillBox >
virtual void AttachView (FillBox &model)=0
 Attach the display-specific view. More...
 
- Public Member Functions inherited from HoverRace::Display::ViewAttacher< KeycapIcon >
virtual void AttachView (KeycapIcon &model)=0
 Attach the display-specific view. More...
 
- Public Member Functions inherited from HoverRace::Display::ViewAttacher< Label >
virtual void AttachView (Label &model)=0
 Attach the display-specific view. More...
 
- Public Member Functions inherited from HoverRace::Display::ViewAttacher< Picture >
virtual void AttachView (Picture &model)=0
 Attach the display-specific view. More...
 
- Public Member Functions inherited from HoverRace::Display::ViewAttacher< RuleLine >
virtual void AttachView (RuleLine &model)=0
 Attach the display-specific view. More...
 
- Public Member Functions inherited from HoverRace::Display::ViewAttacher< ScreenFade >
virtual void AttachView (ScreenFade &model)=0
 Attach the display-specific view. More...
 
- Public Member Functions inherited from HoverRace::Display::ViewAttacher< Slider >
virtual void AttachView (Slider &model)=0
 Attach the display-specific view. More...
 
- Public Member Functions inherited from HoverRace::Display::ViewAttacher< SymbolIcon >
virtual void AttachView (SymbolIcon &model)=0
 Attach the display-specific view. More...
 
- Public Member Functions inherited from HoverRace::Display::ViewAttacher< Wallpaper >
virtual void AttachView (Wallpaper &model)=0
 Attach the display-specific view. More...
 

Public Attributes

Styles styles
 

Protected Member Functions

void FireDisplayConfigChangedSignal (int width, int height) const
 
void FireUiScaleChangedSignal (double scale) const
 
virtual std::shared_ptr< TypeCaseMakeTypeCase (const UiFont &font)=0
 Create a new TypeCase for a given font. More...
 

Private Attributes

displayConfigChangedSignal_t displayConfigChangedSignal
 
std::unordered_map< UiFont, std::weak_ptr< TypeCase > > typeCases
 
uiLayoutFlags_t uiLayoutFlags
 
Vec2 uiOffset
 
Vec2 uiOrigin
 
double uiScale
 
uiScaleChangedSignal_t uiScaleChangedSignal
 
Vec2 uiScreenSize
 

Detailed Description

Base class for display managers.

A display manager handles the API-specific tasks of lifecycle stages, instantiating views, and accessing shared resources.

See also
SdlDisplay
Author
Michael Imamura

Member Typedef Documentation

using HoverRace::Display::Display::displayConfigChangedSignal_t = boost::signals2::signal<void(int, int)>
using HoverRace::Display::Display::uiScaleChangedSignal_t = boost::signals2::signal<void(double)>

Constructor & Destructor Documentation

HoverRace::Display::Display::Display ( )
inline
virtual HoverRace::Display::Display::~Display ( )
inlinevirtual

Member Function Documentation

uiLayoutFlags_t HoverRace::Display::Display::AddUiLayoutFlags ( uiLayoutFlags_t  flags)
inlinenoexcept

Combine the current UI layout flags with new flags.

Parameters
flagsThe new flags.
Returns
The old flags.
See also
SetUiLayoutFlags
Vec2 HoverRace::Display::Display::AddUiOrigin ( const Vec2 vec)
inlinenoexcept

Shift the current UI origin coordinates by an offset.

Parameters
vecThe offset (in UI-space).
Returns
The old offset, so it can be restored later.
See also
SetUiOrigin(const Vec2&)
void HoverRace::Display::Display::CleanTypeCaseCache ( )

Clean up the cache of TypeCase instances.

This only should be called when the font rendering has changed in some way (e.g., the global font scale changes, a new style is loaded, etc.) that may cause many of the TypeCase instances to no longer be used.

void HoverRace::Display::Display::FireDisplayConfigChangedSignal ( int  width,
int  height 
) const
protected
void HoverRace::Display::Display::FireUiScaleChangedSignal ( double  scale) const
protected
virtual void HoverRace::Display::Display::Flip ( )
pure virtual

Rendering for the frame has completed; update the screen.

Implemented in HoverRace::Display::SDL::SdlDisplay.

displayConfigChangedSignal_t& HoverRace::Display::Display::GetDisplayConfigChangedSignal ( )
inline
virtual VideoServices::VideoBuffer& HoverRace::Display::Display::GetLegacyDisplay ( ) const
pure virtual

Retrieve the legacy (8-bit) framebuffer.

The legacy framebuffer provides an 8-bit surface for drawing. This framebuffer is drawn as the background layer since it doesn't have an alpha channel.

Returns
The framebuffer.

Implemented in HoverRace::Display::SDL::SdlDisplay.

std::shared_ptr< TypeCase > HoverRace::Display::Display::GetTypeCase ( const UiFont font)

Retrieve or create the TypeCase for a particular font.

Parameters
fontThe font.
Returns
The TypeCase, never nullptr.
const Vec2& HoverRace::Display::Display::GetUiOffset ( ) const
inlinenoexcept
const Vec2& HoverRace::Display::Display::GetUiOrigin ( ) const
inlinenoexcept

Retrieve the current UI origin coordinates.

Returns
The coordinates, in UI-space.
double HoverRace::Display::Display::GetUiScale ( ) const
inlinenoexcept
uiScaleChangedSignal_t& HoverRace::Display::Display::GetUiScaleChangedSignal ( )
inline
const Vec2& HoverRace::Display::Display::GetUiScreenSize ( ) const
inlinenoexcept

Retrieve the dimensions of the screen, in UI coordinates.

This is useful for components with UiLayoutFlags::FLOATING set, but without UiLayoutFlags::UNSCALED.

Returns
The dimensions.
Vec2 HoverRace::Display::Display::LayoutUiPosition ( const Vec2 relPos,
uiLayoutFlags_t  layoutFlags = 0 
)
inlinenoexcept
virtual std::shared_ptr<TypeCase> HoverRace::Display::Display::MakeTypeCase ( const UiFont font)
protectedpure virtual

Create a new TypeCase for a given font.

This is called by GetTypeCase() when the TypeCase is not in the cache.

Parameters
fontThe normalized font.
Returns
The TypeCase, never nullptr.

Implemented in HoverRace::Display::SDL::SdlDisplay.

virtual void HoverRace::Display::Display::OnDesktopModeChanged ( int  width,
int  height 
)
pure virtual

Reconfigure the display when the desktop resolution has changed.

This should be called whenever the desktop resolution changes, so the aspect ratio can be maintained in windowed mode.

Parameters
widthThe width of the desktop in pixels.
heightThe height of the desktop in pixels.

Implemented in HoverRace::Display::SDL::SdlDisplay.

void HoverRace::Display::Display::OnDisplayConfigChanged ( )
virtual

Reconfigure the display based on the new configuration.

This should be called whenever the video configuration of Util::Config changes.

Warning
Depending on the underlying API and what configuration options changed, this may trigger resources to be reloaded or regenerated.
Note
Subclasses should call the base class implementation to ensure that the UI scale is updated and views are notified.

Reimplemented in HoverRace::Display::SDL::SdlDisplay.

virtual void HoverRace::Display::Display::Screenshot ( )
pure virtual

Take a screenshot.

Implemented in HoverRace::Display::SDL::SdlDisplay.

void HoverRace::Display::Display::SetUiLayoutFlags ( uiLayoutFlags_t  flags)
inlinenoexcept

Explicitly set the current UI layout flags.

Calls to LayoutUiPosition combine the current layout flags with the widget layout flags when determining the adjusted position.

Parameters
flagsThe new flags.
void HoverRace::Display::Display::SetUiOrigin ( const Vec2 vec)
inlinenoexcept

Explicitly set the UI origin coordinates.

All UI coordinates go through LayoutUiPosition will be translated by this offset. In other words, this shifts where in UI-space the coordinates (0.0, 0.0) are.

Parameters
vecThe coordinates (in UI-space).

Member Data Documentation

displayConfigChangedSignal_t HoverRace::Display::Display::displayConfigChangedSignal
private
Styles HoverRace::Display::Display::styles
std::unordered_map<UiFont, std::weak_ptr<TypeCase> > HoverRace::Display::Display::typeCases
private
uiLayoutFlags_t HoverRace::Display::Display::uiLayoutFlags
private
Vec2 HoverRace::Display::Display::uiOffset
private
Vec2 HoverRace::Display::Display::uiOrigin
private
double HoverRace::Display::Display::uiScale
private
uiScaleChangedSignal_t HoverRace::Display::Display::uiScaleChangedSignal
private
Vec2 HoverRace::Display::Display::uiScreenSize
private

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