template<class ChildType>
class daisy::ColorGraphicsDisplayImpl< ChildType >
This class is intended as a intermediary class for your actual implementation of the ColorGraphicsDisplay interface. It uses the CRTP design pattern where the template argument is the child class. It provides implementations for most of the functions, except DrawPixel(), SetColorFG(), SetColorBG, Update() and Fill(), which you'll have to provide in your child class. The main goal of this class is to provide common drawing functions without relying on massive amounts of virtual function calls that would result in a performance loss. To achieve this, any drawing function that is implemented here and internally calls other drawing functions (e.g. DrawRect() which internally calls DrawPixel() and DrawLine()) makes these calls via the qualified name of these functions to explicitly suppress the virtual dispatch mechanism like this:
ChildType::DrawPixel(...); // no virtual function call; direct call into the child class function
To create a custom ColorGraphicsDisplay implementation, you can A) inherit from ColorGraphicsDisplay directly and provide all the drawing functions yourself B) Inherit from ColorGraphicsDisplayImpl and only provide DrawPixel(), Fill() and Update() like this:
class MyDisplayClass : public ColorGraphicsDisplayImpl<MyDisplayClass> { public: void Fill() override { ... }; void DrawPixel(uint_fast8_t x, uint_fast8_t y, bool on) override { ... }; void Update() override { ... } };
|
| ColorGraphicsDisplayImpl () |
|
virtual | ~ColorGraphicsDisplayImpl () |
|
void | DrawLine (uint_fast8_t x1, uint_fast8_t y1, uint_fast8_t x2, uint_fast8_t y2, bool on) override |
|
void | DrawRect (uint_fast8_t x1, uint_fast8_t y1, uint_fast8_t x2, uint_fast8_t y2, bool on, bool fill=false) override |
|
void | DrawArc (uint_fast8_t x, uint_fast8_t y, uint_fast8_t radius, int_fast16_t start_angle, int_fast16_t sweep, bool on) override |
|
char | WriteChar (char ch, FontDef font, bool on) override |
|
char | WriteString (const char *str, FontDef font, bool on) override |
|
Rectangle | WriteStringAligned (const char *str, const FontDef &font, Rectangle boundingBox, Alignment alignment, bool on) override |
|
| ColorGraphicsDisplay () |
|
virtual | ~ColorGraphicsDisplay () |
|
virtual uint16_t | Height () const =0 |
|
virtual uint16_t | Width () const =0 |
|
Rectangle | GetBounds () const |
|
size_t | CurrentX () |
|
size_t | CurrentY () |
|
virtual void | Fill (bool on)=0 |
|
virtual void | DrawPixel (uint_fast8_t x, uint_fast8_t y, bool on)=0 |
|
virtual void | SetColorFG (uint8_t red, uint8_t green, uint8_t blue)=0 |
|
virtual void | SetColorBG (uint8_t red, uint8_t green, uint8_t blue)=0 |
|
void | DrawRect (const Rectangle &rect, bool on, bool fill=false) |
|
void | DrawCircle (uint_fast8_t x, uint_fast8_t y, uint_fast8_t radius, bool on) |
|
void | SetCursor (uint16_t x, uint16_t y) |
|
virtual void | Update ()=0 |
|