Skip to content

Commit

Permalink
Allow landscape
Browse files Browse the repository at this point in the history
  • Loading branch information
Eeems committed Jan 13, 2024
1 parent 336cfd8 commit 250d797
Show file tree
Hide file tree
Showing 2 changed files with 420 additions and 382 deletions.
15 changes: 14 additions & 1 deletion src/gameboy.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Gameboy : public QQuickPaintedItem {
Q_PROPERTY(bool paused READ paused NOTIFY pausedChanged REVISION 1)
Q_PROPERTY(bool slowedDown READ slowedDown NOTIFY slowedDownChanged REVISION 1)
Q_PROPERTY(bool greyscale READ isGreyscale WRITE setGreyscale NOTIFY greyscaleChanged REVISION 1)
Q_PROPERTY(bool landscape READ isLandscape WRITE setLandscape NOTIFY landscapeChanged REVISION 1)
Q_PROPERTY(QString homeFolder READ homeFolder CONSTANT REVISION 1)
Q_PROPERTY(QString romsFolder READ romsFolder CONSTANT REVISION 1)
Q_PROPERTY(QString romName READ romName NOTIFY romNameChanged REVISION 1)
Expand Down Expand Up @@ -78,21 +79,32 @@ class Gameboy : public QQuickPaintedItem {
greyscale = value;
emit greyscaleChanged(greyscale);
}
bool isLandscape(){ return landscape; }
void setLandscape(bool value){
landscape = value;
emit landscapeChanged(landscape);
}

signals:
void runningChanged(bool);
void pausedChanged(bool);
void slowedDownChanged(bool);
void romNameChanged(QString);
void greyscaleChanged(bool);
void landscapeChanged(bool);

protected slots:
void updated(){
QRect rect = boundingRect().toRect();
#ifdef EPAPER
rect.moveCenter(screenCentre);
QPainter painter(EPFrameBuffer::instance()->framebuffer());
painter.drawImage(rect, *image, image->rect());
QImage finalImage = landscape ? image->transformed(QTransform().rotate(90.0), Qt::FastTransformation) : *image;
painter.drawImage(
rect,
finalImage,
finalImage.rect()
);
painter.end();
EPFrameBuffer::sendUpdate(
rect,
Expand Down Expand Up @@ -132,4 +144,5 @@ protected slots:
GameboyThread* thread;
QPoint screenCentre;
bool greyscale;
bool landscape;
};
Loading

0 comments on commit 250d797

Please sign in to comment.