PCB Editor: make Mirror menu items conditional
Fixes: https://gitlab.com/kicad/code/kicad/-/issues/13230
This commit is contained in:
parent
f1fab140a1
commit
741d1e043a
|
@ -684,6 +684,21 @@ void PCB_EDIT_FRAME::setupUIConditions()
|
||||||
mgr->SetConditions( ACTIONS::doDelete, ENABLE( cond.HasItems() ) );
|
mgr->SetConditions( ACTIONS::doDelete, ENABLE( cond.HasItems() ) );
|
||||||
mgr->SetConditions( ACTIONS::duplicate, ENABLE( cond.HasItems() ) );
|
mgr->SetConditions( ACTIONS::duplicate, ENABLE( cond.HasItems() ) );
|
||||||
|
|
||||||
|
auto canMirror =
|
||||||
|
[ this ]( const SELECTION& aSelection )
|
||||||
|
{
|
||||||
|
if( !this->IsType( FRAME_FOOTPRINT_EDITOR )
|
||||||
|
&& SELECTION_CONDITIONS::OnlyTypes( { PCB_PAD_T } )( aSelection ) )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SELECTION_CONDITIONS::HasTypes( EDIT_TOOL::MirrorableItems )( aSelection );
|
||||||
|
};
|
||||||
|
|
||||||
|
mgr->SetConditions( PCB_ACTIONS::mirrorH, ENABLE( canMirror ) );
|
||||||
|
mgr->SetConditions( PCB_ACTIONS::mirrorV, ENABLE( canMirror ) );
|
||||||
|
|
||||||
mgr->SetConditions( PCB_ACTIONS::group, ENABLE( SELECTION_CONDITIONS::MoreThan( 1 ) ) );
|
mgr->SetConditions( PCB_ACTIONS::group, ENABLE( SELECTION_CONDITIONS::MoreThan( 1 ) ) );
|
||||||
mgr->SetConditions( PCB_ACTIONS::ungroup, ENABLE( SELECTION_CONDITIONS::HasType( PCB_GROUP_T ) ) );
|
mgr->SetConditions( PCB_ACTIONS::ungroup, ENABLE( SELECTION_CONDITIONS::HasType( PCB_GROUP_T ) ) );
|
||||||
mgr->SetConditions( PCB_ACTIONS::lock, ENABLE( PCB_SELECTION_CONDITIONS::HasUnlockedItems ) );
|
mgr->SetConditions( PCB_ACTIONS::lock, ENABLE( PCB_SELECTION_CONDITIONS::HasUnlockedItems ) );
|
||||||
|
|
|
@ -144,6 +144,18 @@ bool EDIT_TOOL::Init()
|
||||||
return m_isFootprintEditor;
|
return m_isFootprintEditor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto canMirror =
|
||||||
|
[ this ]( const SELECTION& aSelection )
|
||||||
|
{
|
||||||
|
if( !m_isFootprintEditor
|
||||||
|
&& SELECTION_CONDITIONS::OnlyTypes( { PCB_PAD_T } )( aSelection ) )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SELECTION_CONDITIONS::HasTypes( EDIT_TOOL::MirrorableItems )( aSelection );
|
||||||
|
};
|
||||||
|
|
||||||
auto singleFootprintCondition = SELECTION_CONDITIONS::OnlyTypes( { PCB_FOOTPRINT_T } )
|
auto singleFootprintCondition = SELECTION_CONDITIONS::OnlyTypes( { PCB_FOOTPRINT_T } )
|
||||||
&& SELECTION_CONDITIONS::Count( 1 );
|
&& SELECTION_CONDITIONS::Count( 1 );
|
||||||
|
|
||||||
|
@ -218,10 +230,8 @@ bool EDIT_TOOL::Init()
|
||||||
menu.AddItem( PCB_ACTIONS::rotateCcw, SELECTION_CONDITIONS::NotEmpty );
|
menu.AddItem( PCB_ACTIONS::rotateCcw, SELECTION_CONDITIONS::NotEmpty );
|
||||||
menu.AddItem( PCB_ACTIONS::rotateCw, SELECTION_CONDITIONS::NotEmpty );
|
menu.AddItem( PCB_ACTIONS::rotateCw, SELECTION_CONDITIONS::NotEmpty );
|
||||||
menu.AddItem( PCB_ACTIONS::flip, SELECTION_CONDITIONS::NotEmpty );
|
menu.AddItem( PCB_ACTIONS::flip, SELECTION_CONDITIONS::NotEmpty );
|
||||||
menu.AddItem( PCB_ACTIONS::mirrorH, SELECTION_CONDITIONS::NotEmpty
|
menu.AddItem( PCB_ACTIONS::mirrorH, canMirror );
|
||||||
&& !singleFootprintCondition );
|
menu.AddItem( PCB_ACTIONS::mirrorV, canMirror );
|
||||||
menu.AddItem( PCB_ACTIONS::mirrorV, SELECTION_CONDITIONS::NotEmpty
|
|
||||||
&& !singleFootprintCondition );
|
|
||||||
menu.AddItem( PCB_ACTIONS::swap, SELECTION_CONDITIONS::MoreThan( 1 ) );
|
menu.AddItem( PCB_ACTIONS::swap, SELECTION_CONDITIONS::MoreThan( 1 ) );
|
||||||
menu.AddItem( PCB_ACTIONS::packAndMoveFootprints, SELECTION_CONDITIONS::MoreThan( 1 )
|
menu.AddItem( PCB_ACTIONS::packAndMoveFootprints, SELECTION_CONDITIONS::MoreThan( 1 )
|
||||||
&& SELECTION_CONDITIONS::HasType( PCB_FOOTPRINT_T ) );
|
&& SELECTION_CONDITIONS::HasType( PCB_FOOTPRINT_T ) );
|
||||||
|
@ -1582,6 +1592,21 @@ static void mirrorPadY( PAD& aPad, const VECTOR2I& aMirrorPoint )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const std::vector<KICAD_T> EDIT_TOOL::MirrorableItems = {
|
||||||
|
PCB_FP_SHAPE_T,
|
||||||
|
PCB_SHAPE_T,
|
||||||
|
PCB_FP_TEXT_T,
|
||||||
|
PCB_TEXT_T,
|
||||||
|
PCB_FP_TEXTBOX_T,
|
||||||
|
PCB_TEXTBOX_T,
|
||||||
|
PCB_FP_ZONE_T,
|
||||||
|
PCB_ZONE_T,
|
||||||
|
PCB_PAD_T,
|
||||||
|
PCB_TRACE_T,
|
||||||
|
PCB_ARC_T,
|
||||||
|
PCB_VIA_T,
|
||||||
|
};
|
||||||
|
|
||||||
int EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
|
int EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
if( isRouterActive() )
|
if( isRouterActive() )
|
||||||
|
@ -1623,29 +1648,11 @@ int EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
for( EDA_ITEM* item : selection )
|
for( EDA_ITEM* item : selection )
|
||||||
{
|
{
|
||||||
// only modify items we can mirror
|
if( !item->IsType( MirrorableItems ) )
|
||||||
switch( item->Type() )
|
|
||||||
{
|
|
||||||
case PCB_FP_SHAPE_T:
|
|
||||||
case PCB_SHAPE_T:
|
|
||||||
case PCB_FP_TEXT_T:
|
|
||||||
case PCB_TEXT_T:
|
|
||||||
case PCB_FP_TEXTBOX_T:
|
|
||||||
case PCB_TEXTBOX_T:
|
|
||||||
case PCB_FP_ZONE_T:
|
|
||||||
case PCB_ZONE_T:
|
|
||||||
case PCB_PAD_T:
|
|
||||||
case PCB_TRACE_T:
|
|
||||||
case PCB_ARC_T:
|
|
||||||
case PCB_VIA_T:
|
|
||||||
if( !item->IsNew() && !IsFootprintEditor() )
|
|
||||||
m_commit->Modify( item );
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
if( !item->IsNew() && !IsFootprintEditor() )
|
||||||
|
m_commit->Modify( item );
|
||||||
|
|
||||||
// modify each object as necessary
|
// modify each object as necessary
|
||||||
switch( item->Type() )
|
switch( item->Type() )
|
||||||
|
|
|
@ -111,6 +111,8 @@ public:
|
||||||
*/
|
*/
|
||||||
int Mirror( const TOOL_EVENT& aEvent );
|
int Mirror( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
static const std::vector<KICAD_T> MirrorableItems;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swap currently selected items' positions. Changes position of each item to the next.
|
* Swap currently selected items' positions. Changes position of each item to the next.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue