#include <DeviceDrawableHelper.h>
Public Member Functions | |
DeviceDrawableHelper (DeviceDrawable *root, color_t *palette, uint8_t paletteSize, const Coord &startPosition, const Coord &size) | |
DeviceDrawableHelper (DeviceDrawable *root) | |
void | reConfigure (color_t *palette, uint8_t paletteSize, const Coord &startPosition, const Coord &size) |
DeviceDrawable * | getDrawable () |
Coord | offsetLocation (const Coord &source) const |
Coord | offsetLocation (const Coord &source, int xOffs, int yOffs) const |
void | endDraw () |
void | setFont (const DeviceFontDrawingMode &font) |
void | drawText (const Coord &where, color_t color, const char *text) |
Coord | textExtents (const char *text, int *bl) |
void | setFontFromParameters (const void *font, uint8_t mag) |
Wraps a drawable regardless of if we are on a sub device or root device, this class handles all the differences between the two with helper functions for dealing with palette colors and offset differences. It also has helpers that work out if TcUnicode(Adafruit or Unicode)/Native fonts are being used and calls the right drawing functions
DeviceDrawableHelper::DeviceDrawableHelper | ( | DeviceDrawable * | root, |
color_t * | palette, | ||
uint8_t | paletteSize, | ||
const Coord & | startPosition, | ||
const Coord & | size | ||
) |
Create a drawable helper given the drawable, palette, position and size, if it is possible, it will create a subdevice for drawing. When you call drawing functions that take a where coordinate, use the offsetLocation function that corrects for the sub drawable for you automatically.
root | the root device drawable |
palette | the palette of colors for the sub drawable |
paletteSize | the size of the palette |
startPosition | the starting position on the screen to draw at |
size | how large the area is |
|
explicit |
For global constructions, we can also initially construct as root, and it will reconfigure later.
root | the drawable that will act as root |
|
inline |
Get the drawable, not that this could be either the root device or a sub-device, always use offset location to ensure your where parameters are correctly positioned
If on a sub-device, this call will correct the coordinate to match the area of the screen that the sub-device is drawing to.
source | the source in screen coordinates |
If on a sub-device, this call will correct the coordinate to match the area of the screen that the sub-device is drawing to.
source | the source in screen coordinates |
xOffs | an additional x offset to apply |
yOffs | an additional y offset to apply |
|
inline |
You must call this once drawing is concluded to ensure that the results are drawn, in the case of a sub-device this is critical.
|
inline |
Set the font drawing mode for the subsequent text operations
font | the font drawing mode |
Draw text in the current font onto the display using the current drawable. Ensure you've called setFont before this with a suitable font.
where | where to draw (will automatically apply offsetLocation) |
color | the color to draw in (not the index) |
text | the text to be presented |
Coord DeviceDrawableHelper::textExtents | ( | const char * | text, |
int * | bl | ||
) |
Gets the size of the text for the current font as set by setFont. It's coordinates are returned, and the baseline is copied into the baseline parameter
text | the text to measure |
bl | the baseline pointer to fill in - int pointer |
void DeviceDrawableHelper::setFontFromParameters | ( | const void * | font, |
uint8_t | mag | ||
) |
Set the font from the theme font pointer and magnification values, by determining if tcUnicode is enabled and then choosing either native or TcUnicode based operation.