Changeset View
Changeset View
Standalone View
Standalone View
ui/presentationwidget.cpp
| Show First 20 Lines • Show All 891 Lines • ▼ Show 20 Line(s) | 888 | #endif | |||
|---|---|---|---|---|---|
| 892 | 892 | | |||
| 893 | // paint drawings | 893 | // paint drawings | ||
| 894 | if ( m_frameIndex != -1 ) | 894 | if ( m_frameIndex != -1 ) | ||
| 895 | { | 895 | { | ||
| 896 | painter.save(); | 896 | painter.save(); | ||
| 897 | 897 | | |||
| 898 | const QRect & geom = m_frames[ m_frameIndex ]->geometry; | 898 | const QRect & geom = m_frames[ m_frameIndex ]->geometry; | ||
| 899 | 899 | | |||
| 900 | QPixmap pm( geom.size() ); | 900 | const QSize pmSize( geom.width() * dpr, geom.height() * dpr ); | ||
tobiasdeiminger: Maybe use a scoped
```
const QSizeF pmSize { geom.width() * dpr, geom.height() * dpr };
```… | |||||
sander: Okay! | |||||
| 901 | QPixmap pm( pmSize ); | ||||
| 901 | pm.fill( Qt::transparent ); | 902 | pm.fill( Qt::transparent ); | ||
| 902 | QPainter pmPainter( &pm ); | 903 | QPainter pmPainter( &pm ); | ||
| 903 | 904 | | |||
| 905 | pm.setDevicePixelRatio( dpr ); | ||||
| 904 | pmPainter.setRenderHints( QPainter::Antialiasing ); | 906 | pmPainter.setRenderHints( QPainter::Antialiasing ); | ||
| 907 | | ||||
| 908 | // Paint old paths | ||||
| 905 | foreach ( const SmoothPath &drawing, m_frames[ m_frameIndex ]->drawings ) | 909 | foreach ( const SmoothPath &drawing, m_frames[ m_frameIndex ]->drawings ) | ||
| 906 | drawing.paint( &pmPainter, geom.width(), geom.height() ); | 910 | drawing.paint( &pmPainter, pmSize.width(), pmSize.height() ); | ||
| 907 | 911 | | |||
| 912 | // Paint the path that is currently being drawn by the user | ||||
| 908 | if ( m_drawingEngine && m_drawingRect.intersects( pe->rect() ) ) | 913 | if ( m_drawingEngine && m_drawingRect.intersects( pe->rect() ) ) | ||
| 909 | m_drawingEngine->paint( &pmPainter, geom.width(), geom.height(), m_drawingRect.intersected( pe->rect() ) ); | 914 | m_drawingEngine->paint( &pmPainter, pmSize.width(), pmSize.height(), m_drawingRect.intersected( pe->rect() ) ); | ||
| 910 | 915 | | |||
| 911 | painter.setRenderHints( QPainter::Antialiasing ); | 916 | painter.setRenderHints( QPainter::Antialiasing ); | ||
| 912 | painter.drawPixmap( geom.topLeft() , pm ); | 917 | painter.drawPixmap( geom.topLeft() , pm ); | ||
| 913 | 918 | | |||
| 914 | painter.restore(); | 919 | painter.restore(); | ||
| 915 | } | 920 | } | ||
| 916 | painter.end(); | 921 | painter.end(); | ||
| 917 | } | 922 | } | ||
| ▲ Show 20 Lines • Show All 398 Lines • ▼ Show 20 Line(s) | 1313 | { | |||
| 1316 | AnnotatorEngine::Button button; | 1321 | AnnotatorEngine::Button button; | ||
| 1317 | 1322 | | |||
| 1318 | // figure out the event type and button | 1323 | // figure out the event type and button | ||
| 1319 | AnnotatorEngine::decodeEvent( e, &eventType, &button ); | 1324 | AnnotatorEngine::decodeEvent( e, &eventType, &button ); | ||
| 1320 | 1325 | | |||
| 1321 | static bool hasclicked = false; | 1326 | static bool hasclicked = false; | ||
| 1322 | if ( eventType == AnnotatorEngine::Press ) | 1327 | if ( eventType == AnnotatorEngine::Press ) | ||
| 1323 | hasclicked = true; | 1328 | hasclicked = true; | ||
| 1324 | 1329 | | |||
Is this change necessary? Conversion to double was already there. screenPos() would change semantic from "relative to widget" to "relative to screen". Doesn't matter because widget is probably always full screen. But otoh the whole thing is called PresentationWidget, so keeping "relative to widget" seems reasonable. tobiasdeiminger: Is this change necessary? Conversion to `double` was already there. `screenPos()` would change… | |||||
You cannot use x() and y() because they return integer coordinates, while with fractional screen scaling the coordinates really are fractional, too. But I agree that keeping with "relative to widget" positions is better, so I changed screenPos to localPos. sander: You cannot use `x()` and `y()` because they return integer coordinates, while with fractional… | |||||
| 1325 | double nX = ( (double)e->x() - (double)geom.left() ) / (double)geom.width(); | 1330 | QPointF mousePos = e->localPos(); | ||
| 1326 | double nY = ( (double)e->y() - (double)geom.top() ) / (double)geom.height(); | 1331 | double nX = ( mousePos.x() - (double)geom.left() ) / (double)geom.width(); | ||
| 1332 | double nY = ( mousePos.y() - (double)geom.top() ) / (double)geom.height(); | ||||
| 1327 | QRect ret; | 1333 | QRect ret; | ||
| 1328 | bool isInside = nX >= 0 && nX < 1 && nY >= 0 && nY < 1; | 1334 | bool isInside = nX >= 0 && nX < 1 && nY >= 0 && nY < 1; | ||
| 1329 | 1335 | | |||
| 1330 | if ( hasclicked && !isInside ) { | 1336 | if ( hasclicked && !isInside ) { | ||
| 1331 | // Fake a move to the last border pos | 1337 | // Fake a move to the last border pos | ||
| 1332 | nX = qBound(0., nX, 1.); | 1338 | nX = qBound(0., nX, 1.); | ||
| 1333 | nY = qBound(0., nY, 1.); | 1339 | nY = qBound(0., nY, 1.); | ||
| 1334 | m_drawingEngine->event( AnnotatorEngine::Move, button, nX, nY, geom.width(), geom.height(), page ); | 1340 | m_drawingEngine->event( AnnotatorEngine::Move, button, nX, nY, geom.width(), geom.height(), page ); | ||
| ▲ Show 20 Lines • Show All 1157 Lines • Show Last 20 Lines | |||||
Maybe use a scoped
const QSizeF pmSize { geom.width() * dpr, geom.height() * dpr };instead of repeatedly recalculating width and height?