all repos — mgba @ 6ae001037d5b9a632954f9fc2417d1e998de5709

mGBA Game Boy Advance Emulator

Qt: Redraw screen when a status message is posted
Jeffrey Pfau jeffrey@endrift.com
Mon, 03 Aug 2015 20:28:46 -0700
commit

6ae001037d5b9a632954f9fc2417d1e998de5709

parent

03f166509f71b455ca5938f9ca21cb0e9babc24e

M src/platform/qt/Display.cppsrc/platform/qt/Display.cpp

@@ -72,6 +72,9 @@ }

void Display::showMessage(const QString& message) { m_messagePainter.showMessage(message); + if (!isDrawing()) { + forceDraw(); + } } void Display::mouseMoveEvent(QMouseEvent*) {
M src/platform/qt/Display.hsrc/platform/qt/Display.h

@@ -33,6 +33,8 @@

bool isAspectRatioLocked() const { return m_lockAspectRatio; } bool isFiltered() const { return m_filter; } + virtual bool isDrawing() const = 0; + signals: void showCursor(); void hideCursor();
M src/platform/qt/DisplayGL.cppsrc/platform/qt/DisplayGL.cpp

@@ -16,6 +16,7 @@ using namespace QGBA;

DisplayGL::DisplayGL(const QGLFormat& format, QWidget* parent) : Display(parent) + , m_isDrawing(false) , m_gl(new EmptyGLWidget(format, this)) , m_painter(new PainterGL(m_gl)) , m_drawThread(nullptr)

@@ -33,6 +34,7 @@ void DisplayGL::startDrawing(GBAThread* thread) {

if (m_drawThread) { return; } + m_isDrawing = true; m_painter->setContext(thread); m_painter->setMessagePainter(messagePainter()); m_context = thread;

@@ -55,6 +57,7 @@ }

void DisplayGL::stopDrawing() { if (m_drawThread) { + m_isDrawing = false; if (GBAThreadIsActive(m_context)) { GBAThreadInterrupt(m_context); }

@@ -69,6 +72,7 @@ }

void DisplayGL::pauseDrawing() { if (m_drawThread) { + m_isDrawing = false; if (GBAThreadIsActive(m_context)) { GBAThreadInterrupt(m_context); }

@@ -81,6 +85,7 @@ }

void DisplayGL::unpauseDrawing() { if (m_drawThread) { + m_isDrawing = true; if (GBAThreadIsActive(m_context)) { GBAThreadInterrupt(m_context); }
M src/platform/qt/DisplayGL.hsrc/platform/qt/DisplayGL.h

@@ -43,6 +43,8 @@ public:

DisplayGL(const QGLFormat& format, QWidget* parent = nullptr); ~DisplayGL(); + bool isDrawing() const override { return m_isDrawing; } + public slots: void startDrawing(GBAThread* context) override; void stopDrawing() override;

@@ -60,6 +62,7 @@

private: void resizePainter(); + bool m_isDrawing; QGLWidget* m_gl; PainterGL* m_painter; QThread* m_drawThread;
M src/platform/qt/DisplayQt.cppsrc/platform/qt/DisplayQt.cpp

@@ -15,11 +15,13 @@ using namespace QGBA;

DisplayQt::DisplayQt(QWidget* parent) : Display(parent) + , m_isDrawing(false) , m_backing(nullptr) { } void DisplayQt::startDrawing(GBAThread*) { + m_isDrawing = true; } void DisplayQt::lockAspectRatio(bool lock) {
M src/platform/qt/DisplayQt.hsrc/platform/qt/DisplayQt.h

@@ -21,11 +21,13 @@

public: DisplayQt(QWidget* parent = nullptr); + bool isDrawing() const override { return m_isDrawing; } + public slots: void startDrawing(GBAThread* context) override; - void stopDrawing() override {} - void pauseDrawing() override {} - void unpauseDrawing() override {} + void stopDrawing() override { m_isDrawing = false; } + void pauseDrawing() override { m_isDrawing = false; } + void unpauseDrawing() override { m_isDrawing = true; } void forceDraw() override { update(); } void lockAspectRatio(bool lock) override; void filter(bool filter) override;

@@ -35,6 +37,7 @@ protected:

virtual void paintEvent(QPaintEvent*) override; private: + bool m_isDrawing; QImage m_backing; };