mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
UI
Add extra color for led to UI led class
This commit is contained in:
+19
-3
@@ -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
@@ -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;
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user