Handle justification for vertical text when mirroring.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15036
This commit is contained in:
Jeff Young 2023-11-17 21:49:50 +00:00
parent afb050a67f
commit f098405218
4 changed files with 13 additions and 23 deletions

View File

@ -526,19 +526,8 @@ void SCH_LABEL_BASE::MirrorHorizontally( int aCenter )
for( SCH_FIELD& field : m_fields )
{
switch( field.GetHorizJustify() )
{
case GR_TEXT_H_ALIGN_LEFT:
field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
case GR_TEXT_H_ALIGN_CENTER:
break;
case GR_TEXT_H_ALIGN_RIGHT:
field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break;
}
if( field.GetTextAngle() == ANGLE_HORIZONTAL )
field.FlipHJustify();
VECTOR2I pos = field.GetTextPos();
VECTOR2I delta = old_pos - pos;
@ -556,6 +545,9 @@ void SCH_LABEL_BASE::MirrorVertically( int aCenter )
for( SCH_FIELD& field : m_fields )
{
if( field.GetTextAngle() == ANGLE_VERTICAL )
field.FlipHJustify();
VECTOR2I pos = field.GetTextPos();
VECTOR2I delta = old_pos - pos;
pos.y = GetPosition().y + delta.y;

View File

@ -76,15 +76,6 @@ VECTOR2I SCH_TEXT::GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) co
}
void SCH_TEXT::FlipHJustify()
{
if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
else if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
}
void SCH_TEXT::MirrorHorizontally( int aCenter )
{
if( GetTextAngle() == ANGLE_HORIZONTAL )

View File

@ -106,7 +106,6 @@ public:
EDA_TEXT::Offset( aMoveVector );
}
void FlipHJustify();
void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( int aCenter ) override;
void Rotate( const VECTOR2I& aCenter ) override;

View File

@ -165,6 +165,14 @@ public:
void SetKeepUpright( bool aKeepUpright );
bool IsKeepUpright() const { return m_attributes.m_KeepUpright; }
void FlipHJustify()
{
if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
else if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
}
/**
* Set the text attributes from another instance.
*/