diff --git a/resources/icons/settings.svg b/resources/icons/settings.svg index db5bf458d7..d4801ae0bb 100644 --- a/resources/icons/settings.svg +++ b/resources/icons/settings.svg @@ -37,7 +37,7 @@ - - diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 9420db561d..42e743bc88 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -5137,7 +5137,7 @@ bool GLCanvas3D::_init_main_toolbar() if (!m_main_toolbar.add_separator()) return false; - +/* item.name = "settings"; item.icon_filename = "settings.svg"; item.tooltip = _u8L("Switch to Settings") + "\n" + "[" + GUI::shortkey_ctrl_prefix() + "2] - " + _u8L("Print Settings Tab") + @@ -5149,7 +5149,7 @@ bool GLCanvas3D::_init_main_toolbar() item.left.action_callback = []() { wxGetApp().mainframe->select_tab(); }; if (!m_main_toolbar.add_item(item)) return false; - +*/ if (!m_main_toolbar.add_separator()) return false; diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 5bdaa4751b..b5d6152b6c 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -585,12 +585,20 @@ void MainFrame::update_title() SetTitle(title); } +static wxString GetTooltipForSettingsButton(PrinterTechnology pt) +{ + std::string tooltip = _u8L("Switch to Settings") + "\n" + "[" + shortkey_ctrl_prefix() + "2] - " + _u8L("Print Settings Tab") + + "\n" + "[" + shortkey_ctrl_prefix() + "3] - " + (pt == ptFFF ? _u8L("Filament Settings Tab") : _u8L("Material Settings Tab")) + + "\n" + "[" + shortkey_ctrl_prefix() + "4] - " + _u8L("Printer Settings Tab"); + return from_u8(tooltip); +} + void MainFrame::init_tabpanel() { wxGetApp().update_ui_colours_from_appconfig(); if (wxGetApp().is_editor()) { - m_tmp_top_bar = new TopBar(this, &m_bar_menus); + m_tmp_top_bar = new TopBar(this, &m_bar_menus, false); m_tmp_top_bar->SetFont(Slic3r::GUI::wxGetApp().normal_font()); m_tmp_top_bar->Hide(); } @@ -651,6 +659,9 @@ void MainFrame::init_tabpanel() if (full_config.has("nozzle_diameter")) { m_plater->sidebar().set_extruders_count(full_config.option("nozzle_diameter")->values.size()); } + + if (wxGetApp().is_editor()) + m_tmp_top_bar->SetSettingsButtonTooltip(GetTooltipForSettingsButton(m_plater->printer_technology())); } } @@ -2076,10 +2087,12 @@ void MainFrame::add_to_recent_projects(const wxString& filename) void MainFrame::technology_changed() { + PrinterTechnology pt = plater()->printer_technology(); + m_tmp_top_bar->SetSettingsButtonTooltip(GetTooltipForSettingsButton(pt)); + if (!m_menubar) return; // update menu titles - PrinterTechnology pt = plater()->printer_technology(); if (int id = m_menubar->FindMenu(pt == ptFFF ? _L("Material Settings") : _L("Filament Settings")); id != wxNOT_FOUND) m_menubar->SetMenuLabel(id , pt == ptSLA ? _L("Material Settings") : _L("Filament Settings")); diff --git a/src/slic3r/GUI/TopBar.cpp b/src/slic3r/GUI/TopBar.cpp index 2cd629672f..0a7447e81b 100644 --- a/src/slic3r/GUI/TopBar.cpp +++ b/src/slic3r/GUI/TopBar.cpp @@ -2,6 +2,7 @@ #include "TopBarMenus.hpp" #include "GUI_App.hpp" +#include "MainFrame.hpp" #include "Plater.hpp" #include "Search.hpp" #include "UserAccount.hpp" @@ -34,21 +35,18 @@ TopBarItemsCtrl::Button::Button(wxWindow* parent, const wxString& label, const s { int btn_margin = em_unit(this); int x, y; - GetTextExtent(label, &x, &y); + GetTextExtent(label.IsEmpty() ? "a" : label, &x, &y); wxSize size(x + 4 * btn_margin, y + int(1.5 * btn_margin)); if (icon_name.empty()) this->SetMinSize(size); -#ifdef _WIN32 else if (label.IsEmpty()) { - const int btn_side = px_cnt + btn_margin; + const int btn_side = size.y; this->SetMinSize(wxSize(btn_side, btn_side)); } else +#ifdef _WIN32 this->SetMinSize(wxSize(-1, size.y)); #else - else if (label.IsEmpty()) - this->SetMinSize(wxSize(px_cnt, px_cnt)); - else this->SetMinSize(wxSize(size.x + px_cnt, size.y)); #endif @@ -130,9 +128,11 @@ void TopBarItemsCtrl::Button::render() wxPoint pt = { 0, 0 }; + wxString text = GetLabelText(); + if (m_bmp_bundle.IsOk()) { wxSize szIcon = get_preferred_size(m_bmp_bundle, this); - pt.x = em; + pt.x = text.IsEmpty() ? ((rc.width - szIcon.x) / 2) : em; pt.y = (rc.height - szIcon.y) / 2; #ifdef __WXGTK3__ dc.DrawBitmap(m_bmp_bundle.GetBitmap(szIcon), pt); @@ -144,7 +144,6 @@ void TopBarItemsCtrl::Button::render() // Draw text - wxString text = GetLabelText(); if (!text.IsEmpty()) { wxSize labelSize = dc.GetTextExtent(text); if (labelSize.x > rc.width) @@ -277,7 +276,7 @@ wxPoint TopBarItemsCtrl::ButtonWithPopup::get_popup_pos() return pos; } -TopBarItemsCtrl::TopBarItemsCtrl(wxWindow *parent, TopBarMenus* menus/* = nullptr*/) : +TopBarItemsCtrl::TopBarItemsCtrl(wxWindow *parent, TopBarMenus* menus/* = nullptr*/, bool is_main/* = true*/) : wxControl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE | wxTAB_TRAVERSAL) ,m_menus(menus) { @@ -306,6 +305,14 @@ TopBarItemsCtrl::TopBarItemsCtrl(wxWindow *parent, TopBarMenus* menus/* = nullpt }); #endif + if (!is_main) { + m_settings_btn = new Button(this, "", "settings"); + m_settings_btn->Bind(wxEVT_BUTTON, [](wxCommandEvent& event) { + wxGetApp().mainframe->select_tab(); + }); + left_sizer->Add(m_settings_btn, 0, wxALIGN_CENTER_VERTICAL); + } + m_buttons_sizer = new wxFlexGridSizer(1, m_btn_margin, m_btn_margin); left_sizer->Add(m_buttons_sizer, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, m_btn_margin); @@ -394,6 +401,8 @@ void TopBarItemsCtrl::OnColorsChanged() wxGetApp().UpdateDarkUI(this); if (m_menu_btn) m_menu_btn->sys_color_changed(); + if (m_settings_btn) + m_settings_btn->sys_color_changed(); m_workspace_btn->sys_color_changed(); m_account_btn->sys_color_changed(); @@ -478,6 +487,8 @@ void TopBarItemsCtrl::ShowFull() { if (m_menu_btn) m_menu_btn->Show(); + if (m_settings_btn) + m_settings_btn->Show(); m_account_btn->Show(); UpdateAccountButton(); m_menus->set_cb_on_user_item([this]() { @@ -490,6 +501,14 @@ void TopBarItemsCtrl::ShowJustMode() { if (m_menu_btn) m_menu_btn->Hide(); + if (m_settings_btn) + m_settings_btn->Hide(); m_account_btn->Hide(); m_menus->set_cb_on_user_item(nullptr); } + +void TopBarItemsCtrl::SetSettingsButtonTooltip(const wxString& tooltip) +{ + if (m_settings_btn) + m_settings_btn->SetToolTip(tooltip); +} diff --git a/src/slic3r/GUI/TopBar.hpp b/src/slic3r/GUI/TopBar.hpp index ee0fabf6e5..e56489578c 100644 --- a/src/slic3r/GUI/TopBar.hpp +++ b/src/slic3r/GUI/TopBar.hpp @@ -63,7 +63,8 @@ class TopBarItemsCtrl : public wxControl public: TopBarItemsCtrl(wxWindow* parent, - TopBarMenus* menus = nullptr); + TopBarMenus* menus = nullptr, + bool is_main = true); ~TopBarItemsCtrl() {} void OnPaint(wxPaintEvent&); @@ -84,15 +85,17 @@ public: void CreateSearch(); void ShowFull(); void ShowJustMode(); + void SetSettingsButtonTooltip(const wxString& tooltip); wxWindow* GetSearchCtrl() { return m_search->GetTextCtrl(); } private: wxFlexGridSizer* m_buttons_sizer; wxFlexGridSizer* m_sizer; - ButtonWithPopup* m_menu_btn {nullptr}; + ButtonWithPopup* m_menu_btn {nullptr}; ButtonWithPopup* m_workspace_btn {nullptr}; - ButtonWithPopup* m_account_btn {nullptr}; + ButtonWithPopup* m_account_btn {nullptr}; + Button* m_settings_btn {nullptr}; std::vector m_pageButtons; int m_selection {-1}; int m_btn_margin; @@ -115,12 +118,13 @@ public: } TopBar( wxWindow * parent, - TopBarMenus* menus) + TopBarMenus* menus, + bool is_main = true) { Init(); // wxNB_NOPAGETHEME: Disable Windows Vista theme for the Notebook background. The theme performance is terrible on Windows 10 // with multiple high resolution displays connected. - Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME, menus); + Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME, menus, is_main); } bool Create(wxWindow * parent, @@ -128,12 +132,13 @@ public: const wxPoint & pos = wxDefaultPosition, const wxSize & size = wxDefaultSize, long style = 0, - TopBarMenus* menus = nullptr) + TopBarMenus* menus = nullptr, + bool is_main = true) { if (!wxBookCtrlBase::Create(parent, winid, pos, size, style | wxBK_TOP)) return false; - m_bookctrl = new TopBarItemsCtrl(this, menus); + m_bookctrl = new TopBarItemsCtrl(this, menus, is_main); wxSizer* mainSizer = new wxBoxSizer(IsVertical() ? wxVERTICAL : wxHORIZONTAL); @@ -429,7 +434,11 @@ public: void ShowJustMode() { Show(); GetTopBarItemsCtrl()->ShowJustMode(); - }; + } + + void SetSettingsButtonTooltip(const wxString& tooltip) { + GetTopBarItemsCtrl()->SetSettingsButtonTooltip(tooltip); + } protected: virtual void UpdateSelectedPage(size_t WXUNUSED(newsel)) override