Improve updating of symbol and footprint trees.

In particular, update highlighting when changing footprints.
This commit is contained in:
Jeff Young 2018-11-01 23:33:31 +00:00
parent d7ff3f8af5
commit 69952a7b9f
6 changed files with 24 additions and 20 deletions

View File

@ -628,7 +628,8 @@ void LIB_EDIT_FRAME::loadPart( const wxString& aAlias, const wxString& aLibrary,
if( !alias )
{
wxString msg = wxString::Format( _( "Symbol name \"%s\" not found in library \"%s\"" ),
GetChars( aAlias ), GetChars( aLibrary ) );
GetChars( aAlias ),
GetChars( aLibrary ) );
DisplayError( this, msg );
return;
}

View File

@ -125,11 +125,7 @@ void SYMBOL_TREE_PANE::Regenerate()
void SYMBOL_TREE_PANE::onComponentSelected( wxCommandEvent& aEvent )
{
// Repost the event
wxCommandEvent evt( ID_LIBEDIT_EDIT_PART );
// I cannot figure out why the two methods below do not work..
//wxPostEvent( libEditFrame, evt );
//wxQueueEvent( m_libEditFrame, new wxCommandEvent( ID_LIBEDIT_EDIT_PART ) );
m_libEditFrame->OnEditPart( evt );
// Make sure current-part highlighting doesn't get lost in seleciton highlighting

View File

@ -228,6 +228,7 @@ void FOOTPRINT_EDIT_FRAME::LoadModuleFromLibrary( LIB_ID aFPID)
m_treePane->GetLibTree()->ExpandLibId( aFPID );
m_treePane->GetLibTree()->CenterLibId( aFPID );
m_treePane->GetLibTree()->Refresh(); // update highlighting
}
@ -459,6 +460,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
// Save Library As
const wxString& libName = getTargetFPID().GetLibNickname();
if( SaveLibraryAs( Prj().PcbFootprintLibs()->FindRow( libName )->GetFullURI() ) )
SyncLibraryTree( true );
}
@ -469,14 +471,16 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( footprint && SaveFootprintAs( footprint ) )
{
m_footprintNameWhenLoaded = footprint->GetFPID().GetLibItemName();
m_toolManager->GetView()->Update( GetBoard()->m_Modules );
GetScreen()->ClrModify();
if( IsGalCanvasActive() && GetGalCanvas() )
GetGalCanvas()->ForceRefresh();
else
GetCanvas()->Refresh();
GetScreen()->ClrModify();
SyncLibraryTree( true );
}
}
else
@ -484,8 +488,8 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// Save Selected Footprint As
MODULE* footprint = LoadFootprint( getTargetFPID() );
if( footprint )
SaveFootprintAs( footprint );
if( footprint && SaveFootprintAs( footprint ) )
SyncLibraryTree( true );
}
m_treePane->GetLibTree()->Refresh();

View File

@ -712,9 +712,17 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprint( MODULE* aModule )
else
return false;
}
if( libraryName.IsEmpty() || footprintName.IsEmpty() )
return SaveFootprintAs( aModule );
else if( libraryName.IsEmpty() || footprintName.IsEmpty() )
{
if( SaveFootprintAs( aModule ) )
{
m_footprintNameWhenLoaded = footprintName;
SyncLibraryTree( true );
return true;
}
else
return false;
}
FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs();
@ -963,8 +971,6 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintAs( MODULE* aModule )
if( !saveFootprintInLibrary( aModule, libraryName ) )
return false;
m_footprintNameWhenLoaded = footprintName;
// Once saved-as a board footprint is no longer a board footprint
aModule->SetLink( 0 );
@ -975,8 +981,6 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintAs( MODULE* aModule )
SetStatusText( msg );
updateTitle();
SyncLibraryTree( true );
return true;
}

View File

@ -128,11 +128,7 @@ void FOOTPRINT_TREE_PANE::Regenerate()
void FOOTPRINT_TREE_PANE::onComponentSelected( wxCommandEvent& aEvent )
{
// Repost the event
wxCommandEvent evt( wxEVT_COMMAND_TOOL_CLICKED, ID_MODEDIT_EDIT_MODULE );
// I cannot figure out why the two methods below do not work..
//wxPostEvent( libEditFrame, evt );
//wxQueueEvent( m_libEditFrame, new wxCommandEvent( ID_LIBEDIT_EDIT_PART ) );
m_frame->Process_Special_Functions( evt );
// Make sure current-part highlighting doesn't get lost in seleciton highlighting

View File

@ -46,7 +46,7 @@ using namespace std::placeholders;
#include <macros.h>
#include <fp_lib_table.h>
#include <lib_id.h>
#include <footprint_tree_pane.h>
#include <class_board.h>
#include <class_module.h>
#include <io_mgr.h>
@ -59,6 +59,7 @@ using namespace std::placeholders;
#include <footprint_viewer_frame.h>
#include <wildcards_and_files_ext.h>
#include <widgets/progress_reporter.h>
#include <widgets/lib_tree.h>
#include "fp_tree_model_adapter.h"
@ -155,6 +156,8 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule )
updateView();
m_canvas->Refresh();
m_treePane->GetLibTree()->Refresh(); // update any previously-highlighted items
return true;
}