GUI improvements to hierarchy navigator.

(1) and (3) from the linked issue.

Fixes https://gitlab.com/kicad/code/kicad/issues/11762
This commit is contained in:
Jeff Young 2022-10-24 23:00:10 +01:00
parent d0d354872b
commit 6c9d8f1ae7
4 changed files with 35 additions and 5 deletions

View File

@ -47,7 +47,7 @@ class TREE_ITEM_DATA : public wxTreeItemData
public:
SCH_SHEET_PATH m_SheetPath;
TREE_ITEM_DATA( SCH_SHEET_PATH& sheet ) :
TREE_ITEM_DATA( SCH_SHEET_PATH& sheet ) :
wxTreeItemData()
{
m_SheetPath = sheet;
@ -151,7 +151,9 @@ void HIERARCHY_NAVIG_PANEL::UpdateHierarchySelection()
m_events_bound = false;
}
std::function<void( const wxTreeItemId& )> selectSheet =
bool sheetSelected = false;
std::function<void( const wxTreeItemId& )> recursiveDescent =
[&]( const wxTreeItemId& id )
{
wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
@ -159,9 +161,20 @@ void HIERARCHY_NAVIG_PANEL::UpdateHierarchySelection()
TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
if( itemData->m_SheetPath == m_frame->GetCurrentSheet() )
{
m_tree->EnsureVisible( id );
m_tree->SetItemBold( id, true );
}
else
{
m_tree->SetItemBold( id, false );
}
if( itemData->m_SheetPath.Last()->IsSelected() )
{
m_tree->EnsureVisible( id );
m_tree->SelectItem( id );
sheetSelected = true;
}
wxTreeItemIdValue cookie;
@ -169,12 +182,15 @@ void HIERARCHY_NAVIG_PANEL::UpdateHierarchySelection()
while( child.IsOk() )
{
selectSheet( child );
recursiveDescent( child );
child = m_tree->GetNextChild( id, cookie );
}
};
selectSheet( m_tree->GetRootItem() );
recursiveDescent( m_tree->GetRootItem() );
if( !sheetSelected && m_tree->GetSelection() )
m_tree->SelectItem( m_tree->GetSelection(), false );
if( eventsWereBound )
{
@ -210,7 +226,6 @@ void HIERARCHY_NAVIG_PANEL::UpdateHierarchyTree()
m_tree->DeleteAllItems();
wxTreeItemId root = m_tree->AddRoot( getRootString(), 0, 1 );
m_tree->SetItemBold( root, true );
m_tree->SetItemData( root, new TREE_ITEM_DATA( m_list ) );
buildHierarchyTree( &m_list, root );

View File

@ -1029,6 +1029,12 @@ void SCH_EDIT_FRAME::UpdateHierarchyNavigator()
}
void SCH_EDIT_FRAME::UpdateHierarchySelection()
{
m_hierarchy->UpdateHierarchySelection();
}
void SCH_EDIT_FRAME::ShowFindReplaceDialog( bool aReplace )
{
wxString findString;

View File

@ -209,6 +209,12 @@ public:
*/
void UpdateHierarchyNavigator();
/**
* Update the hierarchy navigation tree selection (cross-probe from schematic to hierarchy
* pane).
*/
void UpdateHierarchySelection();
void ShowFindReplaceStatus( const wxString& aMsg, int aStatusTime );
void ClearFindReplaceStatus();

View File

@ -325,7 +325,10 @@ int EE_INSPECTION_TOOL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
}
if( SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
{
editFrame->UpdateNetHighlightStatus();
editFrame->UpdateHierarchySelection();
}
return 0;
}