Make sub menus conditional on them having child items.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/16631
This commit is contained in:
parent
7aad7fcce6
commit
97cb15dd47
|
@ -124,7 +124,7 @@ void CONDITIONAL_MENU::Resolve()
|
|||
}
|
||||
|
||||
|
||||
void CONDITIONAL_MENU::Evaluate( SELECTION& aSelection )
|
||||
void CONDITIONAL_MENU::Evaluate( const SELECTION& aSelection )
|
||||
{
|
||||
Clear();
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ public:
|
|||
/**
|
||||
* Update the contents of the menu based on the supplied conditions.
|
||||
*/
|
||||
void Evaluate( SELECTION& aSelection );
|
||||
void Evaluate( const SELECTION& aSelection );
|
||||
|
||||
/**
|
||||
* Update the initial contents so that wxWidgets doesn't get its knickers tied in a knot
|
||||
|
|
|
@ -182,6 +182,22 @@ bool EDIT_TOOL::Init()
|
|||
std::shared_ptr<CONDITIONAL_MENU> shapeModificationSubMenu = makeShapeModificationMenu( this );
|
||||
m_selectionTool->GetToolMenu().RegisterSubMenu( shapeModificationSubMenu );
|
||||
|
||||
auto positioningToolsCondition =
|
||||
[&]( const SELECTION& aSel )
|
||||
{
|
||||
std::shared_ptr<CONDITIONAL_MENU> subMenu = makePositioningToolsMenu( this );
|
||||
subMenu->Evaluate( aSel );
|
||||
return subMenu->GetMenuItemCount() > 0;
|
||||
};
|
||||
|
||||
auto shapeModificationCondition =
|
||||
[&]( const SELECTION& aSel )
|
||||
{
|
||||
std::shared_ptr<CONDITIONAL_MENU> subMenu = makeShapeModificationMenu( this );
|
||||
subMenu->Evaluate( aSel );
|
||||
return subMenu->GetMenuItemCount() > 0;
|
||||
};
|
||||
|
||||
auto propertiesCondition =
|
||||
[&]( const SELECTION& aSel )
|
||||
{
|
||||
|
@ -337,8 +353,8 @@ bool EDIT_TOOL::Init()
|
|||
|
||||
// Add the submenu for the special tools: modfiers and positioning tools
|
||||
menu.AddSeparator( 100 );
|
||||
menu.AddMenu( shapeModificationSubMenu.get(), SELECTION_CONDITIONS::NotEmpty, 100 );
|
||||
menu.AddMenu( positioningToolsSubMenu.get(), SELECTION_CONDITIONS::NotEmpty, 100 );
|
||||
menu.AddMenu( shapeModificationSubMenu.get(), shapeModificationCondition, 100 );
|
||||
menu.AddMenu( positioningToolsSubMenu.get(), positioningToolsCondition, 100 );
|
||||
|
||||
menu.AddSeparator( 150 );
|
||||
menu.AddItem( ACTIONS::cut, SELECTION_CONDITIONS::NotEmpty, 150 );
|
||||
|
|
Loading…
Reference in New Issue