diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 1af1ce5412..511e7edd13 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -118,8 +118,8 @@ std::vector g_tabs_list; wxLocale* g_wxLocale; -std::shared_ptr m_optgroup; -double m_brim_width = 0.0; +std::vector > m_optgroups; +double m_brim_width = 0.0; wxButton* g_wiping_dialog_button = nullptr; //showed/hided controls according to the view mode @@ -379,8 +379,7 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l // local_menu->Append(config_id_base + ConfigMenuUpdate, _(L("Check for updates")), _(L("Check for configuration updates"))); local_menu->AppendSeparator(); local_menu->Append(config_id_base + ConfigMenuPreferences, _(L("Preferences"))+"\u2026\tCtrl+,", _(L("Application preferences"))); - local_menu->Append(config_id_base + ConfigMenuLanguage, _(L("Change Application Language"))); - local_menu->AppendSeparator(); + local_menu->AppendSeparator(); auto mode_menu = new wxMenu(); mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeSimple, _(L("&Simple")), _(L("Simple View Mode"))); mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeRegular, _(L("&Regular")), _(L("Regular View Mode"))); @@ -389,6 +388,11 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l local_menu->AppendSubMenu(mode_menu, _(L("&Mode")), _(L("Slic3r View Mode"))); local_menu->AppendSeparator(); local_menu->Append(config_id_base + ConfigMenuLanguage, _(L("Change Application Language"))); + local_menu->AppendSeparator(); + local_menu->Append(config_id_base + ConfigMenuFlashFirmware, _(L("Flash printer firmware")), _(L("Upload a firmware image into an Arduino based printer"))); + // TODO: for when we're able to flash dictionaries + // local_menu->Append(config_id_base + FirmwareMenuDict, _(L("Flash language file")), _(L("Upload a language dictionary file into a Prusa printer"))); + local_menu->Bind(wxEVT_MENU, [config_id_base, event_language_change, event_preferences_changed](wxEvent &event){ switch (event.GetId() - config_id_base) { case ConfigMenuWizard: @@ -876,8 +880,36 @@ wxBoxSizer* content_objects_list(wxWindow *win) wxBoxSizer* content_object_settings(wxWindow *win) { + DynamicPrintConfig* config = &g_PresetBundle->prints.get_edited_preset().config; + std::shared_ptr optgroup = std::make_shared(win, "", config, false, ogSIDE_OPTIONS_VERTICAL); + optgroup->label_width = 100; + + Line line = { _(L("Position")), "" }; + ConfigOptionDef def; + + def.label = L("X"); + def.type = coInt; + def.default_value = new ConfigOptionInt(1); + def.sidetext = L("mm"); + + Option option = Option(def, "position_X"); + option.opt.full_width = true; + line.append_option(option); + + def.label = L("Y"); + option = Option(def, "position_Y"); + line.append_option(option); + + def.label = L("Z"); + option = Option(def, "position_Z"); + line.append_option(option); + + optgroup->append_line(line); + + m_optgroups.push_back(optgroup); // ogObjectSettings + auto sizer = new wxBoxSizer(wxVERTICAL); - sizer->Add(new wxStaticText(win, wxID_ANY, "Some object text")); + sizer->Add(optgroup->sizer, 1, wxEXPAND | wxBOTTOM, 2); return sizer; } @@ -929,10 +961,10 @@ void add_expert_mode_part(wxWindow* parent, wxBoxSizer* sizer) void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFlexGridSizer* preset_sizer) { DynamicPrintConfig* config = &g_PresetBundle->prints.get_edited_preset().config; - m_optgroup = std::make_shared(parent, "", config); + std::shared_ptr optgroup = std::make_shared(parent, "", config); const wxArrayInt& ar = preset_sizer->GetColWidths(); - m_optgroup->label_width = ar.IsEmpty() ? 100 : ar.front()-4; // doesn't work - m_optgroup->m_on_change = [config](t_config_option_key opt_key, boost::any value){ + optgroup->label_width = ar.IsEmpty() ? 100 : ar.front()-4; // doesn't work + optgroup->m_on_change = [config](t_config_option_key opt_key, boost::any value){ TabPrint* tab_print = nullptr; for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++i) { Tab *tab = dynamic_cast(g_wxTabPanel->GetPage(i)); @@ -947,7 +979,7 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl return; if (opt_key == "fill_density"){ - value = m_optgroup->get_config_value(*config, opt_key); + value = m_optgroups[ogFrequentlyChangingParameters]->get_config_value(*config, opt_key); tab_print->set_value(opt_key, value); tab_print->update(); } @@ -985,10 +1017,10 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl tab_print->update_dirty(); }; - Option option = m_optgroup->get_option("fill_density"); + Option option = optgroup->get_option("fill_density"); option.opt.sidetext = ""; option.opt.full_width = true; - m_optgroup->append_single_option_line(option); + optgroup->append_single_option_line(option); ConfigOptionDef def; @@ -1007,7 +1039,7 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl def.default_value = new ConfigOptionStrings { selection }; option = Option(def, "support"); option.opt.full_width = true; - m_optgroup->append_single_option_line(option); + optgroup->append_single_option_line(option); m_brim_width = config->opt_float("brim_width"); def.label = L("Brim"); @@ -1016,7 +1048,7 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl def.gui_type = ""; def.default_value = new ConfigOptionBool{ m_brim_width > 0.0 ? true : false }; option = Option(def, "brim"); - m_optgroup->append_single_option_line(option); + optgroup->append_single_option_line(option); Line line = { "", "" }; @@ -1041,9 +1073,11 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl })); return sizer; }; - m_optgroup->append_line(line); + optgroup->append_line(line); - sizer->Add(m_optgroup->sizer, 1, wxEXPAND | wxBOTTOM, 2); + sizer->Add(optgroup->sizer, 1, wxEXPAND | wxBOTTOM, 2); + + m_optgroups.push_back(optgroup);// ogFrequentlyChangingParameters } void show_frequently_changed_parameters(bool show) @@ -1094,9 +1128,9 @@ void update_mode() g_right_panel->Layout(); } -ConfigOptionsGroup* get_optgroup() +ConfigOptionsGroup* get_optgroup(size_t i) { - return m_optgroup.get(); + return m_optgroups[i].get(); } diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 3681827b6d..243c63cc3e 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -47,9 +47,10 @@ class TabIface; namespace GUI { -enum ogDrawFlag{ - ogDEFAULT, - ogSIDE_OPTIONS_TO_GRID +enum ogGroup{ + ogFrequentlyChangingParameters, + ogObjectSettings, + ogPartSettings }; class Tab; @@ -173,7 +174,7 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl // Update view mode according to selected menu void update_mode(); -ConfigOptionsGroup* get_optgroup(); +ConfigOptionsGroup* get_optgroup(size_t i); wxButton* get_wiping_dialog_button(); void add_export_option(wxFileDialog* dlg, const std::string& format); diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index e17315802e..052bf6e6ca 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -175,9 +175,9 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/* // If we're here, we have more than one option or a single option with sidetext // so we need a horizontal sizer to arrange these things - // If we have a single option with no sidetext just add it directly to the grid sizer - auto sizer = new wxBoxSizer(wxHORIZONTAL); + auto sizer = new wxBoxSizer((m_flag & ogSIDE_OPTIONS_VERTICAL) != 0 ? wxVERTICAL :wxHORIZONTAL); grid_sizer->Add(sizer, 0, wxEXPAND | (staticbox ? wxALL : wxBOTTOM|wxTOP|wxLEFT), staticbox ? 0 : 1); + // If we have a single option with no sidetext just add it directly to the grid sizer if (option_set.size() == 1 && option_set.front().opt.sidetext.size() == 0 && option_set.front().side_widget == nullptr && line.get_extra_widgets().size() == 0) { const auto& option = option_set.front(); diff --git a/xs/src/slic3r/GUI/OptionsGroup.hpp b/xs/src/slic3r/GUI/OptionsGroup.hpp index 7da39dbf9e..d302fa1ece 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.hpp +++ b/xs/src/slic3r/GUI/OptionsGroup.hpp @@ -26,6 +26,11 @@ namespace Slic3r { namespace GUI { +enum ogDrawFlag{ + ogDEFAULT, + ogSIDE_OPTIONS_VERTICAL +}; + /// Widget type describes a function object that returns a wxWindow (our widget) and accepts a wxWidget (parent window). using widget_t = std::function;//!std::function; using column_t = std::function; @@ -183,8 +188,8 @@ protected: class ConfigOptionsGroup: public OptionsGroup { public: - ConfigOptionsGroup(wxWindow* parent, const wxString& title, DynamicPrintConfig* _config = nullptr, bool is_tab_opt = false) : - OptionsGroup(parent, title, is_tab_opt), m_config(_config) {} + ConfigOptionsGroup(wxWindow* parent, const wxString& title, DynamicPrintConfig* _config = nullptr, bool is_tab_opt = false, ogDrawFlag flag = ogDEFAULT) : + OptionsGroup(parent, title, is_tab_opt, flag), m_config(_config) {} /// reference to libslic3r config, non-owning pointer (?). DynamicPrintConfig* m_config {nullptr}; diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 52fc499d52..88a97c5c85 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -679,8 +679,8 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value) } if (opt_key == "fill_density") { - boost::any val = get_optgroup()->get_config_value(*m_config, opt_key); - get_optgroup()->set_value(opt_key, val); + boost::any val = get_optgroup(ogFrequentlyChangingParameters)->get_config_value(*m_config, opt_key); + get_optgroup(ogFrequentlyChangingParameters)->set_value(opt_key, val); } if (opt_key == "support_material" || opt_key == "support_material_buildplate_only") { @@ -689,12 +689,12 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value) m_config->opt_bool("support_material_buildplate_only") ? _("Support on build plate only") : _("Everywhere"); - get_optgroup()->set_value("support", new_selection); + get_optgroup(ogFrequentlyChangingParameters)->set_value("support", new_selection); } if (opt_key == "brim_width") { bool val = m_config->opt_float("brim_width") > 0.0 ? true : false; - get_optgroup()->set_value("brim", val); + get_optgroup(ogFrequentlyChangingParameters)->set_value("brim", val); } if (opt_key == "wipe_tower" || opt_key == "single_extruder_multi_material" || opt_key == "extruders_count" ) @@ -784,18 +784,18 @@ void Tab::update_preset_description_line() void Tab::update_frequently_changed_parameters() { - boost::any value = get_optgroup()->get_config_value(*m_config, "fill_density"); - get_optgroup()->set_value("fill_density", value); + boost::any value = get_optgroup(ogFrequentlyChangingParameters)->get_config_value(*m_config, "fill_density"); + get_optgroup(ogFrequentlyChangingParameters)->set_value("fill_density", value); wxString new_selection = !m_config->opt_bool("support_material") ? _("None") : m_config->opt_bool("support_material_buildplate_only") ? _("Support on build plate only") : _("Everywhere"); - get_optgroup()->set_value("support", new_selection); + get_optgroup(ogFrequentlyChangingParameters)->set_value("support", new_selection); bool val = m_config->opt_float("brim_width") > 0.0 ? true : false; - get_optgroup()->set_value("brim", val); + get_optgroup(ogFrequentlyChangingParameters)->set_value("brim", val); update_wiping_button_visibility(); }