From 26d52595a83ac0ae03d7ba0ea03a3327a39780b9 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 26 Apr 2024 16:45:14 +0200 Subject: [PATCH] WIP of Fixing of the re-scaling + TopBar: Deleted unused code --- src/slic3r/GUI/MainFrame.cpp | 26 +++++++++++++++++--------- src/slic3r/GUI/TopBar.cpp | 21 ++++++++++++--------- src/slic3r/GUI/TopBar.hpp | 1 - 3 files changed, 29 insertions(+), 19 deletions(-) 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/TopBar.cpp b/src/slic3r/GUI/TopBar.cpp index b984ec1180..cbe010759f 100644 --- a/src/slic3r/GUI/TopBar.cpp +++ b/src/slic3r/GUI/TopBar.cpp @@ -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,12 @@ 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); + 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 +244,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 +366,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 +478,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 +529,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(); };