Fixed gizmos' tooltips

This commit is contained in:
enricoturri1966 2020-03-16 12:45:39 +01:00 committed by bubnikv
parent e1ecf03e0c
commit df6170b9bd
8 changed files with 47 additions and 28 deletions

View file

@ -1951,6 +1951,25 @@ void GLCanvas3D::render()
auto end_time = std::chrono::high_resolution_clock::now();
m_render_stats.last_frame = std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time).count();
#endif // ENABLE_RENDER_STATISTICS
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_view_toolbar.get_tooltip();
set_tooltip(tooltip);
}
#if ENABLE_THUMBNAIL_GENERATOR
@ -3587,24 +3606,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
else if (evt.Moving())
{
m_mouse.position = pos.cast<double>();
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_view_toolbar.get_tooltip();
set_tooltip(tooltip);
// updates gizmos overlay
if (m_selection.is_empty())
@ -3692,7 +3693,6 @@ void GLCanvas3D::set_tooltip(const std::string& tooltip) const
}
}
void GLCanvas3D::do_move(const std::string& snapshot_type)
{
if (m_model == nullptr)

View file

@ -265,7 +265,7 @@ void GLGizmoBase::render_grabbers_for_picking(const BoundingBoxf3& box) const
void GLGizmoBase::set_tooltip(const std::string& tooltip) const
{
m_parent.set_tooltip(tooltip);
m_tooltip = tooltip;
}
std::string GLGizmoBase::format(float value, unsigned int decimals) const

View file

@ -100,6 +100,7 @@ protected:
mutable std::vector<Grabber> m_grabbers;
ImGuiWrapper* m_imgui;
bool m_first_input_window_render;
mutable std::string m_tooltip;
public:
GLGizmoBase(GLCanvas3D& parent,
@ -145,10 +146,12 @@ public:
void update(const UpdateData& data);
void render() const { on_render(); }
void render() const { m_tooltip.clear(); on_render(); }
void render_for_picking() const { on_render_for_picking(); }
void render_input_window(float x, float y, float bottom_limit);
virtual const std::string& get_tooltip() const { return m_tooltip; }
protected:
virtual bool on_init() = 0;
virtual void on_load(cereal::BinaryInputArchive& ar) {}

View file

@ -79,9 +79,8 @@ void GLGizmoCut::on_update(const UpdateData& data)
void GLGizmoCut::on_render() const
{
if (m_grabbers[0].dragging) {
if (m_hover_id == 0 || m_grabbers[0].dragging)
set_tooltip("Z: " + format(m_cut_z, 2));
}
const Selection& selection = m_parent.get_selection();

View file

@ -135,10 +135,8 @@ void GLGizmoRotate::on_render() const
case Z: { axis = "Z"; break; }
}
if (!m_dragging && (m_hover_id == 0))
set_tooltip(axis);
else if (m_dragging)
set_tooltip(axis + ": " + format((float)Geometry::rad2deg(m_angle), 4) + "\u00B0");
if (m_hover_id == 0 || m_grabbers[0].dragging)
set_tooltip(axis + ": " + format((float)Geometry::rad2deg(m_angle), 4));
else
{
m_center = box.center();

View file

@ -81,6 +81,16 @@ public:
Vec3d get_rotation() const { return Vec3d(m_gizmos[X].get_angle(), m_gizmos[Y].get_angle(), m_gizmos[Z].get_angle()); }
void set_rotation(const Vec3d& rotation) { m_gizmos[X].set_angle(rotation(0)); m_gizmos[Y].set_angle(rotation(1)); m_gizmos[Z].set_angle(rotation(2)); }
virtual const std::string& get_tooltip() const
{
m_tooltip = m_gizmos[X].get_tooltip();
if (m_tooltip.empty())
m_tooltip = m_gizmos[Y].get_tooltip();
if (m_tooltip.empty())
m_tooltip = m_gizmos[Z].get_tooltip();
return m_tooltip;
}
protected:
virtual bool on_init();
virtual std::string on_get_name() const;

View file

@ -422,6 +422,15 @@ void GLGizmosManager::render_overlay() const
do_render_overlay();
}
std::string GLGizmosManager::get_tooltip() const
{
if (!m_tooltip.empty())
return m_tooltip;
const GLGizmoBase* curr = get_current();
return (curr != nullptr) ? curr->get_tooltip() : "";
}
bool GLGizmosManager::on_mouse_wheel(wxMouseEvent& evt)
{
bool processed = false;

View file

@ -204,7 +204,7 @@ public:
void render_overlay() const;
const std::string& get_tooltip() const { return m_tooltip; }
std::string get_tooltip() const;
bool on_mouse(wxMouseEvent& evt);
bool on_mouse_wheel(wxMouseEvent& evt);