Add reset text attributes function to GAL - use for arc tool
Independent drawing functions (that don't expect any particular state to be set up fo them) on the GAL need to reset the GAL properties they use. This adds GAL::ResetTextAttributes() to make this easier. This is important, as failing to reset mirroring can cause asserts in OpenGL. This is used in the Ruler tool (which previously did it one attribute at a time) and also the Arc layout assistant, which previously failed to reset mirroring. Also reset on GAL construction, as these members appear to be uninitialised.
This commit is contained in:
parent
9b876d9d98
commit
c3ff34e0df
|
@ -70,6 +70,9 @@ GAL::GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions ) :
|
||||||
forceDisplayCursor = false;
|
forceDisplayCursor = false;
|
||||||
SetCursorEnabled( false );
|
SetCursorEnabled( false );
|
||||||
|
|
||||||
|
// Initialize text properties
|
||||||
|
ResetTextAttributes();
|
||||||
|
|
||||||
strokeFont.LoadNewStrokeFont( newstroke_font, newstroke_font_bufsize );
|
strokeFont.LoadNewStrokeFont( newstroke_font, newstroke_font_bufsize );
|
||||||
|
|
||||||
// subscribe for settings updates
|
// subscribe for settings updates
|
||||||
|
@ -147,6 +150,21 @@ void GAL::SetTextAttributes( const EDA_TEXT* aText )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GAL::ResetTextAttributes()
|
||||||
|
{
|
||||||
|
// Tiny but non-zero - this will always need setting
|
||||||
|
// there is no built-in default
|
||||||
|
SetGlyphSize( { 1.0, 1.0 } );
|
||||||
|
|
||||||
|
SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
|
||||||
|
SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
|
||||||
|
|
||||||
|
SetFontBold( false );
|
||||||
|
SetFontItalic( false );
|
||||||
|
SetTextMirrored( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
VECTOR2D GAL::GetTextLineSize( const UTF8& aText ) const
|
VECTOR2D GAL::GetTextLineSize( const UTF8& aText ) const
|
||||||
{
|
{
|
||||||
// Compute the X and Y size of a given text.
|
// Compute the X and Y size of a given text.
|
||||||
|
|
|
@ -131,6 +131,8 @@ void ARC_ASSISTANT::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
|
||||||
gal.SetIsStroke( true );
|
gal.SetIsStroke( true );
|
||||||
gal.SetIsFill( true );
|
gal.SetIsFill( true );
|
||||||
|
|
||||||
|
gal.ResetTextAttributes();
|
||||||
|
|
||||||
// constant text size on screen
|
// constant text size on screen
|
||||||
SetConstantGlyphHeight( gal, 12.0 );
|
SetConstantGlyphHeight( gal, 12.0 );
|
||||||
|
|
||||||
|
|
|
@ -238,9 +238,8 @@ void RULER_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
|
||||||
gal.SetIsStroke( true );
|
gal.SetIsStroke( true );
|
||||||
gal.SetIsFill( false );
|
gal.SetIsFill( false );
|
||||||
gal.SetStrokeColor( PreviewOverlayDefaultColor() );
|
gal.SetStrokeColor( PreviewOverlayDefaultColor() );
|
||||||
gal.SetFontBold( false );
|
|
||||||
gal.SetFontItalic( false );
|
gal.ResetTextAttributes();
|
||||||
gal.SetTextMirrored( false );
|
|
||||||
|
|
||||||
// draw the main line from the origin to cursor
|
// draw the main line from the origin to cursor
|
||||||
gal.DrawLine( origin, end );
|
gal.DrawLine( origin, end );
|
||||||
|
|
|
@ -361,6 +361,14 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void SetTextAttributes( const EDA_TEXT* aText );
|
virtual void SetTextAttributes( const EDA_TEXT* aText );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset text attributes to default styling
|
||||||
|
*
|
||||||
|
* Normally, custom attributes will be set individually after this,
|
||||||
|
* otherwise you can use SetTextAttributes()
|
||||||
|
*/
|
||||||
|
void ResetTextAttributes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set the font glyph size.
|
* @brief Set the font glyph size.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue