2018-12-19 12:06:24 +00:00
# include "KBShortcutsDialog.hpp"
# include "I18N.hpp"
2018-12-19 13:01:13 +00:00
# include "libslic3r/Utils.hpp"
2018-12-19 12:06:24 +00:00
# include "GUI.hpp"
# include <wx/scrolwin.h>
2018-12-20 11:52:16 +00:00
# include "GUI_App.hpp"
2019-02-11 13:14:35 +00:00
# include "wxExtensions.hpp"
2018-12-19 12:06:24 +00:00
2019-08-06 14:53:17 +00:00
namespace Slic3r {
2018-12-19 12:06:24 +00:00
namespace GUI {
KBShortcutsDialog : : KBShortcutsDialog ( )
2019-08-06 14:53:17 +00:00
: DPIDialog ( NULL , wxID_ANY , wxString ( SLIC3R_APP_NAME ) + " - " + _ ( L ( " Keyboard Shortcuts " ) ) ,
2019-04-18 00:03:40 +00:00
wxDefaultPosition , wxDefaultSize , wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
2018-12-19 12:06:24 +00:00
{
2019-08-06 14:53:17 +00:00
SetBackgroundColour ( wxSystemSettings : : GetColour ( wxSYS_COLOUR_WINDOW ) ) ;
2018-12-19 12:06:24 +00:00
2019-08-06 14:53:17 +00:00
auto main_sizer = new wxBoxSizer ( wxVERTICAL ) ;
2018-12-19 12:06:24 +00:00
// logo
2019-05-13 10:13:28 +00:00
m_logo_bmp = ScalableBitmap ( this , " PrusaSlicer_32px.png " , 32 ) ;
2018-12-19 12:06:24 +00:00
// fonts
2019-04-18 13:05:17 +00:00
const wxFont & font = wxGetApp ( ) . normal_font ( ) ;
2019-08-06 14:53:17 +00:00
const wxFont & bold_font = wxGetApp ( ) . bold_font ( ) ;
2019-04-18 13:05:17 +00:00
SetFont ( font ) ;
2019-04-24 23:45:00 +00:00
wxFont head_font = bold_font ;
2018-12-19 12:06:24 +00:00
# ifdef __WXOSX__
2018-12-20 11:52:16 +00:00
head_font . SetPointSize ( 14 ) ;
# else
2019-04-24 23:45:00 +00:00
head_font . SetPointSize ( bold_font . GetPointSize ( ) + 2 ) ;
2018-12-20 11:52:16 +00:00
# endif // __WXOSX__
2018-12-19 12:06:24 +00:00
fill_shortcuts ( ) ;
2019-08-23 11:21:56 +00:00
panel = new wxScrolledWindow ( this , wxID_ANY , wxDefaultPosition , get_size ( ) ) ;
2019-08-23 07:43:38 +00:00
panel - > SetScrollbars ( 1 , 20 , 1 , 2 ) ;
2018-12-20 11:52:16 +00:00
auto main_grid_sizer = new wxFlexGridSizer ( 2 , 10 , 10 ) ;
panel - > SetSizer ( main_grid_sizer ) ;
2018-12-19 12:06:24 +00:00
main_sizer - > Add ( panel , 1 , wxEXPAND | wxALL , 0 ) ;
2018-12-20 11:52:16 +00:00
wxBoxSizer * l_sizer = new wxBoxSizer ( wxVERTICAL ) ;
main_grid_sizer - > Add ( l_sizer , 0 ) ;
wxBoxSizer * r_sizer = new wxBoxSizer ( wxVERTICAL ) ;
main_grid_sizer - > Add ( r_sizer , 0 ) ;
2019-04-18 00:03:40 +00:00
m_head_bitmaps . reserve ( m_full_shortcuts . size ( ) ) ;
2019-05-04 00:07:07 +00:00
for ( auto & shortcut : m_full_shortcuts )
2018-12-19 12:06:24 +00:00
{
2019-05-04 00:07:07 +00:00
auto sizer = shortcut . second . second = = szLeft ? l_sizer : r_sizer ;
2018-12-19 12:06:24 +00:00
wxBoxSizer * hsizer = new wxBoxSizer ( wxHORIZONTAL ) ;
2018-12-20 11:52:16 +00:00
sizer - > Add ( hsizer , 0 , wxEXPAND | wxTOP | wxBOTTOM , 10 ) ;
2018-12-19 12:06:24 +00:00
// logo
2019-04-18 00:03:40 +00:00
m_head_bitmaps . push_back ( new wxStaticBitmap ( panel , wxID_ANY , m_logo_bmp . bmp ( ) ) ) ;
hsizer - > Add ( m_head_bitmaps . back ( ) , 0 , wxEXPAND | wxLEFT | wxRIGHT , 15 ) ;
2018-12-19 12:06:24 +00:00
// head
2019-05-15 13:41:12 +00:00
wxStaticText * head = new wxStaticText ( panel , wxID_ANY , shortcut . first ) ;
2018-12-19 12:06:24 +00:00
head - > SetFont ( head_font ) ;
hsizer - > Add ( head , 0 , wxALIGN_CENTER_VERTICAL ) ;
2019-04-18 00:03:40 +00:00
2018-12-19 12:06:24 +00:00
// Shortcuts list
2018-12-20 11:52:16 +00:00
auto grid_sizer = new wxFlexGridSizer ( 2 , 5 , 15 ) ;
sizer - > Add ( grid_sizer , 0 , wxEXPAND | wxLEFT | wxRIGHT , 15 ) ;
2018-12-19 12:06:24 +00:00
2019-05-04 00:07:07 +00:00
for ( auto pair : shortcut . second . first )
2018-12-19 12:06:24 +00:00
{
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 ) ;
}
}
2019-08-06 14:53:17 +00:00
2018-12-19 12:06:24 +00:00
wxStdDialogButtonSizer * buttons = this - > CreateStdDialogButtonSizer ( wxOK ) ;
2018-12-20 11:52:16 +00:00
this - > SetEscapeId ( wxID_OK ) ;
2018-12-19 12:06:24 +00:00
this - > Bind ( wxEVT_BUTTON , & KBShortcutsDialog : : onCloseDialog , this , wxID_OK ) ;
2018-12-20 11:52:16 +00:00
main_sizer - > Add ( buttons , 0 , wxEXPAND | wxRIGHT | wxBOTTOM , 15 ) ;
2019-08-06 14:53:17 +00:00
2018-12-19 12:06:24 +00:00
this - > Bind ( wxEVT_LEFT_DOWN , & KBShortcutsDialog : : onCloseDialog , this ) ;
2019-08-06 14:53:17 +00:00
SetSizer ( main_sizer ) ;
main_sizer - > SetSizeHints ( this ) ;
2018-12-19 12:06:24 +00:00
}
void KBShortcutsDialog : : fill_shortcuts ( )
{
2019-02-03 10:10:25 +00:00
const std : : string & ctrl = GUI : : shortkey_ctrl_prefix ( ) ;
const std : : string & alt = GUI : : shortkey_alt_prefix ( ) ;
2018-12-20 11:52:16 +00:00
2019-01-31 12:21:17 +00:00
m_full_shortcuts . reserve ( 4 ) ;
2018-12-19 12:06:24 +00:00
Shortcuts main_shortcuts ;
main_shortcuts . reserve ( 25 ) ;
2018-12-20 11:52:16 +00:00
main_shortcuts . push_back ( Shortcut ( ctrl + " O " , L ( " Open project STL/OBJ/AMF/3MF with config, delete bed " ) ) ) ;
2018-12-21 08:19:00 +00:00
main_shortcuts . push_back ( Shortcut ( ctrl + " I " , L ( " Import STL/OBJ/AMF/3MF without config, keep bed " ) ) ) ;
2018-12-20 11:52:16 +00:00
main_shortcuts . push_back ( Shortcut ( ctrl + " L " , L ( " Load Config from .ini/amf/3mf/gcode " ) ) ) ;
2019-01-21 11:34:28 +00:00
main_shortcuts . push_back ( Shortcut ( ctrl + " G " , L ( " Export G-code " ) ) ) ;
2018-12-20 11:52:16 +00:00
main_shortcuts . push_back ( Shortcut ( ctrl + " S " , L ( " Save project (3MF) " ) ) ) ;
main_shortcuts . push_back ( Shortcut ( ctrl + alt + " L " , L ( " Load Config from .ini/amf/3mf/gcode and merge " ) ) ) ;
main_shortcuts . push_back ( Shortcut ( ctrl + " R " , L ( " (Re)slice " ) ) ) ;
2019-04-24 09:01:59 +00:00
// main_shortcuts.push_back(Shortcut(ctrl+"U" ,L("Quick slice")));
// main_shortcuts.push_back(Shortcut(ctrl+"Shift+U" ,L("Repeat last quick slice")));
2018-12-20 11:52:16 +00:00
main_shortcuts . push_back ( Shortcut ( ctrl + " 1 " , L ( " Select Plater Tab " ) ) ) ;
2019-05-09 16:18:21 +00:00
// main_shortcuts.push_back(Shortcut(ctrl+alt+"U" ,L("Quick slice and Save as")));
2018-12-20 11:52:16 +00:00
main_shortcuts . push_back ( Shortcut ( ctrl + " 2 " , L ( " Select Print Settings Tab " ) ) ) ;
2019-01-21 11:34:28 +00:00
main_shortcuts . push_back ( Shortcut ( ctrl + " 3 " , L ( " Select Filament Settings Tab " ) ) ) ;
main_shortcuts . push_back ( Shortcut ( ctrl + " 4 " , L ( " Select Printer Settings Tab " ) ) ) ;
2018-12-20 11:52:16 +00:00
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 " ) ) ) ;
2019-01-10 16:52:14 +00:00
main_shortcuts . push_back ( Shortcut ( ctrl + " J " , L ( " Print host upload queue " ) ) ) ;
2019-05-09 13:39:15 +00:00
main_shortcuts . push_back ( Shortcut ( " 0-6 " , L ( " Camera view " ) ) ) ;
main_shortcuts . push_back ( Shortcut ( " + " , L ( " Add Instance of the selected object " ) ) ) ;
main_shortcuts . push_back ( Shortcut ( " - " , L ( " Remove Instance of the selected object " ) ) ) ;
2018-12-20 11:52:16 +00:00
main_shortcuts . push_back ( Shortcut ( " ? " , L ( " Show keyboard shortcuts list " ) ) ) ;
2019-05-04 00:07:07 +00:00
main_shortcuts . push_back ( Shortcut ( ctrl /*+"LeftMouse"*/ , L ( " Press to select multiple object or move multiple object with mouse " ) ) ) ;
2018-12-19 12:06:24 +00:00
2019-04-18 00:03:40 +00:00
m_full_shortcuts . push_back ( std : : make_pair ( _ ( L ( " Main Shortcuts " ) ) , std : : make_pair ( main_shortcuts , szLeft ) ) ) ;
2018-12-19 12:06:24 +00:00
Shortcuts plater_shortcuts ;
plater_shortcuts . reserve ( 20 ) ;
plater_shortcuts . push_back ( Shortcut ( " A " , L ( " Arrange " ) ) ) ;
2019-08-06 14:53:17 +00:00
plater_shortcuts . push_back ( Shortcut ( " Shift+A " , L ( " Arrange selection " ) ) ) ;
2018-12-20 11:52:16 +00:00
plater_shortcuts . push_back ( Shortcut ( ctrl + " A " , L ( " Select All objects " ) ) ) ;
2018-12-19 12:06:24 +00:00
plater_shortcuts . push_back ( Shortcut ( " Del " , L ( " Delete selected " ) ) ) ;
2019-01-21 11:34:28 +00:00
plater_shortcuts . push_back ( Shortcut ( ctrl + " Del " , L ( " Delete All " ) ) ) ;
2019-04-16 11:47:37 +00:00
plater_shortcuts . push_back ( Shortcut ( ctrl + " C " , L ( " Copy to clipboard " ) ) ) ;
plater_shortcuts . push_back ( Shortcut ( ctrl + " V " , L ( " Paste from clipboard " ) ) ) ;
2018-12-19 12:06:24 +00:00
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 " ) ) ) ;
2019-05-14 13:16:37 +00:00
plater_shortcuts . push_back ( Shortcut ( " Shift+ " , L ( " Press to activate selection rectangle \n or to snap by 5% in Gizmo scale \n or to snap by 1mm in Gizmo move " ) ) ) ;
2019-05-24 13:53:15 +00:00
plater_shortcuts . push_back ( Shortcut ( " F " , L ( " Press to scale selection to fit print volume \n in Gizmo scale " ) ) ) ;
2019-05-14 13:16:37 +00:00
plater_shortcuts . push_back ( Shortcut ( alt , L ( " Press to activate deselection rectangle \n or to scale or rotate selected objects \n around their own center " ) ) ) ;
plater_shortcuts . push_back ( Shortcut ( ctrl , L ( " Press to activate one direction scaling in Gizmo scale " ) ) ) ;
2019-06-19 12:33:09 +00:00
plater_shortcuts . push_back ( Shortcut ( " K " , L ( " Change camera type " ) ) ) ;
2018-12-19 12:06:24 +00:00
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 " ) ) ) ;
2019-05-14 13:16:37 +00:00
plater_shortcuts . push_back ( Shortcut ( " ESC " , L ( " Unselect gizmo / Clear selection " ) ) ) ;
2019-06-27 09:25:04 +00:00
# if ENABLE_RENDER_PICKING_PASS
plater_shortcuts . push_back ( Shortcut ( " T " , L ( " Toggle picking pass texture rendering on/off " ) ) ) ;
# endif // ENABLE_RENDER_PICKING_PASS
2018-12-19 12:06:24 +00:00
2019-04-18 00:03:40 +00:00
m_full_shortcuts . push_back ( std : : make_pair ( _ ( L ( " Plater Shortcuts " ) ) , std : : make_pair ( plater_shortcuts , szRight ) ) ) ;
2019-01-31 12:21:17 +00:00
// Shortcuts gizmo_shortcuts;
// gizmo_shortcuts.reserve(2);
2019-08-06 14:53:17 +00:00
//
2019-01-31 12:21:17 +00:00
// gizmo_shortcuts.push_back(Shortcut("Shift+", L("Press to snap by 5% in Gizmo Scale\n or by 1mm in Gizmo Move")));
// gizmo_shortcuts.push_back(Shortcut(alt, L("Press to scale or rotate selected objects around their own center")));
2019-08-06 14:53:17 +00:00
//
2019-01-31 12:21:17 +00:00
// m_full_shortcuts.push_back(std::make_pair(_(L("Gizmo Shortcuts")), std::make_pair(gizmo_shortcuts, 1)));
2018-12-19 12:06:24 +00:00
Shortcuts preview_shortcuts ;
2019-01-31 12:21:17 +00:00
preview_shortcuts . reserve ( 4 ) ;
2018-12-19 12:06:24 +00:00
preview_shortcuts . push_back ( Shortcut ( L ( " Arrow Up " ) , L ( " Upper Layer " ) ) ) ;
preview_shortcuts . push_back ( Shortcut ( L ( " Arrow Down " ) , L ( " Lower Layer " ) ) ) ;
2019-01-31 12:21:17 +00:00
preview_shortcuts . push_back ( Shortcut ( " U " , L ( " Upper Layer " ) ) ) ;
preview_shortcuts . push_back ( Shortcut ( " D " , L ( " Lower Layer " ) ) ) ;
2019-06-22 15:39:09 +00:00
preview_shortcuts . push_back ( Shortcut ( " L " , L ( " Show/Hide (L)egend " ) ) ) ;
2019-01-31 12:21:17 +00:00
2019-04-18 00:03:40 +00:00
m_full_shortcuts . push_back ( std : : make_pair ( _ ( L ( " Preview Shortcuts " ) ) , std : : make_pair ( preview_shortcuts , szLeft ) ) ) ;
2019-01-31 12:21:17 +00:00
Shortcuts layers_slider_shortcuts ;
layers_slider_shortcuts . reserve ( 6 ) ;
2019-04-16 11:53:57 +00:00
layers_slider_shortcuts . push_back ( Shortcut ( L ( " Arrow Up " ) , L ( " Move current slider thumb Up " ) ) ) ;
layers_slider_shortcuts . push_back ( Shortcut ( L ( " Arrow Down " ) , L ( " Move current slider thumb Down " ) ) ) ;
2019-01-31 12:21:17 +00:00
layers_slider_shortcuts . push_back ( Shortcut ( L ( " Arrow Left " ) , L ( " Set upper thumb to current slider thumb " ) ) ) ;
layers_slider_shortcuts . push_back ( Shortcut ( L ( " Arrow Right " ) , L ( " Set lower thumb to current slider thumb " ) ) ) ;
layers_slider_shortcuts . push_back ( Shortcut ( " + " , L ( " Add color change marker for current layer " ) ) ) ;
layers_slider_shortcuts . push_back ( Shortcut ( " - " , L ( " Delete color change marker for current layer " ) ) ) ;
2018-12-19 12:06:24 +00:00
2019-04-18 00:03:40 +00:00
m_full_shortcuts . push_back ( std : : make_pair ( _ ( L ( " Layers Slider Shortcuts " ) ) , std : : make_pair ( layers_slider_shortcuts , szRight ) ) ) ;
}
void KBShortcutsDialog : : on_dpi_changed ( const wxRect & suggested_rect )
{
2019-04-24 23:45:00 +00:00
m_logo_bmp . msw_rescale ( ) ;
2019-04-18 00:03:40 +00:00
for ( wxStaticBitmap * bmp : m_head_bitmaps )
bmp - > SetBitmap ( m_logo_bmp . bmp ( ) ) ;
2019-04-25 13:06:44 +00:00
const int em = em_unit ( ) ;
msw_buttons_rescale ( this , em , { wxID_OK } ) ;
2019-08-23 11:21:56 +00:00
wxSize size = get_size ( ) ;
2019-08-23 07:43:38 +00:00
panel - > SetMinSize ( size ) ;
2019-04-18 00:03:40 +00:00
SetMinSize ( size ) ;
2019-04-25 13:06:44 +00:00
Fit ( ) ;
2019-04-18 00:03:40 +00:00
Refresh ( ) ;
2018-12-19 12:06:24 +00:00
}
void KBShortcutsDialog : : onCloseDialog ( wxEvent & )
{
this - > EndModal ( wxID_CLOSE ) ;
}
2019-08-23 11:21:56 +00:00
wxSize KBShortcutsDialog : : get_size ( )
{
wxTopLevelWindow * window = Slic3r : : GUI : : find_toplevel_parent ( this ) ;
const int display_idx = wxDisplay : : GetFromWindow ( window ) ;
wxRect display ;
if ( display_idx = = wxNOT_FOUND ) {
display = wxDisplay ( 0u ) . GetClientArea ( ) ;
window - > Move ( display . GetTopLeft ( ) ) ;
}
else {
display = wxDisplay ( display_idx ) . GetClientArea ( ) ;
}
const int em = em_unit ( ) ;
wxSize dialog_size = wxSize ( 90 * em , 85 * em ) ;
const int margin = 10 * em ;
if ( dialog_size . x > display . GetWidth ( ) )
dialog_size . x = display . GetWidth ( ) - margin ;
if ( dialog_size . y > display . GetHeight ( ) )
dialog_size . y = display . GetHeight ( ) - margin ;
return dialog_size ;
}
2018-12-19 12:06:24 +00:00
} // namespace GUI
} // namespace Slic3r