From 661086554af7d255f51438e3d4e26d0a70241655 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 19 Dec 2018 13:06:24 +0100 Subject: [PATCH] Added "Keyboard Shortcuts" dialog --- src/slic3r/CMakeLists.txt | 2 + src/slic3r/GUI/GUI_App.cpp | 8 ++ src/slic3r/GUI/GUI_App.hpp | 1 + src/slic3r/GUI/KBShortcutsDialog.cpp | 152 +++++++++++++++++++++++++++ src/slic3r/GUI/KBShortcutsDialog.hpp | 32 ++++++ src/slic3r/GUI/MainFrame.cpp | 3 + 6 files changed, 198 insertions(+) create mode 100644 src/slic3r/GUI/KBShortcutsDialog.cpp create mode 100644 src/slic3r/GUI/KBShortcutsDialog.hpp diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index 3b6bad16d8..d794214390 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -10,6 +10,8 @@ add_library(libslic3r_gui STATIC GUI/AboutDialog.hpp GUI/SysInfoDialog.cpp GUI/SysInfoDialog.hpp + GUI/KBShortcutsDialog.cpp + GUI/KBShortcutsDialog.hpp GUI/AppConfig.cpp GUI/AppConfig.hpp GUI/BackgroundSlicingProcess.cpp diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index e4db9b6e1a..88c77c1937 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -35,6 +35,7 @@ #include "Preferences.hpp" #include "Tab.hpp" #include "SysInfoDialog.hpp" +#include "KBShortcutsDialog.hpp" namespace Slic3r { namespace GUI { @@ -301,6 +302,13 @@ void GUI_App::system_info() dlg.Destroy(); } +void GUI_App::keyboard_shortcuts() +{ + KBShortcutsDialog dlg; + dlg.ShowModal(); + dlg.Destroy(); +} + // static method accepting a wxWindow object as first parameter bool GUI_App::catch_error(std::function cb, // wxMessageDialog* message_dialog, diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 3c2b4a21fa..81175b7cac 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -115,6 +115,7 @@ public: void recreate_GUI(); void system_info(); + void keyboard_shortcuts(); void load_project(wxWindow *parent, wxString& input_file); void import_model(wxWindow *parent, wxArrayString& input_files); static bool catch_error(std::function cb, diff --git a/src/slic3r/GUI/KBShortcutsDialog.cpp b/src/slic3r/GUI/KBShortcutsDialog.cpp new file mode 100644 index 0000000000..25419b4383 --- /dev/null +++ b/src/slic3r/GUI/KBShortcutsDialog.cpp @@ -0,0 +1,152 @@ +#include "KBShortcutsDialog.hpp" +#include "I18N.hpp" +#include "..\libslic3r\Utils.hpp" +#include "GUI.hpp" +#include + +namespace Slic3r { +namespace GUI { + +KBShortcutsDialog::KBShortcutsDialog() + : wxDialog(NULL, wxID_ANY, _(L("Slic3r Prusa Edition - Keyboard Shortcuts")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER) +{ + SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); + + auto main_sizer = new wxBoxSizer(wxVERTICAL); + + // logo + wxBitmap logo_bmp = wxBitmap(from_u8(Slic3r::var("Slic3r_32px.png")), wxBITMAP_TYPE_PNG); + + // fonts + wxFont head_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold(); + head_font.SetPointSize(19); + + wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + font.SetPointSize(10); + const wxFont bold_font = font.Bold(); +#ifdef __WXOSX__ + font.SetPointSize(12); + bold_font.SetPointSize(14); +#endif /*__WXOSX__*/ + + fill_shortcuts(); + + auto panel = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxSize(500, 600)); + panel->SetScrollbars(0, 20, 1, 2); + auto sizer = new wxBoxSizer(wxVERTICAL); + panel->SetSizer(sizer); + main_sizer->Add(panel, 1, wxEXPAND | wxALL, 0); + + for (auto& sc : m_full_shortcuts) + { + wxBoxSizer* hsizer = new wxBoxSizer(wxHORIZONTAL); + sizer->Add(hsizer, 0, wxEXPAND | wxTOP, 25); + + // logo + auto *logo = new wxStaticBitmap(panel, wxID_ANY, logo_bmp); + hsizer->Add(logo, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); + + // head + wxStaticText* head = new wxStaticText(panel, wxID_ANY, sc.first, wxDefaultPosition, wxSize(400,-1)); + head->SetFont(head_font); + hsizer->Add(head, 0, wxALIGN_CENTER_VERTICAL); + + // Shortcuts list + auto grid_sizer = new wxFlexGridSizer(2, 10, 25); + sizer->Add(grid_sizer, 0, wxEXPAND | wxLEFT | wxTOP, 10); + + for (auto pair : sc.second) + { + auto shortcut = new wxStaticText(panel, wxID_ANY, _(pair.first)); + shortcut->SetFont(bold_font); + grid_sizer->Add(shortcut, -1, wxALIGN_CENTRE_VERTICAL); + + auto description = new wxStaticText(panel, wxID_ANY, _(pair.second)); + description->SetFont(font); + grid_sizer->Add(description, -1, wxALIGN_CENTRE_VERTICAL); + } + } + + wxStdDialogButtonSizer* buttons = this->CreateStdDialogButtonSizer(wxOK); + + this->SetEscapeId(wxID_CLOSE); + this->Bind(wxEVT_BUTTON, &KBShortcutsDialog::onCloseDialog, this, wxID_OK); + main_sizer->Add(buttons, 0, wxEXPAND | wxALL, 15); + + this->Bind(wxEVT_LEFT_DOWN, &KBShortcutsDialog::onCloseDialog, this); + + SetSizer(main_sizer); + main_sizer->SetSizeHints(this); +} + +void KBShortcutsDialog::fill_shortcuts() +{ + Shortcuts main_shortcuts; + main_shortcuts.reserve(25); + + main_shortcuts.push_back(Shortcut("Ctrl+O", L("Open project STL/OBJ/AMF/3MF with config, delete bed"))); + main_shortcuts.push_back(Shortcut("Ctrl+I", L("Import STL//OBJ/AMF/3MF without config, keep bed"))); + main_shortcuts.push_back(Shortcut("Ctrl+L", L("Load Config from .ini/amf/3mf/gcode"))); + main_shortcuts.push_back(Shortcut("Ctrl+Alt+L", L("Load Config from .ini/amf/3mf/gcode and merge"))); + main_shortcuts.push_back(Shortcut("Ctrl+G", L("Export Gcode"))); + main_shortcuts.push_back(Shortcut("Ctrl+S", L("Save project (3MF)"))); + main_shortcuts.push_back(Shortcut("Ctrl+R", L("(Re)slice"))); + main_shortcuts.push_back(Shortcut("Ctrl+U", L("Quick slice"))); + main_shortcuts.push_back(Shortcut("Ctrl+Alt+U", L("Quick slice and Save as"))); + main_shortcuts.push_back(Shortcut("Ctrl+Shift+U", L("Repeat last quick slice"))); + main_shortcuts.push_back(Shortcut("Ctrl+1", L("Select Plater Tab"))); + main_shortcuts.push_back(Shortcut("Ctrl+2", L("Select Print Settings Tab"))); + main_shortcuts.push_back(Shortcut("Ctrl+3", L("Select Filament Setting Tab"))); + main_shortcuts.push_back(Shortcut("Ctrl+4", L("Select Printer Setting Tab"))); + main_shortcuts.push_back(Shortcut("Ctrl+5", L("Switch to 3D"))); + main_shortcuts.push_back(Shortcut("Ctrl+6", L("Switch to Preview"))); + main_shortcuts.push_back(Shortcut("Ctrl+P", L("Preferences"))); + main_shortcuts.push_back(Shortcut("0-6", L("Camera view "))); + main_shortcuts.push_back(Shortcut("+", L("Add Instance to selected object "))); + main_shortcuts.push_back(Shortcut("-", L("Remove Instance from selected object"))); + main_shortcuts.push_back(Shortcut("PgUp/PgDn", L("Switch between 3D and Preview"))); + main_shortcuts.push_back(Shortcut("Shift+LeftMouse",L("Select multiple object/Move multiple object"))); + + m_full_shortcuts.emplace(_(L("Main Shortcuts")), main_shortcuts); + + + Shortcuts plater_shortcuts; + plater_shortcuts.reserve(20); + + plater_shortcuts.push_back(Shortcut("A", L("Arrange"))); + plater_shortcuts.push_back(Shortcut("Ctrl+A", L("Select All objects"))); + plater_shortcuts.push_back(Shortcut("Del", L("Delete selected"))); + plater_shortcuts.push_back(Shortcut("Ctrl+Del", L("Delete all"))); + plater_shortcuts.push_back(Shortcut("M", L("Gizmo move"))); + plater_shortcuts.push_back(Shortcut("S", L("Gizmo scale"))); + plater_shortcuts.push_back(Shortcut("R", L("Gizmo rotate"))); + plater_shortcuts.push_back(Shortcut("C", L("Gizmo cut"))); + plater_shortcuts.push_back(Shortcut("F", L("Gizmo Place face on bed"))); + plater_shortcuts.push_back(Shortcut("L", L("Gizmo SLA support points"))); + plater_shortcuts.push_back(Shortcut("B", L("Zoom to Bed"))); + plater_shortcuts.push_back(Shortcut("Z", L("Zoom to all objects in scene, if none selected"))); + plater_shortcuts.push_back(Shortcut("Z", L("Zoom to selected object"))); + plater_shortcuts.push_back(Shortcut("I", L("Zoom in"))); + plater_shortcuts.push_back(Shortcut("O", L("Zoom out"))); + plater_shortcuts.push_back(Shortcut("ESC", L("Unselect gizmo, keep object selection"))); + + m_full_shortcuts.emplace(_(L("Plater Shortcuts")), plater_shortcuts); + + + Shortcuts preview_shortcuts; + preview_shortcuts.reserve(2); + + preview_shortcuts.push_back(Shortcut(L("Arrow Up"), L("Upper Layer"))); + preview_shortcuts.push_back(Shortcut(L("Arrow Down"), L("Lower Layer"))); + + m_full_shortcuts.emplace(_(L("Preview Shortcuts")), preview_shortcuts); +} + +void KBShortcutsDialog::onCloseDialog(wxEvent &) +{ + this->EndModal(wxID_CLOSE); + this->Close(); +} + +} // namespace GUI +} // namespace Slic3r diff --git a/src/slic3r/GUI/KBShortcutsDialog.hpp b/src/slic3r/GUI/KBShortcutsDialog.hpp new file mode 100644 index 0000000000..8517544b57 --- /dev/null +++ b/src/slic3r/GUI/KBShortcutsDialog.hpp @@ -0,0 +1,32 @@ +#ifndef slic3r_GUI_KBShortcutsDialog_hpp_ +#define slic3r_GUI_KBShortcutsDialog_hpp_ + +#include +#include + +namespace Slic3r { +namespace GUI { + +class KBShortcutsDialog : public wxDialog +{ + typedef std::pair Shortcut; + typedef std::vector< Shortcut > Shortcuts; + typedef std::map ShortcutsMap; + + wxString text_info {wxEmptyString}; + + ShortcutsMap m_full_shortcuts; + +public: + KBShortcutsDialog(); + + void fill_shortcuts(); + +private: + void onCloseDialog(wxEvent &); +}; + +} // namespace GUI +} // namespace Slic3r + +#endif diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 4d4ee17aeb..2211023f06 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -432,6 +432,9 @@ void MainFrame::init_menubar() [this](wxCommandEvent&) { wxLaunchDefaultBrowser("http://github.com/prusa3d/slic3r/issues/new"); }); append_menu_item(helpMenu, wxID_ANY, _(L("About Slic3r")), _(L("Show about dialog")), [this](wxCommandEvent&) { Slic3r::GUI::about(); }); + helpMenu->AppendSeparator(); + append_menu_item(helpMenu, wxID_ANY, _(L("Keyboard Shortcuts")) + "\t?", _(L("Show the list of the keyboard shortcuts")), + [this](wxCommandEvent&) { wxGetApp().keyboard_shortcuts(); }); } // menubar