Avoid a invalidate when not needed
This commit is contained in:
+7
-5
@@ -21,7 +21,8 @@
|
|||||||
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
class Progress : public Window {
|
class Progress: public Window
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
Progress(Window * parent, const rect_t & rect):
|
Progress(Window * parent, const rect_t & rect):
|
||||||
Window(parent, rect)
|
Window(parent, rect)
|
||||||
@@ -35,10 +36,12 @@ class Progress : public Window {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void setValue(int value)
|
void setValue(int newValue)
|
||||||
{
|
{
|
||||||
this->value = value;
|
if (newValue != value) {
|
||||||
invalidate();
|
value = newValue;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void paint(BitmapBuffer * dc) override;
|
void paint(BitmapBuffer * dc) override;
|
||||||
@@ -46,4 +49,3 @@ class Progress : public Window {
|
|||||||
protected:
|
protected:
|
||||||
int value = 0;
|
int value = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+6
-3
@@ -45,8 +45,10 @@ class StaticText: public Window
|
|||||||
|
|
||||||
void setText(std::string value)
|
void setText(std::string value)
|
||||||
{
|
{
|
||||||
text = std::move(value);
|
if (text != value) {
|
||||||
invalidate();
|
text = std::move(value);
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBackgroundColor(LcdFlags color)
|
void setBackgroundColor(LcdFlags color)
|
||||||
@@ -59,7 +61,8 @@ class StaticText: public Window
|
|||||||
LcdFlags bgColor = 0;
|
LcdFlags bgColor = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Subtitle: public StaticText {
|
class Subtitle: public StaticText
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
Subtitle(Window * parent, const rect_t & rect, const char * text):
|
Subtitle(Window * parent, const rect_t & rect, const char * text):
|
||||||
StaticText(parent, rect, text, 0, FONT(BOLD))
|
StaticText(parent, rect, text, 0, FONT(BOLD))
|
||||||
|
|||||||
Reference in New Issue
Block a user