Show gizmos and toolbars tooltips when hovering on a disabled item

This commit is contained in:
Enrico Turri 2019-01-16 11:10:24 +01:00
parent 02a22ba991
commit 52493e1739
2 changed files with 18 additions and 21 deletions

View file

@ -2800,13 +2800,13 @@ std::string GLCanvas3D::Gizmos::update_hover_state(const GLCanvas3D& canvas, con
float icon_size = (float)it->second->get_textures_size() * OverlayIconsScale;
bool inside = (OverlayBorder <= (float)mouse_pos(0)) && ((float)mouse_pos(0) <= OverlayBorder + icon_size) && (top_y <= (float)mouse_pos(1)) && ((float)mouse_pos(1) <= top_y + icon_size);
if (inside)
name = it->second->get_name();
if (it->second->is_activable(selection) && (it->second->get_state() != GLGizmoBase::On))
{
bool inside = (OverlayBorder <= (float)mouse_pos(0)) && ((float)mouse_pos(0) <= OverlayBorder + icon_size) && (top_y <= (float)mouse_pos(1)) && ((float)mouse_pos(1) <= top_y + icon_size);
it->second->set_state(inside ? GLGizmoBase::Hover : GLGizmoBase::Off);
if (inside)
name = it->second->get_name();
}
top_y += (icon_size + OverlayGapY);
}
@ -5365,9 +5365,8 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
std::string tooltip = "";
// updates gizmos overlay
if (!m_selection.is_empty())
tooltip = m_gizmos.update_hover_state(*this, m_mouse.position, m_selection);
else
tooltip = m_gizmos.update_hover_state(*this, m_mouse.position, m_selection);
if (m_selection.is_empty())
m_gizmos.reset_all_states();
// updates toolbar overlay
@ -5452,7 +5451,9 @@ void GLCanvas3D::set_tooltip(const std::string& tooltip) const
wxToolTip* t = m_canvas->GetToolTip();
if (t != nullptr)
{
if (t->GetTip() != tooltip)
if (tooltip.empty())
m_canvas->UnsetToolTip();
else
t->SetTip(tooltip);
}
else

View file

@ -530,6 +530,8 @@ 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 (inside)
tooltip = item->get_tooltip();
switch (state)
{
@ -545,9 +547,7 @@ std::string GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLC
}
case GLToolbarItem::Hover:
{
if (inside)
tooltip = item->get_tooltip();
else
if (!inside)
{
item->set_state(GLToolbarItem::Normal);
parent.set_as_dirty();
@ -567,9 +567,7 @@ std::string GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLC
}
case GLToolbarItem::HoverPressed:
{
if (inside)
tooltip = item->get_tooltip();
else
if (!inside)
{
item->set_state(GLToolbarItem::Pressed);
parent.set_as_dirty();
@ -623,6 +621,8 @@ 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 (inside)
tooltip = item->get_tooltip();
switch (state)
{
@ -638,9 +638,7 @@ std::string GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCan
}
case GLToolbarItem::Hover:
{
if (inside)
tooltip = item->get_tooltip();
else
if (!inside)
{
item->set_state(GLToolbarItem::Normal);
parent.set_as_dirty();
@ -660,9 +658,7 @@ std::string GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCan
}
case GLToolbarItem::HoverPressed:
{
if (inside)
tooltip = item->get_tooltip();
else
if (!inside)
{
item->set_state(GLToolbarItem::Pressed);
parent.set_as_dirty();