diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp index 4976520fa..32a43e78c 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp @@ -1127,19 +1127,23 @@ void GLGizmoSlaSupports::on_set_state() m_new_point_head_diameter = static_cast(cfg.option("support_head_front_diameter"))->value; } if (m_state == Off && m_old_state != Off) { // the gizmo was just turned Off - wxGetApp().CallAfter([this]() { - // Following is called through CallAfter, because otherwise there was a problem - // on OSX with the wxMessageDialog being shown several times when clicked into. - if (m_model_object) { - if (m_editing_mode && unsaved_changes()) { - wxMessageDialog dlg(GUI::wxGetApp().mainframe, _(L("Do you want to save your manually edited support points?")) + "\n", - _(L("Save changes?")), wxICON_QUESTION | wxYES | wxNO); + bool will_ask = m_model_object && m_editing_mode && unsaved_changes(); + if (will_ask) { + wxGetApp().CallAfter([this]() { + // Following is called through CallAfter, because otherwise there was a problem + // on OSX with the wxMessageDialog being shown several times when clicked into. + wxMessageDialog dlg(GUI::wxGetApp().mainframe, _(L("Do you want to save your manually " + "edited support points?")) + "\n",_(L("Save changes?")), wxICON_QUESTION | wxYES | wxNO); if (dlg.ShowModal() == wxID_YES) editing_mode_apply_changes(); else editing_mode_discard_changes(); - } - } + }); + // refuse to be turned off so the gizmo is active when the CallAfter is executed + m_state = m_old_state; + } + else { + // we are actually shutting down m_parent.toggle_model_objects_visibility(true); disable_editing_mode(); // so it is not active next time the gizmo opens m_normal_cache.clear(); @@ -1149,7 +1153,7 @@ void GLGizmoSlaSupports::on_set_state() m_its = nullptr; m_tms.reset(); m_supports_tms.reset(); - }); + } } m_old_state = m_state; } diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index 99a2f229f..bd176b231 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -280,8 +280,8 @@ bool GLGizmosManager::handle_shortcut(int key) if (m_parent.get_selection().is_empty()) return false; - EType old_current = m_current; bool handled = false; + for (GizmosMap::iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it) { if ((it->second == nullptr) || !it->second->is_selectable()) @@ -294,25 +294,34 @@ bool GLGizmosManager::handle_shortcut(int key) if ((it->second->get_state() == GLGizmoBase::On)) { it->second->set_state(GLGizmoBase::Off); - m_current = Undefined; + if (it->second->get_state() == GLGizmoBase::Off) { + m_current = Undefined; + } handled = true; } else if ((it->second->get_state() == GLGizmoBase::Off)) { - it->second->set_state(GLGizmoBase::On); - m_current = it->first; + // Before turning anything on, turn everything else off to see if + // nobody refuses. Only then activate the gizmo. + bool can_open = true; + for (GizmosMap::iterator i = m_gizmos.begin(); i != m_gizmos.end(); ++i) { + if (i->first != it->first) { + if (m_current == i->first && i->second->get_state() != GLGizmoBase::Off ) { + i->second->set_state(GLGizmoBase::Off); + if (i->second->get_state() != GLGizmoBase::Off) + can_open = false; + } + } + } + if (can_open) { + it->second->set_state(GLGizmoBase::On); + m_current = it->first; + } handled = true; } } } - if (handled && (old_current != Undefined) && (old_current != m_current)) - { - GizmosMap::const_iterator it = m_gizmos.find(old_current); - if (it != m_gizmos.end()) - it->second->set_state(GLGizmoBase::Off); - } - return handled; } @@ -1098,8 +1107,11 @@ void GLGizmosManager::update_on_off_state(const Vec2d& mouse_pos) { if ((gizmo->get_state() == GLGizmoBase::On)) { - gizmo->set_state(GLGizmoBase::Hover); - m_current = Undefined; + gizmo->set_state(GLGizmoBase::Off); + if (gizmo->get_state() == GLGizmoBase::Off) { + gizmo->set_state(GLGizmoBase::Hover); + m_current = Undefined; + } } else if ((gizmo->get_state() == GLGizmoBase::Hover) && could_activate) {