From 4500b064d868bb53739962766cd0bf701c829e2e Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 27 Aug 2019 21:27:39 -0700 Subject: [PATCH] Handle active layer overloading Setting the active layer should be tied to the events that are triggered by the layer change and overloaded for each frame. This ties the hotkey back to these events. Note: In the 5.1 cherry-pick this also adds the missing hotkey to footprint editor Fixes: lp:1838244 * https://bugs.launchpad.net/kicad/+bug/1838244 (cherry picked from commit 494d0de9b8565bd1e12a3704f887410b76128603) --- pcbnew/class_zone.cpp | 2 +- pcbnew/footprint_editor_utils.cpp | 4 +++- pcbnew/hotkeys.cpp | 4 ++++ pcbnew/pcb_base_frame.cpp | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 4a1181c5b8..90037612a4 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -280,7 +280,7 @@ void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMod return; wxPoint seg_start, seg_end; - PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; + PCB_LAYER_ID curr_layer = ( ( PCB_SCREEN* ) panel->GetScreen() )->m_Active_Layer; BOARD* brd = GetBoard(); auto frame = static_cast ( panel->GetParent() ); diff --git a/pcbnew/footprint_editor_utils.cpp b/pcbnew/footprint_editor_utils.cpp index 0d1690d8cf..951aeecf43 100644 --- a/pcbnew/footprint_editor_utils.cpp +++ b/pcbnew/footprint_editor_utils.cpp @@ -1066,11 +1066,13 @@ void FOOTPRINT_EDIT_FRAME::SetActiveLayer( PCB_LAYER_ID aLayer ) { PCB_BASE_FRAME::SetActiveLayer( aLayer ); - m_Layers->SelectLayer( GetActiveLayer() ); + m_Layers->SelectLayer( aLayer ); m_Layers->OnLayerSelected(); if( IsGalCanvasActive() ) { + m_toolManager->RunAction( PCB_ACTIONS::layerChanged ); // notify other tools + GetCanvas()->SetFocus(); // allow capture of hotkeys GetGalCanvas()->SetHighContrastLayer( aLayer ); GetGalCanvas()->Refresh(); } diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index 215e5cc7f2..5047a65fe3 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -512,6 +512,10 @@ EDA_HOTKEY* module_edit_Hotkey_List[] = { &HkSwitchGridToNext, &HkSwitchGridToPrevious, + // Active Layer + &HkSwitch2ComponentLayer, + &HkSwitch2CopperLayer, + // Display &HkSwitchHighContrastMode, &HkCanvasDefault, diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index 69109c1a90..54ea11de77 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -526,7 +526,7 @@ void PCB_BASE_FRAME::SwitchLayer( wxDC* DC, PCB_LAYER_ID layer ) // and a non-copper layer, or vice-versa? // ... - GetScreen()->m_Active_Layer = layer; + SetActiveLayer( layer ); if( displ_opts->m_ContrastModeDisplay ) m_canvas->Refresh();