Removal of tabs from plater -> Fixed buttons update when switching between views using keyboard

This commit is contained in:
Enrico Turri 2018-12-06 12:37:39 +01:00
parent c908a4674a
commit 8d78b23c78
5 changed files with 22 additions and 8 deletions

View file

@ -4985,7 +4985,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
// updates view toolbar overlay // updates view toolbar overlay
if (tooltip.empty() && (m_view_toolbar != nullptr)) if (tooltip.empty() && (m_view_toolbar != nullptr))
{ {
tooltip = m_view_toolbar->update_hover_state(m_mouse.position, *this); tooltip = m_view_toolbar->update_hover_state(m_mouse.position, *this);
if (!tooltip.empty()) if (!tooltip.empty())
m_dirty = true; m_dirty = true;
} }

View file

@ -939,7 +939,7 @@ int GLRadioToolbar::contains_mouse(const Vec2d& mouse_pos, const GLCanvas3D& par
return -1; return -1;
} }
std::string GLRadioToolbar::update_hover_state(const Vec2d& mouse_pos, const GLCanvas3D& parent) std::string GLRadioToolbar::update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent)
{ {
float zoom = parent.get_camera_zoom(); float zoom = parent.get_camera_zoom();
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f; float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
@ -967,7 +967,10 @@ std::string GLRadioToolbar::update_hover_state(const Vec2d& mouse_pos, const GLC
case GLRadioToolbarItem::Normal: case GLRadioToolbarItem::Normal:
{ {
if (inside) if (inside)
{
item->set_state(GLRadioToolbarItem::Hover); item->set_state(GLRadioToolbarItem::Hover);
parent.set_as_dirty();
}
break; break;
} }
@ -976,14 +979,20 @@ std::string GLRadioToolbar::update_hover_state(const Vec2d& mouse_pos, const GLC
if (inside) if (inside)
tooltip = item->get_tooltip(); tooltip = item->get_tooltip();
else else
{
item->set_state(GLRadioToolbarItem::Normal); item->set_state(GLRadioToolbarItem::Normal);
parent.set_as_dirty();
}
break; break;
} }
case GLRadioToolbarItem::Pressed: case GLRadioToolbarItem::Pressed:
{ {
if (inside) if (inside)
{
item->set_state(GLRadioToolbarItem::HoverPressed); item->set_state(GLRadioToolbarItem::HoverPressed);
parent.set_as_dirty();
}
break; break;
} }
@ -992,7 +1001,10 @@ std::string GLRadioToolbar::update_hover_state(const Vec2d& mouse_pos, const GLC
if (inside) if (inside)
tooltip = item->get_tooltip(); tooltip = item->get_tooltip();
else else
{
item->set_state(GLRadioToolbarItem::Pressed); item->set_state(GLRadioToolbarItem::Pressed);
parent.set_as_dirty();
}
break; break;
} }

View file

@ -268,7 +268,7 @@ public:
// returns the id of the item under the given mouse position or -1 if none // 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(const Vec2d& mouse_pos, const GLCanvas3D& parent) const;
std::string update_hover_state(const Vec2d& mouse_pos, const GLCanvas3D& parent); std::string update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent);
void do_action(unsigned int item_id, GLCanvas3D& parent); void do_action(unsigned int item_id, GLCanvas3D& parent);

View file

@ -345,9 +345,9 @@ void MainFrame::init_menubar()
if (m_plater) { if (m_plater) {
windowMenu->AppendSeparator(); windowMenu->AppendSeparator();
wxMenuItem* item_3d = append_menu_item(windowMenu, wxID_ANY, L("3D\tCtrl+5"), L("Show the 3D editing view"), wxMenuItem* item_3d = append_menu_item(windowMenu, wxID_ANY, L("3D\tCtrl+5"), L("Show the 3D editing view"),
[this](wxCommandEvent&) { m_plater->select_view_3D("3D"); }, ""); [this](wxCommandEvent&) { m_plater->select_view_3D("3D"); }, "");
wxMenuItem* item_preview = append_menu_item(windowMenu, wxID_ANY, L("Preview\tCtrl+6"), L("Show the 3D slices preview"), wxMenuItem* item_preview = append_menu_item(windowMenu, wxID_ANY, L("Preview\tCtrl+6"), L("Show the 3D slices preview"),
[this](wxCommandEvent&) { m_plater->select_view_3D("Preview"); }, ""); [this](wxCommandEvent&) { m_plater->select_view_3D("Preview"); }, "");
Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_change_view()); }, item_3d->GetId()); Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_change_view()); }, item_3d->GetId());
Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_change_view()); }, item_preview->GetId()); Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_change_view()); }, item_preview->GetId());

View file

@ -1295,6 +1295,8 @@ void Plater::priv::select_view_3D(const std::string& name)
set_current_panel(view3D); set_current_panel(view3D);
else if (name == "Preview") else if (name == "Preview")
set_current_panel(preview); set_current_panel(preview);
view_toolbar.set_selection(name);
} }
#else #else
void Plater::priv::select_view(const std::string& direction) void Plater::priv::select_view(const std::string& direction)
@ -2482,14 +2484,14 @@ void Plater::priv::init_view_toolbar()
GLRadioToolbarItem::Data item; GLRadioToolbarItem::Data item;
item.name = "3d"; item.name = "3D";
item.tooltip = GUI::L_str("3D editor view"); item.tooltip = GUI::L_str("3D editor view");
item.sprite_id = 0; item.sprite_id = 0;
item.action_event = EVT_GLVIEWTOOLBAR_3D; item.action_event = EVT_GLVIEWTOOLBAR_3D;
if (!view_toolbar.add_item(item)) if (!view_toolbar.add_item(item))
return; return;
item.name = "preview"; item.name = "Preview";
item.tooltip = GUI::L_str("Preview"); item.tooltip = GUI::L_str("Preview");
item.sprite_id = 1; item.sprite_id = 1;
item.action_event = EVT_GLVIEWTOOLBAR_PREVIEW; item.action_event = EVT_GLVIEWTOOLBAR_PREVIEW;
@ -2499,7 +2501,7 @@ void Plater::priv::init_view_toolbar()
view3D->set_view_toolbar(&view_toolbar); view3D->set_view_toolbar(&view_toolbar);
preview->set_view_toolbar(&view_toolbar); preview->set_view_toolbar(&view_toolbar);
view_toolbar.set_selection("3d"); view_toolbar.set_selection("3D");
} }
#endif // ENABLE_REMOVE_TABS_FROM_PLATER #endif // ENABLE_REMOVE_TABS_FROM_PLATER