Avoid a invalidate when not needed

This commit is contained in:
Bertrand Songis
2021-03-10 10:43:36 +01:00
parent 8a196f5982
commit f0d963386f
2 changed files with 13 additions and 8 deletions
+7 -5
View File
@@ -21,7 +21,8 @@
#include "window.h"
class Progress : public Window {
class Progress: public Window
{
public:
Progress(Window * parent, const rect_t & rect):
Window(parent, rect)
@@ -35,10 +36,12 @@ class Progress : public Window {
}
#endif
void setValue(int value)
void setValue(int newValue)
{
this->value = value;
invalidate();
if (newValue != value) {
value = newValue;
invalidate();
}
}
void paint(BitmapBuffer * dc) override;
@@ -46,4 +49,3 @@ class Progress : public Window {
protected:
int value = 0;
};
+6 -3
View File
@@ -45,8 +45,10 @@ class StaticText: public Window
void setText(std::string value)
{
text = std::move(value);
invalidate();
if (text != value) {
text = std::move(value);
invalidate();
}
}
void setBackgroundColor(LcdFlags color)
@@ -59,7 +61,8 @@ class StaticText: public Window
LcdFlags bgColor = 0;
};
class Subtitle: public StaticText {
class Subtitle: public StaticText
{
public:
Subtitle(Window * parent, const rect_t & rect, const char * text):
StaticText(parent, rect, text, 0, FONT(BOLD))