Rose
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
rose::ImageStore Class Reference

Public Member Functions

ImageId nextImageId ()
 Get the next dyname ImageId.
 
void setImage (ImageId imageId, gm::Texture &&texture)
 Set, or reset the Texture associated with the ImageId.
 
bool exists (ImageId imageId)
 Test to see if a Texture is associated with an ImageId.
 
Size size (ImageId imageId)
 Get the size of the Texture associated with an ImageId. More...
 
int renderCopy (gm::Context &context, ImageId imageId, Rectangle dst)
 Render the Texture associated with an Image Id. More...
 
int renderCopy (gm::Context &context, ImageId imageId, Rectangle src, Rectangle dst)
 Render the Texture associated with an Image Id. More...
 
int renderCopyEx (gm::Context &context, ImageId imageId, Rectangle src, Rectangle dst, double angle, gm::RenderFlip flip)
 Render the Texture associated with an Image Id with with optional rotation and flipping. More...
 

Static Public Member Functions

static ImageStoregetStore ()
 Get access to the Singleton ImageStore. More...
 
static ImageStoregetStore (gm::Context &context)
 Get access to, and initialize, the Singleton ImageStore. More...
 

Protected Member Functions

void createIcon (gm::Context &context, IconImage iconImage)
 Create an Icon using the Entypo font.
 
template<typename Iterator >
void createIcons (gm::Context &context, Iterator first, Iterator last)
 Create many Icons using a container of IconImage structures.
 
void initialize (gm::Context &context)
 Initialize the ImageStore.
 
void createSquareCorners (gm::Context &context, int radius, int borderWidth, color::RGBA top, color::RGBA bot, color::RGBA left, color::RGBA right)
 
void createRoundCorners (gm::Context &context, int scale, int radius, int borderWidth, color::RGBA top, color::RGBA bot, color::RGBA left, color::RGBA right)
 
void createCenters (gm::Context &context, int scale, int radius)
 

Protected Attributes

bool mInitialized {false}
 True after initialization.
 
int mNextImageId {static_cast<int>(ImageId::DynamicIdStart)}
 The next ImageId for storage of dynamic images.
 
std::map< ImageId, gm::TexturemImageMap {}
 The Texture storage map.
 

Member Function Documentation

◆ getStore() [1/2]

static ImageStore& rose::ImageStore::getStore ( )
inlinestatic

Get access to the Singleton ImageStore.

Returns
A reference to the ImageStore.

◆ getStore() [2/2]

static ImageStore& rose::ImageStore::getStore ( gm::Context context)
inlinestatic

Get access to, and initialize, the Singleton ImageStore.

This must be called by the application after the GraphicModel and Context have been initialized but before any access to the image storage.

Parameters
contextThe graphics Context used to create some icons.
Returns
A reference to the ImageStore.

◆ renderCopy() [1/2]

int rose::ImageStore::renderCopy ( gm::Context context,
ImageId  imageId,
Rectangle  dst 
)
inline

Render the Texture associated with an Image Id.

The source rectangle is set to the full Texture,

Parameters
contextThe Context to use.
imageIdThe ImageId.
dstThe destination Rectangle.
Returns
The return status code from the SDL API.

◆ renderCopy() [2/2]

int rose::ImageStore::renderCopy ( gm::Context context,
ImageId  imageId,
Rectangle  src,
Rectangle  dst 
)
inline

Render the Texture associated with an Image Id.

Parameters
contextThe Context to use.
imageIdThe ImageId.
srcThe source Rectangel.
dstThe destination Rectangle.
Returns
The return status code from the SDL API.

◆ renderCopyEx()

int rose::ImageStore::renderCopyEx ( gm::Context context,
ImageId  imageId,
Rectangle  src,
Rectangle  dst,
double  angle,
gm::RenderFlip  flip 
)
inline

Render the Texture associated with an Image Id with with optional rotation and flipping.

Parameters
contextThe Context to use.
imageIdThe Id of the image in the ImageStore.
srcThe source Rectangle.
dstThe destination Rectangle.
angleThe rotation Angle.
flipFlipping parameters
Returns
The return status code from the SDL API.

◆ size()

Size rose::ImageStore::size ( ImageId  imageId)
inline

Get the size of the Texture associated with an ImageId.

It is not an error for there to be no associated Texture. When this is the case Size::Zero is returned.

Parameters
imageIdThe ImageId.
Returns
A Size object.

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