diff options
Diffstat (limited to 'src/slic3r/GUI/GLToolbar.cpp')
-rw-r--r-- | src/slic3r/GUI/GLToolbar.cpp | 173 |
1 files changed, 0 insertions, 173 deletions
diff --git a/src/slic3r/GUI/GLToolbar.cpp b/src/slic3r/GUI/GLToolbar.cpp index 715eb7442..5ac5bf92f 100644 --- a/src/slic3r/GUI/GLToolbar.cpp +++ b/src/slic3r/GUI/GLToolbar.cpp @@ -30,11 +30,9 @@ wxDEFINE_EVENT(EVT_GLTOOLBAR_LAYERSEDITING, SimpleEvent); wxDEFINE_EVENT(EVT_GLVIEWTOOLBAR_3D, SimpleEvent); wxDEFINE_EVENT(EVT_GLVIEWTOOLBAR_PREVIEW, SimpleEvent); -#if ENABLE_CANVAS_GUI_REFACTORING const GLToolbarItem::ActionCallback GLToolbarItem::Default_Action_Callback = [](){}; const GLToolbarItem::VisibilityCallback GLToolbarItem::Default_Visibility_Callback = []()->bool { return true; }; const GLToolbarItem::EnabledStateCallback GLToolbarItem::Default_Enabled_State_Callback = []()->bool { return true; }; -#endif // ENABLE_CANVAS_GUI_REFACTORING GLToolbarItem::Data::Data() : name("") @@ -45,33 +43,19 @@ GLToolbarItem::Data::Data() , sprite_id(-1) , is_toggable(false) , visible(true) -#if ENABLE_CANVAS_GUI_REFACTORING , action_callback(Default_Action_Callback) , visibility_callback(Default_Visibility_Callback) , enabled_state_callback(Default_Enabled_State_Callback) -#endif // ENABLE_CANVAS_GUI_REFACTORING { } GLToolbarItem::GLToolbarItem(GLToolbarItem::EType type, const GLToolbarItem::Data& data) : m_type(type) -#if ENABLE_CANVAS_GUI_REFACTORING , m_state(Normal) -#else - , m_state(Disabled) -#endif // ENABLE_CANVAS_GUI_REFACTORING , m_data(data) { } -#if !ENABLE_CANVAS_GUI_REFACTORING -void GLToolbarItem::do_action(wxEvtHandler *target) -{ - wxPostEvent(target, SimpleEvent(m_data.action_event)); -} -#endif // !ENABLE_CANVAS_GUI_REFACTORING - -#if ENABLE_CANVAS_GUI_REFACTORING bool GLToolbarItem::update_visibility() { bool visible = m_data.visibility_callback(); @@ -91,7 +75,6 @@ bool GLToolbarItem::update_enabled_state() return ret; } -#endif // ENABLE_CANVAS_GUI_REFACTORING void GLToolbarItem::render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const { @@ -174,10 +157,8 @@ GLToolbar::GLToolbar(GLToolbar::EType type) #if ENABLE_SVG_ICONS , m_icons_texture_dirty(true) #endif // ENABLE_SVG_ICONS -#if ENABLE_CANVAS_GUI_REFACTORING , m_mouse_capture({false, false, false}) , m_tooltip("") -#endif // ENABLE_CANVAS_GUI_REFACTORING { } @@ -342,32 +323,6 @@ float GLToolbar::get_height() const return m_layout.height; } -#if !ENABLE_CANVAS_GUI_REFACTORING -void GLToolbar::enable_item(const std::string& name) -{ - for (GLToolbarItem* item : m_items) - { - if ((item->get_name() == name) && (item->get_state() == GLToolbarItem::Disabled)) - { - item->set_state(GLToolbarItem::Normal); - return; - } - } -} - -void GLToolbar::disable_item(const std::string& name) -{ - for (GLToolbarItem* item : m_items) - { - if (item->get_name() == name) - { - item->set_state(GLToolbarItem::Disabled); - return; - } - } -} -#endif // !ENABLE_CANVAS_GUI_REFACTORING - void GLToolbar::select_item(const std::string& name) { if (is_item_disabled(name)) @@ -416,35 +371,6 @@ bool GLToolbar::is_item_visible(const std::string& name) const return false; } -#if !ENABLE_CANVAS_GUI_REFACTORING -void GLToolbar::set_item_visible(const std::string& name, bool visible) -{ - for (GLToolbarItem* item : m_items) - { - if ((item->get_name() == name) && (item->is_visible() != visible)) - { - item->set_visible(visible); - m_layout.dirty = true; - break; - } - } - - // updates separators visibility to avoid having two consecutive - bool any_item_visible = false; - for (GLToolbarItem* item : m_items) - { - if (!item->is_separator()) - any_item_visible |= item->is_visible(); - else - { - item->set_visible(any_item_visible); - any_item_visible = false; - } - } -} -#endif // !ENABLE_CANVAS_GUI_REFACTORING - -#if ENABLE_CANVAS_GUI_REFACTORING bool GLToolbar::update_items_state() { bool ret = false; @@ -452,73 +378,6 @@ bool GLToolbar::update_items_state() ret |= update_items_enabled_state(); return ret; } -#endif // ENABLE_CANVAS_GUI_REFACTORING - -#if !ENABLE_CANVAS_GUI_REFACTORING -std::string GLToolbar::update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent) -{ - if (!m_enabled) - return ""; - - switch (m_layout.type) - { - default: - case Layout::Horizontal: { return update_hover_state_horizontal(mouse_pos, parent); } - case Layout::Vertical: { return update_hover_state_vertical(mouse_pos, parent); } - } -} - -int GLToolbar::contains_mouse(const Vec2d& mouse_pos, const GLCanvas3D& parent) const -{ - if (!m_enabled) - return -1; - - switch (m_layout.type) - { - default: - case Layout::Horizontal: { return contains_mouse_horizontal(mouse_pos, parent); } - case Layout::Vertical: { return contains_mouse_vertical(mouse_pos, parent); } - } -} - -void GLToolbar::do_action(unsigned int item_id, GLCanvas3D& parent) -{ - if (item_id < (unsigned int)m_items.size()) - { - GLToolbarItem* item = m_items[item_id]; - if ((item != nullptr) && !item->is_separator() && item->is_hovered()) - { - if (item->is_toggable()) - { - GLToolbarItem::EState state = item->get_state(); - if (state == GLToolbarItem::Hover) - item->set_state(GLToolbarItem::HoverPressed); - else if (state == GLToolbarItem::HoverPressed) - item->set_state(GLToolbarItem::Hover); - - parent.render(); - item->do_action(parent.get_wxglcanvas()); - } - else - { - if (m_type == Radio) - select_item(item->get_name()); - else - item->set_state(GLToolbarItem::HoverPressed); - - parent.render(); - item->do_action(parent.get_wxglcanvas()); - if ((m_type == Normal) && (item->get_state() != GLToolbarItem::Disabled)) - { - // the item may get disabled during the action, if not, set it back to hover state - item->set_state(GLToolbarItem::Hover); - parent.render(); - } - } - } - } -} -#endif // !ENABLE_CANVAS_GUI_REFACTORING void GLToolbar::render(const GLCanvas3D& parent) const { @@ -545,7 +404,6 @@ void GLToolbar::render(const GLCanvas3D& parent) const ::glPopMatrix(); } -#if ENABLE_CANVAS_GUI_REFACTORING bool GLToolbar::on_mouse(wxMouseEvent& evt, GLCanvas3D& parent) { Vec2d mouse_pos((double)evt.GetX(), (double)evt.GetY()); @@ -592,7 +450,6 @@ bool GLToolbar::on_mouse(wxMouseEvent& evt, GLCanvas3D& parent) return processed; } -#endif // ENABLE_CANVAS_GUI_REFACTORING void GLToolbar::calc_layout() const { @@ -683,7 +540,6 @@ float GLToolbar::get_main_size() const return size; } -#if ENABLE_CANVAS_GUI_REFACTORING void GLToolbar::do_action(unsigned int item_id, GLCanvas3D& parent) { if (item_id < (unsigned int)m_items.size()) @@ -734,7 +590,6 @@ std::string GLToolbar::update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& pa case Layout::Vertical: { return update_hover_state_vertical(mouse_pos, parent); } } } -#endif // ENABLE_CANVAS_GUI_REFACTORING std::string GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D& parent) { @@ -945,7 +800,6 @@ std::string GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCan return tooltip; } -#if ENABLE_CANVAS_GUI_REFACTORING int GLToolbar::contains_mouse(const Vec2d& mouse_pos, const GLCanvas3D& parent) const { if (!m_enabled) @@ -958,7 +812,6 @@ int GLToolbar::contains_mouse(const Vec2d& mouse_pos, const GLCanvas3D& parent) case Layout::Vertical: { return contains_mouse_vertical(mouse_pos, parent); } } } -#endif // ENABLE_CANVAS_GUI_REFACTORING int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3D& parent) const { @@ -983,10 +836,6 @@ int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3 float scaled_separator_size = m_layout.separator_size * factor; float scaled_gap_size = m_layout.gap_size * factor; float scaled_border = m_layout.border * factor; -#if !ENABLE_CANVAS_GUI_REFACTORING - float separator_stride = scaled_separator_size + scaled_gap_size; - float icon_stride = scaled_icons_size + scaled_gap_size; -#endif // !ENABLE_CANVAS_GUI_REFACTORING float left = m_layout.left + scaled_border; float top = m_layout.top - scaled_border; @@ -1001,7 +850,6 @@ int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3 continue; if (item->is_separator()) -#if ENABLE_CANVAS_GUI_REFACTORING { float right = left + scaled_separator_size; float bottom = top - scaled_icons_size; @@ -1022,9 +870,6 @@ int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3 left = right; } -#else - left += separator_stride; -#endif // ENABLE_CANVAS_GUI_REFACTORING else { float right = left + scaled_icons_size; @@ -1034,7 +879,6 @@ int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3 if ((left <= (float)scaled_mouse_pos(0)) && ((float)scaled_mouse_pos(0) <= right) && (bottom <= (float)scaled_mouse_pos(1)) && ((float)scaled_mouse_pos(1) <= top)) return id; -#if ENABLE_CANVAS_GUI_REFACTORING left = right; right += scaled_gap_size; @@ -1046,9 +890,6 @@ int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3 } left = right; -#else - left += icon_stride; -#endif // ENABLE_CANVAS_GUI_REFACTORING } } @@ -1078,10 +919,6 @@ int GLToolbar::contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D& float scaled_separator_size = m_layout.separator_size * factor; float scaled_gap_size = m_layout.gap_size * factor; float scaled_border = m_layout.border * factor; -#if !ENABLE_CANVAS_GUI_REFACTORING - float separator_stride = scaled_separator_size + scaled_gap_size; - float icon_stride = scaled_icons_size + scaled_gap_size; -#endif // !ENABLE_CANVAS_GUI_REFACTORING float left = m_layout.left + scaled_border; float top = m_layout.top - scaled_border; @@ -1096,7 +933,6 @@ int GLToolbar::contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D& continue; if (item->is_separator()) -#if ENABLE_CANVAS_GUI_REFACTORING { float right = left + scaled_icons_size; float bottom = top - scaled_separator_size; @@ -1117,9 +953,6 @@ int GLToolbar::contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D& top = bottom; } -#else - top -= separator_stride; -#endif // ENABLE_CANVAS_GUI_REFACTORING else { float right = left + scaled_icons_size; @@ -1129,7 +962,6 @@ int GLToolbar::contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D& if ((left <= (float)scaled_mouse_pos(0)) && ((float)scaled_mouse_pos(0) <= right) && (bottom <= (float)scaled_mouse_pos(1)) && ((float)scaled_mouse_pos(1) <= top)) return id; -#if ENABLE_CANVAS_GUI_REFACTORING top = bottom; bottom -= scaled_gap_size; @@ -1141,9 +973,6 @@ int GLToolbar::contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D& } top = bottom; -#else - top -= icon_stride; -#endif // ENABLE_CANVAS_GUI_REFACTORING } } @@ -1498,7 +1327,6 @@ bool GLToolbar::generate_icons_texture() const } #endif // ENABLE_SVG_ICONS -#if ENABLE_CANVAS_GUI_REFACTORING bool GLToolbar::update_items_visibility() { bool ret = false; @@ -1541,7 +1369,6 @@ bool GLToolbar::update_items_enabled_state() return ret; } -#endif // ENABLE_CANVAS_GUI_REFACTORING } // namespace GUI } // namespace Slic3r |