diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b45e5eee4..2d4d09561 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -194,6 +194,7 @@ set(UI_TEST_SOURCES ${GUI_TESTDIR}/test_field_point3.cpp ${GUI_TESTDIR}/test_field_colorpicker.cpp ${GUI_TESTDIR}/test_field_slider.cpp + ${GUI_TESTDIR}/test_optionsgroup.cpp ${GUI_TESTDIR}/test_misc_ui.cpp ) diff --git a/src/GUI/OptionsGroup.hpp b/src/GUI/OptionsGroup.hpp new file mode 100644 index 000000000..56bc3dadf --- /dev/null +++ b/src/GUI/OptionsGroup.hpp @@ -0,0 +1,70 @@ +#include "ConfigBase.hpp" +#include "Config.hpp" +#include "OptionsGroup/Field.hpp" +#include +#include +#include + +namespace Slic3r { namespace GUI { + +class Option; +class Line; +class OptionsGroup; +class ConfigOptionsGroup; + +/// Class to +class Option { +public: + /// TODO: Constructor needs to include a default value + /// Reference to the configuration store. + ConfigOptionDef& desc; + Option(const ConfigOptionType& _type, const ConfigOption& _def) : desc(this->_desc) { + desc.type = _type; + // set _default to whatever it needs to be based on _type + + + // set desc default value to our stored one. + desc.default_value = _default; + } + + // move constructor, owns the Config item. + Option(ConfigOptionDef&& remote) : desc(this->_desc), _desc(std::move(remote)) { } + + /// Destructor to take care of the owned default value. + ~Option() { + if (_default != nullptr) delete _default; + _default = nullptr; + } + + + /// TODO: Represent a sidebar widget + void* side_widget {nullptr}; + +private: + /// Actual configuration store. + /// Holds important information related to this configuration item. + ConfigOptionDef _desc; + + /// default value, passed into _desc on construction. + /// Owns the data. + ConfigOption* _default {nullptr}; +}; + +class OptionsGroup { +public: + OptionsGroup() {} + ConfigOption* get_field(const t_config_option_key& opt_id) { return nullptr; } +protected: + std::map> _options; + std::map> _fields; +}; + +class ConfigOptionsGroup : public OptionsGroup { +public: + + std::shared_ptr config; +protected: + +}; + +}} // namespace Slic3r::GUI diff --git a/src/test/GUI/test_optionsgroup.cpp b/src/test/GUI/test_optionsgroup.cpp new file mode 100644 index 000000000..3b782e2e8 --- /dev/null +++ b/src/test/GUI/test_optionsgroup.cpp @@ -0,0 +1,29 @@ +#include +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/sizer.h" + #include "wx/uiaction.h" +#endif // WX_PRECOMP +#include + +#include "OptionsGroup.hpp" +#include "ConfigBase.hpp" +#include "Config.hpp" + +using namespace Slic3r::GUI; + +SCENARIO("OptionsGroup: Construction.") { +} +SCENARIO("ConfigOptionsGroup: Factory methods") { + GIVEN("A default Slic3r config") { + OptionsGroup optgroup; + WHEN("add_single_option is called for avoid_crossing_perimeters") { + THEN("a UI_Checkbox is added to the field map") { + REQUIRE(optgroup.get_field("avoid_crossing_perimeters") != nullptr); + } + THEN("a ConfigOptionBool is added to the option map") { + REQUIRE(optgroup.get_field("avoid_crossing_perimeters") != nullptr); + } + } + } +}