MCPcopy Create free account
hub / github.com/CE-Programming/CEmu / paintEvent

Method paintEvent

gui/qt/lcdwidget.cpp:40–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40void LCDWidget::paintEvent(QPaintEvent*) {
41 if (!guiEmuValid) {
42 return;
43 }
44
45 QPainter c(this);
46 const QRect &cw = c.window();
47
48 if ((control.ports[5] & 1 << 4) && (lcd.control & 1 << 11)) {
49 QSizeF targetSize = cw.size();
50 if (isFullScreen() && m_fullscreenArea != StretchToFill) {
51 targetSize = QSizeF(LCD_WIDTH, LCD_HEIGHT).scaled(cw.size(), Qt::KeepAspectRatio);
52 }
53 QSizeF pixelSize = targetSize * c.device()->devicePixelRatioF();
54 qreal widthScale = pixelSize.width() / LCD_WIDTH;
55 qreal heightScale = pixelSize.height() / LCD_HEIGHT;
56 bool forceBilinear = m_upscale == Bilinear;
57 if (isFullScreen() && m_fullscreenArea == IntegerUpscale) {
58 /* widthScale and heightScale should be equal since we kept the aspect ratio */
59 targetSize /= widthScale;
60 widthScale = heightScale = qFloor(widthScale);
61 targetSize *= widthScale;
62 forceBilinear = false;
63 }
64 QRectF target = QRectF(QPointF(), targetSize);
65 target.moveCenter(QRectF(cw).center());
66 QSize integerSize = QSize(qMax(qRound(widthScale), 1) * LCD_WIDTH, qMax(qRound(heightScale), 1) * LCD_HEIGHT);
67 bool sharpUsesBilinear = m_upscale == SharpBilinear && integerSize != pixelSize;
68 c.setRenderHint(QPainter::SmoothPixmapTransform, forceBilinear || sharpUsesBilinear);
69 if (sharpUsesBilinear && integerSize != QSize(LCD_WIDTH, LCD_HEIGHT)) {
70 m_mutex.lock();
71 QImage integerFrame = m_currFrame->scaled(integerSize);
72 m_mutex.unlock();
73 c.drawImage(target, integerFrame);
74 } else {
75 m_mutex.lock();
76 c.drawImage(target, *m_currFrame);
77 m_mutex.unlock();
78 }
79 } else {
80 c.fillRect(cw, Qt::black);
81 c.setPen(Qt::white);
82 c.drawText(cw, Qt::AlignCenter, tr("LCD OFF"));
83 }
84 if (m_transferDrag) {
85 m_left = cw;
86 m_right = m_left;
87 m_left.setRight(m_left.right() >> 1);
88 m_right.setLeft(m_left.right());
89 c.fillRect(m_left, QColor(0, 0, m_side == LcdLeft ? 245 : 200, 128));
90 c.fillRect(m_right, QColor(0, m_side == LcdRight ? 245 : 200, 0, 128));
91 c.setPen(Qt::white);
92 c.drawText(m_left, Qt::AlignCenter, tr("Archive"));
93 c.drawText(m_right, Qt::AlignCenter, tr("RAM"));
94 }
95}
96
97void LCDWidget::dropEvent(QDropEvent *e) {

Callers

nothing calls this directly

Calls 1

QSizeClass · 0.70

Tested by

no test coverage detected