← Back to team overview

kicad-developers team mailing list archive

Modedit hotkeys

 

Hi,

The attached patch adds hotkey support for moving, rotating, editing, and
deleting pads, texts, and edges in module editor.

Regards,

Marco
=== modified file 'pcbnew/hotkeys.cpp'
--- pcbnew/hotkeys.cpp	2010-08-10 18:34:26 +0000
+++ pcbnew/hotkeys.cpp	2010-08-23 19:03:52 +0000
@@ -174,7 +174,12 @@
 };
 
 // List of hotkey descriptors for the module editor
-Ki_HotkeyInfo* s_module_edit_Hotkey_List[] = { NULL };
+Ki_HotkeyInfo* s_module_edit_Hotkey_List[] = 
+{
+    &HkEditBoardItem,          &HkRotateFootprint,           &HkMoveFootprint,
+    &HkDelete,
+    NULL
+};
 
 // list of sections and corresponding hotkey list for pcbnew (used to create an hotkey config file)
 struct Ki_HotkeyInfoSectionDescriptor s_Pcbnew_Editor_Hokeys_Descr[] =
@@ -775,6 +780,94 @@
         cmd.SetId( ID_ZOOM_PAGE );
         GetEventHandler()->ProcessEvent( cmd );
         break;
+
+    case HK_DELETE:
+        if( ItemFree )
+        {
+            BOARD_ITEM * item = ModeditLocateAndDisplay( hotkey );
+            if ( item == NULL )
+                break;
+	    SetCurItem( item );
+	    switch( item->Type() )
+	    {
+	    case TYPE_PAD:
+	        cmd.SetId( ID_POPUP_PCB_DELETE_PAD );
+		Process_Special_Functions( cmd );
+		break;
+	    case TYPE_TEXTE_MODULE:
+	        cmd.SetId( ID_POPUP_PCB_DELETE_TEXTMODULE );
+		Process_Special_Functions( cmd );
+		break;
+	    case TYPE_EDGE_MODULE:
+	        cmd.SetId( ID_POPUP_PCB_DELETE_EDGE );
+		Process_Special_Functions( cmd );
+		break;
+	    }
+        }
+	break;
+
+    case HK_MOVE_FOOTPRINT_OR_TRACK:
+        if( ItemFree )
+        {
+            BOARD_ITEM * item = ModeditLocateAndDisplay( hotkey );
+            if ( item == NULL )
+                break;
+	    SetCurItem( item );
+	    switch( item->Type() )
+	    {
+	    case TYPE_PAD:
+	        cmd.SetId( ID_POPUP_PCB_MOVE_PAD_REQUEST );
+		Process_Special_Functions( cmd );
+		break;
+	    case TYPE_TEXTE_MODULE:
+	        cmd.SetId( ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST );
+		Process_Special_Functions( cmd );
+		break;
+	    case TYPE_EDGE_MODULE:
+	        cmd.SetId( ID_POPUP_PCB_MOVE_EDGE );
+		Process_Special_Functions( cmd );
+		break;
+	    }
+        }
+        break;
+
+    case HK_EDIT_ITEM:
+        if( ItemFree )
+        {
+            BOARD_ITEM * item = ModeditLocateAndDisplay( hotkey );
+            if ( item == NULL )
+                break;
+	    SetCurItem( item );
+	    switch( item->Type() )
+	    {
+	    case TYPE_PAD:
+	        cmd.SetId( ID_POPUP_PCB_EDIT_PAD );
+		Process_Special_Functions( cmd );
+		break;
+	    case TYPE_TEXTE_MODULE:
+	        cmd.SetId( ID_POPUP_PCB_EDIT_TEXTMODULE );
+		Process_Special_Functions( cmd );
+		break;
+	    }
+        }
+        break;
+
+    case HK_ROTATE_FOOTPRINT:
+        if( ItemFree )
+        {
+            BOARD_ITEM * item = ModeditLocateAndDisplay( hotkey );
+            if ( item == NULL )
+                break;
+	    SetCurItem( item );
+	    switch( item->Type() )
+	    {
+	    case TYPE_TEXTE_MODULE:
+	        cmd.SetId( ID_POPUP_PCB_ROTATE_TEXTMODULE );
+		Process_Special_Functions( cmd );
+		break;
+	    }
+        }
+	break;
     }
 }
 

