From 0bcfa06b0963e996f17f7a9716fc325ec77e9ab7 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 f2cc6f5a6..98b354ed4 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 e9225a545e1e985a5ba02af83130d5dbdc28a8ec 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 36bbb273f..e87fa383d 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 732f371f4ff5a081b9f0f19c9a9eb74f157705dc 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 c28df81d8..498824d4e 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 2f642ce83ce1126e1cfd803d1bc0c1398101341a 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 498824d4e..880eddafb 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 a875b4f1c0d5e0f6755cc2ffa63e4687cd9d72fb 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 98b354ed4..afa7172df 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 1448e0363..00933d1cb 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 9755f82b90a55df77e282c06ea0728886bb0874c 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 880eddafb..9a6334459 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; }