diff --git a/resources/icons/user_mask.svg b/resources/icons/user_mask.svg new file mode 100644 index 0000000000..16a3b55fdf --- /dev/null +++ b/resources/icons/user_mask.svg @@ -0,0 +1,15 @@ + + + + + Mask for user icon + + + \ No newline at end of file diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 1348564a4f..5e19f3fe27 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -5028,10 +5028,12 @@ bool GLCanvas3D::_init_main_toolbar() GLToolbarItem::Data item; + unsigned int sprite_id = 0; + item.name = "add"; item.icon_filename = "add.svg"; item.tooltip = _u8L("Add...") + " [" + GUI::shortkey_ctrl_prefix() + "I]"; - item.sprite_id = 0; + item.sprite_id = sprite_id++; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_ADD)); }; if (!m_main_toolbar.add_item(item)) return false; @@ -5039,7 +5041,7 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "delete"; item.icon_filename = "remove.svg"; item.tooltip = _u8L("Delete") + " [Del]"; - item.sprite_id = 1; + item.sprite_id = sprite_id++; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_DELETE)); }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_delete(); }; if (!m_main_toolbar.add_item(item)) @@ -5048,7 +5050,7 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "deleteall"; item.icon_filename = "delete_all.svg"; item.tooltip = _u8L("Delete all") + " [" + GUI::shortkey_ctrl_prefix() + "Del]"; - item.sprite_id = 2; + item.sprite_id = sprite_id++; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_DELETE_ALL)); }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_delete_all(); }; if (!m_main_toolbar.add_item(item)) @@ -5057,7 +5059,7 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "arrange"; item.icon_filename = "arrange.svg"; item.tooltip = _u8L("Arrange") + " [A]\n" + _u8L("Arrange selection") + " [Shift+A]\n" + _u8L("Click right mouse button to show arrangement options"); - item.sprite_id = 3; + item.sprite_id = sprite_id++; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_ARRANGE)); }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_arrange(); }; item.right.toggable = true; @@ -5077,7 +5079,7 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "copy"; item.icon_filename = "copy.svg"; item.tooltip = _u8L("Copy") + " [" + GUI::shortkey_ctrl_prefix() + "C]"; - item.sprite_id = 4; + item.sprite_id = sprite_id++; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_COPY)); }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_copy_to_clipboard(); }; if (!m_main_toolbar.add_item(item)) @@ -5086,7 +5088,7 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "paste"; item.icon_filename = "paste.svg"; item.tooltip = _u8L("Paste") + " [" + GUI::shortkey_ctrl_prefix() + "V]"; - item.sprite_id = 5; + item.sprite_id = sprite_id++; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_PASTE)); }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_paste_from_clipboard(); }; if (!m_main_toolbar.add_item(item)) @@ -5098,7 +5100,7 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "more"; item.icon_filename = "instance_add.svg"; item.tooltip = _u8L("Add instance") + " [+]"; - item.sprite_id = 6; + item.sprite_id = sprite_id++; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_MORE)); }; item.visibility_callback = []()->bool { return wxGetApp().get_mode() != comSimple; }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_increase_instances(); }; @@ -5109,7 +5111,7 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "fewer"; item.icon_filename = "instance_remove.svg"; item.tooltip = _u8L("Remove instance") + " [-]"; - item.sprite_id = 7; + item.sprite_id = sprite_id++; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_FEWER)); }; item.visibility_callback = []()->bool { return wxGetApp().get_mode() != comSimple; }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_decrease_instances(); }; @@ -5122,7 +5124,7 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "splitobjects"; item.icon_filename = "split_objects.svg"; item.tooltip = _u8L("Split to objects"); - item.sprite_id = 8; + item.sprite_id = sprite_id++; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_SPLIT_OBJECTS)); }; item.visibility_callback = GLToolbarItem::Default_Visibility_Callback; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_split_to_objects(); }; @@ -5132,7 +5134,7 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "splitvolumes"; item.icon_filename = "split_parts.svg"; item.tooltip = _u8L("Split to parts"); - item.sprite_id = 9; + item.sprite_id = sprite_id++; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_SPLIT_VOLUMES)); }; item.visibility_callback = []()->bool { return wxGetApp().get_mode() != comSimple; }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_split_to_volumes(); }; @@ -5147,7 +5149,7 @@ bool GLCanvas3D::_init_main_toolbar() item.tooltip = _u8L("Switch to Settings") + "\n" + "[" + GUI::shortkey_ctrl_prefix() + "2] - " + _u8L("Print Settings Tab") + "\n" + "[" + GUI::shortkey_ctrl_prefix() + "3] - " + (current_printer_technology() == ptFFF ? _u8L("Filament Settings Tab") : _u8L("Material Settings Tab") + "\n" + "[" + GUI::shortkey_ctrl_prefix() + "4] - " + _u8L("Printer Settings Tab")) ; - item.sprite_id = 10; + item.sprite_id = sprite_id++; item.enabling_callback = GLToolbarItem::Default_Enabling_Callback; item.visibility_callback = []() { return wxGetApp().app_config->get_bool("dlg_settings_layout_mode"); }; item.left.action_callback = []() { wxGetApp().mainframe->select_tab(); }; @@ -5160,7 +5162,7 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "layersediting"; item.icon_filename = "layers_white.svg"; item.tooltip = _u8L("Variable layer height"); - item.sprite_id = 12; + item.sprite_id = sprite_id++; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_LAYERSEDITING)); }; item.visibility_callback = [this]()->bool { bool res = current_printer_technology() == ptFFF; @@ -5210,10 +5212,12 @@ bool GLCanvas3D::_init_undoredo_toolbar() GLToolbarItem::Data item; + unsigned int sprite_id = 0; + item.name = "undo"; item.icon_filename = "undo_toolbar.svg"; item.tooltip = _u8L("Undo") + " [" + GUI::shortkey_ctrl_prefix() + "Z]\n" + _u8L("Click right mouse button to open/close History"); - item.sprite_id = 0; + item.sprite_id = sprite_id++; item.left.action_callback = [this]() { post_event(SimpleEvent(EVT_GLCANVAS_UNDO)); }; item.right.toggable = true; item.right.action_callback = [this]() { m_imgui_undo_redo_hovered_pos = -1; }; @@ -5250,7 +5254,7 @@ bool GLCanvas3D::_init_undoredo_toolbar() item.name = "redo"; item.icon_filename = "redo_toolbar.svg"; item.tooltip = _u8L("Redo") + " [" + GUI::shortkey_ctrl_prefix() + "Y]\n" + _u8L("Click right mouse button to open/close History"); - item.sprite_id = 1; + item.sprite_id = sprite_id++; item.left.action_callback = [this]() { post_event(SimpleEvent(EVT_GLCANVAS_REDO)); }; item.right.action_callback = [this]() { m_imgui_undo_redo_hovered_pos = -1; }; item.right.render_callback = [this](float left, float right, float, float) { diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 1e77343bdc..b6644e0f75 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -404,7 +404,7 @@ void MainFrame::update_layout() { m_plater->Reparent(m_tabpanel); m_plater->Layout(); - m_tabpanel->InsertNewPage(0, m_plater, _L("Plater"), std::string("plater"), true); +// m_tabpanel->InsertNewPage(0, m_plater, _L("Plater"), std::string("plater"), true); m_main_sizer->Add(m_tabpanel, 1, wxEXPAND | wxTOP, 1); m_plater->Show(); @@ -475,6 +475,9 @@ void MainFrame::update_layout() } } #endif //__WXMSW__ + + if (m_layout == ESettingsLayout::Old) + m_tabpanel->InsertNewPage(0, m_plater, _L("Plater"), "", true); Layout(); Thaw(); @@ -1050,7 +1053,8 @@ void MainFrame::on_dpi_changed(const wxRect& suggested_rect) this->SetFont(this->normal_font()); #ifdef _WIN32 - // update common mode sizer + if (m_tmp_top_bar->IsShown()) + m_tmp_top_bar->Rescale(); m_tabpanel->Rescale(); #endif @@ -1062,6 +1066,10 @@ void MainFrame::on_dpi_changed(const wxRect& suggested_rect) for (auto tab : wxGetApp().tabs_list) tab->msw_rescale(); + wxGetApp().searcher().dlg_msw_rescale(); + + return; // #ysFIXME - delete_after_testing - It looks like next code is no need any more + // Workarounds for correct Window rendering after rescale /* Even if Window is maximized during moving, @@ -1082,8 +1090,6 @@ void MainFrame::on_dpi_changed(const wxRect& suggested_rect) this->SetSize(sz); this->Maximize(is_maximized); - - wxGetApp().searcher().dlg_msw_rescale(); } void MainFrame::on_sys_color_changed() @@ -2242,8 +2248,9 @@ void SettingsDialog::on_dpi_changed(const wxRect& suggested_rect) if (wxGetApp().is_gcode_viewer()) return; - const int& em = em_unit(); - const wxSize& size = wxSize(85 * em, 50 * em); +// #ysFIXME - delete_after_testing +// const int& em = em_unit(); +// const wxSize& size = wxSize(85 * em, 50 * em); #ifdef _WIN32 m_tabpanel->Rescale(); @@ -2253,9 +2260,10 @@ void SettingsDialog::on_dpi_changed(const wxRect& suggested_rect) for (auto tab : wxGetApp().tabs_list) tab->msw_rescale(); - SetMinSize(size); - Fit(); - Refresh(); +// #ysFIXME - delete_after_testing +// SetMinSize(size); +// Fit(); +// Refresh(); } diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index a90e7c8bca..62e0c5f6b6 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -3253,10 +3253,12 @@ bool Plater::priv::init_view_toolbar() GLToolbarItem::Data item; + unsigned int sprite_id = 0; + item.name = "3D"; item.icon_filename = "editor.svg"; item.tooltip = _u8L("3D editor view") + " [" + GUI::shortkey_ctrl_prefix() + "5]"; - item.sprite_id = 0; + item.sprite_id = sprite_id++; item.left.action_callback = [this]() { if (this->q != nullptr) wxPostEvent(this->q, SimpleEvent(EVT_GLVIEWTOOLBAR_3D)); }; if (!view_toolbar.add_item(item)) return false; @@ -3264,7 +3266,7 @@ bool Plater::priv::init_view_toolbar() item.name = "Preview"; item.icon_filename = "preview.svg"; item.tooltip = _u8L("Preview") + " [" + GUI::shortkey_ctrl_prefix() + "6]"; - item.sprite_id = 1; + item.sprite_id = sprite_id++; item.left.action_callback = [this]() { if (this->q != nullptr) wxPostEvent(this->q, SimpleEvent(EVT_GLVIEWTOOLBAR_PREVIEW)); }; if (!view_toolbar.add_item(item)) return false; diff --git a/src/slic3r/GUI/TopBar.cpp b/src/slic3r/GUI/TopBar.cpp index b984ec1180..fdca313fdb 100644 --- a/src/slic3r/GUI/TopBar.cpp +++ b/src/slic3r/GUI/TopBar.cpp @@ -135,9 +135,9 @@ void TopBarItemsCtrl::Button::render() 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); + dc.DrawBitmap(m_bmp_bundle.GetBitmap(szIcon), pt, true); #else - dc.DrawBitmap(m_bmp_bundle.GetBitmapFor(this), pt); + dc.DrawBitmap(m_bmp_bundle.GetBitmapFor(this), pt, true); #endif pt.x += szIcon.x; } @@ -170,7 +170,7 @@ TopBarItemsCtrl::ButtonWithPopup::ButtonWithPopup(wxWindow* parent, const wxStri :TopBarItemsCtrl::Button(parent, label, icon_name, 24, size) { if (size != wxDefaultSize) - m_fixed_width = size.x; + m_fixed_width = size.x * 0.1; this->SetLabel(label); } @@ -193,7 +193,7 @@ void TopBarItemsCtrl::ButtonWithPopup::SetLabel(const wxString& label) const int label_width = GetTextExtent(text).GetWidth(); bool resize_and_layout{ false }; if (m_fixed_width != wxDefaultCoord) { - const int text_width = m_fixed_width - 2 * btn_height; + const int text_width = m_fixed_width * em_unit(this) - 2 * btn_height; if (label_width > text_width || GetMinSize().GetWidth() <= btn_height) { wxWindowDC wdc(this); text = wxControl::Ellipsize(text, wdc, wxELLIPSIZE_END, text_width); @@ -215,7 +215,7 @@ void TopBarItemsCtrl::ButtonWithPopup::SetLabel(const wxString& label) #endif ScalableButton::SetLabel(full_label); if (resize_and_layout) { - SetMinSize(wxSize(m_fixed_width, btn_height)); + SetMinSize(wxSize(m_fixed_width * em_unit(this), btn_height)); GetParent()->Layout(); } } @@ -225,11 +225,13 @@ void TopBarItemsCtrl::UpdateAccountButton(bool avatar/* = false*/) auto user_account = wxGetApp().plater()->get_user_account(); const wxString user_name = user_account->is_logged() ? from_u8(user_account->get_username()) : _L("Anonymous"); m_account_btn->SetLabel(m_collapsed_btns ? "" : user_name); + m_account_btn->SetToolTip(user_name); + const int icon_sz = 24; #ifdef __linux__ if (avatar) { if (user_account->is_logged()) { boost::filesystem::path path = user_account->get_avatar_path(true); - ScalableBitmap new_logo(this, path, m_account_btn->GetBitmapSize()); + ScalableBitmap new_logo(this, path, wxSize(icon_sz, icon_sz)); if (new_logo.IsOk()) m_account_btn->SetBitmap_(new_logo); else @@ -243,14 +245,14 @@ void TopBarItemsCtrl::UpdateAccountButton(bool avatar/* = false*/) if (avatar) { if (user_account->is_logged()) { boost::filesystem::path path = user_account->get_avatar_path(true); - ScalableBitmap new_logo(this, path, m_account_btn->GetBitmapSize()); + ScalableBitmap new_logo(this, path, wxSize(icon_sz, icon_sz)); if (new_logo.IsOk()) m_account_btn->SetBitmapBundle(new_logo.bmp()); else - m_account_btn->SetBitmapBundle(*get_bmp_bundle("user", 24)); + m_account_btn->SetBitmapBundle(*get_bmp_bundle("user", icon_sz)); } else { - m_account_btn->SetBitmapBundle(*get_bmp_bundle("user", 24)); + m_account_btn->SetBitmapBundle(*get_bmp_bundle("user", icon_sz)); } } #endif @@ -365,7 +367,6 @@ void TopBarItemsCtrl::update_margins() { int em = em_unit(this); m_btn_margin = std::lround(0.9 * em); - m_line_margin = std::lround(0.1 * em); } wxPoint TopBarItemsCtrl::ButtonWithPopup::get_popup_pos() @@ -478,7 +479,7 @@ TopBarItemsCtrl::TopBarItemsCtrl(wxWindow *parent, TopBarMenus* menus/* = nullpt m_menus->Popup(this, &m_menus->workspaces, m_workspace_btn->get_popup_pos()); }); - m_account_btn = new ButtonWithPopup(this, _L("Anonymous"), "user", wxSize(18 * em_unit(this), -1)); + m_account_btn = new ButtonWithPopup(this, _L("Anonymous"), "user", wxSize(180, -1)); right_sizer->Add(m_account_btn, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxRIGHT, m_btn_margin); m_account_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) { @@ -529,6 +530,9 @@ void TopBarItemsCtrl::Rescale() m_buttons_sizer->SetVGap(m_btn_margin); m_buttons_sizer->SetHGap(m_btn_margin); + // call Layout before update buttons width to process recaling of the buttons + m_sizer->Layout(); + update_btns_width(); UpdateSearchSizeAndPosition(); m_sizer->Layout(); diff --git a/src/slic3r/GUI/TopBar.hpp b/src/slic3r/GUI/TopBar.hpp index 252a24e69f..ac9fe018d5 100644 --- a/src/slic3r/GUI/TopBar.hpp +++ b/src/slic3r/GUI/TopBar.hpp @@ -105,7 +105,6 @@ private: std::vector m_pageButtons; int m_selection {-1}; int m_btn_margin; - int m_line_margin; void update_margins(); }; diff --git a/src/slic3r/GUI/TopBarMenus.cpp b/src/slic3r/GUI/TopBarMenus.cpp index b84da244c7..b3c28309cb 100644 --- a/src/slic3r/GUI/TopBarMenus.cpp +++ b/src/slic3r/GUI/TopBarMenus.cpp @@ -59,11 +59,6 @@ void TopBarMenus::ApplyWorkspacesMenu() void TopBarMenus::CreateAccountMenu() { - m_user_item = append_menu_item(&account, wxID_ANY, "", "", - [this](wxCommandEvent& e) { if (m_cb_on_user_item) m_cb_on_user_item(); }, get_bmp_bundle("user", 16)); - - account.AppendSeparator(); - remember_me_item_id = wxWindow::NewControlId(); append_menu_check_item(&account, remember_me_item_id, _L("Remember me"), "" , [](wxCommandEvent&) { wxGetApp().plater()->get_user_account()->toggle_remember_session(); } , nullptr); @@ -85,10 +80,6 @@ void TopBarMenus::UpdateAccountMenu(Slic3r::GUI::UserAccount* user_account) m_login_item->SetItemLabel(is_logged ? _L("Prusa Account Log out") : _L("Prusa Account Log in")); m_login_item->SetBitmap(is_logged ? *get_bmp_bundle("logout", 16) : *get_bmp_bundle("login", 16)); } - - const wxString user_name = is_logged ? from_u8(user_account->get_username()) : _L("Anonymous"); - if (m_user_item) - m_user_item->SetItemLabel(user_name); } void TopBarMenus::Popup(TopBarItemsCtrl* popup_ctrl, wxMenu* menu, wxPoint pos) diff --git a/src/slic3r/GUI/TopBarMenus.hpp b/src/slic3r/GUI/TopBarMenus.hpp index 0a0017b245..a86f09a051 100644 --- a/src/slic3r/GUI/TopBarMenus.hpp +++ b/src/slic3r/GUI/TopBarMenus.hpp @@ -15,7 +15,6 @@ class UserAccount; class TopBarMenus { // Prusa Account menu items - wxMenuItem* m_user_item { nullptr }; wxMenuItem* m_login_item { nullptr }; TopBarItemsCtrl* m_popup_ctrl { nullptr }; diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index ef70cdf9ae..a0c73cdb01 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -855,15 +855,36 @@ ScalableBitmap::ScalableBitmap(wxWindow* parent, boost::filesystem::path& icon_p wxString path = Slic3r::GUI::from_u8(icon_path.string()); wxBitmap bitmap; const std::string ext = icon_path.extension().string(); - if (ext == ".png") { - bitmap.LoadFile(path, wxBITMAP_TYPE_PNG); - wxBitmap::Rescale(bitmap, icon_size); - m_bmp = wxBitmapBundle(bitmap); - } - else if (ext == ".jpg") { - bitmap.LoadFile(path, wxBITMAP_TYPE_JPEG); - wxBitmap::Rescale(bitmap, icon_size); - m_bmp = wxBitmapBundle(bitmap); + + if (ext == ".png" || ext == ".jpg") { + bitmap.LoadFile(path, ext == ".png" ? wxBITMAP_TYPE_PNG : wxBITMAP_TYPE_JPEG); + + // set mask for circle shape + + wxBitmapBundle mask_bmps = *get_bmp_bundle("user_mask", bitmap.GetSize().GetWidth()); + wxMask* mask = new wxMask(mask_bmps.GetBitmap(bitmap.GetSize()), *wxBLACK); + bitmap.SetMask(mask); + + // get allowed scale factors + + std::set scales = { 1.0 }; +#ifdef __APPLE__ + scales.emplace(Slic3r::GUI::mac_max_scaling_factor()); +#elif _WIN32 + size_t disp_cnt = wxDisplay::GetCount(); + for (size_t disp = 0; disp < disp_cnt; ++disp) + scales.emplace(wxDisplay(disp).GetScaleFactor()); +#endif + + // create bitmaps for bundle + + wxVector bmps; + for (double scale : scales) { + wxBitmap bmp = bitmap; + wxBitmap::Rescale(bmp, icon_size * scale); + bmps.push_back(bmp); + } + m_bmp = wxBitmapBundle::FromBitmaps(bmps); } else if (ext == ".svg") { m_bmp = wxBitmapBundle::FromSVGFile(path, icon_size);