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

Base class for renderable components. More...

#include <ViewModel.h>

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

Public Member Functions

 ViewModel ()
 
virtual ~ViewModel ()
 
virtual void AttachView (Display &disp)=0
 
ViewGetView () const
 
virtual Vec3 Measure ()
 Calculate the size of the component. More...
 
void PrepareRender ()
 
void Render ()
 
void SetView (std::unique_ptr< View > &&view)
 

Protected Member Functions

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

Private Attributes

bool needsLayout
 
std::unique_ptr< Viewview
 

Detailed Description

Base class for renderable components.

View models only track the state of the renderable. The rendering is handled by the View, which is attached by the API-specific Display when the the view model is added to the scene graph.

Author
Michael Imamura

Constructor & Destructor Documentation

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

Member Function Documentation

virtual void HoverRace::Display::ViewModel::AttachView ( Display disp)
pure virtual
template<class T >
void HoverRace::Display::ViewModel::AttachViewDynamic ( Display disp,
T *  self 
)
inlineprotected
virtual void HoverRace::Display::ViewModel::FireModelUpdate ( int  prop)
inlineprotectedvirtual

Indicate that a model property has changed.

If a view is attached, it will be notified.

Parameters
propThe model-specific ID of the property that changed.

Reimplemented in HoverRace::Display::Button, HoverRace::Display::Slider, HoverRace::Display::StateButton, HoverRace::Display::HudDecor, and HoverRace::Display::Minimap.

View* HoverRace::Display::ViewModel::GetView ( ) const
inline
virtual void HoverRace::Display::ViewModel::Layout ( )
inlineprotectedvirtual

Adjust the size and position of any child elements.

Subclasses with child elements should override this function.

This is called automatically during the PrepareRender() phase if RequestLayout() has been called. It is also called the first time PrepareRender() is invoked. After this function is called, it will not be called again until another call to RequestLayout().

Reimplemented in HoverRace::Display::FlexGrid, HoverRace::Display::Hud, HoverRace::Display::BasePickList, HoverRace::Display::Button, HoverRace::Display::Slider, HoverRace::Display::Counter, HoverRace::Display::Chronometer, HoverRace::Display::HudText, HoverRace::Client::BulletinBoard, and HoverRace::Client::BulletinBoard::Bulletin.

virtual Vec3 HoverRace::Display::ViewModel::Measure ( )
inlinevirtual

Calculate the size of the component.

For UI components, the return value is affected by layout flags.

Returns
The size (may be zero if the size cannot be determined yet).
Warning
Depending on the view, this may be an expensive operation since the view may have to call View::PrepareRender to apply model changes. As such, it is recommended to call Measure in the PrepareRender phase itself.

Reimplemented in HoverRace::Display::FlexGrid, HoverRace::Display::BaseContainer, HoverRace::Display::ClickRegion, HoverRace::Display::Button, HoverRace::Display::Slider, HoverRace::Display::RuleLine, HoverRace::Display::Box, and HoverRace::Display::KeycapIcon.

void HoverRace::Display::ViewModel::PrepareRender ( )
inline
void HoverRace::Display::ViewModel::Render ( )
inline
void HoverRace::Display::ViewModel::RequestLayout ( )
inlineprotected

Indicate that the current layout is out-of-date and needs to be adjusted.

Subclasses should call this when a property changes that affects the layout (such as the size).

void HoverRace::Display::ViewModel::SetView ( std::unique_ptr< View > &&  view)
inline

Member Data Documentation

bool HoverRace::Display::ViewModel::needsLayout
private
std::unique_ptr<View> HoverRace::Display::ViewModel::view
private

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