glcanvas: scale icons using icon size, not scale factor (#8301)

# Description

Calculate toolbar icon size the same way as it done on windows:
 manipulate icon size, not toolbar scale.

Scaling icons this way makes images sharper since they getting
rasterized to a target size rather than being rasterized for 40px and
scaled to a desired size later.

# Screenshots/Recordings/Graphs

Test samples with different toolbar scaling/app window width (top one is
original, bottom one - updated)

![Screenshot from 2025-02-03
21-12-23](https://github.com/user-attachments/assets/9fdf810e-9479-4932-b6fd-1124f33fa335)

![Screenshot from 2025-02-03
21-12-40](https://github.com/user-attachments/assets/301306f2-eab2-4770-9a75-19131501342c)

![Screenshot from 2025-02-03
21-13-10](https://github.com/user-attachments/assets/6138958d-0aa9-4e35-af10-643668760f6a)

![Screenshot from 2025-02-03
21-13-26](https://github.com/user-attachments/assets/e1988f20-eac4-4696-98b9-8483a16dcdfd)


## Tests

Tested on Linux only.
This commit is contained in:
Noisyfox 2025-02-08 23:12:40 +08:00 committed by GitHub
commit b29edeb282
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7431,7 +7431,7 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale()
return;
}
float scale = wxGetApp().toolbar_icon_scale();
float scale = wxGetApp().toolbar_icon_scale() * get_scale();
Size cnv_size = get_canvas_size();
//BBS: GUI refactor: GLToolbar
@ -7442,26 +7442,12 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale()
float size = size_i;
// Set current size for all top toolbars. It will be used for next calculations
#if ENABLE_RETINA_GL
const float sc = m_retina_helper->get_scale_factor() * scale;
//BBS: GUI refactor: GLToolbar
m_main_toolbar.set_scale(sc);
m_assemble_view_toolbar.set_scale(sc);
m_separator_toolbar.set_scale(sc);
collapse_toolbar.set_scale(sc / 2.0);
size *= m_retina_helper->get_scale_factor();
auto* m_notification = wxGetApp().plater()->get_notification_manager();
m_notification->set_scale(sc);
m_gizmos.set_overlay_scale(sc);
#else
//BBS: GUI refactor: GLToolbar
m_main_toolbar.set_icons_size(size);
m_assemble_view_toolbar.set_icons_size(size);
m_separator_toolbar.set_icons_size(size);
collapse_toolbar.set_icons_size(size / 2.0);
m_gizmos.set_overlay_icon_size(size);
#endif // ENABLE_RETINA_GL
//BBS: GUI refactor: GLToolbar
#if BBS_TOOLBAR_ON_TOP
@ -7498,9 +7484,7 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale()
// set minimum scale as a auto scale for the toolbars
float new_scale = std::min(new_h_scale, new_v_scale);
#if ENABLE_RETINA_GL
new_scale /= m_retina_helper->get_scale_factor();
#endif
new_scale /= get_scale();
if (fabs(new_scale - scale) > 0.05) // scale is changed by 5% and more
wxGetApp().set_auto_toolbar_icon_scale(new_scale);
}