From 30612ca62df4bc1376b0d7fb51f5d19dd914b8c8 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sat, 23 Feb 2019 19:26:04 -0800 Subject: [PATCH] grid: Set grid to use integer pixels Each dot is an integer number of pixels wide, so supporting 0.5 width steps no longer makes sense. We round up the existing settings to the nearest integer and only allow integers in the dialog. Fixes: lp:1816748 * https://bugs.launchpad.net/kicad/+bug/1816748 --- common/gal/gal_display_options.cpp | 4 ++-- common/gal/graphics_abstraction_layer.cpp | 2 +- common/widgets/gal_options_panel.cpp | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/common/gal/gal_display_options.cpp b/common/gal/gal_display_options.cpp index 0557264127..0c9a43a51d 100644 --- a/common/gal/gal_display_options.cpp +++ b/common/gal/gal_display_options.cpp @@ -51,7 +51,7 @@ GAL_DISPLAY_OPTIONS::GAL_DISPLAY_OPTIONS() : gl_antialiasing_mode( OPENGL_ANTIALIASING_MODE::NONE ), cairo_antialiasing_mode( CAIRO_ANTIALIASING_MODE::NONE ), m_gridStyle( GRID_STYLE::DOTS ), - m_gridLineWidth( 0.5 ), + m_gridLineWidth( 1.0 ), m_gridMinSpacing( 10.0 ), m_axesEnabled( false ), m_fullscreenCursor( false ), @@ -67,7 +67,7 @@ void GAL_DISPLAY_OPTIONS::ReadConfig( wxConfigBase* aCfg, const wxString& aBaseN static_cast( KIGFX::GRID_STYLE::DOTS ) ); m_gridStyle = UTIL::GetValFromConfig( gridStyleConfigVals, readLong ); - aCfg->Read( aBaseName + GalGridLineWidthConfig, &m_gridLineWidth, 0.5 ); + aCfg->Read( aBaseName + GalGridLineWidthConfig, &m_gridLineWidth, 1.0 ); aCfg->Read( aBaseName + GalGridMaxDensityConfig, &m_gridMinSpacing, 10 ); aCfg->Read( aBaseName + GalGridAxesEnabledConfig, &m_axesEnabled, false ); aCfg->Read( aBaseName + GalFullscreenCursorConfig, &m_fullscreenCursor, false ); diff --git a/common/gal/graphics_abstraction_layer.cpp b/common/gal/graphics_abstraction_layer.cpp index 050c6a43da..2518a5fa5e 100644 --- a/common/gal/graphics_abstraction_layer.cpp +++ b/common/gal/graphics_abstraction_layer.cpp @@ -108,7 +108,7 @@ bool GAL::updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions ) if( options.m_gridLineWidth != gridLineWidth ) { - gridLineWidth = options.m_gridLineWidth ; + gridLineWidth = std::floor( options.m_gridLineWidth + 0.5 ); refresh = true; } diff --git a/common/widgets/gal_options_panel.cpp b/common/widgets/gal_options_panel.cpp index ca32033d08..de53371d40 100644 --- a/common/widgets/gal_options_panel.cpp +++ b/common/widgets/gal_options_panel.cpp @@ -32,9 +32,9 @@ /* * Spin control parameters */ -static const double gridThicknessMin = 0.5; +static const double gridThicknessMin = 1.0; static const double gridThicknessMax = 10.0; -static const double gridThicknessStep = 0.5; +static const double gridThicknessStep = 1.0; static const double gridMinSpacingMin = 5; static const double gridMinSpacingMax = 200; @@ -134,7 +134,7 @@ GAL_OPTIONS_PANEL::GAL_OPTIONS_PANEL( wxWindow* aParent, KIGFX::GAL_DISPLAY_OPTI m_gridSizeIncrementer->SetStep( gridThicknessMin, gridThicknessMax, gridThicknessStep ); - m_gridSizeIncrementer->SetPrecision( 1 ); + m_gridSizeIncrementer->SetPrecision( 0 ); m_gridMinSpacingIncrementer = std::make_unique( *m_gridMinSpacingSpinBtn, *m_gridMinSpacing ); @@ -214,7 +214,7 @@ bool GAL_OPTIONS_PANEL::TransferDataFromWindow() m_galOptions.m_gridStyle = UTIL::GetValFromConfig( gridStyleSelectMap, m_gridStyle->GetSelection() ); - m_galOptions.m_gridLineWidth = m_gridSizeIncrementer->GetValue(); + m_galOptions.m_gridLineWidth = std::floor( m_gridSizeIncrementer->GetValue() + 0.5 ); m_galOptions.m_gridMinSpacing = m_gridMinSpacingIncrementer->GetValue();