From f60f0394be2a61c822c01eb36c4e235e05a4d067 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 18 Aug 2025 06:29:03 -0700 Subject: [PATCH] Fix preferential coordinates in rule display Fixes https://gitlab.com/kicad/code/kicad/-/issues/11546 (cherry picked from commit eb89d7ffcc2373b263da2cd1a5e02a24fb972910) --- common/preview_items/ruler_item.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/common/preview_items/ruler_item.cpp b/common/preview_items/ruler_item.cpp index 03c841a8b9..c8d4130d63 100644 --- a/common/preview_items/ruler_item.cpp +++ b/common/preview_items/ruler_item.cpp @@ -339,8 +339,8 @@ void RULER_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const // Choose a text quadrant that keeps the measurement text on-screen while avoiding // overlapping the ruler geometry. Start with the preferred direction (away from the // origin) and fall back to other quadrants as needed to keep the label visible. - int prefX = rulerVec.y < 0.0 ? 1 : -1; - int prefY = rulerVec.x < 0.0 ? -1 : 1; + int prefX = rulerVec.y < 0.0 ? -1 : 1; + int prefY = rulerVec.x < 0.0 ? 1 : -1; double scale = gal->GetWorldScale(); @@ -366,7 +366,6 @@ void RULER_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const auto fits = [&]( int sx, int sy ) { double left, right, top, bottom; - double xStart = cursorScreen.x + ( sx < 0 ? offsetX : -offsetX ); if( sx < 0 ) @@ -399,7 +398,6 @@ void RULER_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const VECTOR2I chosen = candidates[0]; double bestDot = -1.0; - bool found = false; for( const VECTOR2I& c : candidates ) { @@ -411,7 +409,6 @@ void RULER_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const { bestDot = dot; chosen = c; - found = true; } } }