From bd8857389ab4cdd34536a18e0e1b72c95dacf256 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 10 Aug 2023 08:54:48 +0100 Subject: [PATCH] Add a bit of slop for text-shape hit-testing. --- pcbnew/tools/pcb_selection_tool.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pcbnew/tools/pcb_selection_tool.cpp b/pcbnew/tools/pcb_selection_tool.cpp index 90202fd0a2..c5679965a5 100644 --- a/pcbnew/tools/pcb_selection_tool.cpp +++ b/pcbnew/tools/pcb_selection_tool.cpp @@ -2904,14 +2904,22 @@ int PCB_SELECTION_TOOL::hitTestDistance( const VECTOR2I& aWhere, BOARD_ITEM* aIt case PCB_TEXT_T: { PCB_TEXT* text = static_cast( aItem ); - text->GetEffectiveTextShape()->Collide( loc, aMaxDistance, &distance ); + + // Add a bit of slop to text-shapes + if( text->GetEffectiveTextShape()->Collide( loc, aMaxDistance, &distance ) ) + distance = std::clamp( distance - ( aMaxDistance / 2 ), 0, distance ); + break; } case PCB_TEXTBOX_T: { PCB_TEXTBOX* textbox = static_cast( aItem ); - textbox->GetEffectiveTextShape()->Collide( loc, aMaxDistance, &distance ); + + // Add a bit of slop to text-shapes + if( textbox->GetEffectiveTextShape()->Collide( loc, aMaxDistance, &distance ) ) + distance = std::clamp( distance - ( aMaxDistance / 2 ), 0, distance ); + break; }