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

View File

@ -209,6 +209,12 @@ public:
*/ */
void UpdateHierarchyNavigator(); 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 ShowFindReplaceStatus( const wxString& aMsg, int aStatusTime );
void ClearFindReplaceStatus(); 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 ) ) if( SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
{
editFrame->UpdateNetHighlightStatus(); editFrame->UpdateNetHighlightStatus();
editFrame->UpdateHierarchySelection();
}
return 0; return 0;
} }