This commit is contained in:
Jeff Young 2023-09-28 18:18:19 +01:00
parent 974da4ea7c
commit b592a6634e
13 changed files with 84 additions and 208 deletions

View File

@ -186,7 +186,7 @@ LIB_TREE::LIB_TREE( wxWindow* aParent, const wxString& aRecentSearchesKey, LIB_T
// Process hotkeys when the tree control has focus:
m_tree_ctrl->Bind( wxEVT_CHAR_HOOK, &LIB_TREE::onTreeCharHook, this );
Bind( SYMBOL_PRESELECTED, &LIB_TREE::onPreselect, this );
Bind( EVT_LIBITEM_SELECTED, &LIB_TREE::onPreselect, this );
if( m_query_ctrl )
{
@ -465,14 +465,14 @@ void LIB_TREE::expandIfValid( const wxDataViewItem& aTreeId )
void LIB_TREE::postPreselectEvent()
{
wxCommandEvent event( SYMBOL_PRESELECTED );
wxCommandEvent event( EVT_LIBITEM_SELECTED );
wxPostEvent( this, event );
}
void LIB_TREE::postSelectEvent()
{
wxCommandEvent event( SYMBOL_SELECTED );
wxCommandEvent event( EVT_LIBITEM_CHOSEN );
wxPostEvent( this, event );
}
@ -898,5 +898,5 @@ void LIB_TREE::onHeaderContextMenu( wxDataViewEvent& aEvent )
}
wxDEFINE_EVENT( SYMBOL_PRESELECTED, wxCommandEvent );
wxDEFINE_EVENT( SYMBOL_SELECTED, wxCommandEvent );
wxDEFINE_EVENT( EVT_LIBITEM_SELECTED, wxCommandEvent );
wxDEFINE_EVENT( EVT_LIBITEM_CHOSEN, wxCommandEvent );

View File

@ -162,7 +162,7 @@ void SYMBOL_CHOOSER_FRAME::OnOK( wxCommandEvent& aEvent )
WINDOW_SETTINGS* SYMBOL_CHOOSER_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg )
{
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg );
EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg );
wxASSERT( cfg );
return &cfg->m_LibViewPanel.window;
}

View File

