Fix for tooltip not disappearing when loading an object using the top toolbar 'Add' command and when swithing to preview

This commit is contained in:
enricoturri1966 2020-05-07 16:47:15 +02:00
parent 4cef33c50f
commit dcb603bed5
3 changed files with 27 additions and 7 deletions

View File

@ -2109,6 +2109,7 @@ void GLCanvas3D::render()
set_tooltip(tooltip);
if (m_tooltip_enabled)
m_tooltip.render(m_mouse.position, *this);
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
@ -2815,6 +2816,9 @@ 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
}
}
@ -2842,6 +2846,9 @@ 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
}
}
@ -3541,12 +3548,18 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
if (top_level_wnd && top_level_wnd->IsActive())
m_canvas->SetFocus();
m_mouse.position = pos.cast<double>();
#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
@ -3860,6 +3873,15 @@ 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
{
int w = 0;

View File

@ -502,6 +502,7 @@ private:
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;
@ -633,6 +634,9 @@ 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;

View File

@ -707,12 +707,6 @@ void GUI_App::load_project(wxWindow *parent, wxString& input_file) const
void GUI_App::import_model(wxWindow *parent, wxArrayString& input_files) const
{
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
if (this->plater_ != nullptr)
// hides the tooltip
plater_->get_current_canvas3D()->set_tooltip("");
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
input_files.Clear();
wxFileDialog dialog(parent ? parent : GetTopWindow(),
_(L("Choose one or more files (STL/OBJ/AMF/3MF/PRUSA):")),