Fix selection and entering in nested groups.
Fixes https://gitlab.com/kicad/code/kicad/issues/12586
(cherry picked from commit 0fea6f5ac3
)
This commit is contained in:
parent
2ca7a76693
commit
3b0466f3e8
|
@ -92,11 +92,11 @@ public:
|
||||||
void RemoveAll();
|
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 aScope restricts the search to groups within the group scope.
|
||||||
* @param isFootprintEditor true if we should stop promoting at the footprint level
|
* @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 );
|
static PCB_GROUP* TopLevelGroup( BOARD_ITEM* aItem, PCB_GROUP* aScope, bool isFootprintEditor );
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,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;
|
PCB_GROUP* group = nullptr;
|
||||||
|
|
||||||
|
@ -86,6 +87,9 @@ PCB_GROUP* getTopLevelGroup( BOARD_ITEM* aItem, PCB_GROUP* aScope, bool isFootpr
|
||||||
group = aItem->GetParentGroup();
|
group = aItem->GetParentGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( group == aScope )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
while( group && group->GetParentGroup() && group->GetParentGroup() != aScope )
|
while( group && group->GetParentGroup() && group->GetParentGroup() != aScope )
|
||||||
{
|
{
|
||||||
if( group->GetParent()->Type() == PCB_FOOTPRINT_T && isFootprintEditor )
|
if( group->GetParent()->Type() == PCB_FOOTPRINT_T && isFootprintEditor )
|
||||||
|
@ -97,19 +101,21 @@ PCB_GROUP* getTopLevelGroup( BOARD_ITEM* aItem, PCB_GROUP* aScope, bool isFootpr
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PCB_GROUP* PCB_GROUP::TopLevelGroup( BOARD_ITEM* aItem, PCB_GROUP* aScope, bool isFootprintEditor )
|
PCB_GROUP* PCB_GROUP::TopLevelGroup( BOARD_ITEM* aItem, PCB_GROUP* aScope, bool isFootprintEditor )
|
||||||
{
|
{
|
||||||
PCB_GROUP* candidate = getTopLevelGroup( aItem, aScope, isFootprintEditor );
|
return getNestedGroup( aItem, aScope, isFootprintEditor );
|
||||||
|
|
||||||
return candidate == aScope ? nullptr : candidate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PCB_GROUP::WithinScope( BOARD_ITEM* aItem, PCB_GROUP* aScope, bool 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