Tooltip when hovering on gizmo icons
This commit is contained in:
parent
806e59facc
commit
78d813cbc9
5 changed files with 75 additions and 23 deletions
|
@ -18,7 +18,6 @@
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
#include <wx/glcanvas.h>
|
#include <wx/glcanvas.h>
|
||||||
#include <wx/timer.h>
|
|
||||||
#include <wx/bitmap.h>
|
#include <wx/bitmap.h>
|
||||||
#include <wx/dcmemory.h>
|
#include <wx/dcmemory.h>
|
||||||
#include <wx/image.h>
|
#include <wx/image.h>
|
||||||
|
@ -1904,13 +1903,21 @@ void GLCanvas3D::Gizmos::set_enabled(bool enable)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_EXTENDED_SELECTION
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
void GLCanvas3D::Gizmos::update_hover_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos, const GLCanvas3D::Selection& selection)
|
std::string GLCanvas3D::Gizmos::update_hover_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos, const GLCanvas3D::Selection& selection)
|
||||||
#else
|
#else
|
||||||
void GLCanvas3D::Gizmos::update_hover_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos)
|
void GLCanvas3D::Gizmos::update_hover_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos)
|
||||||
#endif // ENABLE_EXTENDED_SELECTION
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
{
|
{
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
std::string name = "";
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
if (!m_enabled)
|
if (!m_enabled)
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
return name;
|
||||||
|
#else
|
||||||
return;
|
return;
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
float cnv_h = (float)canvas.get_canvas_size().get_height();
|
float cnv_h = (float)canvas.get_canvas_size().get_height();
|
||||||
float height = _get_total_overlay_height();
|
float height = _get_total_overlay_height();
|
||||||
|
@ -1932,9 +1939,17 @@ void GLCanvas3D::Gizmos::update_hover_state(const GLCanvas3D& canvas, const Vec2
|
||||||
{
|
{
|
||||||
bool inside = (mouse_pos - Vec2d(OverlayOffsetX + half_tex_size, top_y + half_tex_size)).norm() < half_tex_size;
|
bool inside = (mouse_pos - Vec2d(OverlayOffsetX + half_tex_size, top_y + half_tex_size)).norm() < half_tex_size;
|
||||||
it->second->set_state(inside ? GLGizmoBase::Hover : GLGizmoBase::Off);
|
it->second->set_state(inside ? GLGizmoBase::Hover : GLGizmoBase::Off);
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
if (inside)
|
||||||
|
name = it->second->get_name();
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
}
|
}
|
||||||
top_y += (tex_size + OverlayGapY);
|
top_y += (tex_size + OverlayGapY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
return name;
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_EXTENDED_SELECTION
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
@ -2715,7 +2730,6 @@ wxDEFINE_EVENT(EVT_GIZMO_FLATTEN, Vec3dEvent);
|
||||||
GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas)
|
GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas)
|
||||||
: m_canvas(canvas)
|
: m_canvas(canvas)
|
||||||
, m_context(nullptr)
|
, m_context(nullptr)
|
||||||
, m_timer(nullptr)
|
|
||||||
, m_toolbar(*this)
|
, m_toolbar(*this)
|
||||||
, m_config(nullptr)
|
, m_config(nullptr)
|
||||||
, m_print(nullptr)
|
, m_print(nullptr)
|
||||||
|
@ -2749,7 +2763,7 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas)
|
||||||
#if !ENABLE_USE_UNIQUE_GLCONTEXT
|
#if !ENABLE_USE_UNIQUE_GLCONTEXT
|
||||||
m_context = new wxGLContext(m_canvas);
|
m_context = new wxGLContext(m_canvas);
|
||||||
#endif // !ENABLE_USE_UNIQUE_GLCONTEXT
|
#endif // !ENABLE_USE_UNIQUE_GLCONTEXT
|
||||||
m_timer = new wxTimer(m_canvas);
|
m_timer.SetOwner(m_canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_EXTENDED_SELECTION
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
@ -2761,12 +2775,6 @@ GLCanvas3D::~GLCanvas3D()
|
||||||
{
|
{
|
||||||
reset_volumes();
|
reset_volumes();
|
||||||
|
|
||||||
if (m_timer != nullptr)
|
|
||||||
{
|
|
||||||
delete m_timer;
|
|
||||||
m_timer = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !ENABLE_USE_UNIQUE_GLCONTEXT
|
#if !ENABLE_USE_UNIQUE_GLCONTEXT
|
||||||
if (m_context != nullptr)
|
if (m_context != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -3339,6 +3347,8 @@ void GLCanvas3D::render()
|
||||||
float theta = m_camera.get_theta();
|
float theta = m_camera.get_theta();
|
||||||
bool is_custom_bed = m_bed.is_custom();
|
bool is_custom_bed = m_bed.is_custom();
|
||||||
|
|
||||||
|
set_tooltip("");
|
||||||
|
|
||||||
// picking pass
|
// picking pass
|
||||||
_picking_pass();
|
_picking_pass();
|
||||||
|
|
||||||
|
@ -4498,10 +4508,19 @@ void GLCanvas3D::reset_legend_texture()
|
||||||
m_legend_texture.reset();
|
m_legend_texture.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::set_tooltip(const std::string& tooltip)
|
void GLCanvas3D::set_tooltip(const std::string& tooltip) const
|
||||||
{
|
{
|
||||||
if (m_canvas != nullptr)
|
if (m_canvas != nullptr)
|
||||||
m_canvas->SetToolTip(tooltip);
|
{
|
||||||
|
wxToolTip* t = m_canvas->GetToolTip();
|
||||||
|
if (t != nullptr)
|
||||||
|
{
|
||||||
|
if (t->GetTip() != tooltip)
|
||||||
|
t->SetTip(tooltip);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_canvas->SetToolTip(tooltip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GLCanvas3D::_is_shown_on_screen() const
|
bool GLCanvas3D::_is_shown_on_screen() const
|
||||||
|
@ -4993,7 +5012,11 @@ void GLCanvas3D::_picking_pass() const
|
||||||
// updates gizmos overlay
|
// updates gizmos overlay
|
||||||
#if ENABLE_EXTENDED_SELECTION
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
if (!m_selection.is_empty())
|
if (!m_selection.is_empty())
|
||||||
m_gizmos.update_hover_state(*this, pos, m_selection);
|
{
|
||||||
|
std::string name = m_gizmos.update_hover_state(*this, pos, m_selection);
|
||||||
|
if (!name.empty())
|
||||||
|
set_tooltip(name);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
if (_get_first_selected_object_id() != -1)
|
if (_get_first_selected_object_id() != -1)
|
||||||
m_gizmos.update_hover_state(*this, pos);
|
m_gizmos.update_hover_state(*this, pos);
|
||||||
|
@ -5361,14 +5384,12 @@ Linef3 GLCanvas3D::mouse_ray(const Point& mouse_pos)
|
||||||
|
|
||||||
void GLCanvas3D::_start_timer()
|
void GLCanvas3D::_start_timer()
|
||||||
{
|
{
|
||||||
if (m_timer != nullptr)
|
m_timer.Start(100, wxTIMER_CONTINUOUS);
|
||||||
m_timer->Start(100, wxTIMER_CONTINUOUS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::_stop_timer()
|
void GLCanvas3D::_stop_timer()
|
||||||
{
|
{
|
||||||
if (m_timer != nullptr)
|
m_timer.Stop();
|
||||||
m_timer->Stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !ENABLE_EXTENDED_SELECTION
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
|
@ -7,8 +7,9 @@
|
||||||
#include "GLToolbar.hpp"
|
#include "GLToolbar.hpp"
|
||||||
#include "Event.hpp"
|
#include "Event.hpp"
|
||||||
|
|
||||||
|
#include <wx/timer.h>
|
||||||
|
|
||||||
class wxWindow;
|
class wxWindow;
|
||||||
class wxTimer;
|
|
||||||
class wxSizeEvent;
|
class wxSizeEvent;
|
||||||
class wxIdleEvent;
|
class wxIdleEvent;
|
||||||
class wxKeyEvent;
|
class wxKeyEvent;
|
||||||
|
@ -562,7 +563,7 @@ private:
|
||||||
void set_enabled(bool enable);
|
void set_enabled(bool enable);
|
||||||
|
|
||||||
#if ENABLE_EXTENDED_SELECTION
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
void update_hover_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos, const Selection& selection);
|
std::string update_hover_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos, const Selection& selection);
|
||||||
void update_on_off_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos, const Selection& selection);
|
void update_on_off_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos, const Selection& selection);
|
||||||
void update_on_off_state(const Selection& selection);
|
void update_on_off_state(const Selection& selection);
|
||||||
#else
|
#else
|
||||||
|
@ -678,7 +679,7 @@ private:
|
||||||
wxGLContext* m_context;
|
wxGLContext* m_context;
|
||||||
LegendTexture m_legend_texture;
|
LegendTexture m_legend_texture;
|
||||||
WarningTexture m_warning_texture;
|
WarningTexture m_warning_texture;
|
||||||
wxTimer* m_timer;
|
wxTimer m_timer;
|
||||||
Camera m_camera;
|
Camera m_camera;
|
||||||
Bed m_bed;
|
Bed m_bed;
|
||||||
Axes m_axes;
|
Axes m_axes;
|
||||||
|
@ -866,7 +867,7 @@ public:
|
||||||
|
|
||||||
void reset_legend_texture();
|
void reset_legend_texture();
|
||||||
|
|
||||||
void set_tooltip(const std::string& tooltip);
|
void set_tooltip(const std::string& tooltip) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _is_shown_on_screen() const;
|
bool _is_shown_on_screen() const;
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include "../../libslic3r/libslic3r.h"
|
#include "../../libslic3r/libslic3r.h"
|
||||||
#include "GLGizmo.hpp"
|
#include "GLGizmo.hpp"
|
||||||
|
|
||||||
|
#include "GUI.hpp"
|
||||||
|
|
||||||
#include "../../libslic3r/Utils.hpp"
|
#include "../../libslic3r/Utils.hpp"
|
||||||
#if !ENABLE_EXTENDED_SELECTION
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
#include "../../slic3r/GUI/GLCanvas3D.hpp"
|
#include "../../slic3r/GUI/GLCanvas3D.hpp"
|
||||||
|
@ -281,7 +283,6 @@ void GLGizmoBase::start_dragging(const BoundingBoxf3& box)
|
||||||
void GLGizmoBase::stop_dragging()
|
void GLGizmoBase::stop_dragging()
|
||||||
{
|
{
|
||||||
m_dragging = false;
|
m_dragging = false;
|
||||||
set_tooltip("");
|
|
||||||
|
|
||||||
for (int i = 0; i < (int)m_grabbers.size(); ++i)
|
for (int i = 0; i < (int)m_grabbers.size(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -725,6 +726,11 @@ bool GLGizmoRotate3D::on_init()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string GLGizmoRotate3D::on_get_name() const
|
||||||
|
{
|
||||||
|
return L("Rotate");
|
||||||
|
}
|
||||||
|
|
||||||
#if ENABLE_EXTENDED_SELECTION
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
void GLGizmoRotate3D::on_start_dragging(const GLCanvas3D::Selection& selection)
|
void GLGizmoRotate3D::on_start_dragging(const GLCanvas3D::Selection& selection)
|
||||||
{
|
{
|
||||||
|
@ -817,6 +823,11 @@ bool GLGizmoScale3D::on_init()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string GLGizmoScale3D::on_get_name() const
|
||||||
|
{
|
||||||
|
return L("Scale");
|
||||||
|
}
|
||||||
|
|
||||||
#if ENABLE_EXTENDED_SELECTION
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
void GLGizmoScale3D::on_start_dragging(const GLCanvas3D::Selection& selection)
|
void GLGizmoScale3D::on_start_dragging(const GLCanvas3D::Selection& selection)
|
||||||
#else
|
#else
|
||||||
|
@ -1254,6 +1265,11 @@ bool GLGizmoMove3D::on_init()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string GLGizmoMove3D::on_get_name() const
|
||||||
|
{
|
||||||
|
return L("Move");
|
||||||
|
}
|
||||||
|
|
||||||
#if ENABLE_EXTENDED_SELECTION
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
void GLGizmoMove3D::on_start_dragging(const GLCanvas3D::Selection& selection)
|
void GLGizmoMove3D::on_start_dragging(const GLCanvas3D::Selection& selection)
|
||||||
#else
|
#else
|
||||||
|
@ -1480,6 +1496,11 @@ bool GLGizmoFlatten::on_init()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string GLGizmoFlatten::on_get_name() const
|
||||||
|
{
|
||||||
|
return L("Flatten");
|
||||||
|
}
|
||||||
|
|
||||||
#if ENABLE_EXTENDED_SELECTION
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
void GLGizmoFlatten::on_start_dragging(const GLCanvas3D::Selection& selection)
|
void GLGizmoFlatten::on_start_dragging(const GLCanvas3D::Selection& selection)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -74,6 +74,8 @@ public:
|
||||||
|
|
||||||
bool init() { return on_init(); }
|
bool init() { return on_init(); }
|
||||||
|
|
||||||
|
std::string get_name() const { return on_get_name(); }
|
||||||
|
|
||||||
int get_group_id() const { return m_group_id; }
|
int get_group_id() const { return m_group_id; }
|
||||||
void set_group_id(int id) { m_group_id = id; }
|
void set_group_id(int id) { m_group_id = id; }
|
||||||
|
|
||||||
|
@ -119,6 +121,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool on_init() = 0;
|
virtual bool on_init() = 0;
|
||||||
|
virtual std::string on_get_name() const = 0;
|
||||||
virtual void on_set_state() {}
|
virtual void on_set_state() {}
|
||||||
virtual void on_set_hover_id() {}
|
virtual void on_set_hover_id() {}
|
||||||
#if ENABLE_EXTENDED_SELECTION
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
@ -192,6 +195,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool on_init();
|
virtual bool on_init();
|
||||||
|
virtual std::string on_get_name() const { return ""; }
|
||||||
#if ENABLE_EXTENDED_SELECTION
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
virtual void on_start_dragging(const GLCanvas3D::Selection& selection);
|
virtual void on_start_dragging(const GLCanvas3D::Selection& selection);
|
||||||
#else
|
#else
|
||||||
|
@ -234,6 +238,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool on_init();
|
virtual bool on_init();
|
||||||
|
virtual std::string on_get_name() const;
|
||||||
virtual void on_set_state()
|
virtual void on_set_state()
|
||||||
{
|
{
|
||||||
for (GLGizmoRotate& g : m_gizmos)
|
for (GLGizmoRotate& g : m_gizmos)
|
||||||
|
@ -329,6 +334,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool on_init();
|
virtual bool on_init();
|
||||||
|
virtual std::string on_get_name() const;
|
||||||
#if ENABLE_EXTENDED_SELECTION
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const { return !selection.is_wipe_tower(); }
|
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const { return !selection.is_wipe_tower(); }
|
||||||
#endif // ENABLE_EXTENDED_SELECTION
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
@ -389,6 +395,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool on_init();
|
virtual bool on_init();
|
||||||
|
virtual std::string on_get_name() const;
|
||||||
#if ENABLE_EXTENDED_SELECTION
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
virtual void on_start_dragging(const GLCanvas3D::Selection& selection);
|
virtual void on_start_dragging(const GLCanvas3D::Selection& selection);
|
||||||
virtual void on_stop_dragging();
|
virtual void on_stop_dragging();
|
||||||
|
@ -455,6 +462,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool on_init();
|
virtual bool on_init();
|
||||||
|
virtual std::string on_get_name() const;
|
||||||
#if ENABLE_EXTENDED_SELECTION
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const { return selection.is_single_full_instance(); }
|
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const { return selection.is_single_full_instance(); }
|
||||||
#endif // ENABLE_EXTENDED_SELECTION
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
|
@ -512,7 +512,8 @@ void GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_parent.set_tooltip(tooltip);
|
if (!tooltip.empty())
|
||||||
|
m_parent.set_tooltip(tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos)
|
void GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos)
|
||||||
|
|
Loading…
Add table
Reference in a new issue