Handle DPI_CHANGED events for 3D canvases.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17981
This commit is contained in:
Jeff Young 2024-05-31 17:00:55 +01:00
parent 1322e0bc73
commit e3f77cd410
4 changed files with 32 additions and 0 deletions

View File

@ -194,6 +194,14 @@ EDA_3D_VIEWER_FRAME::EDA_3D_VIEWER_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent
wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() );
}
Bind( wxEVT_DPI_CHANGED,
[&]( wxDPIChangedEvent& aEvt )
{
const DPI_SCALING_COMMON dpi{ Pgm().GetCommonSettings(), this };
m_canvas->SetScaleFactor( dpi.GetScaleFactor() );
aEvt.Skip();
} );
// Fixes bug in Windows (XP and possibly others) where the canvas requires the focus
// in order to receive mouse events. Otherwise, the user has to click somewhere on
// the canvas before it will respond to mouse wheel events.

View File

@ -163,6 +163,14 @@ PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAM
aFrame->Connect( EDA_EVT_UNITS_CHANGED,
wxCommandEventHandler( PANEL_PREVIEW_3D_MODEL::onUnitsChanged ),
nullptr, this );
Bind( wxEVT_DPI_CHANGED,
[&]( wxDPIChangedEvent& aEvt )
{
const DPI_SCALING_COMMON dpi{ Pgm().GetCommonSettings(), this };
m_previewPane->SetScaleFactor( dpi.GetScaleFactor() );
aEvt.Skip();
} );
}

View File

@ -137,6 +137,14 @@ DIALOG_FOOTPRINT_CHOOSER::DIALOG_FOOTPRINT_CHOOSER( PCB_BASE_FRAME* aParent,
Connect( FP_SELECTION_EVENT, wxCommandEventHandler( DIALOG_FOOTPRINT_CHOOSER::onFpChanged ),
nullptr, this );
Bind( wxEVT_DPI_CHANGED,
[&]( wxDPIChangedEvent& aEvt )
{
const DPI_SCALING_COMMON dpi{ Pgm().GetCommonSettings(), this };
m_preview3DCanvas->SetScaleFactor( dpi.GetScaleFactor() );
aEvt.Skip();
} );
}

View File

@ -191,6 +191,14 @@ FOOTPRINT_CHOOSER_FRAME::FOOTPRINT_CHOOSER_FRAME( KIWAY* aKiway, wxWindow* aPare
Connect( FP_SELECTION_EVENT, // custom event fired by a PANEL_FOOTPRINT_CHOOSER
wxCommandEventHandler( FOOTPRINT_CHOOSER_FRAME::onFpChanged ), nullptr, this );
Bind( wxEVT_DPI_CHANGED,
[&]( wxDPIChangedEvent& aEvt )
{
const DPI_SCALING_COMMON dpi{ Pgm().GetCommonSettings(), this };
m_preview3DCanvas->SetScaleFactor( dpi.GetScaleFactor() );
aEvt.Skip();
} );
// Needed on Linux to fix the position of widgets in bottomPanel
PostSizeEvent();
}