diff --git a/3d-viewer/3d_cache/dialogs/panel_prev_3d.cpp b/3d-viewer/3d_cache/dialogs/panel_prev_3d.cpp index 8878169863..2637bdfb5b 100644 --- a/3d-viewer/3d_cache/dialogs/panel_prev_3d.cpp +++ b/3d-viewer/3d_cache/dialogs/panel_prev_3d.cpp @@ -449,7 +449,7 @@ void PANEL_PREV_3D::UpdateDummyFootprint( bool aReloadRequired ) { m_dummyFootprint->Models().clear(); - for( FP_3DMODEL& model : *m_parentModelList) + for( FP_3DMODEL& model : *m_parentModelList ) { if( model.m_Show ) m_dummyFootprint->Models().push_back( model ); diff --git a/common/dialogs/dialog_configure_paths.cpp b/common/dialogs/dialog_configure_paths.cpp index 8941418ab1..cdf116bc79 100644 --- a/common/dialogs/dialog_configure_paths.cpp +++ b/common/dialogs/dialog_configure_paths.cpp @@ -75,11 +75,11 @@ DIALOG_CONFIGURE_PATHS::DIALOG_CONFIGURE_PATHS( wxWindow* aParent, FILENAME_RESO m_EnvVars->UseNativeColHeader( true ); wxGridCellAttr* attr = new wxGridCellAttr; - attr->SetEditor( new GRID_CELL_PATH_EDITOR( this, &m_curdir, wxEmptyString ) ); + attr->SetEditor( new GRID_CELL_PATH_EDITOR( this, m_EnvVars, &m_curdir, wxEmptyString ) ); m_EnvVars->SetColAttr( TV_VALUE_COL, attr ); attr = new wxGridCellAttr; - attr->SetEditor( new GRID_CELL_PATH_EDITOR( this, &m_curdir, wxEmptyString ) ); + attr->SetEditor( new GRID_CELL_PATH_EDITOR( this, m_SearchPaths, &m_curdir, wxEmptyString ) ); m_SearchPaths->SetColAttr( TV_VALUE_COL, attr ); // Give a bit more room for combobox editors diff --git a/common/widgets/grid_text_button_helpers.cpp b/common/widgets/grid_text_button_helpers.cpp index 178c148c1f..6e4f9c92cf 100644 --- a/common/widgets/grid_text_button_helpers.cpp +++ b/common/widgets/grid_text_button_helpers.cpp @@ -1,7 +1,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2018-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2021 CERN + * Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -32,7 +33,7 @@ #include #include #include - +#include #include #include @@ -318,11 +319,13 @@ void GRID_CELL_URL_EDITOR::Create( wxWindow* aParent, wxWindowID aId, class TEXT_BUTTON_FILE_BROWSER : public wxComboCtrl { public: - TEXT_BUTTON_FILE_BROWSER( wxWindow* aParent, DIALOG_SHIM* aParentDlg, + TEXT_BUTTON_FILE_BROWSER( wxWindow* aParent, DIALOG_SHIM* aParentDlg, WX_GRID* aGrid, wxString* aCurrentDir, wxString* aExt = nullptr, - bool aNormalize = false, wxString aNormalizeBasePath = wxEmptyString ) : + bool aNormalize = false, + wxString aNormalizeBasePath = wxEmptyString ) : wxComboCtrl( aParent ), m_dlg( aParentDlg ), + m_grid( aGrid ), m_currentDir( aCurrentDir ), m_ext( aExt ), m_normalize( aNormalize ), @@ -370,6 +373,7 @@ protected: relPath = filePath; SetValue( relPath ); + m_grid->CommitPendingChanges(); *m_currentDir = lastPath; } } @@ -393,12 +397,14 @@ protected: relPath = filePath; SetValue( relPath ); + m_grid->CommitPendingChanges(); *m_currentDir = relPath; } } } DIALOG_SHIM* m_dlg; + WX_GRID* m_grid; wxString* m_currentDir; wxString* m_ext; bool m_normalize; @@ -410,10 +416,10 @@ void GRID_CELL_PATH_EDITOR::Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) { if( m_ext.IsEmpty() ) - m_control = new TEXT_BUTTON_FILE_BROWSER( aParent, m_dlg, m_currentDir, nullptr, + m_control = new TEXT_BUTTON_FILE_BROWSER( aParent, m_dlg, m_grid, m_currentDir, nullptr, m_normalize, m_normalizeBasePath ); else - m_control = new TEXT_BUTTON_FILE_BROWSER( aParent, m_dlg, m_currentDir, &m_ext, + m_control = new TEXT_BUTTON_FILE_BROWSER( aParent, m_dlg, m_grid, m_currentDir, &m_ext, m_normalize, m_normalizeBasePath ); #if wxUSE_VALIDATORS diff --git a/eeschema/dialogs/dialog_lib_symbol_properties.cpp b/eeschema/dialogs/dialog_lib_symbol_properties.cpp index 7ea62cea05..a2e117e073 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_lib_symbol_properties.cpp @@ -62,7 +62,7 @@ DIALOG_LIB_SYMBOL_PROPERTIES::DIALOG_LIB_SYMBOL_PROPERTIES( SYMBOL_EDIT_FRAME* a { // Give a bit more room for combobox editors m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 ); - m_fields = new FIELDS_GRID_TABLE( this, aParent, m_libEntry ); + m_fields = new FIELDS_GRID_TABLE( this, aParent, m_grid, m_libEntry ); m_grid->SetTable( m_fields ); m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this ) ); diff --git a/eeschema/dialogs/dialog_sheet_properties.cpp b/eeschema/dialogs/dialog_sheet_properties.cpp index 1d2c77d010..c40e997168 100644 --- a/eeschema/dialogs/dialog_sheet_properties.cpp +++ b/eeschema/dialogs/dialog_sheet_properties.cpp @@ -49,7 +49,7 @@ DIALOG_SHEET_PROPERTIES::DIALOG_SHEET_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_S m_dummySheetNameField( wxDefaultPosition, SHEETNAME, &m_dummySheet ) { m_sheet = aSheet; - m_fields = new FIELDS_GRID_TABLE( this, aParent, m_sheet ); + m_fields = new FIELDS_GRID_TABLE( this, aParent, m_grid, m_sheet ); m_width = 100; // Will be later set to a better value m_delayedFocusRow = SHEETNAME; m_delayedFocusColumn = FDC_VALUE; diff --git a/eeschema/dialogs/dialog_symbol_properties.cpp b/eeschema/dialogs/dialog_symbol_properties.cpp index fdf0038c08..8af94f27e3 100644 --- a/eeschema/dialogs/dialog_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_symbol_properties.cpp @@ -286,7 +286,7 @@ DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES( SCH_EDIT_FRAME* aParent, // so we need to handle m_part == nullptr wxASSERT( m_part ); - m_fields = new FIELDS_GRID_TABLE( this, aParent, m_part ); + m_fields = new FIELDS_GRID_TABLE( this, aParent, m_fieldsGrid, m_part ); m_width = 0; m_delayedFocusRow = REFERENCE_FIELD; diff --git a/eeschema/dialogs/panel_sym_lib_table.cpp b/eeschema/dialogs/panel_sym_lib_table.cpp index 5c231a74a2..07fd1db1b1 100644 --- a/eeschema/dialogs/panel_sym_lib_table.cpp +++ b/eeschema/dialogs/panel_sym_lib_table.cpp @@ -222,9 +222,9 @@ PANEL_SYM_LIB_TABLE::PANEL_SYM_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent, P wxString wildcards = AllSymbolLibFilesWildcard() + "|" + KiCadSymbolLibFileWildcard() + "|" + LegacySymbolLibFileWildcard(); - attr->SetEditor( new GRID_CELL_PATH_EDITOR( m_parent, &cfg->m_lastSymbolLibDir, - wildcards, true, - m_project->GetProjectPath() ) ); + attr->SetEditor( new GRID_CELL_PATH_EDITOR( m_parent, aGrid, + &cfg->m_lastSymbolLibDir, wildcards, + true, m_project->GetProjectPath() ) ); aGrid->SetColAttr( COL_URI, attr ); attr = new wxGridCellAttr; diff --git a/eeschema/fields_grid_table.cpp b/eeschema/fields_grid_table.cpp index 58212e6183..8ea8a71229 100644 --- a/eeschema/fields_grid_table.cpp +++ b/eeschema/fields_grid_table.cpp @@ -46,9 +46,10 @@ enum template FIELDS_GRID_TABLE::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame, - LIB_PART* aPart ) : + WX_GRID* aGrid, LIB_PART* aPart ) : m_frame( aFrame ), m_userUnits( aDialog->GetUserUnits() ), + m_grid( aGrid ), m_parentType( SCH_COMPONENT_T ), m_mandatoryFieldCount( MANDATORY_FIELDS ), m_part( aPart ), @@ -60,15 +61,16 @@ FIELDS_GRID_TABLE::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* a m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ), m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETFILENAME ) { - initGrid( aDialog ); + initGrid( aDialog, aGrid ); } template FIELDS_GRID_TABLE::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame, - SCH_SHEET* aSheet ) : + WX_GRID* aGrid, SCH_SHEET* aSheet ) : m_frame( aFrame ), m_userUnits( aDialog->GetUserUnits() ), + m_grid( aGrid ), m_parentType( SCH_SHEET_T ), m_mandatoryFieldCount( SHEET_MANDATORY_FIELDS ), m_part( nullptr ), @@ -80,12 +82,12 @@ FIELDS_GRID_TABLE::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* a m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ), m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETFILENAME_V ) { - initGrid( aDialog ); + initGrid( aDialog, aGrid ); } template -void FIELDS_GRID_TABLE::initGrid( DIALOG_SHIM* aDialog ) +void FIELDS_GRID_TABLE::initGrid( DIALOG_SHIM* aDialog, WX_GRID* aGrid ) { // Build the various grid cell attributes. // NOTE: validators and cellAttrs are member variables to get the destruction order @@ -133,7 +135,7 @@ void FIELDS_GRID_TABLE::initGrid( DIALOG_SHIM* aDialog ) exts.push_back( KiCadSchematicFileExtension ); wildCard += AddFileExtListToFilter( exts ); - auto filepathEditor = new GRID_CELL_PATH_EDITOR( aDialog, &m_curdir, wildCard ); + auto filepathEditor = new GRID_CELL_PATH_EDITOR( aDialog, aGrid, &m_curdir, wildCard ); filepathEditor->SetValidator( m_filepathValidator ); m_filepathAttr->SetEditor( filepathEditor ); diff --git a/eeschema/fields_grid_table.h b/eeschema/fields_grid_table.h index a9643a36d9..86b3a3d6ae 100644 --- a/eeschema/fields_grid_table.h +++ b/eeschema/fields_grid_table.h @@ -72,8 +72,10 @@ template class FIELDS_GRID_TABLE : public wxGridTableBase, public std::vector { public: - FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame, LIB_PART* aPart ); - FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame, SCH_SHEET* aSheet ); + FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame, WX_GRID* aGrid, + LIB_PART* aPart ); + FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame, WX_GRID* aGrid, + SCH_SHEET* aSheet ); ~FIELDS_GRID_TABLE(); int GetNumberRows() override { return (int) this->size(); } @@ -100,11 +102,12 @@ public: bool BoolFromString( wxString aValue ) const; protected: - void initGrid( DIALOG_SHIM* aDialog ); + void initGrid( DIALOG_SHIM* aDialog, WX_GRID* aGrid ); private: SCH_BASE_FRAME* m_frame; EDA_UNITS m_userUnits; + WX_GRID* m_grid; KICAD_T m_parentType; int m_mandatoryFieldCount; LIB_PART* m_part; diff --git a/include/widgets/grid_text_button_helpers.h b/include/widgets/grid_text_button_helpers.h index 08c3205e05..043910ff09 100644 --- a/include/widgets/grid_text_button_helpers.h +++ b/include/widgets/grid_text_button_helpers.h @@ -1,7 +1,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2018-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2021 CERN + * Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -30,6 +31,7 @@ class wxGrid; +class WX_GRID; class DIALOG_SHIM; @@ -138,13 +140,18 @@ public: * Constructor * * @param aCurrentDir is current directory the path editor will open at - * @param aExt is the file extension(s) to filter by. If empty, the path editor will switch to folder mode instead of file. - * @param aNormalize indicates whether to normalize the selected path (replace part of path with variables or relative path) - * @param aNormalizeBasePath is the path to use when trying to base variables (generally current project path) + * @param aExt is the file extension(s) to filter by. If empty, the path editor will switch + * to folder mode instead of file. + * @param aNormalize indicates whether to normalize the selected path (replace part of path + * with variables or relative path) + * @param aNormalizeBasePath is the path to use when trying to base variables (generally + * current project path) */ - GRID_CELL_PATH_EDITOR( DIALOG_SHIM* aParent, wxString* aCurrentDir, const wxString& aExt, - bool aNormalize = false, wxString aNormalizeBasePath = wxEmptyString ) : - m_dlg( aParent ), + GRID_CELL_PATH_EDITOR( DIALOG_SHIM* aParentDialog, WX_GRID* aGrid, wxString* aCurrentDir, + const wxString& aExt, bool aNormalize = false, + wxString aNormalizeBasePath = wxEmptyString ) : + m_dlg( aParentDialog ), + m_grid( aGrid ), m_currentDir( aCurrentDir ), m_ext( aExt ), m_normalize( aNormalize ), @@ -153,13 +160,14 @@ public: wxGridCellEditor* Clone() const override { - return new GRID_CELL_PATH_EDITOR( m_dlg, m_currentDir, m_ext ); + return new GRID_CELL_PATH_EDITOR( m_dlg, m_grid, m_currentDir, m_ext ); } void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override; protected: DIALOG_SHIM* m_dlg; + WX_GRID* m_grid; wxString* m_currentDir; wxString m_ext; bool m_normalize; diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp index 27d7dc9849..c97ed1a232 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp @@ -27,7 +27,6 @@ #include #include #include <3d_viewer/eda_3d_viewer.h> -#include #include #include #include @@ -96,8 +95,8 @@ DIALOG_FOOTPRINT_FP_EDITOR::DIALOG_FOOTPRINT_FP_EDITOR( FOOTPRINT_EDIT_FRAME* aP } wxGridCellAttr* attr = new wxGridCellAttr; - attr->SetEditor( new GRID_CELL_PATH_EDITOR( this, &cfg->m_lastFootprint3dDir, "*.*", - true, Prj().GetProjectPath() ) ); + attr->SetEditor( new GRID_CELL_PATH_EDITOR( this, m_modelsGrid, &cfg->m_lastFootprint3dDir, + "*.*", true, Prj().GetProjectPath() ) ); m_modelsGrid->SetColAttr( 0, attr ); // Show checkbox @@ -315,6 +314,7 @@ bool DIALOG_FOOTPRINT_FP_EDITOR::TransferDataToWindow() } select3DModel( 0 ); // will clamp idx within bounds + m_PreviewPane->UpdateDummyFootprint(); for( int col = 0; col < m_itemsGrid->GetNumberCols(); col++ ) { diff --git a/pcbnew/dialogs/dialog_footprint_properties.cpp b/pcbnew/dialogs/dialog_footprint_properties.cpp index 9c066ebc81..a2519e8a5f 100644 --- a/pcbnew/dialogs/dialog_footprint_properties.cpp +++ b/pcbnew/dialogs/dialog_footprint_properties.cpp @@ -105,8 +105,8 @@ DIALOG_FOOTPRINT_PROPERTIES::DIALOG_FOOTPRINT_PROPERTIES( PCB_EDIT_FRAME* aParen } wxGridCellAttr* attr = new wxGridCellAttr; - attr->SetEditor( new GRID_CELL_PATH_EDITOR( this, &cfg->m_lastFootprint3dDir, "*.*", - true, Prj().GetProjectPath() ) ); + attr->SetEditor( new GRID_CELL_PATH_EDITOR( this, m_modelsGrid, &cfg->m_lastFootprint3dDir, + "*.*", true, Prj().GetProjectPath() ) ); m_modelsGrid->SetColAttr( 0, attr ); // Show checkbox diff --git a/pcbnew/dialogs/panel_fp_lib_table.cpp b/pcbnew/dialogs/panel_fp_lib_table.cpp index 8962116893..5fb70ef529 100644 --- a/pcbnew/dialogs/panel_fp_lib_table.cpp +++ b/pcbnew/dialogs/panel_fp_lib_table.cpp @@ -407,8 +407,10 @@ PANEL_FP_LIB_TABLE::PANEL_FP_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent, wxGridCellAttr* attr; attr = new wxGridCellAttr; - attr->SetEditor( new GRID_CELL_PATH_EDITOR( m_parent, &cfg->m_lastFootprintLibDir, - wxEmptyString, true, m_projectBasePath ) ); + attr->SetEditor( new GRID_CELL_PATH_EDITOR( m_parent, aGrid, + &cfg->m_lastFootprintLibDir, + wxEmptyString, true, + m_projectBasePath ) ); aGrid->SetColAttr( COL_URI, attr ); attr = new wxGridCellAttr;