eeschema: Fix cutoff text in pinmap
Ensure the proper bounding box is used when computing the amount of space taken by angled text in the control. Fixes https://gitlab.com/kicad/code/kicad/issues/4761
This commit is contained in:
parent
f481be3358
commit
c6eb072726
|
@ -35,8 +35,12 @@ WX_ANGLE_TEXT::WX_ANGLE_TEXT( wxWindow* aParent, wxWindowID aId, const wxString&
|
|||
font.SetPointSize( font.GetPointSize() + 2 ); // rotated text looks visually smaller
|
||||
SetFont( font );
|
||||
|
||||
// Measure the size of the text
|
||||
wxClientDC dc( this );
|
||||
dc.SetFont( font );
|
||||
|
||||
wxSize size = dc.GetTextExtent( m_label );
|
||||
wxPoint pos = GetPosition();
|
||||
wxSize size = GetTextExtent( m_label );
|
||||
EDA_RECT rect( wxPoint( 0, 0 ), size );
|
||||
EDA_RECT bbox = rect.GetBoundingBoxRotated( rect.GetPosition(), m_angle );
|
||||
|
||||
|
@ -66,7 +70,7 @@ void WX_ANGLE_TEXT::OnPaint( wxPaintEvent& WXUNUSED( aEvent ) )
|
|||
dc.SetTextForeground( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ) );
|
||||
dc.SetTextBackground( wxTransparentColor );
|
||||
|
||||
wxSize size = GetTextExtent( m_label );
|
||||
wxSize size = dc.GetTextExtent( m_label );
|
||||
EDA_RECT rect( wxPoint( 0, 0 ), size );
|
||||
EDA_RECT bbox = rect.GetBoundingBoxRotated( rect.GetPosition(), m_angle );
|
||||
wxPoint pos( 0, -bbox.GetTop() );
|
||||
|
@ -75,3 +79,18 @@ void WX_ANGLE_TEXT::OnPaint( wxPaintEvent& WXUNUSED( aEvent ) )
|
|||
}
|
||||
|
||||
|
||||
EDA_RECT WX_ANGLE_TEXT::GetBoundingBox( wxWindow* aWindow, const wxString& aLabel, double aAngle )
|
||||
{
|
||||
// Create the font used for the text
|
||||
wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
||||
font.SetPointSize( font.GetPointSize() + 2 ); // rotated text looks visually smaller
|
||||
|
||||
// Measure the size of the text
|
||||
wxClientDC dc( aWindow );
|
||||
dc.SetFont( font );
|
||||
|
||||
wxSize size = dc.GetTextExtent( aLabel );
|
||||
EDA_RECT rect( wxPoint( 0, 0 ), size );
|
||||
|
||||
return rect.GetBoundingBoxRotated( rect.GetPosition(), aAngle );
|
||||
}
|
||||
|
|
|
@ -24,15 +24,26 @@
|
|||
#ifndef _WX_ANGLE_TEXT_
|
||||
#define _WX_ANGLE_TEXT_
|
||||
|
||||
#include <eda_rect.h>
|
||||
#include <wx/panel.h>
|
||||
|
||||
|
||||
|
||||
class WX_ANGLE_TEXT : public wxPanel
|
||||
{
|
||||
public:
|
||||
WX_ANGLE_TEXT( wxWindow* aParent, wxWindowID aId, const wxString& aLabel,
|
||||
const wxPoint& aPos, double aAngle );
|
||||
|
||||
/**
|
||||
* Get the bounding box that this angled text will take up on a certain window.
|
||||
*
|
||||
* @param aWindow is the wxWindow the text will go on
|
||||
* @param aLabel is the text string
|
||||
* @param aAngle is the angle of the text
|
||||
*/
|
||||
static EDA_RECT GetBoundingBox( wxWindow* aWindow, const wxString& aLabel, double aAngle );
|
||||
|
||||
protected:
|
||||
void OnEraseBackground( wxEraseEvent& WXUNUSED( aEvent ) );
|
||||
void OnPaint( wxPaintEvent& WXUNUSED( aEvent ) );
|
||||
|
|
|
@ -83,14 +83,15 @@ void PANEL_SETUP_PINMAP::reBuildMatrixPanel()
|
|||
wxPoint pos;
|
||||
// Get the current text size using a dummy text.
|
||||
wxStaticText* text = new wxStaticText( m_matrixPanel, -1, CommentERC_V[0], pos );
|
||||
int text_width = text->GetRect().GetWidth();
|
||||
EDA_RECT bbox = WX_ANGLE_TEXT::GetBoundingBox( m_matrixPanel, CommentERC_V[0], 450 );
|
||||
|
||||
int text_height = text->GetRect().GetHeight();
|
||||
|
||||
bitmap_size.y = std::max( bitmap_size.y, text_height );
|
||||
delete text;
|
||||
|
||||
// compute the Y pos interval:
|
||||
pos.y = text_height + ( text_width / 2 );
|
||||
pos.y = bbox.GetHeight();
|
||||
|
||||
if( !m_initialized )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue