pcbnew: fix Flip Board View from custom toolbars
Flip Board View did not work correctly when it was added to a custom toolbar. The board flip worked from the view menu or appearance panel. This change stores the board flip state in PCB_DISPLAY_OPTIONS and applies it through SetDisplayOptions(), the same way other display toggles are handled. The toolbar, menu, and appearance panel now use the same state, so Flip Board View works correctly from custom toolbars.
This commit is contained in:
@@ -61,6 +61,7 @@ public:
|
||||
double m_ZoneOpacity; ///< Opacity override for filled zone areas
|
||||
double m_ImageOpacity; ///< Opacity override for user images
|
||||
double m_FilledShapeOpacity; ///< Opacity override for graphic shapes
|
||||
bool m_FlipBoardView = false; ///< true if the board is flipped to show the mirrored view
|
||||
};
|
||||
|
||||
#endif // PCBSTRUCT_H_
|
||||
|
||||
@@ -1385,11 +1385,10 @@ void FOOTPRINT_EDIT_FRAME::setupUIConditions()
|
||||
return GetDisplayOptions().m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL;
|
||||
};
|
||||
|
||||
auto boardFlippedCond =
|
||||
[this]( const SELECTION& )
|
||||
{
|
||||
return GetCanvas() && GetCanvas()->GetView()->IsMirroredX();
|
||||
};
|
||||
auto boardFlippedCond = [this]( const SELECTION& )
|
||||
{
|
||||
return GetDisplayOptions().m_FlipBoardView;
|
||||
};
|
||||
|
||||
auto libraryTreeCond =
|
||||
[this](const SELECTION& )
|
||||
|
||||
@@ -1055,6 +1055,9 @@ void PCB_BASE_FRAME::SetDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions, boo
|
||||
KIGFX::PCB_VIEW* view = static_cast<KIGFX::PCB_VIEW*>( canvas->GetView() );
|
||||
|
||||
view->UpdateDisplayOptions( aOptions );
|
||||
view->SetMirror( aOptions.m_FlipBoardView, view->IsMirroredY() );
|
||||
view->RecacheAllItems();
|
||||
|
||||
canvas->SetHighContrastLayer( GetActiveLayer() );
|
||||
OnDisplayOptionsChanged();
|
||||
|
||||
|
||||
@@ -1073,7 +1073,7 @@ void PCB_EDIT_FRAME::setupUIConditions()
|
||||
auto boardFlippedCond =
|
||||
[this]( const SELECTION& )
|
||||
{
|
||||
return GetCanvas() && GetCanvas()->GetView()->IsMirroredX();
|
||||
return GetDisplayOptions().m_FlipBoardView;
|
||||
};
|
||||
|
||||
auto layerManagerCond =
|
||||
|
||||
@@ -1640,6 +1640,7 @@ TOOL_ACTION PCB_ACTIONS::flipBoard( TOOL_ACTION_ARGS()
|
||||
.Scope( AS_GLOBAL )
|
||||
.FriendlyName( _( "Flip Board View" ) )
|
||||
.Tooltip( _( "View board from the opposite side" ) )
|
||||
.ToolbarState( TOOLBAR_STATE::TOGGLE )
|
||||
.Icon( BITMAPS::flip_board ) );
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::rehatchShapes( TOOL_ACTION_ARGS()
|
||||
|
||||
@@ -2784,10 +2784,10 @@ int PCB_CONTROL::PlaceStackup( const TOOL_EVENT& aEvent )
|
||||
|
||||
int PCB_CONTROL::FlipPcbView( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
view()->SetMirror( !view()->IsMirroredX(), false );
|
||||
view()->RecacheAllItems();
|
||||
m_frame->GetCanvas()->ForceRefresh();
|
||||
m_frame->OnDisplayOptionsChanged();
|
||||
PCB_DISPLAY_OPTIONS opts = m_frame->GetDisplayOptions();
|
||||
opts.m_FlipBoardView = !opts.m_FlipBoardView;
|
||||
m_frame->SetDisplayOptions( opts );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -528,7 +528,7 @@ APPEARANCE_CONTROLS::APPEARANCE_CONTROLS( PCB_BASE_FRAME* aParent, wxWindow* aFo
|
||||
passOnFocus();
|
||||
} );
|
||||
|
||||
m_cbFlipBoard->SetValue( m_frame->GetCanvas()->GetView()->IsMirroredX() );
|
||||
m_cbFlipBoard->SetValue( m_frame->GetDisplayOptions().m_FlipBoardView );
|
||||
m_cbFlipBoard->Bind( wxEVT_CHECKBOX,
|
||||
[&]( wxCommandEvent& aEvent )
|
||||
{
|
||||
@@ -1442,7 +1442,7 @@ void APPEARANCE_CONTROLS::UpdateDisplayOptions()
|
||||
case NET_COLOR_MODE::OFF: m_rbNetColorOff->SetValue( true ); break;
|
||||
}
|
||||
|
||||
m_cbFlipBoard->SetValue( m_frame->GetCanvas()->GetView()->IsMirroredX() );
|
||||
m_cbFlipBoard->SetValue( m_frame->GetDisplayOptions().m_FlipBoardView );
|
||||
|
||||
if( !m_isFpEditor )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user