Improve message panel alignment on hidpi monitors.
This commit is contained in:
parent
77b285c8ce
commit
492ce600a4
|
@ -118,7 +118,6 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
|
||||||
m_drawBgColor = COLOR4D( BLACK ); // the background color of the draw canvas:
|
m_drawBgColor = COLOR4D( BLACK ); // the background color of the draw canvas:
|
||||||
// BLACK for Pcbnew, BLACK or WHITE for Eeschema
|
// BLACK for Pcbnew, BLACK or WHITE for Eeschema
|
||||||
m_colorSettings = nullptr;
|
m_colorSettings = nullptr;
|
||||||
m_msgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight( this );
|
|
||||||
m_polarCoords = false;
|
m_polarCoords = false;
|
||||||
m_findReplaceData = std::make_unique<EDA_SEARCH_DATA>();
|
m_findReplaceData = std::make_unique<EDA_SEARCH_DATA>();
|
||||||
m_hotkeyPopup = nullptr;
|
m_hotkeyPopup = nullptr;
|
||||||
|
@ -175,15 +174,16 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
|
||||||
stsbar->SetFont( KIUI::GetStatusFont( this ) );
|
stsbar->SetFont( KIUI::GetStatusFont( this ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_messagePanel = new EDA_MSG_PANEL( this, -1, wxPoint( 0, m_frameSize.y ), wxDefaultSize );
|
||||||
|
m_messagePanel->SetBackgroundColour( COLOR4D( LIGHTGRAY ).ToColour() );
|
||||||
|
m_msgFrameHeight = m_messagePanel->GetBestSize().y;
|
||||||
|
|
||||||
// Create child subwindows.
|
// Create child subwindows.
|
||||||
GetClientSize( &m_frameSize.x, &m_frameSize.y );
|
GetClientSize( &m_frameSize.x, &m_frameSize.y );
|
||||||
m_framePos.x = m_framePos.y = 0;
|
m_framePos.x = m_framePos.y = 0;
|
||||||
m_frameSize.y -= m_msgFrameHeight;
|
m_frameSize.y -= m_msgFrameHeight;
|
||||||
|
|
||||||
m_messagePanel = new EDA_MSG_PANEL( this, -1, wxPoint( 0, m_frameSize.y ),
|
m_messagePanel->SetSize( m_frameSize.x, m_msgFrameHeight );
|
||||||
wxSize( m_frameSize.x, m_msgFrameHeight ) );
|
|
||||||
|
|
||||||
m_messagePanel->SetBackgroundColour( COLOR4D( LIGHTGRAY ).ToColour() );
|
|
||||||
|
|
||||||
Bind( wxEVT_DPI_CHANGED,
|
Bind( wxEVT_DPI_CHANGED,
|
||||||
[&]( wxDPIChangedEvent& )
|
[&]( wxDPIChangedEvent& )
|
||||||
|
@ -195,11 +195,13 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
|
||||||
// especially important even for first launches as the constructor of the window
|
// especially important even for first launches as the constructor of the window
|
||||||
// here usually doesn't have the correct dpi awareness yet
|
// here usually doesn't have the correct dpi awareness yet
|
||||||
m_frameSize.y += m_msgFrameHeight;
|
m_frameSize.y += m_msgFrameHeight;
|
||||||
m_msgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight( this );
|
m_msgFrameHeight = m_messagePanel->GetBestSize().y;
|
||||||
m_frameSize.y -= m_msgFrameHeight;
|
m_frameSize.y -= m_msgFrameHeight;
|
||||||
|
|
||||||
m_messagePanel->SetPosition( wxPoint( 0, m_frameSize.y ) );
|
m_messagePanel->SetPosition( wxPoint( 0, m_frameSize.y ) );
|
||||||
m_messagePanel->SetSize( m_frameSize.x, m_msgFrameHeight );
|
m_messagePanel->SetSize( m_frameSize.x, m_msgFrameHeight );
|
||||||
|
|
||||||
|
// Don't skip, otherwise the frame gets too big
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
|
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE( EDA_MSG_PANEL, wxPanel )
|
BEGIN_EVENT_TABLE( EDA_MSG_PANEL, wxPanel )
|
||||||
|
EVT_DPI_CHANGED( EDA_MSG_PANEL::OnDPIChanged )
|
||||||
EVT_PAINT( EDA_MSG_PANEL::OnPaint )
|
EVT_PAINT( EDA_MSG_PANEL::OnPaint )
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
@ -50,7 +51,9 @@ EDA_MSG_PANEL::EDA_MSG_PANEL( wxWindow* aParent, int aId, const wxPoint& aPositi
|
||||||
|
|
||||||
m_last_x = 0;
|
m_last_x = 0;
|
||||||
|
|
||||||
m_fontSize = GetTextExtent( wxT( "W" ) );
|
updateFontSize();
|
||||||
|
|
||||||
|
InvalidateBestSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,16 +62,31 @@ EDA_MSG_PANEL::~EDA_MSG_PANEL()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int EDA_MSG_PANEL::GetRequiredHeight( wxWindow* aWindow )
|
void EDA_MSG_PANEL::updateFontSize()
|
||||||
{
|
{
|
||||||
wxSize fontSizeInPixels;
|
wxFont font = KIUI::GetControlFont( this );
|
||||||
wxWindowDC dc( aWindow );
|
GetTextExtent( wxT( "W" ), &m_fontSize.x, &m_fontSize.y, 0, 0, &font );
|
||||||
|
}
|
||||||
|
|
||||||
dc.SetFont( KIUI::GetControlFont( aWindow ) );
|
|
||||||
dc.GetTextExtent( wxT( "W" ), &fontSizeInPixels.x, &fontSizeInPixels.y );
|
|
||||||
|
|
||||||
// make space for two rows of text plus a number of pixels between them.
|
wxSize EDA_MSG_PANEL::DoGetBestSize() const
|
||||||
return 2 * fontSizeInPixels.y + 0;
|
{
|
||||||
|
return wxSize( wxDefaultCoord, 2 * m_fontSize.y + 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxSize EDA_MSG_PANEL::DoGetBestClientSize() const
|
||||||
|
{
|
||||||
|
return wxPanel::DoGetBestClientSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EDA_MSG_PANEL::OnDPIChanged( wxDPIChangedEvent& aEvent )
|
||||||
|
{
|
||||||
|
updateFontSize();
|
||||||
|
InvalidateBestSize();
|
||||||
|
|
||||||
|
aEvent.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||||
* Copyright (C) 2011-2012 Wayne Stambaugh <stambaughw@gmail.com>
|
* Copyright (C) 2011-2012 Wayne Stambaugh <stambaughw@gmail.com>
|
||||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -105,16 +105,13 @@ public:
|
||||||
long style=wxTAB_TRAVERSAL, const wxString& name=wxPanelNameStr);
|
long style=wxTAB_TRAVERSAL, const wxString& name=wxPanelNameStr);
|
||||||
~EDA_MSG_PANEL();
|
~EDA_MSG_PANEL();
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the required height (in pixels) of a EDA_MSG_PANEL.
|
|
||||||
*
|
|
||||||
* This takes into consideration the system gui font, wxSYS_DEFAULT_GUI_FONT.
|
|
||||||
*/
|
|
||||||
static int GetRequiredHeight( wxWindow* aWindow );
|
|
||||||
|
|
||||||
void OnPaint( wxPaintEvent& aEvent );
|
void OnPaint( wxPaintEvent& aEvent );
|
||||||
|
void OnDPIChanged( wxDPIChangedEvent& aEvent );
|
||||||
void EraseMsgBox();
|
void EraseMsgBox();
|
||||||
|
|
||||||
|
wxSize DoGetBestSize() const override;
|
||||||
|
wxSize DoGetBestClientSize() const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a message at \a aXPosition to \a aUpperText and \a aLowerText in the message panel.
|
* Set a message at \a aXPosition to \a aUpperText and \a aLowerText in the message panel.
|
||||||
*
|
*
|
||||||
|
@ -154,15 +151,12 @@ public:
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void updateFontSize();
|
||||||
|
|
||||||
void showItem( wxDC& dc, const MSG_PANEL_ITEM& aItem );
|
void showItem( wxDC& dc, const MSG_PANEL_ITEM& aItem );
|
||||||
|
|
||||||
void erase( wxDC* DC );
|
void erase( wxDC* DC );
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculate the width and height of a text string using the system UI font.
|
|
||||||
*/
|
|
||||||
wxSize computeTextSize( const wxString& text ) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector<MSG_PANEL_ITEM> m_Items;
|
std::vector<MSG_PANEL_ITEM> m_Items;
|
||||||
int m_last_x; ///< the last used x coordinate
|
int m_last_x; ///< the last used x coordinate
|
||||||
|
|
Loading…
Reference in New Issue