sim base clean

UI now uses bg_color as led_color
Move add_UI_item to push_ui_item
This commit is contained in:
2026-02-14 14:30:38 +01:00
parent d345affd63
commit b9d3c432bc
9 changed files with 30 additions and 51 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ std::string Simulator_base::name() const
return m_name;
}
void Simulator_base::add_UI_item(UI_item *item)
void Simulator_base::push_ui_item(UI_item *item)
{
// Add a UI item to the simulator
connect(item, &UI_item::value_changed, this, [this] { emit sim_changed(); });
+1 -1
View File
@@ -31,7 +31,7 @@ class Simulator_base : public QObject
*
* @param item The UI item to add
*/
void add_UI_item(UI_item *item);
void push_ui_item(UI_item *item);
/**
* @brief Get the UI items object
*
+1 -1
View File
@@ -4,7 +4,7 @@ Can_Debugger::Can_Debugger(CAN_Wrapper *can_wrapper, QObject *parent)
: Simulator_base("Can_Debugger", can_wrapper, std::chrono::milliseconds(100), parent), m_wrapper(can_wrapper),
m_can_ui(Color::Black, Color::White)
{
this->add_UI_item(&this->m_can_ui);
this->push_ui_item(&this->m_can_ui);
connect(&m_can_ui, &UI_can::on_send, this, [=, this](QCanBusFrame frame) { m_wrapper->send_can_message(frame); });
}
+15 -15
View File
@@ -11,21 +11,21 @@ m_dial("Dial", Color(Color::White), Color(Color::Black), 0, 100, 0),
m_thermo("Thermo", "%", Color(Color::White), Color(Color::Black), 0, 100, 0),
m_led("Led", Color(Color::White), Color(Color::Black), Color(Color::Red))
{
this->m_thermo.set_start_color(Color(Color::Red));
this->m_thermo.set_end_color(Color(Color::Red));
this->m_thermo.add_color_stop(0.10, Color(Color::Yellow));
this->m_thermo.add_color_stop(0.50, Color(Color::Green));
this->m_thermo.add_color_stop(0.60, Color(Color::Yellow));
this->m_thermo.add_color_stop(0.90, Color(Color::Red));
this->m_thermo.set_start_color(Color::Red);
this->m_thermo.set_end_color(Color::Red);
this->m_thermo.add_color_stop(0.10, Color::Yellow);
this->m_thermo.add_color_stop(0.50, Color::Green);
this->m_thermo.add_color_stop(0.60, Color::Yellow);
this->m_thermo.add_color_stop(0.90, Color::Red);
this->add_UI_item(&this->m_button);
this->add_UI_item(&this->m_combobox);
this->add_UI_item(&this->m_label);
this->add_UI_item(&this->m_slider);
this->add_UI_item(&this->m_dial);
this->add_UI_item(&this->m_thermo);
this->add_UI_item(&this->m_led);
this->add_UI_item(&this->m_checkbox);
this->push_ui_item(&this->m_button);
this->push_ui_item(&this->m_combobox);
this->push_ui_item(&this->m_label);
this->push_ui_item(&this->m_slider);
this->push_ui_item(&this->m_dial);
this->push_ui_item(&this->m_thermo);
this->push_ui_item(&this->m_led);
this->push_ui_item(&this->m_checkbox);
QObject::connect(&m_button, &UI_button::on_click, this, [=, this] { button_clicked(&m_button); });
QObject::connect(&m_slider, &UI_slider::on_change, this,
@@ -56,7 +56,7 @@ void Test_Sim::button_clicked(UI_button *id)
this->m_button.set_bg_color(state ? Color(Color::Green) : Color(Color::Red));
this->m_button.set_text(state ? "On" : "Off");
this->m_led.set_led_color(state ? Color(Color::Green) : Color(Color::Red));
this->m_led.set_bg_color(state ? Color(Color::Green) : Color(Color::Red));
return;
}
}