@ -219,11 +219,8 @@ SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
FinishAUIInitialization();
if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame
{
Raise();
Show( true );
}
Raise();
Show( true );
SyncView();
GetCanvas()->SetCanFocus( false );
@ -469,62 +466,10 @@ void SYMBOL_VIEWER_FRAME::updatePreviewSymbol()
}
bool SYMBOL_VIEWER_FRAME::ShowModal( wxString* aSymbol, wxWindow* aParent )
{
if( aSymbol && !aSymbol->IsEmpty() )
{
wxString msg;
LIB_TABLE* libTable = PROJECT_SCH::SchSymbolLibTable( &Prj() );
LIB_ID libid;
libid.Parse( *aSymbol, true );
if( libid.IsValid() )
{
wxString libName = libid.GetLibNickname();
if( !libTable->HasLibrary( libid.GetLibNickname(), false ) )
{
msg.Printf( _( "The current configuration does not include the library '%s'.\n"
"Use Manage Symbol Libraries to edit the configuration." ),
UnescapeString( libName ) );
DisplayErrorMessage( this, _( "Library not found in symbol library table." ), msg );
}
else if ( !libTable->HasLibrary( libid.GetLibNickname(), true ) )
{
msg.Printf( _( "The library '%s' is not enabled in the current configuration.\n"
"Use Manage Symbol Libraries to edit the configuration." ),
UnescapeString( libName ) );
DisplayErrorMessage( aParent, _( "Symbol library not enabled." ), msg );
}
else
{
SetSelectedLibrary( libid.GetLibNickname(), libid.GetSubLibraryName() );
SetSelectedSymbol( libid.GetLibItemName() );
}
}
}
m_libFilter->SetFocus();
return KIWAY_PLAYER::ShowModal( aSymbol, aParent );
}
void SYMBOL_VIEWER_FRAME::doCloseWindow()
{
GetCanvas()->StopDrawing();
if( !IsModal() )
{
Destroy();
}
else if( !IsDismissed() )
{
// only dismiss modal frame if not already dismissed.
DismissModal( false );
// Modal frame will be destroyed by the calling function.
}
Destroy();
}
@ -947,7 +892,7 @@ void SYMBOL_VIEWER_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg)
WINDOW_SETTINGS* SYMBOL_VIEWER_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg )
{
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg );
EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg );
wxASSERT( cfg );
return &cfg->m_LibViewPanel.window;
}
@ -957,7 +902,7 @@ void SYMBOL_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTex
{
SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
auto cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
GetGalDisplayOptions().ReadWindowSettings( cfg->m_LibViewPanel.window );
GetCanvas()->GetGAL()->SetAxesColor( m_colorSettings->GetColor( LAYER_SCHEMATIC_GRID_AXES ) );
@ -993,21 +938,6 @@ void SYMBOL_VIEWER_FRAME::CloseLibraryViewer( wxCommandEvent& event )
}
void SYMBOL_VIEWER_FRAME::SetFilter( const SYMBOL_LIBRARY_FILTER* aFilter )
{
m_listPowerOnly = false;
m_allowedLibs.Clear();
if( aFilter )
{
m_allowedLibs = aFilter->GetAllowedLibList();
m_listPowerOnly = aFilter->GetFilterPowerSymbols();
}
ReCreateLibList();
}
const BOX2I SYMBOL_VIEWER_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
{
LIB_SYMBOL* symbol = GetSelectedSymbol();
@ -1028,21 +958,6 @@ const BOX2I SYMBOL_VIEWER_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) c
}
void SYMBOL_VIEWER_FRAME::FinishModal()
{
if( m_symbolList->GetSelection() >= 0 )
{
DismissModal( true, m_currentSymbol.Format() );
}
else
{
DismissModal( false );
}
Close( true );
}
void SYMBOL_VIEWER_FRAME::OnLibFilter( wxCommandEvent& aEvent )
{
ReCreateLibList();

View File

@ -55,19 +55,6 @@ public:
~SYMBOL_VIEWER_FRAME();
/**
* Runs the symbol viewer as a modal dialog.
*
* @param aSymbol an optional FPID string to initialize the viewer with and to
* return a selected footprint through.
*/
bool ShowModal( wxString* aSymbol, wxWindow* aParent ) override;
/**
* Send the selected symbol back to the caller.
*/
void FinishModal();
void OnSize( wxSizeEvent& event ) override;
/**
@ -102,15 +89,6 @@ public:
void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
/**
* Set a filter to display only libraries and/or symbols which match the filter.
*
* @param aFilter is a filter to pass the allowed library name list and/or some other filter
* see SCH_BASE_FRAME::SelectSymbolFromLibrary() for details.
* if aFilter == NULL, remove all filtering.
*/
void SetFilter( const SYMBOL_LIBRARY_FILTER* aFilter );
/**
* Set the selected library in the library window.
*/

View File

@ -664,22 +664,12 @@ int SYMBOL_EDITOR_CONTROL::AddSymbolToSchematic( const TOOL_EVENT& aEvent )
{
SYMBOL_VIEWER_FRAME* viewerFrame = getEditFrame<SYMBOL_VIEWER_FRAME>();
if( viewerFrame->IsModal() )
{
// if we're modal then we just need to return the symbol selection; the caller is
// already in a EE_ACTIONS::placeSymbol coroutine.
viewerFrame->FinishModal();
return 0;
}
else
{
libSymbol = viewerFrame->GetSelectedSymbol();
unit = viewerFrame->GetUnit();
convert = viewerFrame->GetConvert();
libSymbol = viewerFrame->GetSelectedSymbol();
unit = viewerFrame->GetUnit();
convert = viewerFrame->GetConvert();
if( libSymbol )
libId = libSymbol->GetLibId();
}
if( libSymbol )
libId = libSymbol->GetLibId();
}
if( libSymbol )

View File

@ -22,31 +22,27 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <symbol_library.h>
#include <pgm_base.h>
#include <symbol_library.h> // For SYMBOL_LIBRARY_FILTER
#include <panel_symbol_chooser.h>
#include <eeschema_settings.h>
#include <kiface_base.h>
#include <sch_base_frame.h>
#include <core/kicad_algo.h>
#include <template_fieldnames.h>
#include <project_sch.h>
#include <widgets/footprint_preview_widget.h>
#include <widgets/footprint_select_widget.h>
#include <widgets/lib_tree.h>
#include <widgets/symbol_preview_widget.h>
#include <widgets/footprint_preview_widget.h>
#include <widgets/footprint_select_widget.h>
#include <settings/settings_manager.h>
#include <project/project_file.h>
#include <eeschema_settings.h>
#include <symbol_editor_settings.h>
#include <wx/button.h>
#include <wx/clipbrd.h>
#include <wx/log.h>
#include <wx/panel.h>
#include <wx/sizer.h>
#include <wx/splitter.h>
#include <wx/timer.h>
#include <wx/utils.h>
#include <wx/wxhtml.h>
#include "pgm_base.h"
wxString PANEL_SYMBOL_CHOOSER::g_symbolSearchString;
@ -156,7 +152,7 @@ PANEL_SYMBOL_CHOOSER::PANEL_SYMBOL_CHOOSER( SCH_BASE_FRAME* aFrame, wxWindow* aP
}
// -------------------------------------------------------------------------------------
// Construct the actual dialog
// Construct the actual panel
//
wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
@ -221,7 +217,7 @@ PANEL_SYMBOL_CHOOSER::PANEL_SYMBOL_CHOOSER( SCH_BASE_FRAME* aFrame, wxWindow* aP
m_hsplitter->SetSashGravity( 0.8 );
m_hsplitter->SetMinimumPaneSize( 20 );
m_hsplitter->SplitVertically( treePanel, ConstructRightPanel( m_hsplitter ) );
m_hsplitter->SplitVertically( treePanel, constructRightPanel( m_hsplitter ) );
m_dbl_click_timer = new wxTimer( this );
@ -229,13 +225,13 @@ PANEL_SYMBOL_CHOOSER::PANEL_SYMBOL_CHOOSER( SCH_BASE_FRAME* aFrame, wxWindow* aP
Layout();
Bind( wxEVT_TIMER, &PANEL_SYMBOL_CHOOSER::OnCloseTimer, this, m_dbl_click_timer->GetId() );
Bind( SYMBOL_PRESELECTED, &PANEL_SYMBOL_CHOOSER::OnComponentPreselected, this );
Bind( SYMBOL_SELECTED, &PANEL_SYMBOL_CHOOSER::OnComponentSelected, this );
Bind( wxEVT_TIMER, &PANEL_SYMBOL_CHOOSER::onCloseTimer, this, m_dbl_click_timer->GetId() );
Bind( EVT_LIBITEM_SELECTED, &PANEL_SYMBOL_CHOOSER::onSymbolSelected, this );
Bind( EVT_LIBITEM_CHOSEN, &PANEL_SYMBOL_CHOOSER::onSymbolChosen, this );
if( m_fp_sel_ctrl )
{
m_fp_sel_ctrl->Bind( EVT_FOOTPRINT_SELECTED, &PANEL_SYMBOL_CHOOSER::OnFootprintSelected,
m_fp_sel_ctrl->Bind( EVT_FOOTPRINT_SELECTED, &PANEL_SYMBOL_CHOOSER::onFootprintSelected,
this );
}
@ -249,9 +245,9 @@ PANEL_SYMBOL_CHOOSER::PANEL_SYMBOL_CHOOSER( SCH_BASE_FRAME* aFrame, wxWindow* aP
PANEL_SYMBOL_CHOOSER::~PANEL_SYMBOL_CHOOSER()
{
Unbind( wxEVT_TIMER, &PANEL_SYMBOL_CHOOSER::OnCloseTimer, this );
Unbind( SYMBOL_PRESELECTED, &PANEL_SYMBOL_CHOOSER::OnComponentPreselected, this );
Unbind( SYMBOL_SELECTED, &PANEL_SYMBOL_CHOOSER::OnComponentSelected, this );
Unbind( wxEVT_TIMER, &PANEL_SYMBOL_CHOOSER::onCloseTimer, this );
Unbind( EVT_LIBITEM_SELECTED, &PANEL_SYMBOL_CHOOSER::onSymbolSelected, this );
Unbind( EVT_LIBITEM_CHOSEN, &PANEL_SYMBOL_CHOOSER::onSymbolChosen, this );
// Stop the timer during destruction early to avoid potential race conditions (that do happen)
m_dbl_click_timer->Stop();
@ -264,7 +260,7 @@ PANEL_SYMBOL_CHOOSER::~PANEL_SYMBOL_CHOOSER()
if( m_fp_sel_ctrl )
{
m_fp_sel_ctrl->Unbind( EVT_FOOTPRINT_SELECTED, &PANEL_SYMBOL_CHOOSER::OnFootprintSelected,
m_fp_sel_ctrl->Unbind( EVT_FOOTPRINT_SELECTED, &PANEL_SYMBOL_CHOOSER::onFootprintSelected,
this );
}
@ -277,8 +273,8 @@ PANEL_SYMBOL_CHOOSER::~PANEL_SYMBOL_CHOOSER()
if( EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ) )
{
cfg->m_SymChooserPanel.width = GetSize().x;
cfg->m_SymChooserPanel.height = GetSize().y;
cfg->m_SymChooserPanel.width = GetParent()->GetSize().x;
cfg->m_SymChooserPanel.height = GetParent()->GetSize().y;
cfg->m_SymChooserPanel.sash_pos_h = m_hsplitter->GetSashPosition();
@ -290,7 +286,7 @@ PANEL_SYMBOL_CHOOSER::~PANEL_SYMBOL_CHOOSER()
}
wxPanel* PANEL_SYMBOL_CHOOSER::ConstructRightPanel( wxWindow* aParent )
wxPanel* PANEL_SYMBOL_CHOOSER::constructRightPanel( wxWindow* aParent )
{
EDA_DRAW_PANEL_GAL::GAL_TYPE backend;
@ -425,9 +421,9 @@ LIB_ID PANEL_SYMBOL_CHOOSER::GetSelectedLibId( int* aUnit ) const
}
void PANEL_SYMBOL_CHOOSER::OnCloseTimer( wxTimerEvent& aEvent )
void PANEL_SYMBOL_CHOOSER::onCloseTimer( wxTimerEvent& aEvent )
{
// Hack because of eaten MouseUp event. See PANEL_SYMBOL_CHOOSER::OnComponentSelected
// Hack because of eaten MouseUp event. See PANEL_SYMBOL_CHOOSER::onSymbolChosen
// for the beginning of this spaghetti noodle.
wxMouseState state = wxGetMouseState();
@ -436,7 +432,7 @@ void PANEL_SYMBOL_CHOOSER::OnCloseTimer( wxTimerEvent& aEvent )
{
// Mouse hasn't been raised yet, so fire the timer again. Otherwise the
// purpose of this timer is defeated.
m_dbl_click_timer->StartOnce( PANEL_SYMBOL_CHOOSER::DblClickDelay );
m_dbl_click_timer->StartOnce( PANEL_SYMBOL_CHOOSER::DBLCLICK_DELAY );
}
else
{
@ -445,7 +441,7 @@ void PANEL_SYMBOL_CHOOSER::OnCloseTimer( wxTimerEvent& aEvent )
}
void PANEL_SYMBOL_CHOOSER::ShowFootprintFor( LIB_ID const& aLibId )
void PANEL_SYMBOL_CHOOSER::showFootprintFor( LIB_ID const& aLibId )
{
if( !m_fp_preview || !m_fp_preview->IsInitialized() )
return;
@ -470,16 +466,16 @@ void PANEL_SYMBOL_CHOOSER::ShowFootprintFor( LIB_ID const& aLibId )
LIB_FIELD* fp_field = symbol->GetFieldById( FOOTPRINT_FIELD );
wxString fp_name = fp_field ? fp_field->GetFullText() : wxString( "" );
ShowFootprint( fp_name );
showFootprint( fp_name );
}
void PANEL_SYMBOL_CHOOSER::ShowFootprint( wxString const& aName )
void PANEL_SYMBOL_CHOOSER::showFootprint( wxString const& aFootprint )
{
if( !m_fp_preview || !m_fp_preview->IsInitialized() )
return;
if( aName == wxEmptyString )
if( aFootprint == wxEmptyString )
{
m_fp_preview->SetStatusText( _( "No footprint specified" ) );
}
@ -487,7 +483,7 @@ void PANEL_SYMBOL_CHOOSER::ShowFootprint( wxString const& aName )
{
LIB_ID lib_id;
if( lib_id.Parse( aName ) == -1 && lib_id.IsValid() )
if( lib_id.Parse( aFootprint ) == -1 && lib_id.IsValid() )
{
m_fp_preview->ClearStatus();
m_fp_preview->DisplayFootprint( lib_id );
@ -500,7 +496,7 @@ void PANEL_SYMBOL_CHOOSER::ShowFootprint( wxString const& aName )
}
void PANEL_SYMBOL_CHOOSER::PopulateFootprintSelector( LIB_ID const& aLibId )
void PANEL_SYMBOL_CHOOSER::populateFootprintSelector( LIB_ID const& aLibId )
{
if( !m_fp_sel_ctrl )
return;
@ -550,7 +546,7 @@ void PANEL_SYMBOL_CHOOSER::PopulateFootprintSelector( LIB_ID const& aLibId )
}
void PANEL_SYMBOL_CHOOSER::OnFootprintSelected( wxCommandEvent& aEvent )
void PANEL_SYMBOL_CHOOSER::onFootprintSelected( wxCommandEvent& aEvent )
{
m_fp_override = aEvent.GetString();
@ -561,11 +557,11 @@ void PANEL_SYMBOL_CHOOSER::OnFootprintSelected( wxCommandEvent& aEvent )
m_field_edits.emplace_back( std::make_pair( FOOTPRINT_FIELD, m_fp_override ) );
ShowFootprint( m_fp_override );
showFootprint( m_fp_override );
}
void PANEL_SYMBOL_CHOOSER::OnComponentPreselected( wxCommandEvent& aEvent )
void PANEL_SYMBOL_CHOOSER::onSymbolSelected( wxCommandEvent& aEvent )
{
LIB_TREE_NODE* node = m_tree->GetCurrentTreeNode();
@ -574,11 +570,11 @@ void PANEL_SYMBOL_CHOOSER::OnComponentPreselected( wxCommandEvent& aEvent )
m_symbol_preview->DisplaySymbol( node->m_LibId, node->m_Unit );
if( !node->m_Footprint.IsEmpty() )
ShowFootprint( node->m_Footprint );
showFootprint( node->m_Footprint );
else
ShowFootprintFor( node->m_LibId );
showFootprintFor( node->m_LibId );
PopulateFootprintSelector( node->m_LibId );
populateFootprintSelector( node->m_LibId );
}
else
{
@ -587,27 +583,24 @@ void PANEL_SYMBOL_CHOOSER::OnComponentPreselected( wxCommandEvent& aEvent )
if( m_fp_preview && m_fp_preview->IsInitialized() )
m_fp_preview->SetStatusText( wxEmptyString );
PopulateFootprintSelector( LIB_ID() );
populateFootprintSelector( LIB_ID() );
}
}
void PANEL_SYMBOL_CHOOSER::OnComponentSelected( wxCommandEvent& aEvent )
void PANEL_SYMBOL_CHOOSER::onSymbolChosen( wxCommandEvent& aEvent )
{
if( m_tree->GetSelectedLibId().IsValid() )
{
// Got a selection. We can't just end the modal dialog here, because
// wx leaks some events back to the parent window (in particular, the
// MouseUp following a double click).
// Got a selection. We can't just end the modal dialog here, because wx leaks some events
// back to the parent window (in particular, the MouseUp following a double click).
//
// NOW, here's where it gets really fun. wxTreeListCtrl eats MouseUp.
// This isn't really feasible to bypass without a fully custom
// wxDataViewCtrl implementation, and even then might not be fully
// possible (docs are vague). To get around this, we use a one-shot
// NOW, here's where it gets really fun. wxTreeListCtrl eats MouseUp. This isn't really
// feasible to bypass without a fully custom wxDataViewCtrl implementation, and even then
// might not be fully possible (docs are vague). To get around this, we use a one-shot
// timer to schedule the dialog close.
//
// See PANEL_SYMBOL_CHOOSER::OnCloseTimer for the other end of this
// spaghetti noodle.
m_dbl_click_timer->StartOnce( PANEL_SYMBOL_CHOOSER::DblClickDelay );
// See PANEL_SYMBOL_CHOOSER::onCloseTimer for the other end of this spaghetti noodle.
m_dbl_click_timer->StartOnce( PANEL_SYMBOL_CHOOSER::DBLCLICK_DELAY );
}
}

View File

@ -94,15 +94,15 @@ public:
}
protected:
static constexpr int DblClickDelay = 100; // milliseconds
static constexpr int DBLCLICK_DELAY = 100; // milliseconds
wxPanel* ConstructRightPanel( wxWindow* aParent );
wxPanel* constructRightPanel( wxWindow* aParent );
void OnCharHook( wxKeyEvent& aEvt );
void OnCloseTimer( wxTimerEvent& aEvent );
void onCloseTimer( wxTimerEvent& aEvent );
void OnFootprintSelected( wxCommandEvent& aEvent );
void OnComponentPreselected( wxCommandEvent& aEvent );
void onFootprintSelected( wxCommandEvent& aEvent );
void onSymbolSelected( wxCommandEvent& aEvent );
/**
* Handle the selection of an item. This is called when either the search box or the tree
@ -110,24 +110,24 @@ protected:
* If the item selected is a category, it is expanded or collapsed; if it is a symbol, the
* symbol is picked.
*/
void OnComponentSelected( wxCommandEvent& aEvent );
void onSymbolChosen( wxCommandEvent& aEvent );
/**
* Look up the footprint for a given symbol specified in the #LIB_ID and display it.
*/
void ShowFootprintFor( const LIB_ID& aLibId );
void showFootprintFor( const LIB_ID& aLibId );
/**
* Display the given footprint by name.
*/
void ShowFootprint( const wxString& aFootprint );
void showFootprint( const wxString& aFootprint );
/**
* Populate the footprint selector for a given alias.
*
* @param aLibId the #LIB_ID of the selection or invalid to clear.
*/
void PopulateFootprintSelector( const LIB_ID& aLibId );
void populateFootprintSelector( const LIB_ID& aLibId );
public:
static std::mutex g_Mutex;

View File

@ -51,7 +51,7 @@ SYMBOL_TREE_PANE::SYMBOL_TREE_PANE( SYMBOL_EDIT_FRAME* aParent,
m_libMgr->GetAdapter()->FinishTreeInitialization();
// Event handlers
Bind( SYMBOL_SELECTED, &SYMBOL_TREE_PANE::onSymbolSelected, this );
Bind( EVT_LIBITEM_CHOSEN, &SYMBOL_TREE_PANE::onSymbolSelected, this );
m_tree->Bind( wxEVT_UPDATE_UI, &SYMBOL_TREE_PANE::onUpdateUI, this );
}

View File

@ -251,10 +251,10 @@ protected:
bool m_previewDisabled;
};
///< Custom event sent when a new symbol is preselected
wxDECLARE_EVENT( SYMBOL_PRESELECTED, wxCommandEvent );
///< Custom event sent when an item is selected in the list
wxDECLARE_EVENT( EVT_LIBITEM_SELECTED, wxCommandEvent );
///< Custom event sent when a symbol is selected
wxDECLARE_EVENT( SYMBOL_SELECTED, wxCommandEvent );
///< Custom event sent when an item is chosen (double-clicked)
wxDECLARE_EVENT( EVT_LIBITEM_CHOSEN, wxCommandEvent );
#endif /* LIB_TREE_H */

View File

@ -348,7 +348,7 @@ void FOOTPRINT_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
if( m_treePane )
{
m_treePane->GetLibTree()->SelectLibId( fpId );
wxCommandEvent event( SYMBOL_SELECTED );
wxCommandEvent event( EVT_LIBITEM_CHOSEN );
wxPostEvent( m_treePane, event );
}
}

View File

@ -45,7 +45,7 @@ FOOTPRINT_TREE_PANE::FOOTPRINT_TREE_PANE( FOOTPRINT_EDIT_FRAME* aParent )
m_frame->GetLibTreeAdapter()->FinishTreeInitialization();
// Event handlers
Bind( SYMBOL_SELECTED, &FOOTPRINT_TREE_PANE::onComponentSelected, this );
Bind( EVT_LIBITEM_CHOSEN, &FOOTPRINT_TREE_PANE::onComponentSelected, this );
m_tree->Bind( wxEVT_UPDATE_UI, &FOOTPRINT_TREE_PANE::onUpdateUI, this );
}

View File

@ -90,7 +90,7 @@ PANEL_FOOTPRINT_CHOOSER::PANEL_FOOTPRINT_CHOOSER( PCB_BASE_FRAME* aFrame, wxTopL
adapter->AddLibraries( aFrame );
// -------------------------------------------------------------------------------------
// Construct the actual dialog
// Construct the actual panel
//
wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
@ -147,8 +147,8 @@ PANEL_FOOTPRINT_CHOOSER::PANEL_FOOTPRINT_CHOOSER( PCB_BASE_FRAME* aFrame, wxTopL
m_adapter->FinishTreeInitialization();
Bind( wxEVT_TIMER, &PANEL_FOOTPRINT_CHOOSER::onCloseTimer, this, m_dbl_click_timer->GetId() );
Bind( SYMBOL_PRESELECTED, &PANEL_FOOTPRINT_CHOOSER::onComponentPreselected, this );
Bind( SYMBOL_SELECTED, &PANEL_FOOTPRINT_CHOOSER::onComponentSelected, this );
Bind( EVT_LIBITEM_SELECTED, &PANEL_FOOTPRINT_CHOOSER::onFootprintSelected, this );
Bind( EVT_LIBITEM_CHOSEN, &PANEL_FOOTPRINT_CHOOSER::onFootprintChosen, this );
Layout();
}
@ -157,8 +157,8 @@ PANEL_FOOTPRINT_CHOOSER::PANEL_FOOTPRINT_CHOOSER( PCB_BASE_FRAME* aFrame, wxTopL
PANEL_FOOTPRINT_CHOOSER::~PANEL_FOOTPRINT_CHOOSER()
{
Unbind( wxEVT_TIMER, &PANEL_FOOTPRINT_CHOOSER::onCloseTimer, this );
Unbind( SYMBOL_PRESELECTED, &PANEL_FOOTPRINT_CHOOSER::onComponentPreselected, this );
Unbind( SYMBOL_SELECTED, &PANEL_FOOTPRINT_CHOOSER::onComponentSelected, this );
Unbind( EVT_LIBITEM_SELECTED, &PANEL_FOOTPRINT_CHOOSER::onFootprintSelected, this );
Unbind( EVT_LIBITEM_CHOSEN, &PANEL_FOOTPRINT_CHOOSER::onFootprintChosen, this );
// I am not sure the following two lines are necessary, but they will not hurt anyone
m_dbl_click_timer->Stop();
@ -232,7 +232,7 @@ LIB_ID PANEL_FOOTPRINT_CHOOSER::GetSelectedLibId() const
void PANEL_FOOTPRINT_CHOOSER::onCloseTimer( wxTimerEvent& aEvent )
{
// Hack because of eaten MouseUp event. See PANEL_FOOTPRINT_CHOOSER::onComponentSelected
// Hack because of eaten MouseUp event. See PANEL_FOOTPRINT_CHOOSER::onFootprintChosen
// for the beginning of this spaghetti noodle.
auto state = wxGetMouseState();
@ -250,7 +250,7 @@ void PANEL_FOOTPRINT_CHOOSER::onCloseTimer( wxTimerEvent& aEvent )
}
void PANEL_FOOTPRINT_CHOOSER::onComponentPreselected( wxCommandEvent& aEvent )
void PANEL_FOOTPRINT_CHOOSER::onFootprintSelected( wxCommandEvent& aEvent )
{
if( !m_preview_ctrl || !m_preview_ctrl->IsInitialized() )
return;
@ -269,7 +269,7 @@ void PANEL_FOOTPRINT_CHOOSER::onComponentPreselected( wxCommandEvent& aEvent )
}
void PANEL_FOOTPRINT_CHOOSER::onComponentSelected( wxCommandEvent& aEvent )
void PANEL_FOOTPRINT_CHOOSER::onFootprintChosen( wxCommandEvent& aEvent )
{
if( m_tree->GetSelectedLibId().IsValid() )
{

View File

@ -70,7 +70,7 @@ protected:
void onCloseTimer( wxTimerEvent& aEvent );
void onComponentPreselected( wxCommandEvent& aEvent );
void onFootprintSelected( wxCommandEvent& aEvent );
/**
* Handle the selection of an item. This is called when either the search
@ -78,7 +78,7 @@ protected:
* If the item selected is a category, it is expanded or collapsed; if it
* is a component, the component is picked.
*/
void onComponentSelected( wxCommandEvent& aEvent );
void onFootprintChosen( wxCommandEvent& aEvent );
protected:
wxTimer* m_dbl_click_timer;