Fix some (minor) issues when drawing shadow texts of RULER_ITEM and pin names.
Fixes #15019 https://gitlab.com/kicad/code/kicad/-/issues/15019
This commit is contained in:
parent
9f705f5e81
commit
355575e477
|
@ -154,6 +154,15 @@ void KIGFX::PREVIEW::DrawTextNextToCursor( KIGFX::VIEW* aView, const VECTOR2D& a
|
|||
textPos.x -= 15.0 / gal->GetWorldScale();
|
||||
}
|
||||
|
||||
// text is left (or right) aligned, so a shadow text need a small offset to be draw
|
||||
// around the basic text
|
||||
int shadowXoffset = aDrawingDropShadows ? textDims.ShadowWidth : 0;
|
||||
|
||||
if( ( textAttrs.m_Halign == GR_TEXT_H_ALIGN_LEFT ) != viewFlipped )
|
||||
textPos.x -= shadowXoffset;
|
||||
else
|
||||
textPos.x += shadowXoffset;
|
||||
|
||||
gal->SetStrokeColor( aView->GetPainter()->GetSettings()->GetLayerColor( LAYER_AUX_ITEMS ) );
|
||||
textAttrs.m_Mirrored = viewFlipped; // Prevent text flipping when view is flipped
|
||||
textAttrs.m_Size = textDims.GlyphSize;
|
||||
|
|
|
@ -167,25 +167,38 @@ void drawTicksAlongLine( KIGFX::VIEW* aView, const VECTOR2D& aOrigin, const VECT
|
|||
EDA_ANGLE labelAngle = - EDA_ANGLE( tickLine );
|
||||
VECTOR2I labelOffset = tickLine.Resize( majorTickLen );
|
||||
|
||||
// text is left (or right) aligned, so shadow text need a small offset to be draw
|
||||
// around the basic text
|
||||
int shadowXoffset = 0;
|
||||
|
||||
if( aDrawingDropShadows )
|
||||
{
|
||||
labelDims.StrokeWidth += 2 * labelDims.ShadowWidth;
|
||||
shadowXoffset = labelDims.ShadowWidth;
|
||||
}
|
||||
|
||||
if( aView->IsMirroredX() )
|
||||
{
|
||||
labelOffset = -labelOffset;
|
||||
shadowXoffset = -shadowXoffset;
|
||||
}
|
||||
|
||||
TEXT_ATTRIBUTES labelAttrs;
|
||||
labelAttrs.m_Size = labelDims.GlyphSize;
|
||||
labelAttrs.m_StrokeWidth = labelDims.StrokeWidth;
|
||||
labelAttrs.m_Mirrored = aView->IsMirroredX(); // Prevent text mirrored when view is mirrored
|
||||
|
||||
if( EDA_ANGLE( aLine ) > ANGLE_0 )
|
||||
{
|
||||
labelAttrs.m_Halign = GR_TEXT_H_ALIGN_LEFT;
|
||||
labelAttrs.m_Angle = labelAngle;
|
||||
labelOffset.x -= shadowXoffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
labelAttrs.m_Halign = GR_TEXT_H_ALIGN_RIGHT;
|
||||
labelAttrs.m_Angle = labelAngle + ANGLE_180;
|
||||
labelOffset.x += shadowXoffset;
|
||||
}
|
||||
|
||||
BOX2D viewportD = aView->GetViewport();
|
||||
|
@ -194,6 +207,8 @@ void drawTicksAlongLine( KIGFX::VIEW* aView, const VECTOR2D& aOrigin, const VECT
|
|||
viewport.Inflate( majorTickLen * 2 ); // Doesn't have to be accurate, just big enough not
|
||||
// to exclude anything that should be partially drawn
|
||||
|
||||
int isign = aView->IsMirroredX() ? -1 : 1;
|
||||
|
||||
for( int i = 0; i < numTicks; ++i )
|
||||
{
|
||||
const VECTOR2D tickPos = aOrigin + aLine.Resize( tickSpace * i );
|
||||
|
@ -216,7 +231,7 @@ void drawTicksAlongLine( KIGFX::VIEW* aView, const VECTOR2D& aOrigin, const VECT
|
|||
}
|
||||
|
||||
gal->SetLineWidth( labelAttrs.m_StrokeWidth / 2 );
|
||||
gal->DrawLine( tickPos, tickPos + tickLine.Resize( length ) );
|
||||
gal->DrawLine( tickPos, tickPos + tickLine.Resize( length*isign ) );
|
||||
|
||||
if( drawLabel )
|
||||
{
|
||||
|
@ -244,9 +259,10 @@ void drawBacksideTicks( KIGFX::VIEW* aView, const VECTOR2D& aOrigin, const VECTO
|
|||
TEXT_DIMS textDims = GetConstantGlyphHeight( gal, -1 );
|
||||
const double backTickSpace = aLine.EuclideanNorm() / aNumDivisions;
|
||||
VECTOR2D backTickVec = aLine;
|
||||
int isign = aView->IsMirroredX() ? -1 : 1;
|
||||
|
||||
RotatePoint( backTickVec, -ANGLE_90 );
|
||||
backTickVec = backTickVec.Resize( aTickLen );
|
||||
backTickVec = backTickVec.Resize( aTickLen * isign );
|
||||
|
||||
BOX2D viewportD = aView->GetViewport();
|
||||
BOX2I viewport( VECTOR2I( viewportD.GetPosition() ), VECTOR2I( viewportD.GetSize() ) );
|
||||
|
|
|
@ -1627,6 +1627,12 @@ void SCH_PAINTER::draw( const LIB_PIN* aPin, int aLayer, bool aDimmed )
|
|||
|
||||
for( float& t : thickness )
|
||||
t += shadowWidth;
|
||||
|
||||
// Due to the fact a shadow text in position ISIDE or OUTSIDE is drawn left or right aligned,
|
||||
// it needs an offset = shadowWidth/2 to be drawn at the same place as normal text
|
||||
// texts drawn as GR_TEXT_H_ALIGN_CENTER do not need a specific offset.
|
||||
insideOffset -= shadowWidth/2.0f;
|
||||
outsideOffset -= shadowWidth/2.0f;
|
||||
}
|
||||
|
||||
auto drawText =
|
||||
|
|
|
@ -423,7 +423,12 @@ private:
|
|||
const BOOL res = ::VirtualProtect( m_stack, system_page_size.value(),
|
||||
PAGE_READWRITE | PAGE_GUARD, &old_prot );
|
||||
|
||||
#ifdef NDEBUG
|
||||
// Avoid compil warning (unused variable 'res')
|
||||
(void) res;
|
||||
#else
|
||||
assert( res != false );
|
||||
#endif
|
||||
|
||||
stackSize = alloc_size;
|
||||
sp = static_cast<char*>( m_stack ) + stackSize;
|
||||
|
|
Loading…
Reference in New Issue