mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-27 06:01:14 +01:00
Add test sim
This commit is contained in:
@@ -5,12 +5,15 @@ include(FetchContent)
|
||||
FetchContent_Declare(magic_enum URL https://github.com/Neargye/magic_enum/releases/download/v0.9.6/magic_enum-v0.9.6.tar.gz DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
|
||||
FetchContent_MakeAvailable(magic_enum)
|
||||
|
||||
file(GLOB_RECURSE SIM_SOURCES "simulators/*.cpp")
|
||||
|
||||
target_sources(server PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}/main.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/message_parser.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/simulator_base.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/simulators.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/websocket.cpp
|
||||
${SIM_SOURCES}
|
||||
)
|
||||
|
||||
target_compile_options(server PRIVATE $<$<CONFIG:Debug>:
|
||||
@@ -20,11 +23,13 @@ target_compile_options(server PRIVATE $<$<CONFIG:Debug>:
|
||||
target_include_directories(server
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
${CMAKE_CURRENT_LIST_DIR}/simulators
|
||||
PRIVATE
|
||||
${PROJECT_DIR}/external/websocketpp
|
||||
)
|
||||
|
||||
target_link_libraries(server PRIVATE
|
||||
CAN
|
||||
UI
|
||||
Timer
|
||||
magic_enum::magic_enum
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#include "test_sim.hpp"
|
||||
#include <iostream>
|
||||
|
||||
Test_Sim::Test_Sim() :
|
||||
Simulator_base("Test_Sim"),
|
||||
p_button("button", "Button", Color(Color::White), Color(Color::Black), [](std::string id) { std::cout << "Button " << id << " clicked" << std::endl; }),
|
||||
p_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; }),
|
||||
p_label("label", "Label", Color(Color::White), Color(Color::Black)),
|
||||
p_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; }),
|
||||
p_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; })
|
||||
{
|
||||
this->add_UI_item(&this->p_button);
|
||||
this->add_UI_item(&this->p_combobox);
|
||||
this->add_UI_item(&this->p_label);
|
||||
this->add_UI_item(&this->p_checkbox);
|
||||
this->add_UI_item(&this->p_slider);
|
||||
}
|
||||
|
||||
void Test_Sim::timer()
|
||||
{
|
||||
// Timer function
|
||||
// p_button.click();
|
||||
// p_combobox.set_selected(1);
|
||||
// p_checkbox.toggle_selected("Option 2");
|
||||
// p_slider.set_value(75);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include "simulator_base.hpp"
|
||||
|
||||
class Test_Sim : public Simulator_base {
|
||||
public:
|
||||
Test_Sim();
|
||||
void timer() override;
|
||||
private:
|
||||
UI_button p_button;
|
||||
UI_combobox p_combobox;
|
||||
UI_label p_label;
|
||||
UI_checkbox p_checkbox;
|
||||
UI_slider p_slider;
|
||||
};
|
||||
Reference in New Issue
Block a user