From 895b21fb2b2dcf7273eb877555417c2a908a39a5 Mon Sep 17 00:00:00 2001 From: yw4z Date: Sun, 1 Jun 2025 10:40:44 +0300 Subject: [PATCH] Fix scaling on Plates toolbar for Windows (#9674) Update GLCanvas3D.cpp --- src/slic3r/GUI/GLCanvas3D.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 16a8e96eca..b6cdf94179 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -7911,11 +7911,11 @@ void GLCanvas3D::_render_imgui_select_plate_toolbar() m_render_preview = true; // places the toolbar on the top_left corner of the 3d scene -#if ENABLE_RETINA_GL - float f_scale = m_retina_helper->get_scale_factor(); -#else - float f_scale = wxGetApp().em_unit() / 10; // ORCA add scaling support -#endif + float f_scale = get_scale(); + #ifdef WIN32 + const int dpi = get_dpi_for_window(wxGetApp().GetTopWindow()); + f_scale *= (float) dpi / (float) DPI_DEFAULT; + #endif // WIN32 Size cnv_size = get_canvas_size(); auto canvas_w = float(cnv_size.get_width()); auto canvas_h = float(cnv_size.get_height()); @@ -7935,16 +7935,15 @@ void GLCanvas3D::_render_imgui_select_plate_toolbar() // Make sure the window does not overlap the 3d navigator auto window_height_max = canvas_h - y_offset; if (wxGetApp().show_3d_navigator()) { - float sc = get_scale(); -#ifdef WIN32 - const int dpi = get_dpi_for_window(wxGetApp().GetTopWindow()); - sc *= (float) dpi / (float) DPI_DEFAULT; -#endif // WIN32 - window_height_max -= (128 * sc + 5); + window_height_max -= (128 * f_scale + 5); } // ORCA simplify and correct window size and margin calculations and get values from style ImGuiWrapper& imgui = *wxGetApp().imgui(); + + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8.0f, 8.0f) * f_scale); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4.0f, 4.0f) * f_scale); + int item_count = m_sel_plate_toolbar.m_items.size() + (m_sel_plate_toolbar.show_stats_item ? 1 : 0); float window_height_calc = (item_count * (button_height + (margin_size + button_margin) * 2.0f) + (item_count - 1) * ImGui::GetStyle().ItemSpacing.y + ImGui::GetStyle().WindowPadding.y * 2.0f); bool show_scroll = m_sel_plate_toolbar.is_display_scrollbar && (window_height_calc > window_height_max); @@ -8180,7 +8179,7 @@ void GLCanvas3D::_render_imgui_select_plate_toolbar() } ImGui::SetWindowFontScale(1.0f); ImGui::PopStyleColor(8); - ImGui::PopStyleVar(5); + ImGui::PopStyleVar(7); if (ImGui::IsWindowHovered() || is_hovered) { m_sel_plate_toolbar.is_display_scrollbar = true;