Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best effort for pixel perfect icon rendering #4552

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/slic3r/GUI/GLCanvas3D.cpp
Expand Up @@ -6289,8 +6289,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();
Expand Down Expand Up @@ -6479,7 +6479,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);

Expand Down Expand Up @@ -6536,7 +6536,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();

Expand Down Expand Up @@ -7379,8 +7379,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
Expand All @@ -7397,7 +7400,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);
Expand Down Expand Up @@ -7658,7 +7661,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;
Expand Down
6 changes: 3 additions & 3 deletions src/slic3r/GUI/GLCanvas3D.hpp
Expand Up @@ -850,9 +850,9 @@ class GLCanvas3D
//BBS: add part plate related logic
void select_plate();
//BBS: GUI refactor: GLToolbar&&gizmo
float get_main_toolbar_offset() const;
float get_main_toolbar_height() const { return m_main_toolbar.get_height(); }
float get_main_toolbar_width() const { return m_main_toolbar.get_width(); }
int get_main_toolbar_offset() const;
int get_main_toolbar_height() const { return m_main_toolbar.get_height(); }
int get_main_toolbar_width() const { return m_main_toolbar.get_width(); }
float get_assemble_view_toolbar_width() const { return m_assemble_view_toolbar.get_width(); }
float get_assemble_view_toolbar_height() const { return m_assemble_view_toolbar.get_height(); }
float get_assembly_paint_toolbar_width() const { return m_paint_toolbar_width; }
Expand Down
6 changes: 3 additions & 3 deletions src/slic3r/GUI/Gizmos/GLGizmosManager.cpp
Expand Up @@ -1101,10 +1101,10 @@ void GLGizmosManager::do_render_overlay() const
//float space_width = GLGizmosManager::Default_Icons_Size * wxGetApp().toolbar_icon_scale();
//float zoomed_top_x = 0.5f *(cnv_w + main_toolbar_width - 2 * space_width - width) * inv_zoom;

float main_toolbar_left = -0.5f * cnv_w + m_parent.get_main_toolbar_offset();
int main_toolbar_left = -cnv_w + m_parent.get_main_toolbar_offset() * 2;
//float zoomed_top_x = 0.5f *(main_toolbar_width + collapse_width - width - assemble_view_width) * inv_zoom;
top_x = main_toolbar_left + main_toolbar_width + separator_width / 2;
top_x = top_x * inv_cnv_w * 2;
top_x = main_toolbar_left + main_toolbar_width * 2 + separator_width;
top_x = top_x * inv_cnv_w;
}
float top_y = 1.0f;

Expand Down
6 changes: 3 additions & 3 deletions src/slic3r/GUI/Gizmos/GLGizmosManager.hpp
Expand Up @@ -102,10 +102,10 @@ class GLGizmosManager : public Slic3r::ObjectBase
{
float scale{ 1.0f };
float icons_size{ Default_Icons_Size };
float border{ 5.0f };
float gap_y{ 5.0f };
float border{ 4.0f };
float gap_y{ 4.0f };
//BBS: GUI refactor: to support top layout
float gap_x{ 5.0f };
float gap_x{ 4.0f };
float stride_x() const { return icons_size + gap_x;}
float scaled_gap_x() const { return scale * gap_x; }
float scaled_stride_x() const { return scale * stride_x(); }
Expand Down
4 changes: 2 additions & 2 deletions src/slic3r/GUI/Plater.cpp
Expand Up @@ -7770,8 +7770,8 @@ bool Plater::priv::init_collapse_toolbar()
collapse_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
collapse_toolbar.set_horizontal_orientation(GLToolbar::Layout::HO_Right);
collapse_toolbar.set_vertical_orientation(GLToolbar::Layout::VO_Top);
collapse_toolbar.set_border(5.0f);
collapse_toolbar.set_separator_size(5);
collapse_toolbar.set_border(4.0f);
collapse_toolbar.set_separator_size(4);
collapse_toolbar.set_gap_size(2);

collapse_toolbar.del_all_item();
Expand Down