PL Editor UI Improvements: Menubar, toolbar and hotkeys

This commit is contained in:
Michael Kavanagh 2017-08-29 16:07:48 +01:00 committed by Wayne Stambaugh
parent 55ce984f05
commit 82ce90ecdc
11 changed files with 169 additions and 77 deletions

View File

@ -83,7 +83,7 @@ const wxString LegacyFootprintLibPathWildcard( _( "Legacy footprint library file
const wxString EagleFootprintLibPathWildcard( _( "Eagle ver. 6.x XML library files (*.lbr)|*.lbr" ) );
const wxString GedaPcbFootprintLibFileWildcard( _( "Geda PCB footprint library file (*.fp)|*.fp" ) );
const wxString ComponentFileExtensionWildcard( _( "Component-footprint link file (*.cmp)|*cmp" ) );
const wxString PageLayoutDescrFileWildcard( _( "Page layout descr file (*.kicad_wks)|*kicad_wks" ) );
const wxString PageLayoutDescrFileWildcard( _( "Page layout design file (*.kicad_wks)|*kicad_wks" ) );
// generic:
const wxString AllFilesWildcard( _( "All files (*)|*" ) );

View File

@ -234,6 +234,11 @@ void ParseHotkeyConfig( const wxString& data, struct EDA_HOTKEY_CONFIG* aDescLis
// these hotkey ID are used in many files, so they are define here only once.
enum common_hotkey_id_commnand {
HK_NOT_FOUND = 0,
HK_NEW,
HK_OPEN,
HK_SAVE,
HK_SAVEAS,
HK_PRINT,
HK_RESET_LOCAL_COORD,
HK_SET_GRID_ORIGIN,
HK_RESET_GRID_ORIGIN,

View File

@ -62,7 +62,6 @@ BEGIN_EVENT_TABLE( PL_EDITOR_FRAME, EDA_DRAW_FRAME )
EVT_MENU( wxID_SAVE, PL_EDITOR_FRAME::Files_io )
EVT_MENU( wxID_SAVEAS, PL_EDITOR_FRAME::Files_io )
EVT_MENU( wxID_FILE, PL_EDITOR_FRAME::Files_io )
EVT_MENU( ID_LOAD_DEFAULT_PAGE_LAYOUT, PL_EDITOR_FRAME::Files_io )
EVT_MENU( ID_APPEND_DESCR_FILE, PL_EDITOR_FRAME::Files_io )
EVT_MENU( ID_GEN_PLOT, PL_EDITOR_FRAME::ToPlotter )

View File

@ -78,7 +78,6 @@ void PL_EDITOR_FRAME::Files_io( wxCommandEvent& event )
switch( id )
{
case ID_LOAD_DEFAULT_PAGE_LAYOUT:
case wxID_NEW:
case wxID_OPEN:
if( GetScreen()->IsModify() && !IsOK( this,
@ -94,11 +93,6 @@ void PL_EDITOR_FRAME::Files_io( wxCommandEvent& event )
switch( id )
{
case ID_LOAD_DEFAULT_PAGE_LAYOUT:
pglayout.SetPageLayout();
OnNewPageLayout();
break;
case wxID_NEW:
pglayout.AllowVoidList( true );
SetCurrFileName( wxEmptyString );
@ -108,7 +102,7 @@ void PL_EDITOR_FRAME::Files_io( wxCommandEvent& event )
case ID_APPEND_DESCR_FILE:
{
wxFileDialog openFileDialog(this, _("Append Page Layout Descr File"),
wxFileDialog openFileDialog(this, _("Append Existing Page Layout File"),
wxEmptyString,
wxEmptyString, PageLayoutDescrFileWildcard, wxFD_OPEN);
@ -134,7 +128,7 @@ void PL_EDITOR_FRAME::Files_io( wxCommandEvent& event )
case wxID_OPEN:
{
wxFileDialog openFileDialog(this, _("Open file"), wxEmptyString,
wxFileDialog openFileDialog(this, _("Open"), wxEmptyString,
wxEmptyString, PageLayoutDescrFileWildcard, wxFD_OPEN);
if (openFileDialog.ShowModal() == wxID_CANCEL)
@ -170,7 +164,7 @@ void PL_EDITOR_FRAME::Files_io( wxCommandEvent& event )
case wxID_SAVEAS:
{
wxFileDialog openFileDialog(this, _("Create file"), wxEmptyString,
wxFileDialog openFileDialog(this, _("Save As"), wxEmptyString,
wxEmptyString, PageLayoutDescrFileWildcard, wxFD_SAVE);
if (openFileDialog.ShowModal() == wxID_CANCEL)

View File

@ -88,17 +88,23 @@ static EDA_HOTKEY HkMoveEndPoint( _HKI( "Move End Point" ), HK_MOVE_END_POINT
static EDA_HOTKEY HkDeleteItem( _HKI( "Delete Item" ), HK_DELETE_ITEM, WXK_DELETE,
ID_POPUP_ITEM_DELETE );
// Undo Redo
// Common: hotkeys_basic.h
static EDA_HOTKEY HkUndo( _HKI( "Undo" ), HK_UNDO, GR_KB_CTRL + 'Z', (int) wxID_UNDO );
static EDA_HOTKEY HkRedo( _HKI( "Redo" ), HK_REDO, GR_KB_CTRL + 'Y', (int) wxID_REDO );
static EDA_HOTKEY HkNew( _HKI( "New" ), HK_NEW, GR_KB_CTRL + 'N', (int) wxID_NEW );
static EDA_HOTKEY HkOpen( _HKI( "Open" ), HK_OPEN, GR_KB_CTRL + 'O', (int) wxID_OPEN );
static EDA_HOTKEY HkSave( _HKI( "Save" ), HK_SAVE, GR_KB_CTRL + 'S', (int) wxID_SAVE );
static EDA_HOTKEY HkSaveAs( _HKI( "Save As" ), HK_SAVEAS, GR_KB_CTRL + GR_KB_SHIFT + 'S', (int) wxID_SAVEAS );
static EDA_HOTKEY HkPrint( _HKI( "Print" ), HK_PRINT, GR_KB_CTRL + 'P', (int) wxID_PRINT );
// List of common hotkey descriptors
EDA_HOTKEY* s_Common_Hotkey_List[] =
{
&HkHelp,
&HkNew, &HkOpen, &HkSave, &HkSaveAs, &HkPrint,
&HkUndo, &HkRedo,
&HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter,
&HkZoomAuto, &HkZoomSelection, &HkResetLocalCoord,
&HkUndo, &HkRedo,
&HkHelp,
&HkMouseLeftClick,
&HkMouseLeftDClick,
NULL
@ -176,8 +182,29 @@ bool PL_EDITOR_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode,
OnLeftDClick( aDC, aPosition );
break;
case HK_HELP: // Display Current hotkey list
DisplayHotkeyList( this, PlEditorHokeysDescr );
case HK_NEW:
cmd.SetId( wxID_NEW );
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_OPEN:
cmd.SetId( wxID_OPEN );
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_SAVE:
cmd.SetId( wxID_SAVE );
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_SAVEAS:
cmd.SetId( wxID_SAVEAS );
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_PRINT:
cmd.SetId( wxID_PRINT );
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_UNDO:
@ -222,6 +249,10 @@ bool PL_EDITOR_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode,
GetScreen()->m_O_Curseur = GetCrossHairPosition();
break;
case HK_HELP: // Display Current hotkey list
DisplayHotkeyList( this, PlEditorHokeysDescr );
break;
case HK_SET_GRID_ORIGIN:
SetGridOrigin( GetCrossHairPosition() );
break;

View File

@ -40,6 +40,10 @@
void PL_EDITOR_FRAME::ReCreateMenuBar()
{
wxString msg;
static wxMenu* openRecentMenu; // Open Recent submenu,
// static to remember this menu
// Create and try to get the current menubar
wxMenuBar* menuBar = GetMenuBar();
@ -50,68 +54,122 @@ void PL_EDITOR_FRAME::ReCreateMenuBar()
// This allows language changes of the menu text on the fly.
menuBar->Freeze();
// Before deleting, remove the menus managed by m_fileHistory
// (the file history will be updated when adding/removing files in history
if( openRecentMenu )
Kiface().GetFileHistory().RemoveMenu( openRecentMenu );
// Delete all existing menus
while( menuBar->GetMenuCount() )
delete menuBar->Remove( 0 );
// Recreate all menus:
// Menu File:
// File Menu:
wxMenu* fileMenu = new wxMenu;
// Load
AddMenuItem( fileMenu, wxID_NEW,
_( "&New Page Layout Design" ),
wxEmptyString, KiBitmap( new_generic_xpm ) );
AddMenuItem( fileMenu, wxID_OPEN,
_( "Load Page Layout &File" ),
wxEmptyString, KiBitmap( pagelayout_load_xpm ) );
AddMenuItem( fileMenu, ID_LOAD_DEFAULT_PAGE_LAYOUT,
_( "Load &Default Page Layout" ),
wxEmptyString, KiBitmap( pagelayout_load_xpm ) );
msg = AddHotkeyName( _( "&New" ), PlEditorHokeysDescr, HK_NEW );
AddMenuItem( fileMenu, wxID_NEW, msg,
_( "Create new page layout design" ),
KiBitmap( new_generic_xpm ) );
// Recent gerber files
static wxMenu* openRecentMenu;
// Add this menu to list menu managed by m_fileHistory
// (the file history will be updated when adding/removing files in history
if( openRecentMenu )
Kiface().GetFileHistory().RemoveMenu( openRecentMenu );
msg = AddHotkeyName( _( "&Open..." ), PlEditorHokeysDescr, HK_OPEN );
AddMenuItem( fileMenu, wxID_OPEN, msg,
_( "Open an existing page layout design file" ),
KiBitmap( pagelayout_load_xpm ) );
openRecentMenu = new wxMenu();
Kiface().GetFileHistory().UseMenu( openRecentMenu );
Kiface().GetFileHistory().AddFilesToMenu();
AddMenuItem( fileMenu, openRecentMenu,
wxID_ANY, _( "Open &Recent Page Layout File" ),
wxEmptyString, KiBitmap( recent_xpm ) );
wxID_ANY,
_( "Open &Recent" ),
_( "Open recent page layout design file" ),
KiBitmap( recent_xpm ) );
fileMenu->AppendSeparator();
// Save current sheet
AddMenuItem( fileMenu, wxID_SAVE,
_( "&Save Page Layout Design" ),
wxEmptyString, KiBitmap( save_xpm ) );
// Save current sheet as
AddMenuItem( fileMenu, wxID_SAVEAS,
_( "Save Page Layout Design &As" ),
wxEmptyString, KiBitmap( save_as_xpm ) );
// Print
fileMenu->AppendSeparator();
AddMenuItem( fileMenu, wxID_PRINT, _( "&Print" ),
wxEmptyString, KiBitmap( print_button_xpm ) );
AddMenuItem( fileMenu, wxID_PREVIEW, _( "Print Pre&view" ),
wxEmptyString, KiBitmap( print_button_xpm ) );
// Separator
fileMenu->AppendSeparator();
// Exit
AddMenuItem( fileMenu, wxID_EXIT,
_( "&Close" ),
_( "&Close Page Layout Editor" ),
KiBitmap( exit_xpm ) );
msg = AddHotkeyName( _( "&Save" ), PlEditorHokeysDescr, HK_SAVE );
AddMenuItem( fileMenu, wxID_SAVE, msg,
_( "Save current page layout design file" ),
KiBitmap( save_xpm ) );
msg = AddHotkeyName( _( "Save &As" ), PlEditorHokeysDescr, HK_SAVEAS );
AddMenuItem( fileMenu, wxID_SAVEAS, msg,
_( "Save current page layout design file with a different name" ),
KiBitmap( save_as_xpm ) );
fileMenu->AppendSeparator();
msg = AddHotkeyName( _( "&Print..." ), PlEditorHokeysDescr, HK_PRINT );
AddMenuItem( fileMenu, wxID_PRINT, msg,
wxEmptyString, KiBitmap( print_button_xpm ) );
AddMenuItem( fileMenu, wxID_PREVIEW, _( "Print Pre&view..." ),
wxEmptyString, KiBitmap( print_button_xpm ) );
fileMenu->AppendSeparator();
AddMenuItem( fileMenu, wxID_EXIT, _( "&Close" ),
_( "Close Page Layout Editor" ), KiBitmap( exit_xpm ) );
// Edit Menu:
wxMenu* editMenu = new wxMenu;
msg = AddHotkeyName( _( "Undo" ), PlEditorHokeysDescr, HK_UNDO );
AddMenuItem( editMenu, wxID_UNDO, msg, wxEmptyString, KiBitmap( undo_xpm ) );
msg = AddHotkeyName( _( "Redo" ), PlEditorHokeysDescr, HK_REDO );
AddMenuItem( editMenu, wxID_REDO, msg, wxEmptyString, KiBitmap( redo_xpm ) );
editMenu->AppendSeparator();
AddMenuItem( editMenu, wxID_CUT, _( "Delete" ), wxEmptyString, KiBitmap( delete_xpm ) );
// View Menu:
wxMenu* viewMenu = new wxMenu;
msg = AddHotkeyName( _( "Zoom in" ), PlEditorHokeysDescr, HK_ZOOM_IN );
AddMenuItem( viewMenu, ID_ZOOM_IN, msg, wxEmptyString, KiBitmap( zoom_in_xpm ) );
msg = AddHotkeyName( _( "Zoom out" ), PlEditorHokeysDescr, HK_ZOOM_OUT );
AddMenuItem( viewMenu, ID_ZOOM_OUT, msg, wxEmptyString, KiBitmap( zoom_out_xpm ) );
msg = AddHotkeyName( _( "Zoom all" ), PlEditorHokeysDescr, HK_ZOOM_AUTO );
AddMenuItem( viewMenu, ID_ZOOM_PAGE, msg, wxEmptyString, KiBitmap( zoom_fit_in_page_xpm ) );
msg = AddHotkeyName( _( "Zoom to selection" ), PlEditorHokeysDescr, HK_ZOOM_SELECTION );
AddMenuItem( viewMenu, ID_ZOOM_SELECTION, msg, wxEmptyString, KiBitmap( zoom_area_xpm ) );
viewMenu->AppendSeparator();
msg = AddHotkeyName( _( "Redraw view" ), PlEditorHokeysDescr, HK_ZOOM_REDRAW );
AddMenuItem( viewMenu, ID_ZOOM_REDRAW, msg, wxEmptyString, KiBitmap( zoom_redraw_xpm ) );
// Place Menu:
wxMenu* placeMenu = new wxMenu;
AddMenuItem( placeMenu, ID_POPUP_ITEM_ADD_LINE, _( "&Line..." ),
wxEmptyString, KiBitmap( add_dashed_line_xpm ) );
AddMenuItem( placeMenu, ID_POPUP_ITEM_ADD_RECT, _( "&Rectangle..." ),
wxEmptyString, KiBitmap( add_rectangle_xpm ) );
AddMenuItem( placeMenu, ID_POPUP_ITEM_ADD_TEXT, _( "&Text..." ),
wxEmptyString, KiBitmap( text_xpm ) );
AddMenuItem( placeMenu, ID_POPUP_ITEM_ADD_BITMAP, _( "&Bitmap..." ),
wxEmptyString, KiBitmap( image_xpm ) );
placeMenu->AppendSeparator();
AddMenuItem( placeMenu, ID_APPEND_DESCR_FILE, _( "&Append Existing Page Layout Design File..." ),
_( "Append an existing page layout design file to current file" ),
KiBitmap( pagelayout_load_xpm ) );
// Menu for preferences
wxMenu* preferencesMenu = new wxMenu;
@ -159,8 +217,8 @@ void PL_EDITOR_FRAME::ReCreateMenuBar()
_( "Open \"Getting Started in KiCad\" guide for beginners" ),
KiBitmap( help_xpm ) );
AddMenuItem( helpMenu, ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST,
_( "&List Hotkeys" ),
msg = AddHotkeyName( _( "&List Hotkeys" ), PlEditorHokeysDescr, HK_HELP );
AddMenuItem( helpMenu, ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, msg,
_( "Displays the current hotkeys list and corresponding commands" ),
KiBitmap( hotkeys_xpm ) );
@ -182,7 +240,10 @@ void PL_EDITOR_FRAME::ReCreateMenuBar()
// Append menus to the menubar
menuBar->Append( fileMenu, _( "&File" ) );
menuBar->Append( preferencesMenu, _( "&Preferences" ) );
menuBar->Append( editMenu, _( "&Edit" ) );
menuBar->Append( viewMenu, _( "&View" ) );
menuBar->Append( placeMenu, _( "&Place" ) );
menuBar->Append( preferencesMenu, _( "P&references" ) );
menuBar->Append( helpMenu, _( "&Help" ) );
menuBar->Thaw();

View File

@ -48,12 +48,11 @@ void AddNewItemsCommand( wxMenu* aMainMenu )
KiBitmap( add_rectangle_xpm ) );
AddMenuItem( aMainMenu, ID_POPUP_ITEM_ADD_TEXT, _( "Add Text" ),
KiBitmap( text_xpm ) );
AddMenuItem( aMainMenu, ID_POPUP_ITEM_APPEND_PAGE_LAYOUT,
_( "Append Page Layout Descr File" ),
KiBitmap( import_xpm ) );
AddMenuItem( aMainMenu, ID_POPUP_ITEM_ADD_BITMAP,
_( "Add Bitmap" ),
AddMenuItem( aMainMenu, ID_POPUP_ITEM_ADD_BITMAP, _( "Add Bitmap" ),
KiBitmap( image_xpm ) );
AddMenuItem( aMainMenu, ID_POPUP_ITEM_APPEND_PAGE_LAYOUT,
_( "Append Existing Page Layout Design File" ),
KiBitmap( pagelayout_load_xpm ) );
}
/* Prepare the right-click pullup menu.

View File

@ -97,7 +97,7 @@ public:
}
catch( const IO_ERROR& ioe )
{
wxMessageBox( ioe.What(), _( "Error writing page layout descr file" ) );
wxMessageBox( ioe.What(), _( "Error writing page layout design file" ) );
}
}
@ -125,7 +125,7 @@ public:
}
catch( const IO_ERROR& ioe )
{
wxMessageBox( ioe.What(), _( "Error writing page layout descr file" ) );
wxMessageBox( ioe.What(), _( "Error writing page layout design file" ) );
}
}

View File

@ -243,7 +243,7 @@ void PL_EDITOR_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
if( filename.IsEmpty() )
{
wxFileDialog openFileDialog(this, _("Create file"), wxEmptyString,
wxFileDialog openFileDialog(this, _("Save As"), wxEmptyString,
wxEmptyString, PageLayoutDescrFileWildcard, wxFD_SAVE);
if (openFileDialog.ShowModal() == wxID_CANCEL)

View File

@ -52,7 +52,6 @@ enum pl_editor_ids
ID_SHOW_REAL_MODE,
ID_SHOW_PL_EDITOR_MODE,
ID_SELECT_COORDINATE_ORIGIN,
ID_LOAD_DEFAULT_PAGE_LAYOUT,
ID_SELECT_PAGE_NUMBER,
ID_APPEND_DESCR_FILE,

View File

@ -52,12 +52,13 @@ void PL_EDITOR_FRAME::ReCreateHToolbar( void )
_( "New page layout design" ) );
m_mainToolBar->AddTool( wxID_OPEN, wxEmptyString, KiBitmap( pagelayout_load_xpm ),
_( "Load a page layout file. Previous data will be deleted" ) );
_( "Open an existing page layout design file" ) );
m_mainToolBar->AddTool( wxID_SAVE, wxEmptyString, KiBitmap( save_project_xpm ),
_( "Save page layout design" ) );
m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( ID_SHEET_SET, wxEmptyString, KiBitmap( sheetset_xpm ),
_( "Page settings" ) );
@ -65,14 +66,17 @@ void PL_EDITOR_FRAME::ReCreateHToolbar( void )
_( "Print page layout" ) );
m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( wxID_CUT, wxEmptyString, KiBitmap( delete_xpm ),
_( "Delete selected item" ) );
m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( wxID_UNDO, wxEmptyString,
KiBitmap( undo_xpm ), wxEmptyString );
KiBitmap( undo_xpm ), _( "Undo" ) );
m_mainToolBar->AddTool( wxID_REDO, wxEmptyString,
KiBitmap( redo_xpm ), wxEmptyString );
KiBitmap( redo_xpm ), _( "Redo" ) );
// Standard Zoom controls:
m_mainToolBar->AddSeparator();