Fix library tree updating bug present at least on OSX.

This commit is contained in:
Jeff Young 2019-11-26 21:38:57 +00:00
parent ffcf3b01fc
commit 102b530162
8 changed files with 32 additions and 14 deletions

View File

@ -189,7 +189,7 @@ void LIB_TREE::Regenerate( bool aKeepState )
// Store the state
if( aKeepState )
m_unfilteredState = getState();
current = getState();
wxString filter = m_query_ctrl->GetValue();
m_adapter->UpdateSearchString( filter );
@ -197,7 +197,18 @@ void LIB_TREE::Regenerate( bool aKeepState )
// Restore the state
if( aKeepState )
setState( m_unfilteredState );
setState( current );
}
void LIB_TREE::RefreshLibTree()
{
// Yes, this is an enormous hack. It should be replaced if anyone can figure out a better
// way to get the OSX version to re-fetch the text and attributes from the dataModel for
// each visible item.
int width = m_tree_ctrl->GetColumn( 0 )->GetWidth();
m_tree_ctrl->GetColumn( 0 )->SetWidth( width + 1 );
m_tree_ctrl->GetColumn( 0 )->SetWidth( width );
}

View File

@ -96,6 +96,11 @@ public:
*/
void Regenerate( bool aKeepState );
/**
* Refreshes the tree (mainly to update highlighting and asterisking)
*/
void RefreshLibTree();
void SetFocus() override;
protected:
@ -164,8 +169,6 @@ protected:
wxTextCtrl* m_query_ctrl;
wxDataViewCtrl* m_tree_ctrl;
wxHtmlWindow* m_details_ctrl;
STATE m_unfilteredState;
};
///> Custom event sent when a new component is preselected

View File

@ -428,7 +428,7 @@ void LIB_EDIT_FRAME::OnModify()
GetScreen()->SetModify();
storeCurrentPart();
m_treePane->GetLibTree()->Refresh();
m_treePane->GetLibTree()->RefreshLibTree();
}

View File

@ -266,7 +266,7 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, const wxString& a
void LIB_EDIT_FRAME::SaveAll()
{
saveAllLibraries( false );
m_treePane->Refresh();
m_treePane->GetLibTree()->RefreshLibTree();
refreshSchematic();
}
@ -365,7 +365,7 @@ void LIB_EDIT_FRAME::Save()
m_libMgr->ClearPartModified( partName, libName );
}
m_treePane->Refresh();
m_treePane->GetLibTree()->RefreshLibTree();
refreshSchematic();
}
@ -381,7 +381,7 @@ void LIB_EDIT_FRAME::SaveAs()
else
savePartAs();
m_treePane->Refresh();
m_treePane->GetLibTree()->RefreshLibTree();
refreshSchematic();
}

View File

@ -67,6 +67,10 @@ void SYMBOL_TREE_PANE::Regenerate()
void SYMBOL_TREE_PANE::onComponentSelected( wxCommandEvent& aEvent )
{
m_libEditFrame->GetToolManager()->RunAction( EE_ACTIONS::editSymbol, true );
// Make sure current-part highlighting doesn't get lost in selection highlighting
m_tree->Unselect();
// Turn off any previous current-part highlighting
m_tree->RefreshLibTree();
}

View File

@ -581,7 +581,7 @@ void FOOTPRINT_EDIT_FRAME::OnModify()
{
PCB_BASE_FRAME::OnModify();
Update3DView( false );
m_treePane->GetLibTree()->Refresh();
m_treePane->GetLibTree()->RefreshLibTree();
}

View File

@ -127,7 +127,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
m_treePane->GetLibTree()->RefreshLibTree(); // update highlighting
}
@ -264,7 +264,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
}
}
m_treePane->GetLibTree()->Refresh();
m_treePane->GetLibTree()->RefreshLibTree();
break;
case ID_MODEDIT_SAVE_AS:
@ -301,7 +301,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
SyncLibraryTree( true );
}
m_treePane->GetLibTree()->Refresh();
m_treePane->GetLibTree()->RefreshLibTree();
break;
case ID_ADD_FOOTPRINT_TO_BOARD:
@ -357,7 +357,7 @@ void FOOTPRINT_EDIT_FRAME::editFootprintProperties( MODULE* aModule )
// therefore not yet in tree.
{
static_cast<LIB_TREE_NODE_LIB_ID*>( treeItem.GetID() )->Update( &footprintInfo );
m_treePane->GetLibTree()->Refresh();
m_treePane->GetLibTree()->RefreshLibTree();
}
updateTitle(); // in case of a name change...

View File

@ -157,7 +157,7 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule )
Update3DView( true );
updateView();
GetCanvas()->Refresh();
m_treePane->GetLibTree()->Refresh(); // update any previously-highlighted items
m_treePane->GetLibTree()->RefreshLibTree(); // update any previously-highlighted items
return true;
}