Add extra color for led to UI led class
This commit is contained in:
2024-08-27 11:10:41 +02:00
parent 5a2fb2de22
commit e06007817c
2 changed files with 25 additions and 4 deletions
+19 -3
View File
@@ -1,7 +1,8 @@
#include "UI_led.hpp" #include "UI_led.hpp"
UI_led::UI_led(std::string id, std::string text, Color fg_color, Color bg_color) : UI_led::UI_led(std::string id, std::string text, Color fg_color, Color bg_color, Color led_color) :
UI_item(id, UI_LED_TYPE, text, 12, fg_color, bg_color) UI_item(id, UI_LED_TYPE, text, 12, fg_color, bg_color),
m_led_color(led_color)
{ {
} }
@@ -11,12 +12,27 @@ UI_led::UI_led(const json& j) : UI_item(j)
from_json(j); from_json(j);
} }
Color UI_led::led_color() const
{
return m_led_color;
}
void UI_led::set_led_color(Color led_color)
{
m_led_color = led_color;
}
void UI_led::from_json(const json& j) void UI_led::from_json(const json& j)
{ {
UI_item::from_json(j); UI_item::from_json(j);
std::string color;
j.at("led_color").get_to(color);
m_led_color = Color(color);
} }
json UI_led::to_json() const json UI_led::to_json() const
{ {
return UI_item::to_json(); json j = UI_item::to_json();
j["led_color"] = m_led_color.to_hex();
return j;
} }
+6 -1
View File
@@ -7,9 +7,14 @@
class UI_led : public UI_item class UI_led : public UI_item
{ {
public: public:
UI_led(std::string id, std::string text, Color fg_color, Color bg_color); UI_led(std::string id, std::string text, Color fg_color, Color bg_color, Color led_color);
UI_led(const json& j); UI_led(const json& j);
Color led_color() const;
void set_led_color(Color led_color);
void from_json(const json& j) override; void from_json(const json& j) override;
json to_json() const override; json to_json() const override;
private:
Color m_led_color;
}; };