pcbnew: prompt for reference point in the message panel, add cut/copy/paste entries in the Edit menu

This commit is contained in:
Tomasz Włostowski 2017-09-29 10:58:05 +02:00
parent 5731000135
commit adcda4a3e8
8 changed files with 66 additions and 10 deletions

View File

@ -110,7 +110,10 @@ enum hotkey_id_commnand {
HK_CUSTOM_TRACK_WIDTH, HK_CUSTOM_TRACK_WIDTH,
HK_DP_DIMENSIONS, HK_DP_DIMENSIONS,
HK_VIA_SIZE_INC, 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 // Full list of hotkey descriptors for board editor and footprint editor

View File

@ -174,6 +174,20 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
// Separator // Separator
editMenu->AppendSeparator(); 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 // Properties
AddMenuItem( editMenu, ID_MODEDIT_EDIT_MODULE_PROPERTIES, AddMenuItem( editMenu, ID_MODEDIT_EDIT_MODULE_PROPERTIES,
_( "Footprint &Properties" ), _( "Footprint &Properties" ),

View File

@ -59,7 +59,7 @@ static void prepareToolsMenu( wxMenu* aParentMenu );
static void prepareHelpMenu( wxMenu* aParentMenu ); static void prepareHelpMenu( wxMenu* aParentMenu );
// Build the edit menu // Build the edit menu
static void prepareEditMenu( wxMenu* aParentMenu ); static void prepareEditMenu( wxMenu* aParentMenu, bool aUseGal );
// Build the route menu // Build the route menu
static void prepareRouteMenu( wxMenu* aParentMenu ); static void prepareRouteMenu( wxMenu* aParentMenu );
@ -103,7 +103,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
//----- Edit menu ----------------------------------------------------------- //----- Edit menu -----------------------------------------------------------
wxMenu* editMenu = new wxMenu; wxMenu* editMenu = new wxMenu;
prepareEditMenu( editMenu ); prepareEditMenu( editMenu, IsGalCanvasActive() );
//----- View menu ----------------------------------------------------------- //----- View menu -----------------------------------------------------------
wxMenu* viewMenu = new wxMenu; wxMenu* viewMenu = new wxMenu;
@ -455,7 +455,7 @@ void prepareHelpMenu( wxMenu* aParentMenu )
// Build the edit menu // Build the edit menu
void prepareEditMenu( wxMenu* aParentMenu ) void prepareEditMenu( wxMenu* aParentMenu, bool aUseGal )
{ {
wxString text; wxString text;
@ -469,12 +469,25 @@ void prepareEditMenu( wxMenu* aParentMenu )
_( "&Delete" ), _( "Delete items" ), _( "&Delete" ), _( "Delete items" ),
KiBitmap( delete_xpm ) ); KiBitmap( delete_xpm ) );
aParentMenu->AppendSeparator();
text = AddHotkeyName( _( "&Find" ), g_Pcbnew_Editor_Hokeys_Descr, HK_FIND_ITEM ); text = AddHotkeyName( _( "&Find" ), g_Pcbnew_Editor_Hokeys_Descr, HK_FIND_ITEM );
AddMenuItem( aParentMenu, ID_FIND_ITEMS, text, HELP_FIND , KiBitmap( find_xpm ) ); AddMenuItem( aParentMenu, ID_FIND_ITEMS, text, HELP_FIND , KiBitmap( find_xpm ) );
aParentMenu->AppendSeparator(); 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, AddMenuItem( aParentMenu, ID_PCB_EDIT_ALL_VIAS_AND_TRACK_SIZE,
_( "Edit All Tracks and Vias" ), KiBitmap( width_track_via_xpm ) ); _( "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 * From hotkeys, zooming is made around the mouse cursor position
* (obviously not possible from the toolbar or menubar command) * (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 * for Zoom in and Zoom out sub menus
*/ */
text = AddHotkeyName( _( "Zoom &In" ), g_Pcbnew_Editor_Hokeys_Descr, text = AddHotkeyName( _( "Zoom &In" ), g_Pcbnew_Editor_Hokeys_Descr,

View File

@ -1011,4 +1011,6 @@ void FOOTPRINT_EDIT_FRAME::UseGalCanvas( bool aEnable )
GetGalCanvas()->GetGAL()->SetAxesEnabled( true ); GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
updateView(); updateView();
} }
ReCreateMenuBar();
} }

View File

@ -754,6 +754,8 @@ void PCB_EDIT_FRAME::enableGALSpecificMenus()
// some menus are active only in GAL mode and do nothing in legacy mode. // some menus are active only in GAL mode and do nothing in legacy mode.
// So enable or disable them, depending on the display mode // So enable or disable them, depending on the display mode
ReCreateMenuBar();
if( GetMenuBar() ) if( GetMenuBar() )
{ {
// Enable / disable some menus which are usable only on GAL // 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] ) ) if( GetMenuBar()->FindItem( id_list[ii] ) )
GetMenuBar()->FindItem( id_list[ii] )->Enable( enbl ); GetMenuBar()->FindItem( id_list[ii] )->Enable( enbl );
} }
} }
} }

View File

@ -403,6 +403,9 @@ enum pcbnew_ids
ID_FOOTPRINT_WIZARD_EXPORT_TO_BOARD, ID_FOOTPRINT_WIZARD_EXPORT_TO_BOARD,
ID_UPDATE_PCB_FROM_SCH, ID_UPDATE_PCB_FROM_SCH,
ID_EDIT_CUT,
ID_EDIT_COPY,
ID_EDIT_PASTE,
ID_PCBNEW_END_LIST ID_PCBNEW_END_LIST
}; };

View File

@ -1316,18 +1316,27 @@ bool EDIT_TOOL::pickCopyReferencePoint( VECTOR2I& aP )
int EDIT_TOOL::copyToClipboard( const TOOL_EVENT& aEvent ) int EDIT_TOOL::copyToClipboard( const TOOL_EVENT& aEvent )
{ {
CLIPBOARD_IO io; CLIPBOARD_IO io;
BOARD* board = getModel<BOARD>();
VECTOR2I refPoint; VECTOR2I refPoint;
Activate(); Activate();
auto item1 = MSG_PANEL_ITEM( _(""), _("Select reference point for the block being copied..."), COLOR4D::BLACK );
std::vector<MSG_PANEL_ITEM> msgItems = { item1 };
SELECTION selection = m_selectionTool->RequestSelection(); 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; return 0;
selection.SetReferencePoint( refPoint ); selection.SetReferencePoint( refPoint );
io.SetBoard( board ); io.SetBoard( board() );
io.SaveSelection( selection ); io.SaveSelection( selection );
return 0; return 0;

View File

@ -184,6 +184,15 @@ boost::optional<TOOL_EVENT> PCB_ACTIONS::TranslateLegacyId( int aId )
case ID_PCB_MUWAVE_TOOL_SELF_CMD: case ID_PCB_MUWAVE_TOOL_SELF_CMD:
return PCB_ACTIONS::microwaveCreateLine.MakeEvent(); 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<TOOL_EVENT>(); return boost::optional<TOOL_EVENT>();