Fix spacing/scaling of indicators on MacOS.

Also pushes indicator scaling improvements to GerbView.
This commit is contained in:
Jeff Young 2024-05-26 14:37:05 +01:00
parent 7774a43762
commit 30b5adde17
5 changed files with 34 additions and 20 deletions

View File

@ -100,8 +100,6 @@ APPEARANCE_CONTROLS_3D::APPEARANCE_CONTROLS_3D( EDA_3D_VIEWER_FRAME* aParent,
{
DPI_SCALING_COMMON dpi( nullptr, m_frame );
const int c_indicatorSizeDIP = 10;
int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y );
m_pointSize = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ).GetPointSize();
@ -154,7 +152,7 @@ APPEARANCE_CONTROLS_3D::APPEARANCE_CONTROLS_3D( EDA_3D_VIEWER_FRAME* aParent,
KeyNameFromKeyCode( VIEWPORT_SWITCH_KEY ),
KeyNameFromKeyCode( VIEWPORT_SWITCH_KEY ) ) );
if( screenHeight <= 900 && m_pointSize >= FromDIP( c_indicatorSizeDIP ) )
if( screenHeight <= 900 && m_pointSize >= FromDIP( KIUI::c_IndicatorSizeDIP ) )
m_pointSize = m_pointSize * 8 / 10;
m_cbLayerPresets->Bind( wxEVT_CHOICE, &APPEARANCE_CONTROLS_3D::onLayerPresetChanged, this );

View File

@ -21,6 +21,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <kiplatform/ui.h>
#include <widgets/indicator_icon.h>
#include <wx/event.h>
#include <wx/settings.h>
@ -75,9 +76,12 @@ wxImage createBlankImage( int size )
wxImage image( size, size );
image.InitAlpha();
for( int y = 0; y < size; ++y )
{
for( int x = 0; x < size; ++x )
image.SetAlpha( x, y, wxIMAGE_ALPHA_TRANSPARENT );
}
#ifdef __WXMSW__
// wxWidgets on Windows chokes on an empty fully transparent bitmap and draws it
@ -162,14 +166,20 @@ wxBitmap createDiamond( int size, double aScaleFactor, wxColour aColour )
ROW_ICON_PROVIDER::ROW_ICON_PROVIDER( int aSizeDIP, wxWindow* aWindow )
{
auto toPhys = [&]( int dip )
{
return aWindow->ToPhys( aWindow->FromDIP( dip ) );
};
auto toPhys =
[&]( int dip )
{
return aWindow->ToPhys( aWindow->FromDIP( dip ) );
};
double scale = aWindow->GetDPIScaleFactor();
wxColour shadowColor = wxSystemSettings().GetColour( wxSYS_COLOUR_3DDKSHADOW );
#ifdef __WXMAC__
// Adjust for Retina
scale /= KIPLATFORM::UI::GetPixelScaleFactor( aWindow );
#endif
m_blankBitmap = wxBitmap( createBlankImage( toPhys( aSizeDIP ) ) );
m_blankBitmap.SetScaleFactor( scale );

View File

@ -446,12 +446,14 @@ void LAYER_WIDGET::insertRenderRow( int aRow, const ROW& aSpec )
bmb->SetToolTip( _( "Left double click or middle click for color change" ) );
m_RenderFlexGridSizer->wxSizer::Insert( index+col, bmb, 0, flags );
bmb->Bind( wxEVT_RIGHT_DOWN, [this, bmb, renderName] ( wxMouseEvent& aEvt ) {
OnRightDownRender( aEvt, bmb, renderName );
} );
cb->Bind( wxEVT_RIGHT_DOWN, [this, bmb, renderName] ( wxMouseEvent& aEvt ) {
OnRightDownRender( aEvt, bmb, renderName );
} );
bmb->Bind( wxEVT_RIGHT_DOWN, [this, bmb, renderName] ( wxMouseEvent& aEvt )
{
OnRightDownRender( aEvt, bmb, renderName );
} );
cb->Bind( wxEVT_RIGHT_DOWN, [this, bmb, renderName] ( wxMouseEvent& aEvt )
{
OnRightDownRender( aEvt, bmb, renderName );
} );
// could add a left click handler on the color button that toggles checkbox.
}
@ -488,13 +490,12 @@ LAYER_WIDGET::LAYER_WIDGET( wxWindow* aParent, wxWindow* aFocusOwner, wxWindowID
wxPanel( aParent, id, pos, size, style ),
m_smallestLayerString( wxT( "M...M" ) )
{
int indicatorSize = ConvertDialogToPixels( wxSize( 6, 6 ) ).x;
m_IconProvider = new ROW_ICON_PROVIDER( indicatorSize, this );
m_IconProvider = new ROW_ICON_PROVIDER( KIUI::c_IndicatorSizeDIP, this );
int pointSize = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ).GetPointSize();
int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y );
if( screenHeight <= 900 && pointSize >= indicatorSize )
if( screenHeight <= 900 && pointSize >= FromDIP( KIUI::c_IndicatorSizeDIP ) )
pointSize = pointSize * 8 / 10;
m_PointSize = pointSize;

View File

@ -48,6 +48,13 @@ class wxMenu;
namespace KIUI
{
#ifdef __WXMAC__
const int c_IndicatorSizeDIP = 6;
#else
const int c_IndicatorSizeDIP = 10;
#endif
/**
* Get the standard margin around a widget in the KiCad UI
* @return margin in pixels

View File

@ -413,10 +413,8 @@ APPEARANCE_CONTROLS::APPEARANCE_CONTROLS( PCB_BASE_FRAME* aParent, wxWindow* aFo
// Correct the min size from wxformbuilder not using fromdip
SetMinSize( FromDIP( GetMinSize() ) );
const int c_indicatorSizeDIP = 10;
int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y );
m_iconProvider = new ROW_ICON_PROVIDER( c_indicatorSizeDIP, this );
m_iconProvider = new ROW_ICON_PROVIDER( KIUI::c_IndicatorSizeDIP, this );
m_pointSize = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ).GetPointSize();
m_layerPanelColour = m_panelLayers->GetBackgroundColour().ChangeLightness( 110 );
@ -465,7 +463,7 @@ APPEARANCE_CONTROLS::APPEARANCE_CONTROLS( PCB_BASE_FRAME* aParent, wxWindow* aFo
m_txtNetFilter->SetHint( _( "Filter nets" ) );
if( screenHeight <= 900 && m_pointSize >= FromDIP( c_indicatorSizeDIP ) )
if( screenHeight <= 900 && m_pointSize >= FromDIP( KIUI::c_IndicatorSizeDIP ) )
m_pointSize = m_pointSize * 8 / 10;
wxFont font = m_notebook->GetFont();