diff options
author | YuSanka <yusanka@gmail.com> | 2018-05-17 15:07:50 +0300 |
---|---|---|
committer | YuSanka <yusanka@gmail.com> | 2018-05-17 17:03:18 +0300 |
commit | 4e47f4973cc7ac151ce6bc16f9a12ae2af48888d (patch) | |
tree | a1a52e5c672fcf4e32dfe3cc4a841a849a0b67bb /xs/src/slic3r | |
parent | d3106684620e8bac7f422daac25e6d959d0ba63b (diff) |
Updating of the right column according selected view mode
Diffstat (limited to 'xs/src/slic3r')
-rw-r--r-- | xs/src/slic3r/GUI/GUI.cpp | 61 | ||||
-rw-r--r-- | xs/src/slic3r/GUI/GUI.hpp | 7 | ||||
-rw-r--r-- | xs/src/slic3r/GUI/OptionsGroup.cpp | 25 | ||||
-rw-r--r-- | xs/src/slic3r/GUI/OptionsGroup.hpp | 1 | ||||
-rw-r--r-- | xs/src/slic3r/GUI/Tab.hpp | 2 |
5 files changed, 75 insertions, 21 deletions
diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 3cf3c8d0d..09ede75be 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -202,6 +202,7 @@ double m_brim_width = 0.0; wxButton* g_wiping_dialog_button = nullptr; //showed/hided controls according to the view mode +wxWindow *g_plater = nullptr; wxBoxSizer *g_frequently_changed_parameters_sizer = nullptr; wxBoxSizer *g_expert_mode_part_sizer = nullptr; wxBoxSizer *g_scrolled_window_sizer = nullptr; @@ -209,7 +210,7 @@ wxButton *g_btn_export_stl = nullptr; wxButton *g_btn_reslice = nullptr; wxButton *g_btn_print = nullptr; wxButton *g_btn_send_gcode = nullptr; -wxButton *g_btn_export_gcode = nullptr; +bool g_show_print_info = false; static void init_label_colours() { @@ -270,11 +271,12 @@ void set_preset_updater(PresetUpdater *updater) g_PresetUpdater = updater; } -void set_objects_from_perl( wxBoxSizer *frequently_changed_parameters_sizer, +void set_objects_from_perl( wxWindow* parent, wxBoxSizer *frequently_changed_parameters_sizer, wxBoxSizer *expert_mode_part_sizer, wxBoxSizer *scrolled_window_sizer, - wxButton *btn_export_stl, wxButton *btn_reslice, wxButton *btn_print, - wxButton *btn_send_gcode, wxButton *btn_export_gcode) + wxButton *btn_export_stl, wxButton *btn_reslice, + wxButton *btn_print, wxButton *btn_send_gcode) { + g_plater = parent; g_frequently_changed_parameters_sizer = frequently_changed_parameters_sizer; g_expert_mode_part_sizer = expert_mode_part_sizer; g_scrolled_window_sizer = scrolled_window_sizer; @@ -282,7 +284,11 @@ void set_objects_from_perl( wxBoxSizer *frequently_changed_parameters_sizer, g_btn_reslice = btn_reslice; g_btn_print = btn_print; g_btn_send_gcode = btn_send_gcode; - g_btn_export_gcode = btn_export_gcode; +} + +void set_show_print_info(bool show) +{ + g_show_print_info = show; } std::vector<Tab *>& get_tabs_list() @@ -601,6 +607,7 @@ void create_preset_tabs(bool no_controller, int event_value_change, int event_pr tab->set_event_value_change(wxEventType(event_value_change)); tab->set_event_presets_changed(wxEventType(event_presets_changed)); } + update_mode();// TODO change place of call this function } TabIface* get_preset_tab_iface(char *name) @@ -1082,9 +1089,51 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl sizer->Add(m_optgroup->sizer, 1, wxEXPAND | wxBOTTOM, 2); } -void update_mode() +void show_frequently_changed_parameters(bool show) { + g_frequently_changed_parameters_sizer->Show(show); + if (!show) return; + + for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++i) { + Tab *tab = dynamic_cast<Tab*>(g_wxTabPanel->GetPage(i)); + if (!tab) + continue; + tab->update_wiping_button_visibility(); + break; + } +} +void show_buttons(bool show) +{ + g_btn_export_stl->Show(show); + g_btn_reslice->Show(show); + for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++i) { + TabPrinter *tab = dynamic_cast<TabPrinter*>(g_wxTabPanel->GetPage(i)); + if (!tab) + continue; + g_btn_print->Show(show && !tab->m_config->opt_string("serial_port").empty()); + g_btn_send_gcode->Show(show && !tab->m_config->opt_string("octoprint_host").empty()); + break; + } +} + +void show_scrolled_window_sizer(bool show) +{ + g_scrolled_window_sizer->Show(static_cast<size_t>(0), show); + g_scrolled_window_sizer->Show(1, show); + g_scrolled_window_sizer->Show(2, show && g_show_print_info); +} + +void update_mode() +{ + wxWindowUpdateLocker noUpdates(g_plater); + ConfigMenuIDs mode = get_view_mode(); + + show_frequently_changed_parameters(mode >= ConfigMenuModeRegular); + g_expert_mode_part_sizer->Show(mode == ConfigMenuModeExpert); + show_scrolled_window_sizer(mode >= ConfigMenuModeRegular); + show_buttons(mode >= ConfigMenuModeRegular); + g_plater->Layout(); } ConfigOptionsGroup* get_optgroup() diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 28359decd..1cca99319 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -79,14 +79,15 @@ void set_tab_panel(wxNotebook *tab_panel); void set_app_config(AppConfig *app_config); void set_preset_bundle(PresetBundle *preset_bundle); void set_preset_updater(PresetUpdater *updater); -void set_objects_from_perl( wxBoxSizer *frequently_changed_parameters_sizer, +void set_objects_from_perl( wxWindow* parent, + wxBoxSizer *frequently_changed_parameters_sizer, wxBoxSizer *expert_mode_part_sizer, wxBoxSizer *scrolled_window_sizer, wxButton *btn_export_stl, wxButton *btn_reslice, wxButton *btn_print, - wxButton *btn_send_gcode, - wxButton *btn_export_gcode); + wxButton *btn_send_gcode); +void set_show_print_info(bool show); AppConfig* get_app_config(); wxApp* get_app(); diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index 657ad03c0..40176a000 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -86,15 +86,21 @@ const t_field& OptionsGroup::build_field(const t_config_option_key& id, const Co if (!this->m_disabled) this->back_to_sys_value(opt_id); }; + + // assign function objects for callbacks, etc. + return field; +} + +void OptionsGroup::add_undo_buttuns_to_sizer(wxBoxSizer* sizer, const t_field& field) +{ if (!m_is_tab_opt) { field->m_Undo_btn->Hide(); field->m_Undo_to_sys_btn->Hide(); + return; } -// if (nonsys_btn_icon != nullptr) -// field->set_nonsys_btn_icon(*nonsys_btn_icon); - - // assign function objects for callbacks, etc. - return field; + + sizer->Add(field->m_Undo_to_sys_btn, 0, wxALIGN_CENTER_VERTICAL); + sizer->Add(field->m_Undo_btn, 0, wxALIGN_CENTER_VERTICAL); } void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/* = nullptr*/) { @@ -131,8 +137,7 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/* const auto& field = build_field(option); auto btn_sizer = new wxBoxSizer(wxHORIZONTAL); - btn_sizer->Add(field->m_Undo_to_sys_btn); - btn_sizer->Add(field->m_Undo_btn); + add_undo_buttuns_to_sizer(btn_sizer, field); tmp_sizer->Add(btn_sizer, 0, wxEXPAND | wxALL, 0); if (is_window_field(field)) tmp_sizer->Add(field->getWindow(), 0, wxEXPAND | wxALL, wxOSX ? 0 : 5); @@ -176,8 +181,7 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/* const auto& option = option_set.front(); const auto& field = build_field(option, label); - sizer->Add(field->m_Undo_to_sys_btn, 0, wxALIGN_CENTER_VERTICAL); - sizer->Add(field->m_Undo_btn, 0, wxALIGN_CENTER_VERTICAL); + add_undo_buttuns_to_sizer(sizer, field); if (is_window_field(field)) sizer->Add(field->getWindow(), option.opt.full_width ? 1 : 0, (option.opt.full_width ? wxEXPAND : 0) | wxBOTTOM | wxTOP | wxALIGN_CENTER_VERTICAL, wxOSX ? 0 : 2); @@ -205,8 +209,7 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/* // add field const Option& opt_ref = opt; auto& field = build_field(opt_ref, label); - sizer->Add(field->m_Undo_to_sys_btn, 0, wxALIGN_CENTER_VERTICAL); - sizer->Add(field->m_Undo_btn, 0, wxALIGN_CENTER_VERTICAL, 0); + add_undo_buttuns_to_sizer(sizer, field); is_sizer_field(field) ? sizer->Add(field->getSizer(), 0, wxALIGN_CENTER_VERTICAL, 0) : sizer->Add(field->getWindow(), 0, wxALIGN_CENTER_VERTICAL, 0); diff --git a/xs/src/slic3r/GUI/OptionsGroup.hpp b/xs/src/slic3r/GUI/OptionsGroup.hpp index 83b5b1233..55a8dc70b 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.hpp +++ b/xs/src/slic3r/GUI/OptionsGroup.hpp @@ -171,6 +171,7 @@ protected: const t_field& build_field(const t_config_option_key& id, const ConfigOptionDef& opt, wxStaticText* label = nullptr); const t_field& build_field(const t_config_option_key& id, wxStaticText* label = nullptr); const t_field& build_field(const Option& opt, wxStaticText* label = nullptr); + void add_undo_buttuns_to_sizer(wxBoxSizer* sizer, const t_field& field); virtual void on_kill_focus (){}; virtual void on_change_OG(const t_config_option_key& opt_id, const boost::any& value); diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 62030bce3..8f540b197 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -264,11 +264,11 @@ public: void on_value_change(const std::string& opt_key, const boost::any& value); + void update_wiping_button_visibility(); protected: void on_presets_changed(); void update_preset_description_line(); void update_frequently_changed_parameters(); - void update_wiping_button_visibility(); void update_tab_presets(wxComboCtrl* ui, bool show_incompatible); void fill_icon_descriptions(); void set_tooltips_text(); |