From 7d30a2bc54df8eb27f8a2b9291a789b7ef7a29ce Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 10 Jun 2023 13:34:54 +0100 Subject: [PATCH] Make FOOTPRINT_PREVIEW_PANEL a FPHOLDER. Also makes sure it get its user_units set up. Fixes https://gitlab.com/kicad/code/kicad/-/issues/14913 (cherry picked from commit d18b0c62f6ba8f121ba356c5bedb11692ebc76d3) --- pcbnew/footprint_preview_panel.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pcbnew/footprint_preview_panel.cpp b/pcbnew/footprint_preview_panel.cpp index 8d6033c89b..9b26cf6582 100644 --- a/pcbnew/footprint_preview_panel.cpp +++ b/pcbnew/footprint_preview_panel.cpp @@ -40,6 +40,7 @@ #include #include #include +#include FOOTPRINT_PREVIEW_PANEL::FOOTPRINT_PREVIEW_PANEL( KIWAY* aKiway, wxWindow* aParent, std::unique_ptr aOpts, @@ -53,8 +54,22 @@ FOOTPRINT_PREVIEW_PANEL::FOOTPRINT_PREVIEW_PANEL( KIWAY* aKiway, wxWindow* aPare ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_NEVER ); EnableScrolling( false, false ); // otherwise Zoom Auto disables GAL canvas + wxWindow* topLevelParent = aParent; + + while( topLevelParent && !topLevelParent->IsTopLevel() ) + topLevelParent = topLevelParent->GetParent(); + + if( topLevelParent ) + { + if( DIALOG_SHIM* parentDlg = dynamic_cast( topLevelParent ) ) + m_userUnits = parentDlg->GetUserUnits(); + else if( UNITS_PROVIDER* parentFrame = dynamic_cast( topLevelParent ) ) + m_userUnits = parentFrame->GetUserUnits(); + } + m_dummyBoard = std::make_unique(); m_dummyBoard->SetUserUnits( m_userUnits ); + m_dummyBoard->SetBoardUse( BOARD_USE::FPHOLDER ); UpdateColors(); SyncLayersVisibility( m_dummyBoard.get() );