From a0283eadb68179ef025daee5259c889cdcb54f10 Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Fri, 22 Mar 2019 11:24:56 -0700 Subject: [PATCH] fix game panel size on wxGTK #325 On wxWidgets 3.1.2, which is what vcpkg uses (and we use vcpkg for Visual Studio) the wxEXPAND flag for the game area in the sizer throws an XRC error dialog, removing the flag works correctly on Windows, but not on wxGTK. As a workaround, do not use the wxEXPAND flag on Windows. TODO: with max zoom set, the game area is not centered vertically in wxGTK. Signed-off-by: Rafael Kitover --- src/wx/panel.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/wx/panel.cpp b/src/wx/panel.cpp index 3b34d0de..1b395825 100644 --- a/src/wx/panel.cpp +++ b/src/wx/panel.cpp @@ -1034,7 +1034,16 @@ void GameArea::OnIdle(wxIdleEvent& event) // add spacers on top and bottom to center panel vertically GetSizer()->Add(0, 0, 1, wxEXPAND); - GetSizer()->Add(w, 0, gopts.retain_aspect ? (wxSHAPED | wxALIGN_CENTER) : wxEXPAND); + + // On windows with the vcpkg version of wxWidgets which is 3.1.2, the + // wxEXPAND flag throws an XRC error, but everything works fine without it. + // On GTK however, the flag is necessary. +#if defined(__WXMSW__) + GetSizer()->Add(w, 0, gopts.retain_aspect ? (wxSHAPED | wxALIGN_CENTER_HORIZONTAL) : wxEXPAND); +#else + GetSizer()->Add(w, 0, gopts.retain_aspect ? (wxSHAPED | wxALIGN_CENTER_HORIZONTAL | wxEXPAND) : wxEXPAND); +#endif + GetSizer()->Add(0, 0, 1, wxEXPAND); Layout();