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

SDL implementation of TypeCase. More...

#include <SdlTypeCase.h>

+ Inheritance diagram for HoverRace::Display::SDL::SdlTypeCase:

Classes

struct  Metrics
 

Public Member Functions

 SdlTypeCase (SdlDisplay &display, const UiFont &font, int width, int height)
 Constructor. More...
 
 SdlTypeCase (const SdlTypeCase &)=delete
 
virtual ~SdlTypeCase ()
 
MR_UInt32 CountTextures () const override
 Count the number of active backing textures. More...
 
SdlTypeCaseoperator= (const SdlTypeCase &)=delete
 
void Prepare (const std::string &s, TypeLine *rects=nullptr) override
 Prepare a string to be rendered. More...
 
void Render (const TypeLine &s, const Color color, int x, int y, boost::optional< size_t > caret={}) override
 Render a string. More...
 
void RenderTexture (MR_UInt32 idx, int x, int y, double scale=1.0) override
 Renders the backing texture (for debugging purposes). More...
 
- Public Member Functions inherited from HoverRace::Display::TypeCase
 TypeCase (const UiFont &font, int width, int height)
 Constructor. More...
 
 TypeCase (const TypeCase &)=delete
 
virtual ~TypeCase ()
 
int GetHeight () const
 Retrieve the height of each of the backing textures. More...
 
int GetWidth () const
 Retrieve the width of each of the backing textures. More...
 
TypeCaseoperator= (const TypeCase &)=delete
 

Protected Attributes

SdlDisplaydisplay
 
- Protected Attributes inherited from HoverRace::Display::TypeCase
const UiFont font
 
const int height
 
const int width
 

Private Types

using glyphPage_t = std::array< GlyphEntry, 256 >
 
using SUPER = TypeCase
 

Private Member Functions

GlyphEntryAddGlyph (GlyphEntry &ent, const std::string &s, MR_UInt32 cp, std::string &added)
 Adds a glyph to the backing textures. More...
 
GlyphEntryFindGlyph (const std::string &s, MR_UInt32 cp, std::string &added)
 Finds a glyph in the backing textures, creating it if necessary. More...
 

Private Attributes

MR_UInt32 curMap
 
int curX
 
int curY
 
std::array< std::unique_ptr< glyphPage_t >, 256 > glyphs
 
std::vector< std::unique_ptr< SdlDynamicTexture > > maps
 
struct HoverRace::Display::SDL::SdlTypeCase::Metrics metrics
 

Detailed Description

SDL implementation of TypeCase.

Author
Michael Imamura

Member Typedef Documentation

Constructor & Destructor Documentation

HoverRace::Display::SDL::SdlTypeCase::SdlTypeCase ( SdlDisplay display,
const UiFont font,
int  width,
int  height 
)

Constructor.

Parameters
displayThe SDL display for rendering.
fontThe font.
widthThe width of the backing texture.
heightThe height of the backing texture.
HoverRace::Display::SDL::SdlTypeCase::SdlTypeCase ( const SdlTypeCase )
delete
HoverRace::Display::SDL::SdlTypeCase::~SdlTypeCase ( )
virtual

Member Function Documentation

GlyphEntry & HoverRace::Display::SDL::SdlTypeCase::AddGlyph ( GlyphEntry ent,
const std::string &  s,
MR_UInt32  cp,
std::string &  added 
)
private

Adds a glyph to the backing textures.

Parameters
[in,out]entThe glyph entry to initialize.
sA single UTF-8 character.
cpThe Unicode code point represented by the character.
addedBuffer of added glyphs.
Returns
The same glyph entry that was passed in.
MR_UInt32 HoverRace::Display::SDL::SdlTypeCase::CountTextures ( ) const
overridevirtual

Count the number of active backing textures.

Returns
The total number of textures (may be zero).

Implements HoverRace::Display::TypeCase.

GlyphEntry & HoverRace::Display::SDL::SdlTypeCase::FindGlyph ( const std::string &  s,
MR_UInt32  cp,
std::string &  added 
)
private

Finds a glyph in the backing textures, creating it if necessary.

Parameters
sA single UTF-8 character.
cpThe Unicode code point represented by the character.
addedBuffer of added glyphs.
Returns
The entry for the glyph.
SdlTypeCase& HoverRace::Display::SDL::SdlTypeCase::operator= ( const SdlTypeCase )
delete
void HoverRace::Display::SDL::SdlTypeCase::Prepare ( const std::string &  s,
TypeLine rects = nullptr 
)
overridevirtual

Prepare a string to be rendered.

If rects is omitted, then this can be used to preemptively add characters to the type case before they are used later.

Parameters
sThe text string that will be rendered.
[out]rectsOptional destination buffer for the prepared text.

Implements HoverRace::Display::TypeCase.

void HoverRace::Display::SDL::SdlTypeCase::Render ( const TypeLine s,
const Color  color,
int  x,
int  y,
boost::optional< size_t >  caret = {} 
)
overridevirtual

Render a string.

Only characters which have been previously added via AddChars() will be rendered.

Parameters
sThe string to render.
colorThe color of the string.
xThe screen X coordinate of the upper-left corner.
yThe screen Y coordinate of the upper-left corner.
caretThe optional caret position.

Implements HoverRace::Display::TypeCase.

void HoverRace::Display::SDL::SdlTypeCase::RenderTexture ( MR_UInt32  idx,
int  x,
int  y,
double  scale = 1.0 
)
overridevirtual

Renders the backing texture (for debugging purposes).

Parameters
idxThe texture index.
xThe x coordinate.
yThe y coordinate.
scaleThe scaling factor.

Implements HoverRace::Display::TypeCase.

Member Data Documentation

MR_UInt32 HoverRace::Display::SDL::SdlTypeCase::curMap
private
int HoverRace::Display::SDL::SdlTypeCase::curX
private
int HoverRace::Display::SDL::SdlTypeCase::curY
private
SdlDisplay& HoverRace::Display::SDL::SdlTypeCase::display
protected
std::array<std::unique_ptr<glyphPage_t>, 256> HoverRace::Display::SDL::SdlTypeCase::glyphs
private
std::vector<std::unique_ptr<SdlDynamicTexture> > HoverRace::Display::SDL::SdlTypeCase::maps
private
struct HoverRace::Display::SDL::SdlTypeCase::Metrics HoverRace::Display::SDL::SdlTypeCase::metrics
private

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