diff --git a/common/dialogs/dialog_edit_library_tables.cpp b/common/dialogs/dialog_edit_library_tables.cpp index 712488efd4..08734f8b73 100644 --- a/common/dialogs/dialog_edit_library_tables.cpp +++ b/common/dialogs/dialog_edit_library_tables.cpp @@ -43,6 +43,9 @@ void DIALOG_EDIT_LIBRARY_TABLES::InstallPanel( wxPanel* aPanel ) auto mainSizer = new wxBoxSizer( wxVERTICAL ); SetSizer( mainSizer ); + m_infoBar = new WX_INFOBAR( this ); + mainSizer->Add( m_infoBar, 0, wxEXPAND, 0 ); + mainSizer->Add( m_contentPanel, 1, wxEXPAND|wxLEFT|wxTOP|wxRIGHT, 5 ); m_contentPanel->SetMinSize( FromDIP( wxSize( 1000, 600 ) ) ); diff --git a/common/lib_table_grid_tricks.cpp b/common/lib_table_grid_tricks.cpp index 9d7458e89b..dcf231ce69 100644 --- a/common/lib_table_grid_tricks.cpp +++ b/common/lib_table_grid_tricks.cpp @@ -21,7 +21,8 @@ #include "lib_table_grid.h" -LIB_TABLE_GRID_TRICKS::LIB_TABLE_GRID_TRICKS( WX_GRID* aGrid ) : GRID_TRICKS( aGrid ) +LIB_TABLE_GRID_TRICKS::LIB_TABLE_GRID_TRICKS( WX_GRID* aGrid ) : + GRID_TRICKS( aGrid ) { } @@ -65,11 +66,14 @@ void LIB_TABLE_GRID_TRICKS::showPopupMenu( wxMenu& menu, wxGridEvent& aEvent ) if( showDeactivate ) menu.Append( LIB_TABLE_GRID_TRICKS_DEACTIVATE_SELECTED, _( "Deactivate selected" ) ); - if( showSetVisible ) - menu.Append( LIB_TABLE_GRID_TRICKS_SET_VISIBLE, _( "Set visible flag" ) ); + if( supportsVisibilityColumn() ) + { + if( showSetVisible ) + menu.Append( LIB_TABLE_GRID_TRICKS_SET_VISIBLE, _( "Set visible flag" ) ); - if( showUnsetVisible ) - menu.Append( LIB_TABLE_GRID_TRICKS_UNSET_VISIBLE, _( "Unset visible flag" ) ); + if( showUnsetVisible ) + menu.Append( LIB_TABLE_GRID_TRICKS_UNSET_VISIBLE, _( "Unset visible flag" ) ); + } bool showSettings = false; diff --git a/eeschema/dialogs/panel_sym_lib_table.cpp b/eeschema/dialogs/panel_sym_lib_table.cpp index 44bbcb38d4..186066c1fa 100644 --- a/eeschema/dialogs/panel_sym_lib_table.cpp +++ b/eeschema/dialogs/panel_sym_lib_table.cpp @@ -226,6 +226,11 @@ protected: m_grid->AutoSizeColumns( false ); } } + + bool supportsVisibilityColumn() override + { + return true; + } }; diff --git a/include/dialogs/dialog_edit_library_tables.h b/include/dialogs/dialog_edit_library_tables.h index 82778304f1..862d4bcec3 100644 --- a/include/dialogs/dialog_edit_library_tables.h +++ b/include/dialogs/dialog_edit_library_tables.h @@ -22,6 +22,8 @@ #define DIALOG_EDIT_LIBRARY_TABLES_H #include +#include +#include class DIALOG_EDIT_LIBRARY_TABLES : public DIALOG_SHIM @@ -38,8 +40,20 @@ public: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; + void ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton = false, + WX_INFOBAR::MESSAGE_TYPE aType = WX_INFOBAR::MESSAGE_TYPE::GENERIC ) + { + m_infoBar->RemoveAllButtons(); + + if( aShowCloseButton ) + m_infoBar->AddCloseButton(); + + m_infoBar->ShowMessageFor( aErrorMsg, 8000, wxICON_ERROR, aType ); + } + protected: - wxPanel* m_contentPanel; + WX_INFOBAR* m_infoBar; + wxPanel* m_contentPanel; }; diff --git a/include/grid_tricks.h b/include/grid_tricks.h index 12644851c9..ab31152f3c 100644 --- a/include/grid_tricks.h +++ b/include/grid_tricks.h @@ -114,7 +114,7 @@ protected: bool isCheckbox( int aRow, int aCol ); bool isReadOnly( int aRow, int aCol ); - bool toggleCell( int aRow, int aCol, bool aPreserveSelection = false ); + virtual bool toggleCell( int aRow, int aCol, bool aPreserveSelection = false ); bool showEditor( int aRow, int aCol ); virtual void paste_clipboard(); diff --git a/include/lib_table_grid_tricks.h b/include/lib_table_grid_tricks.h index ade797ce4d..bd36e46bc8 100644 --- a/include/lib_table_grid_tricks.h +++ b/include/lib_table_grid_tricks.h @@ -42,4 +42,6 @@ public: protected: virtual void optionsEditor( int aRow ) = 0; bool handleDoubleClick( wxGridEvent& aEvent ) override; + + virtual bool supportsVisibilityColumn() { return false; } }; diff --git a/pcbnew/dialogs/panel_fp_lib_table.cpp b/pcbnew/dialogs/panel_fp_lib_table.cpp index d569f4ed32..0d3ff61bb0 100644 --- a/pcbnew/dialogs/panel_fp_lib_table.cpp +++ b/pcbnew/dialogs/panel_fp_lib_table.cpp @@ -215,7 +215,8 @@ class FP_GRID_TRICKS : public LIB_TABLE_GRID_TRICKS { public: FP_GRID_TRICKS( DIALOG_EDIT_LIBRARY_TABLES* aParent, WX_GRID* aGrid ) : - LIB_TABLE_GRID_TRICKS( aGrid ), m_dialog( aParent ) + LIB_TABLE_GRID_TRICKS( aGrid ), + m_dialog( aParent ) { } protected: @@ -294,6 +295,18 @@ protected: m_grid->AutoSizeColumns( false ); } } + + + bool toggleCell( int aRow, int aCol, bool aPreserveSelection ) override + { + if( aCol == COL_VISIBLE ) + { + m_dialog->ShowInfoBarError( _( "Hidden footprint libraries are not yet supported." ) ); + return true; + } + + return LIB_TABLE_GRID_TRICKS::toggleCell( aRow, aCol, aPreserveSelection ); + } }; @@ -376,6 +389,10 @@ PANEL_FP_LIB_TABLE::PANEL_FP_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent, PRO attr->SetReadOnly(); // not really; we delegate interactivity to GRID_TRICKS aGrid->SetColAttr( COL_ENABLED, attr ); + attr = new wxGridCellAttr; + attr->SetRenderer( new wxGridCellBoolRenderer() ); + attr->SetReadOnly(); // not really; we delegate interactivity to GRID_TRICKS + aGrid->SetColAttr( COL_VISIBLE, attr ); // No visibility control for footprint libraries yet; this feature is primarily // useful for database libraries and it's only implemented for schematic symbols // at the moment.