Qt: Simplify display sizing
Vicki Pfau vi@endrift.com
Sat, 10 Mar 2018 17:37:29 -0800
2 files changed,
9 insertions(+),
16 deletions(-)
M
src/platform/qt/Display.cpp
→
src/platform/qt/Display.cpp
@@ -8,12 +8,6 @@
#include "DisplayGL.h" #include "DisplayQt.h" -#ifdef M_CORE_GB -#include <mgba/internal/gb/video.h> -#elif defined(M_CORE_GBA) -#include <mgba/internal/gba/video.h> -#endif - using namespace QGBA; #if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY)@@ -55,11 +49,6 @@ Display::Display(QWidget* parent)
: QWidget(parent) { setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); -#ifdef M_CORE_GB - setMinimumSize(GB_VIDEO_HORIZONTAL_PIXELS, GB_VIDEO_VERTICAL_PIXELS); -#elif defined(M_CORE_GBA) - setMinimumSize(VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS); -#endif connect(&m_mouseTimer, &QTimer::timeout, this, &Display::hideCursor); m_mouseTimer.setSingleShot(true); m_mouseTimer.setInterval(MOUSE_DISAPPEAR_TIMER);
M
src/platform/qt/Window.cpp
→
src/platform/qt/Window.cpp
@@ -668,8 +668,6 @@ #endif
multiplayerChanged(); updateTitle(); QSize size = m_controller->screenDimensions(); - m_display->setMinimumSize(size); - m_screenWidget->setMinimumSize(m_display->minimumSize()); m_screenWidget->setDimensions(size.width(), size.height()); m_config->updateOption("lockIntegerScaling"); m_config->updateOption("lockAspectRatio");@@ -677,6 +675,7 @@ if (m_savedScale > 0) {
resizeFrame(size * m_savedScale); } attachWidget(m_display.get()); + m_display->setMinimumSize(size); #ifndef Q_OS_MAC if (isFullScreen()) {@@ -751,7 +750,6 @@ m_display->setMinimumSize(GB_VIDEO_HORIZONTAL_PIXELS, GB_VIDEO_VERTICAL_PIXELS);
#elif defined(M_CORE_GBA) m_display->setMinimumSize(VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS); #endif - m_screenWidget->setMinimumSize(m_display->minimumSize()); m_videoLayers->clear(); m_audioChannels->clear();@@ -803,8 +801,7 @@ #if defined(BUILD_GL) || defined(BUILD_GLES2)
m_shaderView.reset(); m_shaderView = std::make_unique<ShaderSelector>(m_display.get(), m_config); #endif - m_screenWidget->setMinimumSize(m_display->minimumSize()); - m_screenWidget->setSizePolicy(m_display->sizePolicy()); + connect(this, &Window::shutdown, m_display.get(), &Display::stopDrawing); connect(m_display.get(), &Display::hideCursor, [this]() { if (static_cast<QStackedLayout*>(m_screenWidget->layout())->currentWidget() == m_display.get()) {@@ -830,6 +827,7 @@ }
#endif if (m_controller) { + m_display->setMinimumSize(m_controller->screenDimensions()); connect(m_controller.get(), &CoreController::stopping, m_display.get(), &Display::stopDrawing); connect(m_controller.get(), &CoreController::stateLoaded, m_display.get(), &Display::forceDraw); connect(m_controller.get(), &CoreController::rewound, m_display.get(), &Display::forceDraw);@@ -840,6 +838,12 @@ connect(m_controller.get(), &CoreController::statusPosted, m_display.get(), &Display::showMessage);
attachWidget(m_display.get()); m_display->startDrawing(m_controller); + } else { +#ifdef M_CORE_GB + m_display->setMinimumSize(GB_VIDEO_HORIZONTAL_PIXELS, GB_VIDEO_VERTICAL_PIXELS); +#elif defined(M_CORE_GBA) + m_display->setMinimumSize(VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS); +#endif } }