From e01576a4e3da86f57626a19db084036c87127b31 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Fri, 11 Sep 2020 20:29:58 +0200 Subject: [PATCH 1/6] Document "Tab" in the keyboard shortcuts dialog --- src/slic3r/GUI/KBShortcutsDialog.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/slic3r/GUI/KBShortcutsDialog.cpp b/src/slic3r/GUI/KBShortcutsDialog.cpp index f2cc6f5a65c..98b354ed4e4 100644 --- a/src/slic3r/GUI/KBShortcutsDialog.cpp +++ b/src/slic3r/GUI/KBShortcutsDialog.cpp @@ -140,6 +140,7 @@ void KBShortcutsDialog::fill_shortcuts() // View { "0-6", L("Camera view") }, { "E", L("Show/Hide object/instance labels") }, + { "Tab", L("Switch between Editor/Preview") }, // Configuration { ctrl + "P", L("Preferences") }, // Help From 026dccf75fd7e63726157bef7e9a7e224055662d Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Fri, 11 Sep 2020 20:33:27 +0200 Subject: [PATCH 2/6] Handle Shift+Tab to collapse/expand the sidebar --- src/slic3r/GUI/GLCanvas3D.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 36bbb273f49..e87fa383d92 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -3214,6 +3214,10 @@ void GLCanvas3D::on_key(wxKeyEvent& evt) // m_canvas->HandleAsNavigationKey(evt); // XXX: Doesn't work in some cases / on Linux post_event(SimpleEvent(EVT_GLCANVAS_TAB)); } + else if (keyCode == WXK_TAB && evt.ShiftDown()) { + // Collapse side-panel with Shift+Tab + post_event(SimpleEvent(EVT_GLCANVAS_COLLAPSE_SIDEBAR)); + } else if (keyCode == WXK_SHIFT) { translationProcessor.process(evt); From 56918135107aea48822308330af43eb6c47aa21e Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Fri, 11 Sep 2020 21:16:25 +0200 Subject: [PATCH 3/6] Handle Shift+Tab also in the preview --- src/slic3r/GUI/Plater.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index c28df81d811..498824d4e5c 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1952,6 +1952,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_QUESTION_MARK, [this](SimpleEvent&) { wxGetApp().keyboard_shortcuts(); }); preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_UPDATE_BED_SHAPE, [q](SimpleEvent&) { q->set_bed_shape(); }); preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_TAB, [this](SimpleEvent&) { select_next_view_3D(); }); + preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_COLLAPSE_SIDEBAR, [this](SimpleEvent&) { this->q->collapse_sidebar(!this->q->is_sidebar_collapsed()); }); #if ENABLE_GCODE_VIEWER preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_MOVE_LAYERS_SLIDER, [this](wxKeyEvent& evt) { preview->move_layers_slider(evt); }); preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_EDIT_COLOR_CHANGE, [this](wxKeyEvent& evt) { preview->edit_layers_slider(evt); }); From 1653ba55046c9e34c4093e06a0e2d248b2a31fde Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Fri, 11 Sep 2020 21:17:09 +0200 Subject: [PATCH 4/6] Fix the collapse tooltip (uniform to "sidebar", show hotkey) Sidebar is used everywhere else, so change "right panel" to "sidebar" in collapse button. Also show the hotkey, as done for "Tab" --- src/slic3r/GUI/Plater.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 498824d4e5c..880eddafbf6 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -4075,23 +4075,26 @@ bool Plater::priv::init_collapse_toolbar() GLToolbarItem::Data item; - item.name = "collapse_sidebar"; - item.icon_filename = "collapse.svg"; - item.tooltip = wxGetApp().plater()->is_sidebar_collapsed() ? _utf8(L("Expand right panel")) : _utf8(L("Collapse right panel")); - item.sprite_id = 0; - item.left.action_callback = [this, item]() { - std::string new_tooltip = wxGetApp().plater()->is_sidebar_collapsed() ? - _utf8(L("Collapse right panel")) : _utf8(L("Expand right panel")); - + auto item_tooltip_update = [this, item](bool flip) { + std::string new_tooltip = wxGetApp().plater()->is_sidebar_collapsed() ^ flip? + _utf8(L("Expand sidebar")) : _utf8(L("Collapse sidebar")); + new_tooltip += " [Shift+Tab]"; int id = collapse_toolbar.get_item_id("collapse_sidebar"); collapse_toolbar.set_tooltip(id, new_tooltip); + }; + item.name = "collapse_sidebar"; + item.icon_filename = "collapse.svg"; + item.sprite_id = 0; + item.left.action_callback = [this, item_tooltip_update]() { + item_tooltip_update(true); wxGetApp().plater()->collapse_sidebar(!wxGetApp().plater()->is_sidebar_collapsed()); }; if (!collapse_toolbar.add_item(item)) return false; + item_tooltip_update(false); return true; } From e494d89524c73b8be9d4224faa28529a6db98827 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Fri, 11 Sep 2020 21:18:43 +0200 Subject: [PATCH 5/6] Document Shift+Tab in menus and shortcuts dialog --- src/slic3r/GUI/KBShortcutsDialog.cpp | 1 + src/slic3r/GUI/MainFrame.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/KBShortcutsDialog.cpp b/src/slic3r/GUI/KBShortcutsDialog.cpp index 98b354ed4e4..afa7172df5c 100644 --- a/src/slic3r/GUI/KBShortcutsDialog.cpp +++ b/src/slic3r/GUI/KBShortcutsDialog.cpp @@ -141,6 +141,7 @@ void KBShortcutsDialog::fill_shortcuts() { "0-6", L("Camera view") }, { "E", L("Show/Hide object/instance labels") }, { "Tab", L("Switch between Editor/Preview") }, + { "Shift+Tab", L("Collapse/Expand the sidebar") }, // Configuration { ctrl + "P", L("Preferences") }, // Help diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 1448e036375..00933d1cbc8 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -1295,7 +1295,7 @@ void MainFrame::init_menubar() append_menu_check_item(viewMenu, wxID_ANY, _L("Show &labels") + sep + "E", _L("Show object/instance labels in 3D scene"), [this](wxCommandEvent&) { m_plater->show_view3D_labels(!m_plater->are_view3D_labels_shown()); }, this, [this]() { return m_plater->is_view3D_shown(); }, [this]() { return m_plater->are_view3D_labels_shown(); }, this); - append_menu_check_item(viewMenu, wxID_ANY, _L("&Collapse sidebar"), _L("Collapse sidebar"), + append_menu_check_item(viewMenu, wxID_ANY, _L("&Collapse sidebar") + sep + "Shift+Tab", _L("Collapse sidebar"), [this](wxCommandEvent&) { m_plater->collapse_sidebar(!m_plater->is_sidebar_collapsed()); }, this, []() { return true; }, [this]() { return m_plater->is_sidebar_collapsed(); }, this); } From 08f1efb3f5a2af0fb3bdd01a4915df9a71169ffc Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Sat, 10 Oct 2020 21:58:11 +0200 Subject: [PATCH 6/6] Fix of tooltip updating when sidebar is being hidden/shown The tooltip would only update when the toolbar was clicked, not when respective menu item or keyboard shortcut were used --- src/slic3r/GUI/Plater.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 880eddafbf6..9a6334459f6 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1597,7 +1597,7 @@ struct Plater::priv void show_view3D_labels(bool show) { if (current_panel == view3D) view3D->get_canvas3d()->show_labels(show); } bool is_sidebar_collapsed() const { return sidebar->is_collapsed(); } - void collapse_sidebar(bool show) { sidebar->collapse(show); } + void collapse_sidebar(bool collapse); bool is_view3D_layers_editing_enabled() const { return (current_panel == view3D) && view3D->get_canvas3d()->is_layers_editing_enabled(); } @@ -2128,6 +2128,20 @@ void Plater::priv::select_next_view_3D() set_current_panel(view3D); } +void Plater::priv::collapse_sidebar(bool collapse) +{ + sidebar->collapse(collapse); + + // Now update the tooltip in the toolbar. + std::string new_tooltip = collapse + ? _utf8(L("Expand sidebar")) + : _utf8(L("Collapse sidebar")); + new_tooltip += " [Shift+Tab]"; + int id = collapse_toolbar.get_item_id("collapse_sidebar"); + collapse_toolbar.set_tooltip(id, new_tooltip); +} + + void Plater::priv::reset_all_gizmos() { view3D->get_canvas3d()->reset_all_gizmos(); @@ -4075,26 +4089,19 @@ bool Plater::priv::init_collapse_toolbar() GLToolbarItem::Data item; - auto item_tooltip_update = [this, item](bool flip) { - std::string new_tooltip = wxGetApp().plater()->is_sidebar_collapsed() ^ flip? - _utf8(L("Expand sidebar")) : _utf8(L("Collapse sidebar")); - new_tooltip += " [Shift+Tab]"; - int id = collapse_toolbar.get_item_id("collapse_sidebar"); - collapse_toolbar.set_tooltip(id, new_tooltip); - }; - item.name = "collapse_sidebar"; item.icon_filename = "collapse.svg"; item.sprite_id = 0; - item.left.action_callback = [this, item_tooltip_update]() { - item_tooltip_update(true); + item.left.action_callback = []() { wxGetApp().plater()->collapse_sidebar(!wxGetApp().plater()->is_sidebar_collapsed()); }; if (!collapse_toolbar.add_item(item)) return false; - item_tooltip_update(false); + // Now "collapse" sidebar to current state. This is done so the tooltip + // is updated before the toolbar is first used. + wxGetApp().plater()->collapse_sidebar(wxGetApp().plater()->is_sidebar_collapsed()); return true; }