From f578abcc9797a19d59069300214a7752f4782f76 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 2 Sep 2010 10:23:38 +0200 Subject: [PATCH] Remove pad move/drag/edit hotkeys id board editor (Marco Mattila'patches) --- TODO.txt | 6 +- common/dialog_about/AboutDialog_main.cpp | 2 + include/wxPcbStruct.h | 2 + pcbnew/hotkeys.cpp | 102 ++++++++++++++++++++--- pcbnew/onrightclick.cpp | 10 +-- 5 files changed, 100 insertions(+), 22 deletions(-) diff --git a/TODO.txt b/TODO.txt index 76779de7c2..988977a039 100644 --- a/TODO.txt +++ b/TODO.txt @@ -5,8 +5,6 @@ WXMAC Platform -------------- * Fix hotkey list to match CMD key * Fix AddHotkeyName to let wxWidgets handle Ctrl to CMD key -* Fix About dialog crash, or trash wxAboutDialog and create our own - About dialog to match all platforms. (wxAboutDialog different on platforms) * Fix toolbar button tooltips. Common @@ -14,12 +12,10 @@ Common * Grep for @TODO or TODO for sourcecode tasks * Use doxygen compatible comments on member functions (.h files) * Add tooltip text to all non-obvious controls in every dialog window. - Need to do this using DialogBlocks. + Use wxFormBuilder. * Component and module search displays in which library the module or component lives. * List auto up and down scrolling. -* Integer/long/double input boxes should handle comma and dot separated values, - not only comma. * Push file open semantics down to one of the base frame classes ( likely candidate is WinEDA_BasicFrame ) so that file open behavior is consistent across all applications. diff --git a/common/dialog_about/AboutDialog_main.cpp b/common/dialog_about/AboutDialog_main.cpp index 2f4868bb09..c2f6639cc7 100644 --- a/common/dialog_about/AboutDialog_main.cpp +++ b/common/dialog_about/AboutDialog_main.cpp @@ -200,6 +200,8 @@ static void InitKiCadAboutNew( AboutAppInfo& info ) wxT( "http://boolean.klaasholwerda.nl/bool.html" ) ) ); info.AddDeveloper( new Contributor( wxT( "Lorenzo Marcantonio" ), wxT( "lomarcan@tin.it" ) ) ); info.AddDeveloper( new Contributor( wxT( "Marco Serantoni" ), wxT( "marco.serantoni@gmail.com" ) ) ); + info.AddDeveloper( new Contributor( wxT( "Marco Mattila" ), wxT( "marcom99@gmail.com" ) ) ); + info.AddDeveloper( new Contributor( wxT( "Rafael Sokolowski" ), wxT( "rafael.sokolowski@web.de" ) ) ); info.AddDeveloper( new Contributor( wxT( "Rok Markovic" ), wxT( "rok@kanardia.eu" ) ) ); info.AddDeveloper( new Contributor( wxT( "Tim Hanson" ), wxT( "sideskate@gmail.com" ) ) ); info.AddDeveloper( new Contributor( wxT( "Vesa Solonen" ), wxT( "vesa.solonen@hut.fi" ) ) ); diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index 19dfcd781c..009343013a 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -277,6 +277,8 @@ public: */ bool OnHotkeyDeleteItem( wxDC* aDC ); + bool OnHotkeyEditItem( int aIdCommand ); + /** Function OnHotkeyMoveItem * Moves or drag the item (footprint, track, text .. ) found under the mouse cursor * Only a footprint or a track can be dragged diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index 3c97e323cf..dc1cc892c2 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -503,15 +503,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* aDC, int aHotkeyCode, EDA_BaseStruct* aIte break; case HK_EDIT_ITEM: // Edit board item - if( !itemCurrentlyEdited ) - { - BOARD_ITEM* item = PcbGeneralLocateAndDisplay(); - if( item == NULL ) - break; - - //An item is found, and some can be edited: - OnEditItemRequest( aDC, item ); - } + OnHotkeyEditItem( HK_EDIT_ITEM ); break; // Footprint edition: @@ -908,6 +900,90 @@ bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* aDC ) return true; } +bool WinEDA_PcbFrame::OnHotkeyEditItem( int aIdCommand ) +{ + BOARD_ITEM* item = GetCurItem(); + bool itemCurrentlyEdited = item && item->m_Flags; + + if( itemCurrentlyEdited ) + return false; + + item = PcbGeneralLocateAndDisplay(); + + if( item == NULL ) + return false; + + SetCurItem( item ); + + int evt_type = 0; //Used to post a wxCommandEvent on demand + + switch( item->Type() ) + { + case TYPE_TRACK: + case TYPE_VIA: + if( aIdCommand == HK_EDIT_ITEM ) + evt_type = ID_POPUP_PCB_EDIT_TRACKSEG; + break; + + case TYPE_TEXTE: + if( aIdCommand == HK_EDIT_ITEM ) + evt_type = ID_POPUP_PCB_EDIT_TEXTEPCB; + break; + + case TYPE_MODULE: + if( aIdCommand == HK_EDIT_ITEM ) + evt_type = ID_POPUP_PCB_EDIT_MODULE; + break; + + case TYPE_PAD: + // Post a EDIT_MODULE event here to prevent pads + // from being edited by hotkeys. + // Process_Special_Functions takes care of finding + // the parent. + if( aIdCommand == HK_EDIT_ITEM ) + evt_type = ID_POPUP_PCB_EDIT_MODULE; + break; + + case TYPE_MIRE: + if( aIdCommand == HK_EDIT_ITEM ) + evt_type = ID_POPUP_PCB_EDIT_MIRE; + break; + + case TYPE_DIMENSION: + if( aIdCommand == HK_EDIT_ITEM ) + evt_type = ID_POPUP_PCB_EDIT_DIMENSION; + break; + + case TYPE_TEXTE_MODULE: + if( aIdCommand == HK_EDIT_ITEM ) + evt_type = ID_POPUP_PCB_EDIT_TEXTMODULE; + break; + + case TYPE_DRAWSEGMENT: + if( aIdCommand == HK_EDIT_ITEM ) + evt_type = ID_POPUP_PCB_EDIT_DRAWING; + break; + + case TYPE_ZONE_CONTAINER: + if( aIdCommand == HK_EDIT_ITEM ) + evt_type = ID_POPUP_PCB_EDIT_ZONE_PARAMS; + break; + + default: + break; + } + + if( evt_type != 0 ) + { + wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); + evt.SetEventObject( this ); + evt.SetId( evt_type ); + wxPostEvent( this, evt ); + return true; + } + + return false; +} /** Function OnHotkeyMoveItem * Move or drag the item (footprint, track, text .. ) found under the mouse cursor @@ -953,10 +1029,14 @@ bool WinEDA_PcbFrame::OnHotkeyMoveItem( int aIdCommand ) break; case TYPE_PAD: + // Post MODULE_REQUEST events here to prevent pads + // from being moved or dragged by hotkeys. + // Process_Special_Functions takes care of finding + // the parent. if( aIdCommand == HK_MOVE_ITEM ) - evt_type = ID_POPUP_PCB_MOVE_PAD_REQUEST; + evt_type = ID_POPUP_PCB_MOVE_MODULE_REQUEST; if( aIdCommand == HK_DRAG_ITEM ) - evt_type = ID_POPUP_PCB_DRAG_PAD_REQUEST; + evt_type = ID_POPUP_PCB_DRAG_MODULE_REQUEST; break; case TYPE_TEXTE: diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index 78c0c2dcfe..d02bb332d1 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -741,15 +741,13 @@ void WinEDA_PcbFrame::createPopUpMenuForFpPads( D_PAD* Pad, wxMenu* menu ) sub_menu_Pad = new wxMenu; ADD_MENUITEM_WITH_SUBMENU( menu, sub_menu_Pad, -1, msg, pad_xpm ); - msg = AddHotkeyName( _( "Move" ), s_Board_Editor_Hokeys_Descr, HK_MOVE_ITEM ); ADD_MENUITEM( sub_menu_Pad, ID_POPUP_PCB_MOVE_PAD_REQUEST, - msg, move_pad_xpm ); - msg = AddHotkeyName( _( "Drag" ), s_Board_Editor_Hokeys_Descr, HK_DRAG_ITEM ); + _( "Move" ), move_pad_xpm ); ADD_MENUITEM( sub_menu_Pad, ID_POPUP_PCB_DRAG_PAD_REQUEST, - msg, drag_pad_xpm ); + _( "Drag" ), drag_pad_xpm ); - msg = AddHotkeyName( _( "Edit Pad" ), s_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM ); - ADD_MENUITEM( sub_menu_Pad, ID_POPUP_PCB_EDIT_PAD, msg, options_pad_xpm ); + ADD_MENUITEM( sub_menu_Pad, ID_POPUP_PCB_EDIT_PAD, + _( "Edit" ), options_pad_xpm ); sub_menu_Pad->AppendSeparator(); ADD_MENUITEM_WITH_HELP( sub_menu_Pad, ID_POPUP_PCB_IMPORT_PAD_SETTINGS,