StaticBitmap can now display a mask with a color
This commit is contained in:
+21
-4
@@ -22,7 +22,8 @@
|
|||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "button.h" // TODO just for BUTTON_BACKGROUND
|
#include "button.h" // TODO just for BUTTON_BACKGROUND
|
||||||
|
|
||||||
class StaticText: public Window {
|
class StaticText: public Window
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
StaticText(Window * parent, const rect_t & rect, std::string text = "", WindowFlags windowFlags = 0, LcdFlags textFlags = 0) :
|
StaticText(Window * parent, const rect_t & rect, std::string text = "", WindowFlags windowFlags = 0, LcdFlags textFlags = 0) :
|
||||||
Window(parent, rect, windowFlags, textFlags),
|
Window(parent, rect, windowFlags, textFlags),
|
||||||
@@ -73,7 +74,8 @@ class Subtitle: public StaticText {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
class StaticBitmap: public Window {
|
class StaticBitmap: public Window
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
StaticBitmap(Window * parent, const rect_t & rect, bool scale = false):
|
StaticBitmap(Window * parent, const rect_t & rect, bool scale = false):
|
||||||
Window(parent, rect),
|
Window(parent, rect),
|
||||||
@@ -95,11 +97,24 @@ class StaticBitmap: public Window {
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StaticBitmap(Window * parent, const rect_t & rect, const BitmapBuffer * mask, LcdFlags color, bool scale = false):
|
||||||
|
Window(parent, rect),
|
||||||
|
bitmap(mask),
|
||||||
|
color(color),
|
||||||
|
scale(scale)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void setBitmap(const char * filename)
|
void setBitmap(const char * filename)
|
||||||
{
|
{
|
||||||
setBitmap(BitmapBuffer::loadBitmap(filename));
|
setBitmap(BitmapBuffer::loadBitmap(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setMaskColor(LcdFlags value)
|
||||||
|
{
|
||||||
|
color = value;
|
||||||
|
}
|
||||||
|
|
||||||
void setBitmap(const BitmapBuffer * newBitmap)
|
void setBitmap(const BitmapBuffer * newBitmap)
|
||||||
{
|
{
|
||||||
delete bitmap;
|
delete bitmap;
|
||||||
@@ -117,7 +132,9 @@ class StaticBitmap: public Window {
|
|||||||
void paint(BitmapBuffer * dc) override
|
void paint(BitmapBuffer * dc) override
|
||||||
{
|
{
|
||||||
if (bitmap) {
|
if (bitmap) {
|
||||||
if (scale)
|
if (color != 0xFFFFFFFF)
|
||||||
|
dc->drawMask(0, 0, bitmap, color);
|
||||||
|
else if (scale)
|
||||||
dc->drawScaledBitmap(bitmap, 0, 0, width(), height());
|
dc->drawScaledBitmap(bitmap, 0, 0, width(), height());
|
||||||
else
|
else
|
||||||
dc->drawBitmap((width() - bitmap->width()) / 2, (height() - bitmap->height()) / 2, bitmap);
|
dc->drawBitmap((width() - bitmap->width()) / 2, (height() - bitmap->height()) / 2, bitmap);
|
||||||
@@ -126,6 +143,7 @@ class StaticBitmap: public Window {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
const BitmapBuffer * bitmap = nullptr;
|
const BitmapBuffer * bitmap = nullptr;
|
||||||
|
LcdFlags color = 0xFFFFFFFF;
|
||||||
bool scale = false;
|
bool scale = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -184,4 +202,3 @@ class DynamicNumber: public Window
|
|||||||
const char * prefix;
|
const char * prefix;
|
||||||
const char * suffix;
|
const char * suffix;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user