tcMenu
Public Types | Public Member Functions | List of all members
tcgfx::DrawableIcon Class Reference

#include <DrawingPrimitives.h>

Public Types

enum  IconType : uint8_t {
  ICON_XBITMAP , ICON_MONO , ICON_PALLETE_2BPP , ICON_PALLETE_4BPP ,
  ICON_NATIVE
}
 
enum  MemoryLocation : uint8_t { STORED_IN_ROM , STORED_IN_RAM , LOAD_FROM_STORAGE }
 

Public Member Functions

 DrawableIcon ()
 
 DrawableIcon (const DrawableIcon &other)=default
 
DrawableIconoperator= (const DrawableIcon &other)=default
 
 DrawableIcon (uint16_t id, const Coord &size, IconType ty, const uint8_t *normal, const uint8_t *selected=nullptr)
 
 DrawableIcon (uint16_t id, const Coord &size, IconType ty, const color_t *paletteEntries, const uint8_t *normal, const uint8_t *selected=nullptr)
 
const uint8_t * getIcon (bool selected) const
 
const color_tgetPalette () const
 
Coord getDimensions () const
 
IconType getIconType () const
 
uint16_t getKey () const
 
void setFromValues (const Coord &size, IconType ty, const uint8_t *normal, const uint8_t *selected=nullptr)
 

Detailed Description

Represents an icon that can be presented for actionable menu items such as submenus, boolean items, and action items. It can have two items states, one for selected and one for normal.

Member Enumeration Documentation

◆ IconType

Enumerator
ICON_XBITMAP 

the image is in the well know XBM format, no palette info provided

ICON_MONO 

the image is a regular monochrome bitmap in native format, no palette info provided

ICON_PALLETE_2BPP 

the image is in a palette format, the palette information will be populated, it contains rendering instructions for 2 bits per pixel

ICON_PALLETE_4BPP 

the image is in a palette format, the palette information will be populated, it contains rendering instructions for 4 bits per pixel

ICON_NATIVE 

the image is in a format that can be pushed directly to the display, no palette info provided

◆ MemoryLocation

Enumerator
STORED_IN_ROM 

Indication that this image is in progmem, this is the default

STORED_IN_RAM 

This image is in RAM, if it can be supported by the display. EG board with progmem, driver support

LOAD_FROM_STORAGE 

Not yet supported, will provide for loading images from external storage in a future version

Constructor & Destructor Documentation

◆ DrawableIcon() [1/4]

tcgfx::DrawableIcon::DrawableIcon ( )
inline

Creates an empty drawable icon, used mainly by collection support

◆ DrawableIcon() [2/4]

tcgfx::DrawableIcon::DrawableIcon ( const DrawableIcon other)
default

Copy constructor to copy an existing drawable icon

◆ DrawableIcon() [3/4]

tcgfx::DrawableIcon::DrawableIcon ( uint16_t  id,
const Coord size,
IconType  ty,
const uint8_t *  normal,
const uint8_t *  selected = nullptr 
)
inline

Create a drawable icon providing the size, icon type, and image data

Parameters
idthe menu id that this icon belongs to
sizethe size of the image, better to be in whole byte sizes
tythe type of the image, so the renderer knows what to do with it.
normalthe image in the normal state.
selectedthe image in the selected state.

◆ DrawableIcon() [4/4]

tcgfx::DrawableIcon::DrawableIcon ( uint16_t  id,
const Coord size,
IconType  ty,
const color_t paletteEntries,
const uint8_t *  normal,
const uint8_t *  selected = nullptr 
)
inline

Create a drawable icon providing the size, icon type, and image data along with a palette, this is suited for 2 and 4 bit per pixel images

Parameters
idthe menu id that this icon belongs to
sizethe size of the image, better to be in whole byte sizes
palettethe palette data for the image, will define this as a palette based image
normalthe image in the normal state.
selectedthe image in the selected state.

Member Function Documentation

◆ getIcon()

const uint8_t* tcgfx::DrawableIcon::getIcon ( bool  selected) const
inline

Get the icon data for the current state

Parameters
selectedtrue if the item is selected (IE pressed or ON for booleans)
Returns
the icon data, which may be in program memory on AVR and ESP.

◆ getPalette()

const color_t* tcgfx::DrawableIcon::getPalette ( ) const
inline

Get the palette information (if available) for this icon

Returns
either icon palette data if available or nullptr.

◆ getDimensions()

Coord tcgfx::DrawableIcon::getDimensions ( ) const
inline
Returns
the dimensions of the image

◆ getIconType()

IconType tcgfx::DrawableIcon::getIconType ( ) const
inline
Returns
the icon type for the image

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