From 0b1833a2afd26c54459656894747bdc7fc7cf4bf Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 28 Jun 2018 16:01:06 +0200 Subject: [PATCH 1/6] Try to fix tooltips on OSX --- lib/Slic3r/GUI/MainFrame.pm | 4 ++++ xs/src/slic3r/GUI/ConfigWizard.cpp | 4 ++-- xs/src/slic3r/GUI/GUI.cpp | 7 +++--- xs/src/slic3r/GUI/Tab.cpp | 38 ++++++++++++++++++++++++++++++ xs/src/slic3r/GUI/Tab.hpp | 6 +++-- 5 files changed, 52 insertions(+), 7 deletions(-) diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index 910b86dd8..ea4a158f4 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -110,6 +110,10 @@ sub _init_tabpanel { EVT_NOTEBOOK_PAGE_CHANGED($self, $self->{tabpanel}, sub { my $panel = $self->{tabpanel}->GetCurrentPage; $panel->OnActivate if $panel->can('OnActivate'); + + for my $tab_name (qw(print filament printer)) { + Slic3r::GUI::get_preset_tab("$tab_name")->OnActivate if ("$tab_name" eq $panel->GetName); + } }); if (!$self->{no_plater}) { diff --git a/xs/src/slic3r/GUI/ConfigWizard.cpp b/xs/src/slic3r/GUI/ConfigWizard.cpp index 642c6dce7..2e315a70b 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.cpp +++ b/xs/src/slic3r/GUI/ConfigWizard.cpp @@ -893,9 +893,9 @@ const wxString& ConfigWizard::name() { // A different naming convention is used for the Wizard on Windows vs. OSX & GTK. #if WIN32 - static const wxString config_wizard_name = _(L("Configuration Wizard")); + static const wxString config_wizard_name = L("Configuration Wizard"); #else - static const wxString config_wizard_name = _(L("Configuration Assistant")); + static const wxString config_wizard_name = L("Configuration Assistant"); #endif return config_wizard_name; } diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index c1f8adaf1..250f475e2 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -317,10 +317,11 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l auto local_menu = new wxMenu(); wxWindowID config_id_base = wxWindow::NewControlId((int)ConfigMenuCnt); - const auto config_wizard_tooltip = wxString::Format(_(L("Run %s")), ConfigWizard::name()); + const auto config_wizard_name = _(ConfigWizard::name().wx_str()); + const auto config_wizard_tooltip = wxString::Format(_(L("Run %s")), config_wizard_name); // Cmd+, is standard on OS X - what about other operating systems? - local_menu->Append(config_id_base + ConfigMenuWizard, ConfigWizard::name() + dots, config_wizard_tooltip); - local_menu->Append(config_id_base + ConfigMenuSnapshots, _(L("Configuration Snapshots"))+dots, _(L("Inspect / activate configuration snapshots"))); + local_menu->Append(config_id_base + ConfigMenuWizard, config_wizard_name + dots, config_wizard_tooltip); + local_menu->Append(config_id_base + ConfigMenuSnapshots, _(L("Configuration Snapshots"))+dots, _(L("Inspect / activate configuration snapshots"))); local_menu->Append(config_id_base + ConfigMenuTakeSnapshot, _(L("Take Configuration Snapshot")), _(L("Capture a configuration snapshot"))); // local_menu->Append(config_id_base + ConfigMenuUpdate, _(L("Check for updates")), _(L("Check for configuration updates"))); local_menu->AppendSeparator(); diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 94f8cc3ea..d3d83fee8 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -40,10 +40,24 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_preset_bundle = preset_bundle; // Vertical sizer to hold the choice menu and the rest of the page. +#ifdef __WXOSX__ + auto *main_sizer = new wxBoxSizer(wxVERTICAL); + main_sizer->SetSizeHints(this); + this->SetSizer(main_sizer); + + m_tmp_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL); + auto panel = m_tmp_panel; + auto sizer = new wxBoxSizer(wxVERTICAL); + m_tmp_panel->SetSizer(sizer); + m_tmp_panel->Layout(); + + main_sizer->Add(m_tmp_panel, 1, wxEXPAND | wxALL, 0); +#else Tab *panel = this; auto *sizer = new wxBoxSizer(wxVERTICAL); sizer->SetSizeHints(panel); panel->SetSizer(sizer); +#endif //__WXOSX__ // preset chooser m_presets_choice = new wxBitmapComboBox(panel, wxID_ANY, "", wxDefaultPosition, wxSize(270, -1), 0, 0,wxCB_READONLY); @@ -290,6 +304,28 @@ PageShp Tab::add_options_page(const wxString& title, const std::string& icon, bo return page; } +void Tab::OnActivate() +{ +#ifdef __WXOSX__ + wxWindowUpdateLocker noUpdates(this); + + m_tmp_panel->Fit(); + + Page* page = nullptr; + auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection()); + for (auto p : m_pages) + if (p->title() == selection) + { + page = p.get(); + break; + } + if (page == nullptr) return; + page->Fit(); + m_hsizer->Layout(); + Refresh(); +#endif // __WXOSX__ +} + void Tab::update_labels_colour() { Freeze(); @@ -1248,6 +1284,7 @@ void TabPrint::OnActivate() { m_recommended_thin_wall_thickness_description_line->SetText( from_u8(PresetHints::recommended_thin_wall_thickness(*m_preset_bundle))); + Tab::OnActivate(); } void TabFilament::build() @@ -1405,6 +1442,7 @@ void TabFilament::update() void TabFilament::OnActivate() { m_volumetric_speed_description_line->SetText(from_u8(PresetHints::maximum_volumetric_flow_description(*m_preset_bundle))); + Tab::OnActivate(); } wxSizer* Tab::description_line_widget(wxWindow* parent, ogStaticText* *StaticText) diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index d6bf2cf43..6c9297c71 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -118,7 +118,9 @@ protected: wxButton* m_undo_btn; wxButton* m_undo_to_sys_btn; wxButton* m_question_btn; - +#ifdef __WXOSX__ + wxPanel* m_tmp_panel; +#endif // __WXOSX__ wxComboCtrl* m_cc_presets_choice; wxDataViewTreeCtrl* m_presetctrl; wxImageList* m_preset_icons; @@ -242,7 +244,7 @@ public: PageShp add_options_page(const wxString& title, const std::string& icon, bool is_extruder_pages = false); - virtual void OnActivate(){} + virtual void OnActivate(); virtual void on_preset_loaded(){} virtual void build() = 0; virtual void update() = 0; From 75bda8cfd8ce7ea5995cf494bed0184889226061 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 28 Jun 2018 16:50:06 +0200 Subject: [PATCH 2/6] Addition to last commit --- xs/src/slic3r/GUI/Tab.cpp | 36 +++++++++++++++++++++++------------- xs/src/slic3r/GUI/Tab.hpp | 2 +- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index d3d83fee8..ba75c3c6f 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -45,6 +45,8 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) main_sizer->SetSizeHints(this); this->SetSizer(main_sizer); + // Create additional panel to Fit() it from OnActivate() + // It's needed for tooltip showing on OSX m_tmp_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL); auto panel = m_tmp_panel; auto sizer = new wxBoxSizer(wxVERTICAL); @@ -293,7 +295,12 @@ PageShp Tab::add_options_page(const wxString& title, const std::string& icon, bo } } // Initialize the page. - PageShp page(new Page(this, title, icon_idx)); +#ifdef __WXOSX__ + auto panel = m_tmp_panel; +#else + auto panel = this; +#endif + PageShp page(new Page(panel, title, icon_idx)); page->SetScrollbars(1, 1, 1, 1); page->Hide(); m_hsizer->Add(page.get(), 1, wxEXPAND | wxLEFT, 5); @@ -309,20 +316,22 @@ void Tab::OnActivate() #ifdef __WXOSX__ wxWindowUpdateLocker noUpdates(this); + auto sizer = GetSizer(); + m_tmp_panel->GetSizer()->SetMinSize(sizer->GetSize()); m_tmp_panel->Fit(); - Page* page = nullptr; - auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection()); - for (auto p : m_pages) - if (p->title() == selection) - { - page = p.get(); - break; - } - if (page == nullptr) return; - page->Fit(); - m_hsizer->Layout(); - Refresh(); +// Page* page = nullptr; +// auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection()); +// for (auto p : m_pages) +// if (p->title() == selection) +// { +// page = p.get(); +// break; +// } +// if (page == nullptr) return; +// page->Fit(); +// m_hsizer->Layout(); +// Refresh(); #endif // __WXOSX__ } @@ -2124,6 +2133,7 @@ void Tab::OnTreeSelChange(wxTreeEvent& event) #endif page->Show(); + page->Fit(); m_hsizer->Layout(); Refresh(); diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 6c9297c71..82670121c 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -200,7 +200,7 @@ public: Tab() {} Tab(wxNotebook* parent, const wxString& title, const char* name, bool no_controller) : m_parent(parent), m_title(title), m_name(name), m_no_controller(no_controller) { - Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL); + Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL, name); get_tabs_list().push_back(this); } ~Tab(){ From 0171f49ad0cb3c7d11e5aaa5f613992b2e84f7e0 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 28 Jun 2018 17:14:45 +0200 Subject: [PATCH 3/6] And last try.. --- xs/src/slic3r/GUI/Tab.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index ba75c3c6f..4186cd8db 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -318,7 +318,7 @@ void Tab::OnActivate() auto sizer = GetSizer(); m_tmp_panel->GetSizer()->SetMinSize(sizer->GetSize()); - m_tmp_panel->Fit(); + /*m_tmp_panel->*/Fit(); // Page* page = nullptr; // auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection()); From 896d898124d71d4dac5bac9d86be78c41a83ae65 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 28 Jun 2018 17:52:20 +0200 Subject: [PATCH 4/6] Resizing panel to 1 px --- xs/src/slic3r/GUI/Tab.cpp | 33 +++++++++++++++++---------------- xs/src/slic3r/GUI/Tab.hpp | 7 ++++--- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 4186cd8db..e8323ded3 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -40,7 +40,7 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_preset_bundle = preset_bundle; // Vertical sizer to hold the choice menu and the rest of the page. -#ifdef __WXOSX__ +//#ifdef __WXOSX__ auto *main_sizer = new wxBoxSizer(wxVERTICAL); main_sizer->SetSizeHints(this); this->SetSizer(main_sizer); @@ -54,12 +54,12 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_tmp_panel->Layout(); main_sizer->Add(m_tmp_panel, 1, wxEXPAND | wxALL, 0); -#else - Tab *panel = this; - auto *sizer = new wxBoxSizer(wxVERTICAL); - sizer->SetSizeHints(panel); - panel->SetSizer(sizer); -#endif //__WXOSX__ +// #else +// Tab *panel = this; +// auto *sizer = new wxBoxSizer(wxVERTICAL); +// sizer->SetSizeHints(panel); +// panel->SetSizer(sizer); +// #endif //__WXOSX__ // preset chooser m_presets_choice = new wxBitmapComboBox(panel, wxID_ANY, "", wxDefaultPosition, wxSize(270, -1), 0, 0,wxCB_READONLY); @@ -295,11 +295,11 @@ PageShp Tab::add_options_page(const wxString& title, const std::string& icon, bo } } // Initialize the page. -#ifdef __WXOSX__ +//#ifdef __WXOSX__ auto panel = m_tmp_panel; -#else - auto panel = this; -#endif +// #else +// auto panel = this; +// #endif PageShp page(new Page(panel, title, icon_idx)); page->SetScrollbars(1, 1, 1, 1); page->Hide(); @@ -313,12 +313,13 @@ PageShp Tab::add_options_page(const wxString& title, const std::string& icon, bo void Tab::OnActivate() { -#ifdef __WXOSX__ +// #ifdef __WXOSX__ wxWindowUpdateLocker noUpdates(this); - auto sizer = GetSizer(); - m_tmp_panel->GetSizer()->SetMinSize(sizer->GetSize()); - /*m_tmp_panel->*/Fit(); + auto size = GetSizer()->GetSize(); + m_tmp_panel->GetSizer()->SetMinSize(size.x + m_size_move, size.y); + Fit(); + m_size_move *= -1; // Page* page = nullptr; // auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection()); @@ -332,7 +333,7 @@ void Tab::OnActivate() // page->Fit(); // m_hsizer->Layout(); // Refresh(); -#endif // __WXOSX__ +// #endif // __WXOSX__ } void Tab::update_labels_colour() diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 82670121c..4d14f9de1 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -102,6 +102,10 @@ using PageShp = std::shared_ptr; class Tab: public wxPanel { wxNotebook* m_parent; +//#ifdef __WXOSX__ + wxPanel* m_tmp_panel; + int m_size_move = -1; +//#endif // __WXOSX__ protected: std::string m_name; const wxString m_title; @@ -118,9 +122,6 @@ protected: wxButton* m_undo_btn; wxButton* m_undo_to_sys_btn; wxButton* m_question_btn; -#ifdef __WXOSX__ - wxPanel* m_tmp_panel; -#endif // __WXOSX__ wxComboCtrl* m_cc_presets_choice; wxDataViewTreeCtrl* m_presetctrl; wxImageList* m_preset_icons; From 9e4bea8cceacd0e074223be00c3cb84c0489dfa4 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 28 Jun 2018 18:14:34 +0200 Subject: [PATCH 5/6] Code cleaning --- xs/src/slic3r/GUI/Tab.cpp | 106 +++++--------------------------------- xs/src/slic3r/GUI/Tab.hpp | 4 +- 2 files changed, 15 insertions(+), 95 deletions(-) diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index e8323ded3..f41a14e93 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -40,7 +40,7 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_preset_bundle = preset_bundle; // Vertical sizer to hold the choice menu and the rest of the page. -//#ifdef __WXOSX__ +#ifdef __WXOSX__ auto *main_sizer = new wxBoxSizer(wxVERTICAL); main_sizer->SetSizeHints(this); this->SetSizer(main_sizer); @@ -54,51 +54,16 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_tmp_panel->Layout(); main_sizer->Add(m_tmp_panel, 1, wxEXPAND | wxALL, 0); -// #else -// Tab *panel = this; -// auto *sizer = new wxBoxSizer(wxVERTICAL); -// sizer->SetSizeHints(panel); -// panel->SetSizer(sizer); -// #endif //__WXOSX__ +#else + Tab *panel = this; + auto *sizer = new wxBoxSizer(wxVERTICAL); + sizer->SetSizeHints(panel); + panel->SetSizer(sizer); +#endif //__WXOSX__ // preset chooser m_presets_choice = new wxBitmapComboBox(panel, wxID_ANY, "", wxDefaultPosition, wxSize(270, -1), 0, 0,wxCB_READONLY); - /* - m_cc_presets_choice = new wxComboCtrl(panel, wxID_ANY, L(""), wxDefaultPosition, wxDefaultSize, wxCB_READONLY); - wxDataViewTreeCtrlComboPopup* popup = new wxDataViewTreeCtrlComboPopup; - if (popup != nullptr) - { - // FIXME If the following line is removed, the combo box popup list will not react to mouse clicks. - // On the other side, with this line the combo box popup cannot be closed by clicking on the combo button on Windows 10. -// m_cc_presets_choice->UseAltPopupWindow(); -// m_cc_presets_choice->EnablePopupAnimation(false); - m_cc_presets_choice->SetPopupControl(popup); - popup->SetStringValue(from_u8("Text1")); - - popup->Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, [this, popup](wxCommandEvent& evt) - { - auto selected = popup->GetItemText(popup->GetSelection()); - if (selected != _(L("System presets")) && selected != _(L("Default presets"))) - { - m_cc_presets_choice->SetText(selected); - std::string selected_string = selected.ToUTF8().data(); -#ifdef __APPLE__ -#else - select_preset(selected_string); -#endif - } - }); - -// popup->Bind(wxEVT_KEY_DOWN, [popup](wxKeyEvent& evt) { popup->OnKeyEvent(evt); }); -// popup->Bind(wxEVT_KEY_UP, [popup](wxKeyEvent& evt) { popup->OnKeyEvent(evt); }); - - auto icons = new wxImageList(16, 16, true, 1); - popup->SetImageList(icons); - icons->Add(*new wxIcon(from_u8(Slic3r::var("flag-green-icon.png")), wxBITMAP_TYPE_PNG)); - icons->Add(*new wxIcon(from_u8(Slic3r::var("flag-red-icon.png")), wxBITMAP_TYPE_PNG)); - } -*/ auto color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); //buttons @@ -189,37 +154,6 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle) m_hsizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add(m_hsizer, 1, wxEXPAND, 0); - -/* - - - //temporary left vertical sizer - m_left_sizer = new wxBoxSizer(wxVERTICAL); - m_hsizer->Add(m_left_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 3); - - // tree - m_presetctrl = new wxDataViewTreeCtrl(panel, wxID_ANY, wxDefaultPosition, wxSize(200, -1), wxDV_NO_HEADER); - m_left_sizer->Add(m_presetctrl, 1, wxEXPAND); - m_preset_icons = new wxImageList(16, 16, true, 1); - m_presetctrl->SetImageList(m_preset_icons); - m_preset_icons->Add(*new wxIcon(from_u8(Slic3r::var("flag-green-icon.png")), wxBITMAP_TYPE_PNG)); - m_preset_icons->Add(*new wxIcon(from_u8(Slic3r::var("flag-red-icon.png")), wxBITMAP_TYPE_PNG)); - - m_presetctrl->Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, [this](wxCommandEvent& evt) - { - auto selected = m_presetctrl->GetItemText(m_presetctrl->GetSelection()); - if (selected != _(L("System presets")) && selected != _(L("Default presets"))) - { - std::string selected_string = selected.ToUTF8().data(); -#ifdef __APPLE__ -#else - select_preset(selected_string); -#endif - } - }); - -*/ - //left vertical sizer m_left_sizer = new wxBoxSizer(wxVERTICAL); m_hsizer->Add(m_left_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 3); @@ -295,11 +229,11 @@ PageShp Tab::add_options_page(const wxString& title, const std::string& icon, bo } } // Initialize the page. -//#ifdef __WXOSX__ +#ifdef __WXOSX__ auto panel = m_tmp_panel; -// #else -// auto panel = this; -// #endif +#else + auto panel = this; +#endif PageShp page(new Page(panel, title, icon_idx)); page->SetScrollbars(1, 1, 1, 1); page->Hide(); @@ -313,27 +247,14 @@ PageShp Tab::add_options_page(const wxString& title, const std::string& icon, bo void Tab::OnActivate() { -// #ifdef __WXOSX__ +#ifdef __WXOSX__ wxWindowUpdateLocker noUpdates(this); auto size = GetSizer()->GetSize(); m_tmp_panel->GetSizer()->SetMinSize(size.x + m_size_move, size.y); Fit(); m_size_move *= -1; - -// Page* page = nullptr; -// auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection()); -// for (auto p : m_pages) -// if (p->title() == selection) -// { -// page = p.get(); -// break; -// } -// if (page == nullptr) return; -// page->Fit(); -// m_hsizer->Layout(); -// Refresh(); -// #endif // __WXOSX__ +#endif // __WXOSX__ } void Tab::update_labels_colour() @@ -2134,7 +2055,6 @@ void Tab::OnTreeSelChange(wxTreeEvent& event) #endif page->Show(); - page->Fit(); m_hsizer->Layout(); Refresh(); diff --git a/xs/src/slic3r/GUI/Tab.hpp b/xs/src/slic3r/GUI/Tab.hpp index 4d14f9de1..c755f91f1 100644 --- a/xs/src/slic3r/GUI/Tab.hpp +++ b/xs/src/slic3r/GUI/Tab.hpp @@ -102,10 +102,10 @@ using PageShp = std::shared_ptr; class Tab: public wxPanel { wxNotebook* m_parent; -//#ifdef __WXOSX__ +#ifdef __WXOSX__ wxPanel* m_tmp_panel; int m_size_move = -1; -//#endif // __WXOSX__ +#endif // __WXOSX__ protected: std::string m_name; const wxString m_title; From 16e42b0226fcda1c0d6d4c4dd934f2a2a4f38974 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 29 Jun 2018 11:29:23 +0200 Subject: [PATCH 6/6] Added tooltips for selected Preset --- xs/src/slic3r/GUI/Preset.cpp | 11 ++++++++--- xs/src/slic3r/GUI/PresetBundle.cpp | 7 +++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index 68982185b..536c37002 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -601,6 +601,7 @@ void PresetCollection::update_platter_ui(wxBitmapComboBox *ui) // Otherwise fill in the list from scratch. ui->Freeze(); ui->Clear(); + size_t selected_preset_item = 0; const Preset &selected_preset = this->get_selected_preset(); // Show wide icons if the currently selected preset is not compatible with the current printer, @@ -641,7 +642,7 @@ void PresetCollection::update_platter_ui(wxBitmapComboBox *ui) ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()), (bmp == 0) ? (m_bitmap_main_frame ? *m_bitmap_main_frame : wxNullBitmap) : *bmp); if (i == m_idx_selected) - ui->SetSelection(ui->GetCount() - 1); + selected_preset_item = ui->GetCount() - 1; } else { @@ -658,10 +659,13 @@ void PresetCollection::update_platter_ui(wxBitmapComboBox *ui) for (std::map::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) { ui->Append(it->first, *it->second); if (it->first == selected) - ui->SetSelection(ui->GetCount() - 1); + selected_preset_item = ui->GetCount() - 1; } } - ui->Thaw(); + + ui->SetSelection(selected_preset_item); + ui->SetToolTip(ui->GetString(selected_preset_item)); + ui->Thaw(); } size_t PresetCollection::update_tab_ui(wxBitmapComboBox *ui, bool show_incompatible) @@ -719,6 +723,7 @@ size_t PresetCollection::update_tab_ui(wxBitmapComboBox *ui, bool show_incompati } } ui->SetSelection(selected_preset_item); + ui->SetToolTip(ui->GetString(selected_preset_item)); ui->Thaw(); return selected_preset_item; } diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index d36ef7b6f..5914637bb 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -1108,6 +1108,7 @@ void PresetBundle::update_platter_filament_ui(unsigned int idx_extruder, wxBitma // Fill in the list from scratch. ui->Freeze(); ui->Clear(); + size_t selected_preset_item = 0; const Preset *selected_preset = this->filaments.find_preset(this->filament_presets[idx_extruder]); // Show wide icons if the currently selected preset is not compatible with the current printer, // and draw a red flag in front of the selected preset. @@ -1159,7 +1160,7 @@ void PresetBundle::update_platter_filament_ui(unsigned int idx_extruder, wxBitma ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? Preset::suffix_modified() : "")).c_str()), (bitmap == 0) ? wxNullBitmap : *bitmap); if (selected) - ui->SetSelection(ui->GetCount() - 1); + selected_preset_item = ui->GetCount() - 1; } else { @@ -1178,9 +1179,11 @@ void PresetBundle::update_platter_filament_ui(unsigned int idx_extruder, wxBitma for (std::map::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) { ui->Append(it->first, *it->second); if (it->first == selected_str) - ui->SetSelection(ui->GetCount() - 1); + selected_preset_item = ui->GetCount() - 1; } } + ui->SetSelection(selected_preset_item); + ui->SetToolTip(ui->GetString(selected_preset_item)); ui->Thaw(); }