Start using spdlog library

b CAN
This commit is contained in:
2024-08-27 11:10:37 +02:00
parent d24168e5d1
commit 3f1cf62d5c
10 changed files with 72 additions and 18 deletions
+16 -5
View File
@@ -3,11 +3,11 @@
Test_Sim::Test_Sim() :
Simulator_base("Test_Sim"),
m_button("button", "Button", Color(Color::White), Color(Color::Black), [](std::string id) { std::cout << "Button " << id << " clicked" << std::endl; }),
m_combobox("combobox", "Combobox", Color(Color::White), Color(Color::Black), {"Option 1", "Option 2", "Option 3"}, 0, [](std::string id, std::string selected) { std::cout << "Combobox " << id << " selected " << selected << std::endl; }),
m_button("button", "Off", Color(Color::White), Color(Color::Red), [this](std::string id) { button_clicked(id); }),
m_combobox("combobox", "Combobox", Color(Color::White), Color(Color::Black), {"Option 1", "Option 2", "Option 3"}, 0, [](std::string id, std::string selected) { spdlog::info("Combobox {} selected {}", id, selected); }),
m_label("label", "Label", Color(Color::White), Color(Color::Black)),
m_checkbox("checkbox", "Checkbox", Color(Color::White), Color(Color::Black), {"Option 1", "Option 2", "Option 3"}, [](std::string id, std::vector<std::string> selected) { std::cout << "Checkbox " << id << " selected " << (selected.size() > 0 ? selected[0] : "") << std::endl; }),
m_slider("slider", "Slider", Color(Color::White), Color(Color::Black), 0, 100, 50, [](std::string id, double value) { std::cout << "Slider " << id << " changed to " << value << std::endl; })
m_checkbox("checkbox", "Checkbox", Color(Color::White), Color(Color::Black), {"Option 1", "Option 2", "Option 3"}, [](std::string id, std::vector<std::string> selected) { spdlog::info("Checkbox {} selected {}", id, (selected.size() > 0 ? selected[0] : "")); }),
m_slider("slider", "Slider", Color(Color::White), Color(Color::Black), 0, 100, 50, [](std::string id, double value) { spdlog::info("Slider {} changed to {}", id, value); })
{
this->add_UI_item(&this->m_button);
this->add_UI_item(&this->m_combobox);
@@ -24,5 +24,16 @@ void Test_Sim::timer()
void Test_Sim::run_at_startup()
{
// Run at startup
std::cout << "Test_Sim started" << std::endl;
spdlog::info("Test_Sim started");
}
void Test_Sim::button_clicked(std::string id)
{
if (id == "button")
{
bool state = this->m_button.bg_color() == Color(Color::Red) ? true : false;
this->m_button.set_bg_color(state ? Color(Color::Green) : Color(Color::Red));
this->m_button.set_text(state ? "On" : "Off");
return;
}
}