From 02d9bbbf2b8c8a9926333d31fb9a016e75f181e4 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 18 Dec 2015 10:17:05 +0100 Subject: [PATCH] Improve automatic placement of fields between wires --- eeschema/autoplace_fields.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/eeschema/autoplace_fields.cpp b/eeschema/autoplace_fields.cpp index c8a7aa6942..62dab7a363 100644 --- a/eeschema/autoplace_fields.cpp +++ b/eeschema/autoplace_fields.cpp @@ -561,14 +561,24 @@ protected: return false; } - if( aSide == SIDE_TOP ) - offset = -offset; + // At this point we are recomputing the field box size. Do not + // return false after this point. + m_fbox_size = ComputeFBoxSize( /* aDynamic */ false ); wxPoint pos = aBox->GetPosition(); - pos.y = round_n( pos.y - offset, WIRE_V_SPACING, aSide == SIDE_BOTTOM ) + offset; - // Compensate for padding - pos.y += WIRE_V_SPACING / 2; + // Remove the existing padding to get a bit more space to work with + if( aSide == SIDE_BOTTOM ) + { + pos.y = m_comp_bbox.GetBottom() - get_field_padding(); + } + else + { + pos.y = m_comp_bbox.GetTop() - m_fbox_size.y + get_field_padding(); + } + + pos.y = round_n( pos.y, WIRE_V_SPACING, aSide == SIDE_BOTTOM ); + aBox->SetOrigin( pos ); return true; }