=== modified file 'pcbnew/modedit.cpp'
--- pcbnew/modedit.cpp	2010-08-10 18:34:26 +0000
+++ pcbnew/modedit.cpp	2010-08-23 18:11:13 +0000
@@ -42,6 +42,7 @@
     {
         // @todo: add switch here and add calls to PcbGeneralLocateAndDisplay(
         // int aHotKeyCode ) when searching is needed from a hotkey handler
+        scanList = GENERAL_COLLECTOR::ModulesAndTheirItems;
     }
     else
     {

=== modified file 'pcbnew/modedit_onclick.cpp'
--- pcbnew/modedit_onclick.cpp	2010-08-10 18:34:26 +0000
+++ pcbnew/modedit_onclick.cpp	2010-08-23 18:38:19 +0000
@@ -16,6 +16,7 @@
 #include "bitmaps.h"
 #include "protos.h"
 #include "pcbnew_id.h"
+#include "hotkeys.h"
 
 
 /* Handle the left click in footprint editor
@@ -281,17 +282,20 @@
     case TYPE_PAD:
         if( !flags )
         {
+	    msg = AddHotkeyName( _( "Move Pad" ), s_Module_Editor_Hokeys_Descr, HK_MOVE_FOOTPRINT_OR_TRACK );
             ADD_MENUITEM( PopMenu, ID_POPUP_PCB_MOVE_PAD_REQUEST,
-                          _( "Move Pad" ), move_pad_xpm );
+                          msg, move_pad_xpm );
         }
-        ADD_MENUITEM( PopMenu, ID_POPUP_PCB_EDIT_PAD, _( "Edit Pad" ),
-                      options_pad_xpm );
+	msg = AddHotkeyName( _( "Edit Pad" ), s_Module_Editor_Hokeys_Descr, HK_EDIT_ITEM );
+        ADD_MENUITEM( PopMenu, ID_POPUP_PCB_EDIT_PAD,
+		      msg, options_pad_xpm );
         ADD_MENUITEM( PopMenu, ID_POPUP_PCB_IMPORT_PAD_SETTINGS,
                       _( "New Pad Settings" ), options_new_pad_xpm );
         ADD_MENUITEM( PopMenu, ID_POPUP_PCB_EXPORT_PAD_SETTINGS,
                       _( "Export Pad Settings" ), export_options_pad_xpm );
+	msg = AddHotkeyName( _( "Delete Pad" ), s_Module_Editor_Hokeys_Descr, HK_DELETE );
         ADD_MENUITEM( PopMenu, ID_POPUP_PCB_DELETE_PAD,
-                      _( "delete Pad" ), delete_pad_xpm );
+                      msg, delete_pad_xpm );
         if( !flags )
         {
             PopMenu->AppendSeparator();
@@ -303,18 +307,24 @@
     case TYPE_TEXTE_MODULE:
         if( !flags )
         {
+	    msg = AddHotkeyName( _( "Move Text Mod." ), s_Module_Editor_Hokeys_Descr, HK_MOVE_FOOTPRINT_OR_TRACK );
             ADD_MENUITEM( PopMenu, ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST,
-                          _( "Move Text Mod." ), move_field_xpm );
+                          msg, move_field_xpm );
         }
+	msg = AddHotkeyName( _( "Rotate Text Mod." ), s_Module_Editor_Hokeys_Descr, HK_ROTATE_FOOTPRINT );
         ADD_MENUITEM( PopMenu, ID_POPUP_PCB_ROTATE_TEXTMODULE,
-                      _( "Rotate Text Mod." ), rotate_field_xpm );
+                      msg, rotate_field_xpm );
         if( !flags )
         {
+	    msg = AddHotkeyName( _( "Edit Text Mod." ), s_Module_Editor_Hokeys_Descr, HK_EDIT_ITEM );
             ADD_MENUITEM( PopMenu, ID_POPUP_PCB_EDIT_TEXTMODULE,
-                          _( "Edit Text Mod." ), edit_text_xpm );
+                          msg, edit_text_xpm );
             if( ( (TEXTE_MODULE*) DrawStruct )->m_Type == TEXT_is_DIVERS )
+	    {
+	        msg = AddHotkeyName( _( "Delete Text Mod." ), s_Module_Editor_Hokeys_Descr, HK_DELETE );
                 ADD_MENUITEM( PopMenu, ID_POPUP_PCB_DELETE_TEXTMODULE,
-                              _( "Delete Text Mod." ), delete_text_xpm );
+                              msg, delete_text_xpm );
+	    }
         }
         break;
 
@@ -324,8 +334,9 @@
             ADD_MENUITEM( PopMenu, ID_POPUP_PCB_STOP_CURRENT_DRAWING,
                           _( "End edge" ), apply_xpm );
         if( !flags )
+	    msg = AddHotkeyName( _( "Move Edge" ), s_Module_Editor_Hokeys_Descr, HK_MOVE_FOOTPRINT_OR_TRACK );
             ADD_MENUITEM( PopMenu, ID_POPUP_PCB_MOVE_EDGE,
-                          _( "Move edge" ), move_line_xpm );
+                          msg, move_line_xpm );
         if( ( flags & (IS_NEW | IS_MOVED) ) == IS_MOVED )
             ADD_MENUITEM( PopMenu, ID_POPUP_PCB_PLACE_EDGE,
                           _( "Place edge" ), apply_xpm );
@@ -341,8 +352,9 @@
                       _( "Edit Layer (Current)" ), select_layer_pair_xpm );
         ADD_MENUITEM( edit_mnu, ID_POPUP_PCB_EDIT_LAYER_ALL_EDGE,
                       _( "Edit Layer (All)" ), select_layer_pair_xpm );
+	msg = AddHotkeyName( _( "Delete Edge" ), s_Module_Editor_Hokeys_Descr, HK_DELETE );
         ADD_MENUITEM( PopMenu, ID_POPUP_PCB_DELETE_EDGE,
-                      _( "Delete edge" ), delete_xpm );
+                      msg, delete_xpm );
         append_set_width = TRUE;
     }
     break;