From 9487676680d7243b8520408e0989b7b0bc3e6bb8 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Fri, 15 May 2020 13:40:45 +0200 Subject: [PATCH] ENABLE_CANVAS_TOOLTIP_USING_IMGUI set as default --- src/libslic3r/Technologies.hpp | 9 -- src/slic3r/GUI/GLCanvas3D.cpp | 73 ----------- src/slic3r/GUI/GLCanvas3D.hpp | 8 -- src/slic3r/GUI/GLToolbar.cpp | 144 ---------------------- src/slic3r/GUI/GLToolbar.hpp | 21 ---- src/slic3r/GUI/Gizmos/GLGizmosManager.cpp | 58 --------- 6 files changed, 313 deletions(-) diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 7b1c2bd38..f9a2328fa 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -34,15 +34,6 @@ #define ENABLE_HACK_CLOSING_ON_OSX_10_9_5 (1 && ENABLE_2_2_0_RC1) -//================== -// 2.2.0.final techs -//================== -#define ENABLE_2_2_0_FINAL 1 - -// Enable tooltips for GLCanvas3D using ImGUI -#define ENABLE_CANVAS_TOOLTIP_USING_IMGUI (1 && ENABLE_2_2_0_FINAL) - - //=================== // 2.3.0.alpha1 techs //=================== diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 1bdc95342..ae9e4f929 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -61,11 +61,6 @@ #include #include #include "DoubleSlider.hpp" -#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI -#if ENABLE_RENDER_STATISTICS -#include -#endif // ENABLE_RENDER_STATISTICS -#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI #include @@ -1377,7 +1372,6 @@ void GLCanvas3D::Labels::render(const std::vector& sorted_ } } -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI void GLCanvas3D::Tooltip::set_text(const std::string& text) { // If the mouse is inside an ImGUI dialog, then the tooltip is suppressed. @@ -1429,7 +1423,6 @@ void GLCanvas3D::Tooltip::render(const Vec2d& mouse_position, GLCanvas3D& canvas imgui.end(); ImGui::PopStyleVar(2); } -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI #if ENABLE_SLOPE_RENDERING void GLCanvas3D::Slope::render() const @@ -2093,7 +2086,6 @@ void GLCanvas3D::render() m_camera.debug_render(); #endif // ENABLE_CAMERA_STATISTICS -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI std::string tooltip; // Negative coordinate means out of the window, likely because the window was deactivated. @@ -2123,7 +2115,6 @@ void GLCanvas3D::render() if (m_tooltip_enabled) m_tooltip.render(m_mouse.position, *this); -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI wxGetApp().plater()->get_mouse3d_controller().render_settings_dialog(*this); @@ -2135,30 +2126,6 @@ void GLCanvas3D::render() auto end_time = std::chrono::high_resolution_clock::now(); m_render_stats.last_frame = std::chrono::duration_cast(end_time - start_time).count(); #endif // ENABLE_RENDER_STATISTICS - -#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI - std::string tooltip = ""; - - if (tooltip.empty()) - tooltip = m_layers_editing.get_tooltip(*this); - - if (tooltip.empty()) - tooltip = m_gizmos.get_tooltip(); - - if (tooltip.empty()) - tooltip = m_main_toolbar.get_tooltip(); - - if (tooltip.empty()) - tooltip = m_undoredo_toolbar.get_tooltip(); - - if (tooltip.empty()) - tooltip = m_collapse_toolbar.get_tooltip(); - - if (tooltip.empty()) - tooltip = m_view_toolbar.get_tooltip(); - - set_tooltip(tooltip); -#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI } void GLCanvas3D::render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, bool printable_only, bool parts_only, bool show_bed, bool transparent_background) const @@ -2828,9 +2795,7 @@ void GLCanvas3D::bind_event_handlers() m_canvas->Bind(wxEVT_MIDDLE_DCLICK, &GLCanvas3D::on_mouse, this); m_canvas->Bind(wxEVT_RIGHT_DCLICK, &GLCanvas3D::on_mouse, this); m_canvas->Bind(wxEVT_PAINT, &GLCanvas3D::on_paint, this); -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI m_canvas->Bind(wxEVT_SET_FOCUS, &GLCanvas3D::on_set_focus, this); -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI } } @@ -2858,9 +2823,7 @@ void GLCanvas3D::unbind_event_handlers() m_canvas->Unbind(wxEVT_MIDDLE_DCLICK, &GLCanvas3D::on_mouse, this); m_canvas->Unbind(wxEVT_RIGHT_DCLICK, &GLCanvas3D::on_mouse, this); m_canvas->Unbind(wxEVT_PAINT, &GLCanvas3D::on_paint, this); -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI m_canvas->Unbind(wxEVT_SET_FOCUS, &GLCanvas3D::on_set_focus, this); -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI } } @@ -3445,29 +3408,20 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) Point pos(evt.GetX(), evt.GetY()); ImGuiWrapper* imgui = wxGetApp().imgui(); -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI if (m_tooltip.is_in_imgui() && evt.LeftUp()) // ignore left up events coming from imgui windows and not processed by them m_mouse.ignore_left_up = true; m_tooltip.set_in_imgui(false); -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI if (imgui->update_mouse_data(evt)) { m_mouse.position = evt.Leaving() ? Vec2d(-1.0, -1.0) : pos.cast(); -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI m_tooltip.set_in_imgui(true); -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI render(); #ifdef SLIC3R_DEBUG_MOUSE_EVENTS printf((format_mouse_event_debug_message(evt) + " - Consumed by ImGUI\n").c_str()); #endif /* SLIC3R_DEBUG_MOUSE_EVENTS */ // do not return if dragging or tooltip not empty to allow for tooltip update -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI if (!m_mouse.dragging && m_tooltip.is_empty()) return; -#else - if (!m_mouse.dragging && m_canvas->GetToolTipText().empty()) - return; -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI } #ifdef __WXMSW__ @@ -3526,9 +3480,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) mouse_up_cleanup(); m_mouse.set_start_position_3D_as_invalid(); -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI m_mouse.position = pos.cast(); -#endif /// ENABLE_CANVAS_TOOLTIP_USING_IMGUI return; } @@ -3560,18 +3512,14 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) if (top_level_wnd && top_level_wnd->IsActive()) m_canvas->SetFocus(); m_mouse.position = pos.cast(); -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI m_tooltip_enabled = false; -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI // 1) forces a frame render to ensure that m_hover_volume_idxs is updated even when the user right clicks while // the context menu is shown, ensuring it to disappear if the mouse is outside any volume and to // change the volume hover state if any is under the mouse // 2) when switching between 3d view and preview the size of the canvas changes if the side panels are visible, // so forces a resize to avoid multiple renders with different sizes (seen as flickering) _refresh_if_shown_on_screen(); -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI m_tooltip_enabled = true; -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI } m_mouse.set_start_position_2D_as_invalid(); //#endif @@ -3885,14 +3833,12 @@ void GLCanvas3D::on_paint(wxPaintEvent& evt) this->render(); } -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI void GLCanvas3D::on_set_focus(wxFocusEvent& evt) { m_tooltip_enabled = false; _refresh_if_shown_on_screen(); m_tooltip_enabled = true; } -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI Size GLCanvas3D::get_canvas_size() const { @@ -3940,26 +3886,7 @@ void GLCanvas3D::reset_legend_texture() void GLCanvas3D::set_tooltip(const std::string& tooltip) const { if (m_canvas != nullptr) - { -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI m_tooltip.set_text(tooltip); -#else - wxString txt = wxString::FromUTF8(tooltip.data()); - if (m_canvas->GetToolTipText() != txt) - m_canvas->SetToolTip(txt); - -// wxToolTip* t = m_canvas->GetToolTip(); -// if (t != nullptr) -// { -// if (tooltip.empty()) -// m_canvas->UnsetToolTip(); -// else -// t->SetTip(wxString::FromUTF8(tooltip.data())); -// } -// else if (!tooltip.empty()) // Avoid "empty" tooltips => unset of the empty tooltip leads to application crash under OSX -// m_canvas->SetToolTip(wxString::FromUTF8(tooltip.data())); -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI - } } void GLCanvas3D::do_move(const std::string& snapshot_type) diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index c6875165f..0317eb0b3 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -3,9 +3,7 @@ #include #include -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI #include -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI #include "3DScene.hpp" #include "GLToolbar.hpp" @@ -387,7 +385,6 @@ private: void render(const std::vector& sorted_instances) const; }; -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI class Tooltip { std::string m_text; @@ -403,7 +400,6 @@ private: void set_in_imgui(bool b) { m_in_imgui = b; } bool is_in_imgui() const { return m_in_imgui; } }; -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI #if ENABLE_SLOPE_RENDERING class Slope @@ -506,10 +502,8 @@ private: int m_selected_extruder; Labels m_labels; -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI mutable Tooltip m_tooltip; mutable bool m_tooltip_enabled{ true }; -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI #if ENABLE_SLOPE_RENDERING Slope m_slope; #endif // ENABLE_SLOPE_RENDERING @@ -641,9 +635,7 @@ public: void on_timer(wxTimerEvent& evt); void on_mouse(wxMouseEvent& evt); void on_paint(wxPaintEvent& evt); -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI void on_set_focus(wxFocusEvent& evt); -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI Size get_canvas_size() const; Vec2d get_local_mouse_position() const; diff --git a/src/slic3r/GUI/GLToolbar.cpp b/src/slic3r/GUI/GLToolbar.cpp index c69327cfa..603cfc3ad 100644 --- a/src/slic3r/GUI/GLToolbar.cpp +++ b/src/slic3r/GUI/GLToolbar.cpp @@ -153,9 +153,6 @@ GLToolbar::GLToolbar(GLToolbar::EType type, const std::string& name) , m_name(name) , m_enabled(false) , m_icons_texture_dirty(true) -#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI - , m_tooltip("") -#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI , m_pressed_toggable_id(-1) { } @@ -359,7 +356,6 @@ int GLToolbar::get_item_id(const std::string& name) const return -1; } -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI std::string GLToolbar::get_tooltip() const { std::string tooltip; @@ -382,7 +378,6 @@ std::string GLToolbar::get_tooltip() const return tooltip; } -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI void GLToolbar::get_additional_tooltip(int item_id, std::string& text) { @@ -449,17 +444,11 @@ bool GLToolbar::on_mouse(wxMouseEvent& evt, GLCanvas3D& parent) // prevents loosing selection into the scene if mouse down was done inside the toolbar and mouse up was down outside it, // as when switching between views m_mouse_capture.reset(); -#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI - if (contains_mouse(mouse_pos, parent) == -1) - // mouse is outside the toolbar - m_tooltip.clear(); -#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI return true; } m_mouse_capture.reset(); } -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI if (evt.Moving()) update_hover_state(mouse_pos, parent); else if (evt.LeftUp()) @@ -500,31 +489,9 @@ bool GLToolbar::on_mouse(wxMouseEvent& evt, GLCanvas3D& parent) else return false; } -#else - if (evt.Moving()) - m_tooltip = update_hover_state(mouse_pos, parent); - else if (evt.LeftUp()) - m_mouse_capture.left = false; - else if (evt.MiddleUp()) - m_mouse_capture.middle = false; - else if (evt.RightUp()) - m_mouse_capture.right = false; - else if (evt.Dragging() && m_mouse_capture.any()) - // if the button down was done on this toolbar, prevent from dragging into the scene - processed = true; -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI int item_id = contains_mouse(mouse_pos, parent); -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI if (item_id != -1) -#else - if (item_id == -1) - { - // mouse is outside the toolbar - m_tooltip.clear(); - } - else -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI { // mouse inside toolbar if (evt.LeftDown() || evt.LeftDClick()) @@ -532,12 +499,8 @@ bool GLToolbar::on_mouse(wxMouseEvent& evt, GLCanvas3D& parent) m_mouse_capture.left = true; m_mouse_capture.parent = &parent; processed = true; -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI if ((item_id != -2) && !m_items[item_id]->is_separator() && !m_items[item_id]->is_disabled() && ((m_pressed_toggable_id == -1) || (m_items[item_id]->get_last_action_type() == GLToolbarItem::Left))) -#else - if ((item_id != -2) && !m_items[item_id]->is_separator() && ((m_pressed_toggable_id == -1) || (m_items[item_id]->get_last_action_type() == GLToolbarItem::Left))) -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI { // mouse is inside an icon do_action(GLToolbarItem::Left, item_id, parent, true); @@ -554,22 +517,14 @@ bool GLToolbar::on_mouse(wxMouseEvent& evt, GLCanvas3D& parent) m_mouse_capture.right = true; m_mouse_capture.parent = &parent; processed = true; -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI if ((item_id != -2) && !m_items[item_id]->is_separator() && !m_items[item_id]->is_disabled() && ((m_pressed_toggable_id == -1) || (m_items[item_id]->get_last_action_type() == GLToolbarItem::Right))) -#else - if ((item_id != -2) && !m_items[item_id]->is_separator() && ((m_pressed_toggable_id == -1) || (m_items[item_id]->get_last_action_type() == GLToolbarItem::Right))) -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI { // mouse is inside an icon do_action(GLToolbarItem::Right, item_id, parent, true); parent.set_as_dirty(); } } -#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI - else if (evt.LeftUp()) - processed = true; -#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI } return processed; @@ -654,11 +609,7 @@ void GLToolbar::do_action(GLToolbarItem::EActionType type, int item_id, GLCanvas if ((0 <= item_id) && (item_id < (int)m_items.size())) { GLToolbarItem* item = m_items[item_id]; -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI if ((item != nullptr) && !item->is_separator() && !item->is_disabled() && (!check_hover || item->is_hovered())) -#else - if ((item != nullptr) && !item->is_separator() && (!check_hover || item->is_hovered())) -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI { if (((type == GLToolbarItem::Right) && item->is_right_toggable()) || ((type == GLToolbarItem::Left) && item->is_left_toggable())) @@ -712,7 +663,6 @@ void GLToolbar::do_action(GLToolbarItem::EActionType type, int item_id, GLCanvas } } -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI void GLToolbar::update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent) { if (!m_enabled) @@ -725,26 +675,8 @@ void GLToolbar::update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent) case Layout::Vertical: { update_hover_state_vertical(mouse_pos, parent); break; } } } -#else -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); } - } -} -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI - -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI void GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D& parent) -#else -std::string GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D& parent) -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI { // NB: mouse_pos is already scaled appropriately @@ -765,10 +697,6 @@ std::string GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLC float left = m_layout.left + scaled_border; float top = m_layout.top - scaled_border; -#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI - std::string tooltip; -#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI - for (GLToolbarItem* item : m_items) { if (!item->is_visible()) @@ -783,18 +711,6 @@ std::string GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLC GLToolbarItem::EState state = item->get_state(); bool inside = (left <= (float)scaled_mouse_pos(0)) && ((float)scaled_mouse_pos(0) <= right) && (bottom <= (float)scaled_mouse_pos(1)) && ((float)scaled_mouse_pos(1) <= top); -#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI - if (inside) - { - tooltip = item->get_tooltip(); - if (!item->is_pressed()) - { - const std::string& additional_tooltip = item->get_additional_tooltip(); - if (!additional_tooltip.empty()) - tooltip += "\n" + additional_tooltip; - } - } -#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI switch (state) { @@ -838,7 +754,6 @@ std::string GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLC break; } -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI case GLToolbarItem::Disabled: { if (inside) @@ -863,29 +778,14 @@ std::string GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLC { break; } -#else - default: - case GLToolbarItem::Disabled: - { - break; - } -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI } left += icon_stride; } } - -#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI - return tooltip; -#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI } -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI void GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCanvas3D& parent) -#else -std::string GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCanvas3D& parent) -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI { // NB: mouse_pos is already scaled appropriately @@ -905,10 +805,6 @@ std::string GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCan float left = m_layout.left + scaled_border; float top = m_layout.top - scaled_border; -#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI - std::string tooltip; -#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI - for (GLToolbarItem* item : m_items) { if (!item->is_visible()) @@ -923,18 +819,6 @@ std::string GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCan GLToolbarItem::EState state = item->get_state(); bool inside = (left <= (float)scaled_mouse_pos(0)) && ((float)scaled_mouse_pos(0) <= right) && (bottom <= (float)scaled_mouse_pos(1)) && ((float)scaled_mouse_pos(1) <= top); -#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI - if (inside) - { - tooltip = item->get_tooltip(); - if (!item->is_pressed()) - { - const std::string& additional_tooltip = item->get_additional_tooltip(); - if (!additional_tooltip.empty()) - tooltip += "\n" + additional_tooltip; - } - } -#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI switch (state) { @@ -978,7 +862,6 @@ std::string GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCan break; } -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI case GLToolbarItem::Disabled: { if (inside) @@ -1003,22 +886,11 @@ std::string GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCan { break; } -#else - default: - case GLToolbarItem::Disabled: - { - break; - } -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI } top -= icon_stride; } } - -#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI - return tooltip; -#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI } int GLToolbar::contains_mouse(const Vec2d& mouse_pos, const GLCanvas3D& parent) const @@ -1367,37 +1239,21 @@ bool GLToolbar::generate_icons_texture() const std::vector> states; if (m_name == "Top") { -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI states.push_back({ 1, false }); // Normal states.push_back({ 0, false }); // Pressed states.push_back({ 2, false }); // Disabled states.push_back({ 0, false }); // Hover states.push_back({ 0, false }); // HoverPressed states.push_back({ 2, false }); // HoverDisabled -#else - states.push_back(std::make_pair(1, false)); - states.push_back(std::make_pair(0, false)); - states.push_back(std::make_pair(2, false)); - states.push_back(std::make_pair(0, false)); - states.push_back(std::make_pair(0, false)); -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI } else if (m_name == "View") { -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI states.push_back({ 1, false }); // Normal states.push_back({ 1, true }); // Pressed states.push_back({ 1, false }); // Disabled states.push_back({ 0, false }); // Hover states.push_back({ 1, true }); // HoverPressed states.push_back({ 1, false }); // HoverDisabled -#else - states.push_back(std::make_pair(1, false)); - states.push_back(std::make_pair(1, true)); - states.push_back(std::make_pair(1, false)); - states.push_back(std::make_pair(0, false)); - states.push_back(std::make_pair(1, true)); -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI } unsigned int sprite_size_px = (unsigned int)(m_layout.icons_size * m_layout.scale); diff --git a/src/slic3r/GUI/GLToolbar.hpp b/src/slic3r/GUI/GLToolbar.hpp index 9911bb34a..41c2735c9 100644 --- a/src/slic3r/GUI/GLToolbar.hpp +++ b/src/slic3r/GUI/GLToolbar.hpp @@ -61,9 +61,7 @@ public: Disabled, Hover, HoverPressed, -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI HoverDisabled, -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI Num_States }; @@ -123,15 +121,9 @@ public: void do_left_action() { m_last_action_type = Left; m_data.left.action_callback(); } void do_right_action() { m_last_action_type = Right; m_data.right.action_callback(); } -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI bool is_enabled() const { return (m_state != Disabled) && (m_state != HoverDisabled); } bool is_disabled() const { return (m_state == Disabled) || (m_state == HoverDisabled); } bool is_hovered() const { return (m_state == Hover) || (m_state == HoverPressed) || (m_state == HoverDisabled); } -#else - bool is_enabled() const { return m_state != Disabled; } - bool is_disabled() const { return m_state == Disabled; } - bool is_hovered() const { return (m_state == Hover) || (m_state == HoverPressed); } -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI bool is_pressed() const { return (m_state == Pressed) || (m_state == HoverPressed); } bool is_visible() const { return m_data.visible; } bool is_separator() const { return m_type == Separator; } @@ -262,9 +254,6 @@ private: }; MouseCapture m_mouse_capture; -#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI - std::string m_tooltip; -#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI int m_pressed_toggable_id; public: @@ -310,11 +299,7 @@ public: void force_left_action(int item_id, GLCanvas3D& parent) { do_action(GLToolbarItem::Left, item_id, parent, false); } void force_right_action(int item_id, GLCanvas3D& parent) { do_action(GLToolbarItem::Right, item_id, parent, false); } -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI std::string get_tooltip() const; -#else - const std::string& get_tooltip() const { return m_tooltip; } -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI void get_additional_tooltip(int item_id, std::string& text); void set_additional_tooltip(int item_id, const std::string& text); @@ -336,15 +321,9 @@ private: float get_height_vertical() const; float get_main_size() const; void do_action(GLToolbarItem::EActionType type, int item_id, GLCanvas3D& parent, bool check_hover); -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI void update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent); void update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D& parent); void update_hover_state_vertical(const Vec2d& mouse_pos, GLCanvas3D& parent); -#else - std::string update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent); - std::string update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D& parent); - std::string update_hover_state_vertical(const Vec2d& mouse_pos, GLCanvas3D& parent); -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI // 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; int contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3D& parent) const; diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index 2f2be8063..8f8bebc8e 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -479,22 +479,9 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt) int selected_object_idx = selection.get_object_idx(); bool processed = false; -#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI - // mouse anywhere - if (!evt.Dragging() && !evt.Leaving() && !evt.Entering() && (m_mouse_capture.parent != nullptr)) - { - if (m_mouse_capture.any() && (evt.LeftUp() || evt.MiddleUp() || evt.RightUp())) - // prevents loosing selection into the scene if mouse down was done inside the toolbar and mouse up was down outside it - processed = true; - - m_mouse_capture.reset(); - } -#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI - // mouse anywhere if (evt.Moving()) m_tooltip = update_hover_state(mouse_pos); -#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI else if (evt.LeftUp()) { if (m_mouse_capture.left) @@ -559,24 +546,6 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt) // else // return false; } -#else - else if (evt.LeftUp()) - m_mouse_capture.left = false; - else if (evt.MiddleUp()) - m_mouse_capture.middle = false; - else if (evt.RightUp()) - { - m_mouse_capture.right = false; - if (pending_right_up) - { - pending_right_up = false; - processed = true; - } - } - else if (evt.Dragging() && m_mouse_capture.any()) - // if the button down was done on this toolbar, prevent from dragging into the scene - processed = true; -#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI else if (evt.Dragging() && is_dragging()) { if (!m_parent.get_wxglcanvas()->HasCapture()) @@ -674,29 +643,6 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt) m_parent.set_as_dirty(); processed = true; } -#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI - else if (evt.LeftUp() && is_dragging()) - { - switch (m_current) { - case Move : m_parent.do_move(L("Gizmo-Move")); break; - case Scale : m_parent.do_scale(L("Gizmo-Scale")); break; - case Rotate : m_parent.do_rotate(L("Gizmo-Rotate")); break; - default : break; - } - - stop_dragging(); - update_data(); - - wxGetApp().obj_manipul()->set_dirty(); - // Let the plater know that the dragging finished, so a delayed refresh - // of the scene with the background processing data should be performed. - m_parent.post_event(SimpleEvent(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED)); - // updates camera target constraints - m_parent.refresh_camera_scene_box(); - - processed = true; - } -#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI else if (evt.LeftUp() && (m_current == SlaSupports || m_current == Hollow || m_current == FdmSupports) && !m_parent.is_mouse_dragging()) { // in case SLA/FDM gizmo is selected, we just pass the LeftUp event and stop processing - neither @@ -740,10 +686,6 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt) m_mouse_capture.right = true; m_mouse_capture.parent = &m_parent; } -#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI - else if (evt.LeftUp()) - processed = true; -#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI } return processed;