diff --git a/CMakeLists.txt b/CMakeLists.txt index a4015f6..b0588e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ set(headers + src/icon.h src/tftinterface.h ) diff --git a/src/icon.h b/src/icon.h new file mode 100644 index 0000000..8ca8a1d --- /dev/null +++ b/src/icon.h @@ -0,0 +1,17 @@ +#pragma once + +// system includes +#include + +namespace espgui { +template +struct Icon +{ + static constexpr auto WIDTH=width; + static constexpr auto HEIGHT=height; + + const unsigned short buffer[width*height]; + const char * const name{}; + +}; +} // namespace espgui diff --git a/src/tftinterface.h b/src/tftinterface.h index 8b5bd1f..d5bc972 100644 --- a/src/tftinterface.h +++ b/src/tftinterface.h @@ -3,6 +3,9 @@ // system includes #include +// local includes +#include "icon.h" + namespace espgui { class TftInterface { @@ -73,6 +76,16 @@ public: virtual void fillTriangle(int32_t x1,int32_t y1, int32_t x2,int32_t y2, int32_t x3,int32_t y3, uint32_t color) = 0; // These are used to render images or sprites stored in RAM arrays (used by Sprite class for 16bpp Sprites) + template + void pushImage(int32_t x, int32_t y, const Icon &icon) + { + pushImage(x, y, width, height, icon.buffer); + } + template + void pushImage(int32_t x, int32_t y, const Icon &icon, uint16_t transparent) + { + pushImage(x, y, width, height, icon.buffer, transparent); + } virtual void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *data) = 0; virtual void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *data, uint16_t transparent) = 0;