diff --git a/pcbnew/hotkeys.h b/pcbnew/hotkeys.h index 271a1093e9..cd447137bf 100644 --- a/pcbnew/hotkeys.h +++ b/pcbnew/hotkeys.h @@ -110,7 +110,10 @@ enum hotkey_id_commnand { HK_CUSTOM_TRACK_WIDTH, HK_DP_DIMENSIONS, HK_VIA_SIZE_INC, - HK_VIA_SIZE_DEC + HK_VIA_SIZE_DEC, + HK_EDIT_CUT, + HK_EDIT_PASTE, + HK_EDIT_COPY }; // Full list of hotkey descriptors for board editor and footprint editor diff --git a/pcbnew/menubar_modedit.cpp b/pcbnew/menubar_modedit.cpp index 5de16730d1..9b6be2778a 100644 --- a/pcbnew/menubar_modedit.cpp +++ b/pcbnew/menubar_modedit.cpp @@ -174,6 +174,20 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() // Separator editMenu->AppendSeparator(); + if( IsGalCanvasActive() ) + { + text = AddHotkeyName( _( "&Cut" ), g_Module_Viewer_Hokeys_Descr, HK_EDIT_CUT ); + AddMenuItem( editMenu, ID_EDIT_CUT, text, _( + "Cuts the selected item(s) to the Clipboard" ), KiBitmap( cut_xpm ) ); + text = AddHotkeyName( _( "&Copy" ), g_Module_Viewer_Hokeys_Descr, HK_EDIT_COPY ); + AddMenuItem( editMenu, ID_EDIT_COPY, text, _( + "Copies the selected item(s) to the Clipboard" ), KiBitmap( copy_xpm ) ); + text = AddHotkeyName( _( "&Paste" ), g_Module_Viewer_Hokeys_Descr, HK_EDIT_PASTE ); + AddMenuItem( editMenu, ID_EDIT_PASTE, text, _( + "Pastes item(s) from the Clipboard" ), KiBitmap( paste_xpm ) ); + editMenu->AppendSeparator(); + } + // Properties AddMenuItem( editMenu, ID_MODEDIT_EDIT_MODULE_PROPERTIES, _( "Footprint &Properties" ), diff --git a/pcbnew/menubar_pcbframe.cpp b/pcbnew/menubar_pcbframe.cpp index f6b0e15162..1b5879057e 100644 --- a/pcbnew/menubar_pcbframe.cpp +++ b/pcbnew/menubar_pcbframe.cpp @@ -59,7 +59,7 @@ static void prepareToolsMenu( wxMenu* aParentMenu ); static void prepareHelpMenu( wxMenu* aParentMenu ); // Build the edit menu -static void prepareEditMenu( wxMenu* aParentMenu ); +static void prepareEditMenu( wxMenu* aParentMenu, bool aUseGal ); // Build the route menu static void prepareRouteMenu( wxMenu* aParentMenu ); @@ -103,7 +103,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() //----- Edit menu ----------------------------------------------------------- wxMenu* editMenu = new wxMenu; - prepareEditMenu( editMenu ); + prepareEditMenu( editMenu, IsGalCanvasActive() ); //----- View menu ----------------------------------------------------------- wxMenu* viewMenu = new wxMenu; @@ -455,7 +455,7 @@ void prepareHelpMenu( wxMenu* aParentMenu ) // Build the edit menu -void prepareEditMenu( wxMenu* aParentMenu ) +void prepareEditMenu( wxMenu* aParentMenu, bool aUseGal ) { wxString text; @@ -469,12 +469,25 @@ void prepareEditMenu( wxMenu* aParentMenu ) _( "&Delete" ), _( "Delete items" ), KiBitmap( delete_xpm ) ); - aParentMenu->AppendSeparator(); - text = AddHotkeyName( _( "&Find" ), g_Pcbnew_Editor_Hokeys_Descr, HK_FIND_ITEM ); AddMenuItem( aParentMenu, ID_FIND_ITEMS, text, HELP_FIND , KiBitmap( find_xpm ) ); aParentMenu->AppendSeparator(); + + if( aUseGal ) + { + text = AddHotkeyName( _( "&Cut" ), g_Pcbnew_Editor_Hokeys_Descr, HK_EDIT_CUT ); + AddMenuItem( aParentMenu, ID_EDIT_CUT, text, _( + "Cuts the selected item(s) to the Clipboard" ), KiBitmap( cut_xpm ) ); + text = AddHotkeyName( _( "&Copy" ), g_Pcbnew_Editor_Hokeys_Descr, HK_EDIT_COPY ); + AddMenuItem( aParentMenu, ID_EDIT_COPY, text, _( + "Copies the selected item(s) to the Clipboard" ), KiBitmap( copy_xpm ) ); + text = AddHotkeyName( _( "&Paste" ), g_Pcbnew_Editor_Hokeys_Descr, HK_EDIT_PASTE ); + AddMenuItem( aParentMenu, ID_EDIT_PASTE, text, _( + "Pastes item(s) from the Clipboard" ), KiBitmap( paste_xpm ) ); + aParentMenu->AppendSeparator(); + } + AddMenuItem( aParentMenu, ID_PCB_EDIT_ALL_VIAS_AND_TRACK_SIZE, _( "Edit All Tracks and Vias" ), KiBitmap( width_track_via_xpm ) ); @@ -513,7 +526,7 @@ void prepareViewMenu( wxMenu* aParentMenu ) * From hotkeys, zooming is made around the mouse cursor position * (obviously not possible from the toolbar or menubar command) * - * in other words HK_ZOOM_IN and HK_ZOOM_OUT *are NOT* accelerators + * in other words HK_ZOOM_IN and HK_ZOOM_OUT *are NOT* accelerator * for Zoom in and Zoom out sub menus */ text = AddHotkeyName( _( "Zoom &In" ), g_Pcbnew_Editor_Hokeys_Descr, diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 41b6b14b6f..9b8cb1d65b 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -1011,4 +1011,6 @@ void FOOTPRINT_EDIT_FRAME::UseGalCanvas( bool aEnable ) GetGalCanvas()->GetGAL()->SetAxesEnabled( true ); updateView(); } + + ReCreateMenuBar(); } diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index e243ff25de..8a9ab5558d 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -754,6 +754,8 @@ void PCB_EDIT_FRAME::enableGALSpecificMenus() // some menus are active only in GAL mode and do nothing in legacy mode. // So enable or disable them, depending on the display mode + ReCreateMenuBar(); + if( GetMenuBar() ) { // Enable / disable some menus which are usable only on GAL @@ -775,6 +777,7 @@ void PCB_EDIT_FRAME::enableGALSpecificMenus() if( GetMenuBar()->FindItem( id_list[ii] ) ) GetMenuBar()->FindItem( id_list[ii] )->Enable( enbl ); } + } } diff --git a/pcbnew/pcbnew_id.h b/pcbnew/pcbnew_id.h index bd0a5ec947..8b8e51c3db 100644 --- a/pcbnew/pcbnew_id.h +++ b/pcbnew/pcbnew_id.h @@ -403,6 +403,9 @@ enum pcbnew_ids ID_FOOTPRINT_WIZARD_EXPORT_TO_BOARD, ID_UPDATE_PCB_FROM_SCH, + ID_EDIT_CUT, + ID_EDIT_COPY, + ID_EDIT_PASTE, ID_PCBNEW_END_LIST }; diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 5113f0f3cf..1136977ab1 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -1316,18 +1316,27 @@ bool EDIT_TOOL::pickCopyReferencePoint( VECTOR2I& aP ) int EDIT_TOOL::copyToClipboard( const TOOL_EVENT& aEvent ) { CLIPBOARD_IO io; - BOARD* board = getModel(); VECTOR2I refPoint; Activate(); + auto item1 = MSG_PANEL_ITEM( _(""), _("Select reference point for the block being copied..."), COLOR4D::BLACK ); + std::vector msgItems = { item1 }; + SELECTION selection = m_selectionTool->RequestSelection(); - if( !pickCopyReferencePoint( refPoint ) ) + if( selection.Empty() ) + return 0; + + frame()->SetMsgPanel( msgItems ); + bool rv = pickCopyReferencePoint( refPoint ); + frame()->SetMsgPanel( board() ); + + if( !rv ) return 0; selection.SetReferencePoint( refPoint ); - io.SetBoard( board ); + io.SetBoard( board() ); io.SaveSelection( selection ); return 0; diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index ca1e364d6a..8142884f1d 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -184,6 +184,15 @@ boost::optional PCB_ACTIONS::TranslateLegacyId( int aId ) case ID_PCB_MUWAVE_TOOL_SELF_CMD: return PCB_ACTIONS::microwaveCreateLine.MakeEvent(); + + case ID_EDIT_CUT: + return PCB_ACTIONS::cutToClipboard.MakeEvent(); + + case ID_EDIT_COPY: + return PCB_ACTIONS::copyToClipboard.MakeEvent(); + + case ID_EDIT_PASTE: + return PCB_ACTIONS::pasteFromClipboard.MakeEvent(); } return boost::optional();