diff options
author | Enrico Turri <enricoturri@seznam.cz> | 2018-12-17 13:11:49 +0300 |
---|---|---|
committer | Enrico Turri <enricoturri@seznam.cz> | 2018-12-17 13:11:49 +0300 |
commit | 0a6e4cb39ac4e432863405f07e63eb1506cda92c (patch) | |
tree | 239adb5e24faccb64d2470c7f897f275117f9d0a | |
parent | 083c626770fcfb5a050328641c020ac0bff09919 (diff) |
Scalable toolbar icons
-rw-r--r-- | src/slic3r/GUI/GLToolbar.cpp | 45 | ||||
-rw-r--r-- | src/slic3r/GUI/GLToolbar.hpp | 2 |
2 files changed, 29 insertions, 18 deletions
diff --git a/src/slic3r/GUI/GLToolbar.cpp b/src/slic3r/GUI/GLToolbar.cpp index a7f623b8d..43da81809 100644 --- a/src/slic3r/GUI/GLToolbar.cpp +++ b/src/slic3r/GUI/GLToolbar.cpp @@ -173,6 +173,7 @@ GLToolbar::Layout::Layout() #endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE , separator_size(0.0f) , gap_size(0.0f) + , icons_scale(1.0f) #if ENABLE_TOOLBAR_BACKGROUND_TEXTURE , width(0.0f) , height(0.0f) @@ -290,6 +291,14 @@ void GLToolbar::set_gap_size(float size) #endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE } +void GLToolbar::set_icons_scale(float scale) +{ + m_layout.icons_scale = scale; +#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE + m_layout.dirty = true; +#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE +} + bool GLToolbar::is_enabled() const { return m_enabled; @@ -625,18 +634,18 @@ float GLToolbar::get_width_horizontal() const float GLToolbar::get_width_vertical() const { #if ENABLE_TOOLBAR_BACKGROUND_TEXTURE - return 2.0f * m_layout.border + m_icons_texture.metadata.icon_size; + return 2.0f * m_layout.border + m_icons_texture.metadata.icon_size * m_layout.icons_scale; #else - return m_icons_texture.items_icon_size; + return m_icons_texture.items_icon_size * m_layout.icons_scale; #endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE } float GLToolbar::get_height_horizontal() const { #if ENABLE_TOOLBAR_BACKGROUND_TEXTURE - return 2.0f * m_layout.border + m_icons_texture.metadata.icon_size; + return 2.0f * m_layout.border + m_icons_texture.metadata.icon_size * m_layout.icons_scale; #else - return m_icons_texture.items_icon_size; + return m_icons_texture.items_icon_size * m_layout.icons_scale; #endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE } @@ -658,9 +667,9 @@ float GLToolbar::get_main_size() const size += m_layout.separator_size; else #if ENABLE_TOOLBAR_BACKGROUND_TEXTURE - size += (float)m_icons_texture.metadata.icon_size; + size += (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale; #else - size += (float)m_icons_texture.items_icon_size; + size += (float)m_icons_texture.items_icon_size * m_layout.icons_scale; #endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE } @@ -699,9 +708,9 @@ void GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos) Vec2d scaled_mouse_pos((mouse_pos(0) - 0.5 * (double)cnv_size.get_width()) * inv_zoom, (0.5 * (double)cnv_size.get_height() - mouse_pos(1)) * inv_zoom); #if ENABLE_TOOLBAR_BACKGROUND_TEXTURE - float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * inv_zoom; + float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale * inv_zoom; #else - float scaled_icons_size = (float)m_icons_texture.items_icon_size * inv_zoom; + float scaled_icons_size = (float)m_icons_texture.items_icon_size * m_layout.icons_scale * inv_zoom; #endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float scaled_separator_size = m_layout.separator_size * inv_zoom; float scaled_gap_size = m_layout.gap_size * inv_zoom; @@ -844,9 +853,9 @@ void GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos) Vec2d scaled_mouse_pos((mouse_pos(0) - 0.5 * (double)cnv_size.get_width()) * inv_zoom, (0.5 * (double)cnv_size.get_height() - mouse_pos(1)) * inv_zoom); #if ENABLE_TOOLBAR_BACKGROUND_TEXTURE - float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * inv_zoom; + float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale * inv_zoom; #else - float scaled_icons_size = (float)m_icons_texture.items_icon_size * inv_zoom; + float scaled_icons_size = (float)m_icons_texture.items_icon_size * m_layout.icons_scale * inv_zoom; #endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float scaled_separator_size = m_layout.separator_size * inv_zoom; float scaled_gap_size = m_layout.gap_size * inv_zoom; @@ -980,9 +989,9 @@ int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos) const Vec2d scaled_mouse_pos((mouse_pos(0) - 0.5 * (double)cnv_size.get_width()) * inv_zoom, (0.5 * (double)cnv_size.get_height() - mouse_pos(1)) * inv_zoom); #if ENABLE_TOOLBAR_BACKGROUND_TEXTURE - float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * inv_zoom; + float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale * inv_zoom; #else - float scaled_icons_size = (float)m_icons_texture.items_icon_size * inv_zoom; + float scaled_icons_size = (float)m_icons_texture.items_icon_size * m_layout.icons_scale * inv_zoom; #endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float scaled_separator_size = m_layout.separator_size * inv_zoom; float scaled_gap_size = m_layout.gap_size * inv_zoom; @@ -1045,9 +1054,9 @@ int GLToolbar::contains_mouse_vertical(const Vec2d& mouse_pos) const Vec2d scaled_mouse_pos((mouse_pos(0) - 0.5 * (double)cnv_size.get_width()) * inv_zoom, (0.5 * (double)cnv_size.get_height() - mouse_pos(1)) * inv_zoom); #if ENABLE_TOOLBAR_BACKGROUND_TEXTURE - float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * inv_zoom; + float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale * inv_zoom; #else - float scaled_icons_size = (float)m_icons_texture.items_icon_size * inv_zoom; + float scaled_icons_size = (float)m_icons_texture.items_icon_size * m_layout.icons_scale * inv_zoom; #endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float scaled_separator_size = m_layout.separator_size * inv_zoom; float scaled_gap_size = m_layout.gap_size * inv_zoom; @@ -1109,9 +1118,9 @@ void GLToolbar::render_horizontal() const float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f; #if ENABLE_TOOLBAR_BACKGROUND_TEXTURE - float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * inv_zoom; + float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale * inv_zoom; #else - float scaled_icons_size = (float)m_icons_texture.items_icon_size * inv_zoom; + float scaled_icons_size = (float)m_icons_texture.items_icon_size * m_layout.icons_scale * inv_zoom; #endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float scaled_separator_size = m_layout.separator_size * inv_zoom; float scaled_gap_size = m_layout.gap_size * inv_zoom; @@ -1257,9 +1266,9 @@ void GLToolbar::render_vertical() const float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f; #if ENABLE_TOOLBAR_BACKGROUND_TEXTURE - float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * inv_zoom; + float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale * inv_zoom; #else - float scaled_icons_size = (float)m_icons_texture.items_icon_size * inv_zoom; + float scaled_icons_size = (float)m_icons_texture.items_icon_size * m_layout.icons_scale * inv_zoom; #endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float scaled_separator_size = m_layout.separator_size * inv_zoom; float scaled_gap_size = m_layout.gap_size * inv_zoom; diff --git a/src/slic3r/GUI/GLToolbar.hpp b/src/slic3r/GUI/GLToolbar.hpp index 4e15edd17..430d4a844 100644 --- a/src/slic3r/GUI/GLToolbar.hpp +++ b/src/slic3r/GUI/GLToolbar.hpp @@ -193,6 +193,7 @@ public: #endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float separator_size; float gap_size; + float icons_scale; #if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float width; @@ -249,6 +250,7 @@ public: #endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE void set_separator_size(float size); void set_gap_size(float size); + void set_icons_scale(float scale); bool is_enabled() const; void set_enabled(bool enable); |