Fix layer widget in HiDPI situations

This commit is contained in:
Jon Evans 2023-02-21 20:57:04 -05:00
parent 632f8c1df4
commit 89ef6b36f4
2 changed files with 9 additions and 4 deletions

View File

@ -27,6 +27,7 @@
#include <wx/odcombo.h>
#include <wx/menuitem.h>
#include <gal/dpi_scaling.h>
#include <layer_ids.h>
#include <widgets/layer_box_selector.h>
@ -140,9 +141,12 @@ int LAYER_BOX_SELECTOR::SetLayerSelection( int layer )
void LAYER_BOX_SELECTOR::ResyncBitmapOnly()
{
DPI_SCALING dpi( nullptr, this );
int size = static_cast<int>( dpi.GetScaleFactor() * 14 );
for( int i = 0; i < (int) GetCount(); ++i )
{
wxBitmap layerbmp( 14, 14 );
wxBitmap layerbmp( size, size );
DrawColorSwatch( layerbmp, getLayerColor( LAYER_PCB_BACKGROUND ), getLayerColor( i ) );
}
}

View File

@ -84,7 +84,8 @@ void PCB_LAYER_BOX_SELECTOR::Resync()
Freeze();
Clear();
const int BM_SIZE = 14;
DPI_SCALING dpi( nullptr, this );
int size = static_cast<int>( 14 / dpi.GetScaleFactor() );
LSET show = LSET::AllLayersMask() & ~m_layerMaskDisable;
LSET activated = getEnabledLayers() & ~m_layerMaskDisable;
@ -99,7 +100,7 @@ void PCB_LAYER_BOX_SELECTOR::Resync()
else
layerstatus.Empty();
wxBitmap bmp( BM_SIZE, BM_SIZE );
wxBitmap bmp( size, size );
DrawColorSwatch( bmp, getLayerColor( LAYER_PCB_BACKGROUND ), getLayerColor( layerid ) );
wxString layername = getLayerName( layerid ) + layerstatus;
@ -129,7 +130,7 @@ void PCB_LAYER_BOX_SELECTOR::Resync()
SetMinSize( wxSize( -1, -1 ) );
wxSize bestSize = GetBestSize();
bestSize.x = GetBestSize().x + BM_SIZE + 10;
bestSize.x = GetBestSize().x + size + 10;
SetMinSize( bestSize );
SetSelection( wxNOT_FOUND );