From cdad62022bdb653fa7c4b25107ff5a491be9921c Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 25 Feb 2020 12:17:13 +0000 Subject: [PATCH] Bug fix for double-click in DRC dialog. Also better clean-up of highlighting in board editor window. --- pcbnew/dialogs/dialog_drc.cpp | 60 ++++++++++++------------------ pcbnew/dialogs/dialog_drc.h | 8 +--- pcbnew/dialogs/dialog_drc_base.cpp | 16 ++++---- pcbnew/dialogs/dialog_drc_base.fbp | 10 ++--- pcbnew/dialogs/dialog_drc_base.h | 4 +- pcbnew/tools/selection_tool.cpp | 8 ++++ 6 files changed, 48 insertions(+), 58 deletions(-) diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index b2e1f83ad1..34a3631204 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -67,6 +67,8 @@ DIALOG_DRC_CONTROL::DIALOG_DRC_CONTROL( DRC* aTester, PCB_EDIT_FRAME* aEditorFra m_footprintsTreeModel = new DRC_TREE_MODEL( m_footprintsDataView ); m_footprintsDataView->AssociateModel( m_footprintsTreeModel ); + m_Notebook->SetSelection( 0 ); + // We use a sdbSizer here to get the order right, which is platform-dependent m_sdbSizer1OK->SetLabel( _( "Run DRC" ) ); m_sdbSizer1Cancel->SetLabel( _( "Close" ) ); @@ -82,11 +84,12 @@ DIALOG_DRC_CONTROL::DIALOG_DRC_CONTROL( DRC* aTester, PCB_EDIT_FRAME* aEditorFra DIALOG_DRC_CONTROL::~DIALOG_DRC_CONTROL() { - auto cfg = m_brdEditor->GetSettings(); + m_brdEditor->FocusOnItem( nullptr ); - cfg->m_DrcDialog.refill_zones = m_cbRefillZones->GetValue(); - cfg->m_DrcDialog.test_track_to_zone = m_cbReportAllTrackErrors->GetValue(); - cfg->m_DrcDialog.test_footprints = m_cbTestFootprints->GetValue(); + PCBNEW_SETTINGS* settings = m_brdEditor->GetSettings(); + settings->m_DrcDialog.refill_zones = m_cbRefillZones->GetValue(); + settings->m_DrcDialog.test_track_to_zone = m_cbReportAllTrackErrors->GetValue(); + settings->m_DrcDialog.test_footprints = m_cbTestFootprints->GetValue(); m_markerTreeModel->DecRef(); } @@ -222,7 +225,8 @@ void DIALOG_DRC_CONTROL::OnRunDRCClick( wxCommandEvent& event ) wxEndBusyCursor(); - RedrawDrawPanel(); + RefreshBoardEditor(); + SetFocus(); } @@ -256,43 +260,17 @@ void DIALOG_DRC_CONTROL::OnDRCItemSelected( wxDataViewEvent& event ) } -void DIALOG_DRC_CONTROL::OnDClick( wxDataViewCtrl* ctrl, wxMouseEvent& event ) +void DIALOG_DRC_CONTROL::OnDRCItemDClick( wxDataViewEvent& event ) { - event.Skip(); - - if( ctrl->GetCurrentItem().IsOk() ) + if( event.GetItem().IsOk() ) { // turn control over to m_brdEditor, hide this DIALOG_DRC_CONTROL window, // no destruction so we can preserve listbox cursor if( !IsModal() ) Show( false ); } -} - -void DIALOG_DRC_CONTROL::OnMarkerDClick( wxMouseEvent& event ) -{ - OnDClick( m_markerDataView, event ); -} - - -void DIALOG_DRC_CONTROL::OnLeftDClickUnconnected( wxMouseEvent& event ) -{ - OnDClick( m_unconnectedDataView, event ); -} - - -void DIALOG_DRC_CONTROL::OnLeftDClickFootprints( wxMouseEvent& event ) -{ - OnDClick( m_footprintsDataView, event ); -} - - -void DIALOG_DRC_CONTROL::OnDeleteAllClick( wxCommandEvent& event ) -{ - DelDRCMarkers(); - RedrawDrawPanel(); - UpdateDisplayedCounts(); + event.Skip(); } @@ -315,6 +293,8 @@ void DIALOG_DRC_CONTROL::OnButtonBrowseRptFileClick( wxCommandEvent& ) void DIALOG_DRC_CONTROL::OnCancelClick( wxCommandEvent& event ) { + m_brdEditor->FocusOnItem( nullptr ); + SetReturnCode( wxID_CANCEL ); SetDRCParameters(); @@ -349,7 +329,7 @@ void DIALOG_DRC_CONTROL::OnChangingNotebookPage( wxNotebookEvent& event ) } -void DIALOG_DRC_CONTROL::RedrawDrawPanel() +void DIALOG_DRC_CONTROL::RefreshBoardEditor() { WINDOW_THAWER thawer( m_brdEditor ); @@ -445,7 +425,7 @@ void DIALOG_DRC_CONTROL::OnDeleteOneClick( wxCommandEvent& event ) m_markerTreeModel->DeleteCurrentItem(); // redraw the pcb - RedrawDrawPanel(); + RefreshBoardEditor(); } else if( m_Notebook->GetSelection() == 1 ) { @@ -456,6 +436,14 @@ void DIALOG_DRC_CONTROL::OnDeleteOneClick( wxCommandEvent& event ) } +void DIALOG_DRC_CONTROL::OnDeleteAllClick( wxCommandEvent& event ) +{ + DelDRCMarkers(); + RefreshBoardEditor(); + UpdateDisplayedCounts(); +} + + void DIALOG_DRC_CONTROL::UpdateDisplayedCounts() { wxString msg; diff --git a/pcbnew/dialogs/dialog_drc.h b/pcbnew/dialogs/dialog_drc.h index 59608b0289..a9a2fc451a 100644 --- a/pcbnew/dialogs/dialog_drc.h +++ b/pcbnew/dialogs/dialog_drc.h @@ -105,11 +105,7 @@ private: void OnDeleteOneClick( wxCommandEvent& event ) override; void OnDRCItemSelected( wxDataViewEvent& event ) override; - - void OnDClick( wxDataViewCtrl* ctrl, wxMouseEvent& event ); - void OnMarkerDClick( wxMouseEvent& event ) override; - void OnLeftDClickUnconnected( wxMouseEvent& event ) override; - void OnLeftDClickFootprints( wxMouseEvent& event ) override; + void OnDRCItemDClick( wxDataViewEvent& event ) override; void OnCancelClick( wxCommandEvent& event ) override; @@ -120,7 +116,7 @@ private: void OnChangingNotebookPage( wxNotebookEvent& event ) override; void DelDRCMarkers(); - void RedrawDrawPanel(); + void RefreshBoardEditor(); BOARD* m_currentBoard; // the board currently on test DRC* m_tester; diff --git a/pcbnew/dialogs/dialog_drc_base.cpp b/pcbnew/dialogs/dialog_drc_base.cpp index e6190d2659..96b2bad282 100644 --- a/pcbnew/dialogs/dialog_drc_base.cpp +++ b/pcbnew/dialogs/dialog_drc_base.cpp @@ -160,7 +160,7 @@ DIALOG_DRC_CONTROL_BASE::DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID i wxBoxSizer* bSizerUnconnectedBox; bSizerUnconnectedBox = new wxBoxSizer( wxVERTICAL ); - m_unconnectedDataView = new wxDataViewCtrl( m_panelUnconnectedItems, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + m_unconnectedDataView = new wxDataViewCtrl( m_panelUnconnectedItems, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxDV_NO_HEADER ); bSizerUnconnectedBox->Add( m_unconnectedDataView, 1, wxALL|wxEXPAND, 5 ); @@ -172,7 +172,7 @@ DIALOG_DRC_CONTROL_BASE::DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID i wxBoxSizer* bSizerFootprintsBox; bSizerFootprintsBox = new wxBoxSizer( wxVERTICAL ); - m_footprintsDataView = new wxDataViewCtrl( m_panelFootprintWarnings, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + m_footprintsDataView = new wxDataViewCtrl( m_panelFootprintWarnings, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxDV_NO_HEADER ); bSizerFootprintsBox->Add( m_footprintsDataView, 1, wxALL|wxEXPAND, 5 ); @@ -214,12 +214,12 @@ DIALOG_DRC_CONTROL_BASE::DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID i m_RptFilenameCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnReportFilenameEdited ), NULL, this ); m_BrowseButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnButtonBrowseRptFileClick ), NULL, this ); m_Notebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_DRC_CONTROL_BASE::OnChangingNotebookPage ), NULL, this ); + m_markerDataView->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemDClick ), NULL, this ); m_markerDataView->Connect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemSelected ), NULL, this ); - m_markerDataView->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnMarkerDClick ), NULL, this ); + m_unconnectedDataView->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemDClick ), NULL, this ); m_unconnectedDataView->Connect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemSelected ), NULL, this ); - m_unconnectedDataView->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftDClickUnconnected ), NULL, this ); + m_footprintsDataView->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemDClick ), NULL, this ); m_footprintsDataView->Connect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemSelected ), NULL, this ); - m_footprintsDataView->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftDClickFootprints ), NULL, this ); m_DeleteCurrentMarkerButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnDeleteOneClick ), NULL, this ); m_DeleteAllMarkersButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnDeleteAllClick ), NULL, this ); m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnCancelClick ), NULL, this ); @@ -234,12 +234,12 @@ DIALOG_DRC_CONTROL_BASE::~DIALOG_DRC_CONTROL_BASE() m_RptFilenameCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnReportFilenameEdited ), NULL, this ); m_BrowseButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnButtonBrowseRptFileClick ), NULL, this ); m_Notebook->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_DRC_CONTROL_BASE::OnChangingNotebookPage ), NULL, this ); + m_markerDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemDClick ), NULL, this ); m_markerDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemSelected ), NULL, this ); - m_markerDataView->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnMarkerDClick ), NULL, this ); + m_unconnectedDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemDClick ), NULL, this ); m_unconnectedDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemSelected ), NULL, this ); - m_unconnectedDataView->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftDClickUnconnected ), NULL, this ); + m_footprintsDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemDClick ), NULL, this ); m_footprintsDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_DRC_CONTROL_BASE::OnDRCItemSelected ), NULL, this ); - m_footprintsDataView->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftDClickFootprints ), NULL, this ); m_DeleteCurrentMarkerButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnDeleteOneClick ), NULL, this ); m_DeleteAllMarkersButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnDeleteAllClick ), NULL, this ); m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnCancelClick ), NULL, this ); diff --git a/pcbnew/dialogs/dialog_drc_base.fbp b/pcbnew/dialogs/dialog_drc_base.fbp index 6ef11605c3..a819eaedce 100644 --- a/pcbnew/dialogs/dialog_drc_base.fbp +++ b/pcbnew/dialogs/dialog_drc_base.fbp @@ -1367,8 +1367,8 @@ + OnDRCItemDClick OnDRCItemSelected - OnMarkerDClick @@ -1453,14 +1453,14 @@ protected - + wxDV_NO_HEADER ; ; forward_declare + OnDRCItemDClick OnDRCItemSelected - OnLeftDClickUnconnected @@ -1545,14 +1545,14 @@ protected - + wxDV_NO_HEADER ; ; forward_declare + OnDRCItemDClick OnDRCItemSelected - OnLeftDClickFootprints diff --git a/pcbnew/dialogs/dialog_drc_base.h b/pcbnew/dialogs/dialog_drc_base.h index 76d5331fd9..b22e815940 100644 --- a/pcbnew/dialogs/dialog_drc_base.h +++ b/pcbnew/dialogs/dialog_drc_base.h @@ -79,10 +79,8 @@ class DIALOG_DRC_CONTROL_BASE : public DIALOG_SHIM virtual void OnReportFilenameEdited( wxCommandEvent& event ) { event.Skip(); } virtual void OnButtonBrowseRptFileClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnChangingNotebookPage( wxNotebookEvent& event ) { event.Skip(); } + virtual void OnDRCItemDClick( wxDataViewEvent& event ) { event.Skip(); } virtual void OnDRCItemSelected( wxDataViewEvent& event ) { event.Skip(); } - virtual void OnMarkerDClick( wxMouseEvent& event ) { event.Skip(); } - virtual void OnLeftDClickUnconnected( wxMouseEvent& event ) { event.Skip(); } - virtual void OnLeftDClickFootprints( wxMouseEvent& event ) { event.Skip(); } virtual void OnDeleteOneClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnDeleteAllClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 263cc1fa4d..55b1a805d6 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -213,6 +213,8 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) // Single click? Select single object if( evt->IsClick( BUT_LEFT ) ) { + m_frame->FocusOnItem( nullptr ); + selectPoint( evt->Position() ); } @@ -236,6 +238,8 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) // double click? Display the properties window else if( evt->IsDblClick( BUT_LEFT ) ) { + m_frame->FocusOnItem( nullptr ); + if( m_selection.Empty() ) selectPoint( evt->Position() ); @@ -245,6 +249,8 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) // drag with LMB? Select multiple objects (or at least draw a selection box) or drag them else if( evt->IsDrag( BUT_LEFT ) ) { + m_frame->FocusOnItem( nullptr ); + if( m_additive || m_subtractive || m_exclusive_or || dragAlwaysSelects ) { selectMultiple(); @@ -272,6 +278,8 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) else if( evt->IsCancel() ) { + m_frame->FocusOnItem( nullptr ); + ClearSelection(); if( evt->FirstResponder() == this )