From 631ed8c0fd4bf95dc1560f565360aaa6b203f476 Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Sat, 7 May 2022 16:10:32 +0100 Subject: [PATCH] GUI-WX: Restore panel size override. Fixes the panels going wonky after the recent dead code removal --- pcsx2/gui/pxStaticText.cpp | 26 ++++++++++++++++++++++++++ pcsx2/gui/pxStaticText.h | 1 + 2 files changed, 27 insertions(+) diff --git a/pcsx2/gui/pxStaticText.cpp b/pcsx2/gui/pxStaticText.cpp index f9c1659c6a..62709890fd 100644 --- a/pcsx2/gui/pxStaticText.cpp +++ b/pcsx2/gui/pxStaticText.cpp @@ -124,6 +124,32 @@ int pxStaticText::calcPaddingHeight(int newHeight) const return (int)(newHeight * m_paddingPct_vert * 2) + (m_paddingPix_vert * 2); } +// Overloaded form wxPanel and friends. +wxSize pxStaticText::DoGetBestSize() const +{ + wxClientDC dc(const_cast(this)); + dc.SetFont(GetFontOk()); + + wxSize best; + + if (m_autowrap) + { + best = GetBestWrappedSize(dc); + //best.x = wxDefaultCoord; + } + else + { + // No autowrapping, so we can force a specific size here! + best = dc.GetMultiLineTextExtent(GetLabel()); + best.x += calcPaddingWidth(best.x); + } + + best.y += calcPaddingHeight(best.y); + + CacheBestSize(best); + return best; +} + wxSize pxStaticText::GetBestWrappedSize(const wxClientDC& dc) const { pxAssert(m_autowrap); diff --git a/pcsx2/gui/pxStaticText.h b/pcsx2/gui/pxStaticText.h index abe158c656..8aeaedb958 100644 --- a/pcsx2/gui/pxStaticText.h +++ b/pcsx2/gui/pxStaticText.h @@ -57,6 +57,7 @@ protected: bool AcceptsFocus() const { return false; } bool HasTransparentBackground() { return true; } void DoSetSize(int x, int y, int w, int h, int sizeFlags = wxSIZE_AUTO); + wxSize DoGetBestSize() const; public: pxStaticText(wxWindow* parent, const wxString& label, wxAlignment align = wxALIGN_CENTRE_HORIZONTAL);