diff options
author | Enrico Turri <enricoturri@seznam.cz> | 2019-03-20 11:33:30 +0300 |
---|---|---|
committer | Enrico Turri <enricoturri@seznam.cz> | 2019-03-20 11:33:30 +0300 |
commit | df250039dfb170c420649ec2dadcd2891b2aab27 (patch) | |
tree | b8437df6f9522f7c6ad58a12941c1ac2b37ffb77 /src/slic3r/GUI | |
parent | da1feb2741beb94813a68b4ec2121f2dd14b875c (diff) |
Tech ENABLE_CANVAS_GUI_REFACTORING set as default
Diffstat (limited to 'src/slic3r/GUI')
-rw-r--r-- | src/slic3r/GUI/GLCanvas3D.cpp | 143 | ||||
-rw-r--r-- | src/slic3r/GUI/GLCanvas3D.hpp | 15 | ||||
-rw-r--r-- | src/slic3r/GUI/GLToolbar.cpp | 173 | ||||
-rw-r--r-- | src/slic3r/GUI/GLToolbar.hpp | 50 | ||||
-rw-r--r-- | src/slic3r/GUI/GUI_Preview.cpp | 14 | ||||
-rw-r--r-- | src/slic3r/GUI/GUI_Preview.hpp | 4 | ||||
-rw-r--r-- | src/slic3r/GUI/Plater.cpp | 138 | ||||
-rw-r--r-- | src/slic3r/GUI/Plater.hpp | 2 |
8 files changed, 1 insertions, 538 deletions
diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 1236ee7b4..7fb1ad25e 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -728,9 +728,6 @@ GLCanvas3D::Mouse::Drag::Drag() GLCanvas3D::Mouse::Mouse() : dragging(false) -#if !ENABLE_CANVAS_GUI_REFACTORING - , left_down(false) -#endif // !ENABLE_CANVAS_GUI_REFACTORING , position(DBL_MAX, DBL_MAX) , scene_position(DBL_MAX, DBL_MAX, DBL_MAX) , ignore_up_event(false) @@ -2067,9 +2064,6 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar , m_use_VBOs(false) , m_apply_zoom_to_volumes_filter(false) , m_hover_volume_id(-1) -#if !ENABLE_CANVAS_GUI_REFACTORING - , m_toolbar_action_running(false) -#endif // !ENABLE_CANVAS_GUI_REFACTORING , m_legend_texture_enabled(false) , m_picking_enabled(false) , m_moving_enabled(false) @@ -2373,21 +2367,6 @@ void GLCanvas3D::allow_multisample(bool allow) m_multisample_allowed = allow; } -#if !ENABLE_CANVAS_GUI_REFACTORING -void GLCanvas3D::enable_toolbar_item(const std::string& name, bool enable) -{ - if (enable) - m_toolbar.enable_item(name); - else - m_toolbar.disable_item(name); -} - -bool GLCanvas3D::is_toolbar_item_pressed(const std::string& name) const -{ - return m_toolbar.is_item_pressed(name); -} -#endif // !ENABLE_CANVAS_GUI_REFACTORING - void GLCanvas3D::zoom_to_bed() { _zoom_to_bounding_box(m_bed.get_bounding_box()); @@ -2440,17 +2419,6 @@ void GLCanvas3D::update_volumes_colors_by_extruder() m_volumes.update_colors_by_extruder(m_config); } -#if !ENABLE_CANVAS_GUI_REFACTORING -void GLCanvas3D::update_toolbar_items_visibility() -{ - ConfigOptionMode mode = wxGetApp().get_mode(); - m_toolbar.set_item_visible("more", mode != comSimple); - m_toolbar.set_item_visible("fewer", mode != comSimple); - m_toolbar.set_item_visible("splitvolumes", mode != comSimple); - m_dirty = true; -} -#endif // !ENABLE_CANVAS_GUI_REFACTORING - void GLCanvas3D::render() { wxCHECK_RET(!m_in_render, "GLCanvas3D::render() called recursively"); @@ -3103,10 +3071,8 @@ void GLCanvas3D::on_size(wxSizeEvent& evt) void GLCanvas3D::on_idle(wxIdleEvent& evt) { -#if ENABLE_CANVAS_GUI_REFACTORING m_dirty |= m_toolbar.update_items_state(); m_dirty |= m_view_toolbar.update_items_state(); -#endif // ENABLE_CANVAS_GUI_REFACTORING if (!m_dirty) return; @@ -3386,7 +3352,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) #endif /* SLIC3R_DEBUG_MOUSE_EVENTS */ } -#if ENABLE_CANVAS_GUI_REFACTORING bool processed_by_toolbar = m_toolbar.on_mouse(evt, *this); processed_by_toolbar |= m_view_toolbar.on_mouse(evt, *this); @@ -3395,7 +3360,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) m_mouse.set_start_position_3D_as_invalid(); return; } -#endif // ENABLE_CANVAS_GUI_REFACTORING if (m_picking_enabled) _set_current(); @@ -3404,10 +3368,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) int layer_editing_object_idx = is_layers_editing_enabled() ? selected_object_idx : -1; m_layers_editing.select_object(*m_model, layer_editing_object_idx); bool gizmos_overlay_contains_mouse = m_gizmos.overlay_contains_mouse(*this, m_mouse.position); -#if !ENABLE_CANVAS_GUI_REFACTORING - int toolbar_contains_mouse = m_toolbar.contains_mouse(m_mouse.position, *this); - int view_toolbar_contains_mouse = m_view_toolbar.contains_mouse(m_mouse.position, *this); -#endif // !ENABLE_CANVAS_GUI_REFACTORING if (m_mouse.drag.move_requires_threshold && m_mouse.is_move_start_threshold_position_2D_defined() && m_mouse.is_move_threshold_met(pos)) { @@ -3447,30 +3407,14 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) { // to remove hover on objects when the mouse goes out of this canvas m_mouse.position = Vec2d(-1.0, -1.0); -#if !ENABLE_CANVAS_GUI_REFACTORING - // ensure m_mouse.left_down is reset (it may happen when switching canvas) - m_mouse.left_down = false; -#endif // !ENABLE_CANVAS_GUI_REFACTORING m_dirty = true; } -#if !ENABLE_CANVAS_GUI_REFACTORING - else if (evt.LeftDClick() && (toolbar_contains_mouse != -1)) - { - m_toolbar_action_running = true; - m_mouse.set_start_position_3D_as_invalid(); - m_toolbar.do_action((unsigned int)toolbar_contains_mouse, *this); - } -#endif // !ENABLE_CANVAS_GUI_REFACTORING else if (evt.LeftDClick() && (m_gizmos.get_current_type() != Gizmos::Undefined)) { m_mouse.ignore_up_event = true; } else if (evt.LeftDown() || evt.RightDown()) { -#if !ENABLE_CANVAS_GUI_REFACTORING - m_mouse.left_down = evt.LeftDown(); -#endif // !ENABLE_CANVAS_GUI_REFACTORING - // If user pressed left or right button we first check whether this happened // on a volume or not. m_layers_editing.state = LayersEditing::Unknown; @@ -3522,17 +3466,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) { // event was taken care of by the SlaSupports gizmo } -#if !ENABLE_CANVAS_GUI_REFACTORING - else if (evt.LeftDown() && (view_toolbar_contains_mouse != -1)) - m_view_toolbar.do_action((unsigned int)view_toolbar_contains_mouse, *this); - else if (evt.LeftDown() && (toolbar_contains_mouse != -1)) - { - m_toolbar_action_running = true; - m_mouse.set_start_position_3D_as_invalid(); - m_toolbar.do_action((unsigned int)toolbar_contains_mouse, *this); - m_mouse.left_down = false; - } -#endif // !ENABLE_CANVAS_GUI_REFACTORING else { // Select volume in this 3D canvas. @@ -3692,11 +3625,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) m_dirty = true; } // do not process dragging if the mouse is into any of the HUD elements -#if ENABLE_CANVAS_GUI_REFACTORING else if (evt.Dragging() && !gizmos_overlay_contains_mouse) -#else - else if (evt.Dragging() && !gizmos_overlay_contains_mouse && (toolbar_contains_mouse == -1) && (view_toolbar_contains_mouse == -1)) -#endif // ENABLE_CANVAS_GUI_REFACTORING { m_mouse.dragging = true; @@ -3706,11 +3635,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) _perform_layer_editing_action(&evt); } // do not process the dragging if the left mouse was set down in another canvas -#if ENABLE_CANVAS_GUI_REFACTORING else if (evt.LeftIsDown()) -#else - else if (m_mouse.left_down && evt.LeftIsDown()) -#endif // ENABLE_CANVAS_GUI_REFACTORING { // if dragging over blank area with left button, rotate if ((m_hover_volume_id == -1) && m_mouse.is_start_position_3D_defined()) @@ -3767,11 +3692,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) // that's why the mouse_event function was called so that the gizmo can refuse the deselection in manual editing mode // deselect and propagate event through callback -#if ENABLE_CANVAS_GUI_REFACTORING if (!evt.ShiftDown() && m_picking_enabled && !m_mouse.ignore_up_event) -#else - if (!evt.ShiftDown() && m_picking_enabled && !m_toolbar_action_running && !m_mouse.ignore_up_event) -#endif // ENABLE_CANVAS_GUI_REFACTORING { m_selection.clear(); m_selection.set_mode(Selection::Instance); @@ -3851,10 +3772,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) m_mouse.set_start_position_3D_as_invalid(); m_mouse.set_start_position_2D_as_invalid(); m_mouse.dragging = false; -#if !ENABLE_CANVAS_GUI_REFACTORING - m_mouse.left_down = false; - m_toolbar_action_running = false; -#endif // !ENABLE_CANVAS_GUI_REFACTORING m_dirty = true; if (m_canvas->HasCapture()) @@ -3870,25 +3787,11 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) if (m_selection.is_empty()) m_gizmos.reset_all_states(); -#if ENABLE_CANVAS_GUI_REFACTORING if (tooltip.empty()) tooltip = m_toolbar.get_tooltip(); if (tooltip.empty()) tooltip = m_view_toolbar.get_tooltip(); -#else - // updates toolbar overlay - if (tooltip.empty()) - tooltip = m_toolbar.update_hover_state(m_mouse.position, *this); - - // updates view toolbar overlay - if (tooltip.empty()) - { - tooltip = m_view_toolbar.update_hover_state(m_mouse.position, *this); - if (!tooltip.empty()) - m_dirty = true; - } -#endif // ENABLE_CANVAS_GUI_REFACTORING set_tooltip(tooltip); @@ -4286,11 +4189,7 @@ bool GLCanvas3D::_init_toolbar() #endif // ENABLE_SVG_ICONS item.tooltip = GUI::L_str("Add...") + " [" + GUI::shortkey_ctrl_prefix() + "I]"; item.sprite_id = 0; -#if ENABLE_CANVAS_GUI_REFACTORING item.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_ADD)); }; -#else - item.action_event = EVT_GLTOOLBAR_ADD; -#endif // ENABLE_CANVAS_GUI_REFACTORING if (!m_toolbar.add_item(item)) return false; @@ -4300,12 +4199,8 @@ bool GLCanvas3D::_init_toolbar() #endif // ENABLE_SVG_ICONS item.tooltip = GUI::L_str("Delete") + " [Del]"; item.sprite_id = 1; -#if ENABLE_CANVAS_GUI_REFACTORING item.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_DELETE)); }; item.enabled_state_callback = []()->bool { return wxGetApp().plater()->can_delete(); }; -#else - item.action_event = EVT_GLTOOLBAR_DELETE; -#endif // ENABLE_CANVAS_GUI_REFACTORING if (!m_toolbar.add_item(item)) return false; @@ -4315,12 +4210,8 @@ bool GLCanvas3D::_init_toolbar() #endif // ENABLE_SVG_ICONS item.tooltip = GUI::L_str("Delete all") + " [" + GUI::shortkey_ctrl_prefix() + "Del]"; item.sprite_id = 2; -#if ENABLE_CANVAS_GUI_REFACTORING item.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_DELETE_ALL)); }; item.enabled_state_callback = []()->bool { return wxGetApp().plater()->can_delete_all(); }; -#else - item.action_event = EVT_GLTOOLBAR_DELETE_ALL; -#endif // ENABLE_CANVAS_GUI_REFACTORING if (!m_toolbar.add_item(item)) return false; @@ -4330,12 +4221,8 @@ bool GLCanvas3D::_init_toolbar() #endif // ENABLE_SVG_ICONS item.tooltip = GUI::L_str("Arrange [A]"); item.sprite_id = 3; -#if ENABLE_CANVAS_GUI_REFACTORING item.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_ARRANGE)); }; item.enabled_state_callback = []()->bool { return wxGetApp().plater()->can_arrange(); }; -#else - item.action_event = EVT_GLTOOLBAR_ARRANGE; -#endif // ENABLE_CANVAS_GUI_REFACTORING if (!m_toolbar.add_item(item)) return false; @@ -4348,13 +4235,9 @@ bool GLCanvas3D::_init_toolbar() #endif // ENABLE_SVG_ICONS item.tooltip = GUI::L_str("Add instance [+]"); item.sprite_id = 4; -#if ENABLE_CANVAS_GUI_REFACTORING item.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_MORE)); }; item.visibility_callback = []()->bool { return wxGetApp().get_mode() != comSimple; }; item.enabled_state_callback = []()->bool { return wxGetApp().plater()->can_increase_instances(); }; -#else - item.action_event = EVT_GLTOOLBAR_MORE; -#endif // ENABLE_CANVAS_GUI_REFACTORING if (!m_toolbar.add_item(item)) return false; @@ -4364,13 +4247,9 @@ bool GLCanvas3D::_init_toolbar() #endif // ENABLE_SVG_ICONS item.tooltip = GUI::L_str("Remove instance [-]"); item.sprite_id = 5; -#if ENABLE_CANVAS_GUI_REFACTORING item.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_FEWER)); }; item.visibility_callback = []()->bool { return wxGetApp().get_mode() != comSimple; }; item.enabled_state_callback = []()->bool { return wxGetApp().plater()->can_decrease_instances(); }; -#else - item.action_event = EVT_GLTOOLBAR_FEWER; -#endif // ENABLE_CANVAS_GUI_REFACTORING if (!m_toolbar.add_item(item)) return false; @@ -4383,13 +4262,9 @@ bool GLCanvas3D::_init_toolbar() #endif // ENABLE_SVG_ICONS item.tooltip = GUI::L_str("Split to objects"); item.sprite_id = 6; -#if ENABLE_CANVAS_GUI_REFACTORING item.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_SPLIT_OBJECTS)); }; item.visibility_callback = GLToolbarItem::Default_Visibility_Callback; item.enabled_state_callback = []()->bool { return wxGetApp().plater()->can_split_to_objects(); }; -#else - item.action_event = EVT_GLTOOLBAR_SPLIT_OBJECTS; -#endif // ENABLE_CANVAS_GUI_REFACTORING if (!m_toolbar.add_item(item)) return false; @@ -4399,13 +4274,9 @@ bool GLCanvas3D::_init_toolbar() #endif // ENABLE_SVG_ICONS item.tooltip = GUI::L_str("Split to parts"); item.sprite_id = 7; -#if ENABLE_CANVAS_GUI_REFACTORING item.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_SPLIT_VOLUMES)); }; item.visibility_callback = []()->bool { return wxGetApp().get_mode() != comSimple; }; item.enabled_state_callback = []()->bool { return wxGetApp().plater()->can_split_to_volumes(); }; -#else - item.action_event = EVT_GLTOOLBAR_SPLIT_VOLUMES; -#endif // ENABLE_CANVAS_GUI_REFACTORING if (!m_toolbar.add_item(item)) return false; @@ -4419,22 +4290,12 @@ bool GLCanvas3D::_init_toolbar() item.tooltip = GUI::L_str("Layers editing"); item.sprite_id = 8; item.is_toggable = true; -#if ENABLE_CANVAS_GUI_REFACTORING item.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_LAYERSEDITING)); }; item.visibility_callback = GLToolbarItem::Default_Visibility_Callback; item.enabled_state_callback = []()->bool { return wxGetApp().plater()->can_layers_editing(); }; -#else - item.action_event = EVT_GLTOOLBAR_LAYERSEDITING; -#endif // ENABLE_CANVAS_GUI_REFACTORING if (!m_toolbar.add_item(item)) return false; -#if !ENABLE_CANVAS_GUI_REFACTORING - enable_toolbar_item("add", true); - - update_toolbar_items_visibility(); -#endif // !ENABLE_CANVAS_GUI_REFACTORING - return true; } @@ -4636,11 +4497,7 @@ void GLCanvas3D::_picking_pass() const { const Vec2d& pos = m_mouse.position; -#if ENABLE_CANVAS_GUI_REFACTORING if (m_picking_enabled && !m_mouse.dragging && (pos != Vec2d(DBL_MAX, DBL_MAX))) -#else - if (m_picking_enabled && !m_mouse.dragging && !m_mouse.left_down && (pos != Vec2d(DBL_MAX, DBL_MAX))) -#endif // ENABLE_CANVAS_GUI_REFACTORING { // Render the object for picking. // FIXME This cannot possibly work in a multi - sampled context as the color gets mangled by the anti - aliasing. diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index aec8a4a17..4cbabc438 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -310,9 +310,6 @@ class GLCanvas3D }; bool dragging; -#if !ENABLE_CANVAS_GUI_REFACTORING - bool left_down; -#endif // !ENABLE_CANVAS_GUI_REFACTORING Vec2d position; Vec3d scene_position; Drag drag; @@ -579,9 +576,6 @@ private: bool m_use_VBOs; bool m_apply_zoom_to_volumes_filter; mutable int m_hover_volume_id; -#if !ENABLE_CANVAS_GUI_REFACTORING - bool m_toolbar_action_running; -#endif // !ENABLE_CANVAS_GUI_REFACTORING bool m_warning_texture_enabled; bool m_legend_texture_enabled; bool m_picking_enabled; @@ -660,11 +654,6 @@ public: void enable_dynamic_background(bool enable); void allow_multisample(bool allow); -#if !ENABLE_CANVAS_GUI_REFACTORING - void enable_toolbar_item(const std::string& name, bool enable); - bool is_toolbar_item_pressed(const std::string& name) const; -#endif // !ENABLE_CANVAS_GUI_REFACTORING - void zoom_to_bed(); void zoom_to_volumes(); void zoom_to_selection(); @@ -672,10 +661,6 @@ public: void update_volumes_colors_by_extruder(); -#if !ENABLE_CANVAS_GUI_REFACTORING - void update_toolbar_items_visibility(); -#endif // !ENABLE_CANVAS_GUI_REFACTORING - bool is_dragging() const { return m_gizmos.is_dragging() || m_moving; } void render(); 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 diff --git a/src/slic3r/GUI/GLToolbar.hpp b/src/slic3r/GUI/GLToolbar.hpp index cd5d3f83f..07d1fcb92 100644 --- a/src/slic3r/GUI/GLToolbar.hpp +++ b/src/slic3r/GUI/GLToolbar.hpp @@ -31,11 +31,9 @@ wxDECLARE_EVENT(EVT_GLVIEWTOOLBAR_PREVIEW, SimpleEvent); class GLToolbarItem { public: -#if ENABLE_CANVAS_GUI_REFACTORING typedef std::function<void()> ActionCallback; typedef std::function<bool()> VisibilityCallback; typedef std::function<bool()> EnabledStateCallback; -#endif // ENABLE_CANVAS_GUI_REFACTORING enum EType : unsigned char { @@ -63,24 +61,17 @@ public: std::string tooltip; unsigned int sprite_id; bool is_toggable; -#if !ENABLE_CANVAS_GUI_REFACTORING - wxEventType action_event; -#endif // !ENABLE_CANVAS_GUI_REFACTORING bool visible; -#if ENABLE_CANVAS_GUI_REFACTORING ActionCallback action_callback; VisibilityCallback visibility_callback; EnabledStateCallback enabled_state_callback; -#endif // ENABLE_CANVAS_GUI_REFACTORING Data(); }; -#if ENABLE_CANVAS_GUI_REFACTORING static const ActionCallback Default_Action_Callback; static const VisibilityCallback Default_Visibility_Callback; static const EnabledStateCallback Default_Enabled_State_Callback; -#endif // ENABLE_CANVAS_GUI_REFACTORING private: EType m_type; @@ -99,11 +90,7 @@ public: #endif // ENABLE_SVG_ICONS const std::string& get_tooltip() const { return m_data.tooltip; } -#if ENABLE_CANVAS_GUI_REFACTORING void do_action() { m_data.action_callback(); } -#else - void do_action(wxEvtHandler *target); -#endif // ENABLE_CANVAS_GUI_REFACTORING bool is_enabled() const { return m_state != Disabled; } bool is_disabled() const { return m_state == Disabled; } @@ -112,27 +99,20 @@ public: bool is_toggable() const { return m_data.is_toggable; } bool is_visible() const { return m_data.visible; } -#if !ENABLE_CANVAS_GUI_REFACTORING - void set_visible(bool visible) { m_data.visible = visible; } -#endif // !ENABLE_CANVAS_GUI_REFACTORING bool is_separator() const { return m_type == Separator; } -#if ENABLE_CANVAS_GUI_REFACTORING // returns true if the state changes bool update_visibility(); // returns true if the state changes bool update_enabled_state(); -#endif // ENABLE_CANVAS_GUI_REFACTORING void 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; private: GLTexture::Quad_UVs get_uvs(unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const; -#if ENABLE_CANVAS_GUI_REFACTORING void set_visible(bool visible) { m_data.visible = visible; } friend class GLToolbar; -#endif // ENABLE_CANVAS_GUI_REFACTORING }; #if !ENABLE_SVG_ICONS @@ -250,7 +230,7 @@ private: mutable Layout m_layout; ItemsList m_items; -#if ENABLE_CANVAS_GUI_REFACTORING + struct MouseCapture { bool left; @@ -262,7 +242,6 @@ private: MouseCapture m_mouse_capture; std::string m_tooltip; -#endif // ENABLE_CANVAS_GUI_REFACTORING public: #if ENABLE_SVG_ICONS @@ -303,42 +282,21 @@ public: float get_width() const; float get_height() const; -#if !ENABLE_CANVAS_GUI_REFACTORING - void enable_item(const std::string& name); - void disable_item(const std::string& name); -#endif // !ENABLE_CANVAS_GUI_REFACTORING void select_item(const std::string& name); bool is_item_pressed(const std::string& name) const; bool is_item_disabled(const std::string& name) const; bool is_item_visible(const std::string& name) const; -#if ENABLE_CANVAS_GUI_REFACTORING const std::string& get_tooltip() const { return m_tooltip; } -#endif // ENABLE_CANVAS_GUI_REFACTORING -#if ENABLE_CANVAS_GUI_REFACTORING // returns true if any item changed its state bool update_items_state(); -#else - void set_item_visible(const std::string& name, bool visible); -#endif // ENABLE_CANVAS_GUI_REFACTORING - -#if !ENABLE_CANVAS_GUI_REFACTORING - std::string update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent); - - // returns the id of the item under the given mouse position or -1 if none - int contains_mouse(const Vec2d& mouse_pos, const GLCanvas3D& parent) const; - - void do_action(unsigned int item_id, GLCanvas3D& parent); -#endif // !ENABLE_CANVAS_GUI_REFACTORING void render(const GLCanvas3D& parent) const; -#if ENABLE_CANVAS_GUI_REFACTORING bool on_mouse(wxMouseEvent& evt, GLCanvas3D& parent); -#endif // ENABLE_CANVAS_GUI_REFACTORING private: void calc_layout() const; @@ -347,16 +305,12 @@ private: float get_height_horizontal() const; float get_height_vertical() const; float get_main_size() const; -#if ENABLE_CANVAS_GUI_REFACTORING void do_action(unsigned int item_id, GLCanvas3D& parent); std::string update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent); -#endif // ENABLE_CANVAS_GUI_REFACTORING std::string update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D& parent); std::string update_hover_state_vertical(const Vec2d& mouse_pos, GLCanvas3D& parent); -#if ENABLE_CANVAS_GUI_REFACTORING // returns the id of the item under the given mouse position or -1 if none int contains_mouse(const Vec2d& mouse_pos, const GLCanvas3D& parent) const; -#endif // ENABLE_CANVAS_GUI_REFACTORING int contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3D& parent) const; int contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D& parent) const; @@ -367,12 +321,10 @@ private: bool generate_icons_texture() const; #endif // ENABLE_SVG_ICONS -#if ENABLE_CANVAS_GUI_REFACTORING // returns true if any item changed its state bool update_items_visibility(); // returns true if any item changed its state bool update_items_enabled_state(); -#endif // ENABLE_CANVAS_GUI_REFACTORING }; } // namespace GUI diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index b76628b8d..be3fad9ec 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -110,20 +110,6 @@ void View3D::mirror_selection(Axis axis) m_canvas->mirror_selection(axis); } -#if !ENABLE_CANVAS_GUI_REFACTORING -void View3D::update_toolbar_items_visibility() -{ - if (m_canvas != nullptr) - m_canvas->update_toolbar_items_visibility(); -} - -void View3D::enable_toolbar_item(const std::string& name, bool enable) -{ - if (m_canvas != nullptr) - m_canvas->enable_toolbar_item(name, enable); -} -#endif // !ENABLE_CANVAS_GUI_REFACTORING - int View3D::check_volumes_outside_state() const { return (m_canvas != nullptr) ? m_canvas->check_volumes_outside_state() : false; diff --git a/src/slic3r/GUI/GUI_Preview.hpp b/src/slic3r/GUI/GUI_Preview.hpp index 5a244abb7..182eaa952 100644 --- a/src/slic3r/GUI/GUI_Preview.hpp +++ b/src/slic3r/GUI/GUI_Preview.hpp @@ -50,10 +50,6 @@ public: void delete_selected(); void mirror_selection(Axis axis); -#if !ENABLE_CANVAS_GUI_REFACTORING - void update_toolbar_items_visibility(); - void enable_toolbar_item(const std::string& name, bool enable); -#endif // !ENABLE_CANVAS_GUI_REFACTORING int check_volumes_outside_state() const; bool is_layers_editing_enabled() const; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 630586bb5..f6efb1d91 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1227,7 +1227,6 @@ struct Plater::priv // Sets m_bed.m_polygon to limit the object placement. void set_bed_shape(const Pointfs& shape); -#if ENABLE_CANVAS_GUI_REFACTORING bool can_delete() const; bool can_delete_all() const; bool can_increase_instances() const; @@ -1236,7 +1235,6 @@ struct Plater::priv bool can_split_to_volumes() const; bool can_arrange() const; bool can_layers_editing() const; -#endif // ENABLE_CANVAS_GUI_REFACTORING private: bool init_object_menu(); @@ -1246,22 +1244,9 @@ private: bool complit_init_part_menu(); void init_view_toolbar(); -#if !ENABLE_CANVAS_GUI_REFACTORING - bool can_delete_object() const; - bool can_increase_instances() const; - bool can_decrease_instances() const; -#endif // !ENABLE_CANVAS_GUI_REFACTORING bool can_set_instance_to_object() const; -#if !ENABLE_CANVAS_GUI_REFACTORING - bool can_split_to_objects() const; - bool can_split_to_volumes() const; -#endif // !ENABLE_CANVAS_GUI_REFACTORING bool can_split() const; bool layers_height_allowed() const; -#if !ENABLE_CANVAS_GUI_REFACTORING - bool can_delete_all() const; - bool can_arrange() const; -#endif // !ENABLE_CANVAS_GUI_REFACTORING bool can_mirror() const; void update_fff_scene(); @@ -1821,14 +1806,6 @@ int Plater::priv::get_selected_volume_idx() const void Plater::priv::selection_changed() { -#if !ENABLE_CANVAS_GUI_REFACTORING - view3D->enable_toolbar_item("delete", can_delete_object()); - view3D->enable_toolbar_item("more", can_increase_instances()); - view3D->enable_toolbar_item("fewer", can_decrease_instances()); - view3D->enable_toolbar_item("splitobjects", can_split()); - view3D->enable_toolbar_item("splitvolumes", printer_technology == ptFFF && can_split()); -#endif // !ENABLE_CANVAS_GUI_REFACTORING - // if the selection is not valid to allow for layer editing, we need to turn off the tool if it is running bool enable_layer_editing = layers_height_allowed(); if (!enable_layer_editing && view3D->is_layers_editing_enabled()) { @@ -1836,22 +1813,12 @@ void Plater::priv::selection_changed() on_action_layersediting(evt); } -#if !ENABLE_CANVAS_GUI_REFACTORING - view3D->enable_toolbar_item("layersediting", enable_layer_editing); -#endif // !ENABLE_CANVAS_GUI_REFACTORING - // forces a frame render to update the view (to avoid a missed update if, for example, the context menu appears) view3D->render(); } void Plater::priv::object_list_changed() { -#if !ENABLE_CANVAS_GUI_REFACTORING - // Enable/disable buttons depending on whether there are any objects on the platter. - view3D->enable_toolbar_item("deleteall", can_delete_all()); - view3D->enable_toolbar_item("arrange", can_arrange()); -#endif // !ENABLE_CANVAS_GUI_REFACTORING - const bool export_in_progress = this->background_process.is_export_scheduled(); // || ! send_gcode_file.empty()); // XXX: is this right? const bool model_fits = view3D->check_volumes_outside_state() == ModelInstance::PVS_Inside; @@ -1930,11 +1897,6 @@ void Plater::priv::arrange() wxBusyCursor wait; -#if !ENABLE_CANVAS_GUI_REFACTORING - // Disable the arrange button (to prevent reentrancies, we will call wxYied) - view3D->enable_toolbar_item("arrange", can_arrange()); -#endif // !ENABLE_CANVAS_GUI_REFACTORING - this->background_process.stop(); unsigned count = 0; for(auto obj : model.objects) count += obj->instances.size(); @@ -2005,11 +1967,6 @@ void Plater::priv::arrange() statusbar()->set_cancel_callback(); // remove cancel button arranging.store(false); -#if !ENABLE_CANVAS_GUI_REFACTORING - // We enable back the arrange button - view3D->enable_toolbar_item("arrange", can_arrange()); -#endif // !ENABLE_CANVAS_GUI_REFACTORING - // Do a full refresh of scene tree, including regenerating all the GLVolumes. //FIXME The update function shall just reload the modified matrices. update(true); @@ -2570,12 +2527,6 @@ void Plater::priv::on_process_completed(wxCommandEvent &evt) void Plater::priv::on_layer_editing_toggled(bool enable) { view3D->enable_layers_editing(enable); -#if !ENABLE_CANVAS_GUI_REFACTORING - if (enable && !view3D->is_layers_editing_enabled()) { - // Initialization of the OpenGL shaders failed. Disable the tool. - view3D->enable_toolbar_item("layersediting", false); - } -#endif // !ENABLE_CANVAS_GUI_REFACTORING view3D->set_as_dirty(); } @@ -2597,14 +2548,7 @@ void Plater::priv::on_action_split_volumes(SimpleEvent&) void Plater::priv::on_action_layersediting(SimpleEvent&) { -#if ENABLE_CANVAS_GUI_REFACTORING view3D->enable_layers_editing(!view3D->is_layers_editing_enabled()); -#else - bool enable = !view3D->is_layers_editing_enabled(); - view3D->enable_layers_editing(enable); - if (enable && !view3D->is_layers_editing_enabled()) - view3D->enable_toolbar_item("layersediting", false); -#endif // ENABLE_CANVAS_GUI_REFACTORING } void Plater::priv::on_object_select(SimpleEvent& evt) @@ -2764,11 +2708,7 @@ bool Plater::priv::init_common_menu(wxMenu* menu, const bool is_part/* = false*/ if (q != nullptr) { q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_mirror()); }, item_mirror->GetId()); -#if ENABLE_CANVAS_GUI_REFACTORING q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_delete()); }, item_delete->GetId()); -#else - q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_delete_object()); }, item_delete->GetId()); -#endif // ENABLE_CANVAS_GUI_REFACTORING } return true; @@ -2873,11 +2813,7 @@ void Plater::priv::init_view_toolbar() #endif // ENABLE_SVG_ICONS item.tooltip = GUI::L_str("3D editor view") + " [" + GUI::shortkey_ctrl_prefix() + "5]"; item.sprite_id = 0; -#if ENABLE_CANVAS_GUI_REFACTORING item.action_callback = [this]() { if (this->q != nullptr) wxPostEvent(this->q, SimpleEvent(EVT_GLVIEWTOOLBAR_3D)); }; -#else - item.action_event = EVT_GLVIEWTOOLBAR_3D; -#endif // ENABLE_CANVAS_GUI_REFACTORING item.is_toggable = false; if (!view_toolbar.add_item(item)) return; @@ -2888,67 +2824,21 @@ void Plater::priv::init_view_toolbar() #endif // ENABLE_SVG_ICONS item.tooltip = GUI::L_str("Preview") + " [" + GUI::shortkey_ctrl_prefix() + "6]"; item.sprite_id = 1; -#if ENABLE_CANVAS_GUI_REFACTORING item.action_callback = [this]() { if (this->q != nullptr) wxPostEvent(this->q, SimpleEvent(EVT_GLVIEWTOOLBAR_PREVIEW)); }; -#else - item.action_event = EVT_GLVIEWTOOLBAR_PREVIEW; -#endif // ENABLE_CANVAS_GUI_REFACTORING item.is_toggable = false; if (!view_toolbar.add_item(item)) return; -#if !ENABLE_CANVAS_GUI_REFACTORING - view_toolbar.enable_item("3D"); - view_toolbar.enable_item("Preview"); -#endif // !ENABLE_CANVAS_GUI_REFACTORING - view_toolbar.select_item("3D"); view_toolbar.set_enabled(true); } -#if !ENABLE_CANVAS_GUI_REFACTORING -bool Plater::priv::can_delete_object() const -{ - int obj_idx = get_selected_object_idx(); - return (0 <= obj_idx) && (obj_idx < (int)model.objects.size()); -} - -bool Plater::priv::can_increase_instances() const -{ - int obj_idx = get_selected_object_idx(); - return (0 <= obj_idx) && (obj_idx < (int)model.objects.size()); -} -#endif // !ENABLE_CANVAS_GUI_REFACTORING - bool Plater::priv::can_set_instance_to_object() const { const int obj_idx = get_selected_object_idx(); return (0 <= obj_idx) && (obj_idx < (int)model.objects.size()) && (model.objects[obj_idx]->instances.size() > 1); } -#if !ENABLE_CANVAS_GUI_REFACTORING -bool Plater::priv::can_decrease_instances() const -{ - int obj_idx = get_selected_object_idx(); - return (0 <= obj_idx) && (obj_idx < (int)model.objects.size()) && (model.objects[obj_idx]->instances.size() > 1); -} - -bool Plater::priv::can_split_to_objects() const -{ - int obj_idx = get_selected_object_idx(); - return (0 <= obj_idx) && (obj_idx < (int)model.objects.size()) && !model.objects[obj_idx]->is_multiparts(); -} - -bool Plater::priv::can_split_to_volumes() const -{ - if (printer_technology == ptSLA) - return false; -// int obj_idx = get_selected_object_idx(); -// return (0 <= obj_idx) && (obj_idx < (int)model.objects.size()) && !model.objects[obj_idx]->is_multiparts(); - return sidebar->obj_list()->is_splittable(); -} -#endif // !ENABLE_CANVAS_GUI_REFACTORING - bool Plater::priv::can_split() const { return sidebar->obj_list()->is_splittable(); @@ -2960,18 +2850,6 @@ bool Plater::priv::layers_height_allowed() const return (0 <= obj_idx) && (obj_idx < (int)model.objects.size()) && config->opt_bool("variable_layer_height") && view3D->is_layers_editing_allowed(); } -#if !ENABLE_CANVAS_GUI_REFACTORING -bool Plater::priv::can_delete_all() const -{ - return !model.objects.empty(); -} - -bool Plater::priv::can_arrange() const -{ - return !model.objects.empty() && !arranging.load(); -} -#endif // !ENABLE_CANVAS_GUI_REFACTORING - bool Plater::priv::can_mirror() const { return get_selection().is_from_single_instance(); @@ -2987,7 +2865,6 @@ void Plater::priv::set_bed_shape(const Pointfs& shape) } } -#if ENABLE_CANVAS_GUI_REFACTORING bool Plater::priv::can_delete() const { return !get_selection().is_empty(); @@ -3029,15 +2906,10 @@ bool Plater::priv::can_layers_editing() const { return layers_height_allowed(); } -#endif // ENABLE_CANVAS_GUI_REFACTORING void Plater::priv::update_object_menu() { sidebar->obj_list()->append_menu_items_add_volume(&object_menu); -#if !ENABLE_CANVAS_GUI_REFACTORING - if (view3D != nullptr) - view3D->update_toolbar_items_visibility(); -#endif // !ENABLE_CANVAS_GUI_REFACTORING } void Plater::priv::show_action_buttons(const bool is_ready_to_slice) const @@ -3520,17 +3392,9 @@ void Plater::on_config_change(const DynamicPrintConfig &config) } else if(opt_key == "variable_layer_height") { if (p->config->opt_bool("variable_layer_height") != true) { -#if !ENABLE_CANVAS_GUI_REFACTORING - p->view3D->enable_toolbar_item("layersediting", false); -#endif // !ENABLE_CANVAS_GUI_REFACTORING p->view3D->enable_layers_editing(false); p->view3D->set_as_dirty(); } -#if !ENABLE_CANVAS_GUI_REFACTORING - else if (p->view3D->is_layers_editing_allowed()) { - p->view3D->enable_toolbar_item("layersediting", true); - } -#endif // !ENABLE_CANVAS_GUI_REFACTORING } else if(opt_key == "extruder_colour") { update_scheduled = true; @@ -3652,7 +3516,6 @@ void Plater::fix_through_netfabb(const int obj_idx, const int vol_idx/* = -1*/) void Plater::update_object_menu() { p->update_object_menu(); } -#if ENABLE_CANVAS_GUI_REFACTORING bool Plater::can_delete() const { return p->can_delete(); } bool Plater::can_delete_all() const { return p->can_delete_all(); } bool Plater::can_increase_instances() const { return p->can_increase_instances(); } @@ -3661,6 +3524,5 @@ bool Plater::can_split_to_objects() const { return p->can_split_to_objects(); } bool Plater::can_split_to_volumes() const { return p->can_split_to_volumes(); } bool Plater::can_arrange() const { return p->can_arrange(); } bool Plater::can_layers_editing() const { return p->can_layers_editing(); } -#endif // ENABLE_CANVAS_GUI_REFACTORING }} // namespace Slic3r::GUI diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 8746c1eef..dc5a50cf1 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -176,7 +176,6 @@ public: PrinterTechnology printer_technology() const; void set_printer_technology(PrinterTechnology printer_technology); -#if ENABLE_CANVAS_GUI_REFACTORING bool can_delete() const; bool can_delete_all() const; bool can_increase_instances() const; @@ -185,7 +184,6 @@ public: bool can_split_to_volumes() const; bool can_arrange() const; bool can_layers_editing() const; -#endif // ENABLE_CANVAS_GUI_REFACTORING private: struct priv; |