Best effort for pixel perfect icon rendering (#4552)

* Make sure all icons & toolbars have sizes & locations in whole number pixels, so icons won't be blurry

* Make every size even so it scales well on screen
This commit is contained in:
Noisyfox 2024-05-18 22:49:03 +08:00 committed by GitHub
parent 136313f539
commit ba3016bc3d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 22 additions and 19 deletions

View file

@ -6292,8 +6292,8 @@ bool GLCanvas3D::_init_main_toolbar()
//BBS: main toolbar is at the top and left, we don't need the rounded-corner effect at the right side and the top side
m_main_toolbar.set_horizontal_orientation(GLToolbar::Layout::HO_Right);
m_main_toolbar.set_vertical_orientation(GLToolbar::Layout::VO_Top);
m_main_toolbar.set_border(5.0f);
m_main_toolbar.set_separator_size(5);
m_main_toolbar.set_border(4.0f);
m_main_toolbar.set_separator_size(4);
m_main_toolbar.set_gap_size(4);
m_main_toolbar.del_all_item();
@ -6483,7 +6483,7 @@ bool GLCanvas3D::_init_assemble_view_toolbar()
//BBS: assemble toolbar is at the top and right, we don't need the rounded-corner effect at the left side and the top side
m_assemble_view_toolbar.set_horizontal_orientation(GLToolbar::Layout::HO_Left);
m_assemble_view_toolbar.set_vertical_orientation(GLToolbar::Layout::VO_Top);
m_assemble_view_toolbar.set_border(5.0f);
m_assemble_view_toolbar.set_border(4.0f);
m_assemble_view_toolbar.set_separator_size(10);
m_assemble_view_toolbar.set_gap_size(4);
@ -6540,7 +6540,7 @@ bool GLCanvas3D::_init_separator_toolbar()
//BBS: assemble toolbar is at the top and right, we don't need the rounded-corner effect at the left side and the top side
m_separator_toolbar.set_horizontal_orientation(GLToolbar::Layout::HO_Left);
m_separator_toolbar.set_vertical_orientation(GLToolbar::Layout::VO_Top);
m_separator_toolbar.set_border(5.0f);
m_separator_toolbar.set_border(4.0f);
m_separator_toolbar.del_all_item();
@ -7383,8 +7383,11 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale()
Size cnv_size = get_canvas_size();
//BBS: GUI refactor: GLToolbar
float size = GLToolbar::Default_Icons_Size * scale;
//float main_size = GLGizmosManager::Default_Icons_Size * scale;
int size_i = int(GLToolbar::Default_Icons_Size * scale);
// force even size
if (size_i % 2 != 0)
size_i -= 1;
float size = size_i;
// Set current size for all top toolbars. It will be used for next calculations
#if ENABLE_RETINA_GL
@ -7401,7 +7404,7 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale()
m_gizmos.set_overlay_scale(sc);
#else
//BBS: GUI refactor: GLToolbar
m_main_toolbar.set_icons_size(GLGizmosManager::Default_Icons_Size * scale);
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);
@ -7662,7 +7665,7 @@ void GLCanvas3D::_render_gizmos_overlay()
}
}
float GLCanvas3D::get_main_toolbar_offset() const
int GLCanvas3D::get_main_toolbar_offset() const
{
const float cnv_width = get_canvas_size().get_width();
const float collapse_toolbar_width = get_collapse_toolbar_width() * 2;