From e713849fed7af2f8b8ecd877407949423c6e3d5b Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Thu, 4 Jan 2024 19:28:19 +0800 Subject: [PATCH] QoL: Keyboard shortcuts updates & fixes (#3457) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Bring back the shortcut to zoom in & out * Update keyboard shortcut info * Update keyboard shortcut info * Different handling of shortcut 'T' for emboss text Cherry-picked from prusa3d/PrusaSlicer@58e3143ad8fee1069b01a4ebe85e07711331e5aa Co-authored-by: Filip Sykala - NTB T15p --------- Co-authored-by: Filip Sykala - NTB T15p (cherry picked from commit 002208fc8c952a6a4c132fa7977a7bbdbc7a348d) --- src/slic3r/GUI/GLCanvas3D.cpp | 8 ++++---- src/slic3r/GUI/Gizmos/GLGizmosManager.cpp | 23 ++++++++++++++++------- src/slic3r/GUI/KBShortcutsDialog.cpp | 3 +++ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 078625ccfde..d67269be221 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -3221,8 +3221,8 @@ void GLCanvas3D::on_char(wxKeyEvent& evt) // } // break; //} - //case 'I': - //case 'i': { _update_camera_zoom(1.0); break; } + case 'I': + case 'i': { _update_camera_zoom(1.0); break; } //case 'K': //case 'k': { wxGetApp().plater()->get_camera().select_next_type(); m_dirty = true; break; } //case 'L': @@ -3234,8 +3234,8 @@ void GLCanvas3D::on_char(wxKeyEvent& evt) //} //break; //} - //case 'O': - //case 'o': { _update_camera_zoom(-1.0); break; } + case 'O': + case 'o': { _update_camera_zoom(-1.0); break; } //case 'Z': //case 'z': { // if (!m_selection.is_empty()) diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index 7ab41bb4fa7..a30f87d31ed 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -388,15 +388,24 @@ bool GLGizmosManager::is_running() const bool GLGizmosManager::handle_shortcut(int key) { - if (!m_enabled || m_parent.get_selection().is_empty()) + if (!m_enabled) return false; - auto it = std::find_if(m_gizmos.begin(), m_gizmos.end(), - [key](const std::unique_ptr& gizmo) { - int gizmo_key = gizmo->get_shortcut_key(); - return gizmo->is_activable() - && ((gizmo_key == key - 64) || (gizmo_key == key - 96)); - }); + auto is_key = [pressed_key = key](int gizmo_key) { return (gizmo_key == pressed_key - 64) || (gizmo_key == pressed_key - 96); }; + // allowe open shortcut even when selection is empty + if (GLGizmoBase* gizmo_emboss = m_gizmos[Emboss].get(); + is_key(gizmo_emboss->get_shortcut_key())) { + dynamic_cast(gizmo_emboss)->on_shortcut_key(); + return true; + } + + if (m_parent.get_selection().is_empty()) + return false; + + auto is_gizmo = [is_key](const std::unique_ptr &gizmo) { + return gizmo->is_activable() && is_key(gizmo->get_shortcut_key()); + }; + auto it = std::find_if(m_gizmos.begin(), m_gizmos.end(), is_gizmo); if (it == m_gizmos.end()) return false; diff --git a/src/slic3r/GUI/KBShortcutsDialog.cpp b/src/slic3r/GUI/KBShortcutsDialog.cpp index 3a85d704337..7ad3e36cacf 100644 --- a/src/slic3r/GUI/KBShortcutsDialog.cpp +++ b/src/slic3r/GUI/KBShortcutsDialog.cpp @@ -258,6 +258,9 @@ void KBShortcutsDialog::fill_shortcuts() { "F", L("Gizmo Place face on bed") }, { "L", L("Gizmo SLA support points") }, { "P", L("Gizmo FDM paint-on seam") }, + { "T", L("Gizmo Text emboss / engrave")}, + { "I", L("Zoom in")}, + { "O", L("Zoom out")}, { "Tab", L("Switch between Prepare/Preview") }, };