Add ability to change the color
This commit is contained in:
@ -31,4 +31,22 @@ void ProgressBar::redraw(TftInterface &tft, int value)
|
|||||||
|
|
||||||
m_lastValue = value;
|
m_lastValue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProgressBar::changeColor(TftInterface &tft, const uint32_t color, const uint32_t backgroundColor)
|
||||||
|
{
|
||||||
|
if (color != m_color)
|
||||||
|
{
|
||||||
|
// redraw already drawn area in new color
|
||||||
|
tft.fillRect(m_x+1, m_y+1, m_lastValue-m_x-1, m_height-2, color);
|
||||||
|
m_color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (backgroundColor != m_backgroundColor)
|
||||||
|
{
|
||||||
|
// redraw background in new color
|
||||||
|
tft.fillRect(m_x+1, m_y+1, m_width-2, m_height-2, backgroundColor);
|
||||||
|
m_backgroundColor = backgroundColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace espgui
|
} // namespace espgui
|
||||||
|
@ -21,6 +21,8 @@ public:
|
|||||||
void start(TftInterface &tft);
|
void start(TftInterface &tft);
|
||||||
void redraw(TftInterface &tft, int value);
|
void redraw(TftInterface &tft, int value);
|
||||||
|
|
||||||
|
void changeColor(TftInterface &tft, const uint32_t color = TFT_YELLOW, const uint32_t backgroundColor = TFT_BLACK);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const int m_x;
|
const int m_x;
|
||||||
const int m_y;
|
const int m_y;
|
||||||
@ -28,8 +30,8 @@ private:
|
|||||||
const int m_height;
|
const int m_height;
|
||||||
const int m_min;
|
const int m_min;
|
||||||
const int m_max;
|
const int m_max;
|
||||||
const uint32_t m_color;
|
uint32_t m_color;
|
||||||
const uint32_t m_backgroundColor;
|
uint32_t m_backgroundColor;
|
||||||
|
|
||||||
int m_lastValue{};
|
int m_lastValue{};
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user