Avoid a invalidate when not needed
This commit is contained in:
+7
-5
@@ -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
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user