Fix selection and entering in nested groups.
Fixes https://gitlab.com/kicad/code/kicad/issues/12586
This commit is contained in:
parent
f818f3a445
commit
0fea6f5ac3
|
@ -92,11 +92,11 @@ public:
|
|||
void RemoveAll();
|
||||
|
||||
/*
|
||||
* Search for highest level group containing item.
|
||||
* Search for highest level group inside of aScope, containing item.
|
||||
*
|
||||
* @param aScope restricts the search to groups within the group scope.
|
||||
* @param isFootprintEditor true if we should stop promoting at the footprint level
|
||||
* @return group containing item, if it exists, otherwise, NULL
|
||||
* @return group inside of aScope, containing item, if exists, otherwise, nullptr
|
||||
*/
|
||||
static PCB_GROUP* TopLevelGroup( BOARD_ITEM* aItem, PCB_GROUP* aScope, bool isFootprintEditor );
|
||||
|
||||
|
|
|
@ -71,7 +71,8 @@ void PCB_GROUP::RemoveAll()
|
|||
}
|
||||
|
||||
|
||||
PCB_GROUP* getTopLevelGroup( BOARD_ITEM* aItem, PCB_GROUP* aScope, bool isFootprintEditor )
|
||||
/// Returns the top level group inside the aScope group, or nullptr
|
||||
PCB_GROUP* getNestedGroup( BOARD_ITEM* aItem, PCB_GROUP* aScope, bool isFootprintEditor )
|
||||
{
|
||||
PCB_GROUP* group = nullptr;
|
||||
|
||||
|
@ -87,6 +88,9 @@ PCB_GROUP* getTopLevelGroup( BOARD_ITEM* aItem, PCB_GROUP* aScope, bool isFootpr
|
|||
group = aItem->GetParentGroup();
|
||||
}
|
||||
|
||||
if( group == aScope )
|
||||
return nullptr;
|
||||
|
||||
while( group && group->GetParentGroup() && group->GetParentGroup() != aScope )
|
||||
{
|
||||
if( group->GetParent()->Type() == PCB_FOOTPRINT_T && isFootprintEditor )
|
||||
|
@ -98,19 +102,21 @@ PCB_GROUP* getTopLevelGroup( BOARD_ITEM* aItem, PCB_GROUP* aScope, bool isFootpr
|
|||
return group;
|
||||
}
|
||||
|
||||
|
||||
PCB_GROUP* PCB_GROUP::TopLevelGroup( BOARD_ITEM* aItem, PCB_GROUP* aScope, bool isFootprintEditor )
|
||||
{
|
||||
PCB_GROUP* candidate = getTopLevelGroup( aItem, aScope, isFootprintEditor );
|
||||
|
||||
return candidate == aScope ? nullptr : candidate;
|
||||
return getNestedGroup( aItem, aScope, isFootprintEditor );
|
||||
}
|
||||
|
||||
|
||||
bool PCB_GROUP::WithinScope( BOARD_ITEM* aItem, PCB_GROUP* aScope, bool isFootprintEditor )
|
||||
{
|
||||
PCB_GROUP* candidate = getTopLevelGroup( aItem, aScope, isFootprintEditor );
|
||||
if( aItem->GetParentGroup() && aItem->GetParentGroup() == aScope )
|
||||
return true;
|
||||
|
||||
return candidate == aScope;
|
||||
PCB_GROUP* nested = getNestedGroup( aItem, aScope, isFootprintEditor );
|
||||
|
||||
return nested && nested->GetParentGroup() && nested->GetParentGroup() == aScope;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue