utils: Make hotspot in CursorTheme QPointF
As far as I know, the reason that the CursorTheme provides a QPoint
hotspot is mostly due to the historical reasons. At the time, all
hotspot math had relied upon integer hotspots. After
4cd25cf571
it is no longer the case.
This commit is contained in:
parent
5837d042c9
commit
b26eb86310
4 changed files with 7 additions and 7 deletions
|
@ -25,7 +25,7 @@ class CursorSpritePrivate : public QSharedData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QImage data;
|
QImage data;
|
||||||
QPoint hotspot;
|
QPointF hotspot;
|
||||||
std::chrono::milliseconds delay;
|
std::chrono::milliseconds delay;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ CursorSprite &CursorSprite::operator=(const CursorSprite &other)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
CursorSprite::CursorSprite(const QImage &data, const QPoint &hotspot, const std::chrono::milliseconds &delay)
|
CursorSprite::CursorSprite(const QImage &data, const QPointF &hotspot, const std::chrono::milliseconds &delay)
|
||||||
: d(new CursorSpritePrivate)
|
: d(new CursorSpritePrivate)
|
||||||
{
|
{
|
||||||
d->data = data;
|
d->data = data;
|
||||||
|
@ -103,7 +103,7 @@ QImage CursorSprite::data() const
|
||||||
return d->data;
|
return d->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint CursorSprite::hotspot() const
|
QPointF CursorSprite::hotspot() const
|
||||||
{
|
{
|
||||||
return d->hotspot;
|
return d->hotspot;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Constructs an CursorSprite with the specified @a data, @a hotspot, and @a delay.
|
* Constructs an CursorSprite with the specified @a data, @a hotspot, and @a delay.
|
||||||
*/
|
*/
|
||||||
CursorSprite(const QImage &data, const QPoint &hotspot, const std::chrono::milliseconds &delay);
|
CursorSprite(const QImage &data, const QPointF &hotspot, const std::chrono::milliseconds &delay);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructs the CursorSprite object.
|
* Destructs the CursorSprite object.
|
||||||
|
@ -61,7 +61,7 @@ public:
|
||||||
*
|
*
|
||||||
* The coordinates of the hotspot are in device independent pixels.
|
* The coordinates of the hotspot are in device independent pixels.
|
||||||
*/
|
*/
|
||||||
QPoint hotspot() const;
|
QPointF hotspot() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the time interval between this sprite and the next one, in milliseconds.
|
* Returns the time interval between this sprite and the next one, in milliseconds.
|
||||||
|
|
|
@ -138,7 +138,7 @@ QList<CursorSprite> SvgCursorReader::load(const QString &containerPath, int desi
|
||||||
renderer.render(&painter, bounds);
|
renderer.render(&painter, bounds);
|
||||||
painter.end();
|
painter.end();
|
||||||
|
|
||||||
sprites.append(CursorSprite(image, (entry.hotspot * scale).toPoint(), entry.delay));
|
sprites.append(CursorSprite(image, entry.hotspot * scale, entry.delay));
|
||||||
}
|
}
|
||||||
|
|
||||||
return sprites;
|
return sprites;
|
||||||
|
|
|
@ -44,7 +44,7 @@ QList<CursorSprite> XCursorReader::load(const QString &filePath, int desiredSize
|
||||||
for (int i = 0; i < images->nimage; ++i) {
|
for (int i = 0; i < images->nimage; ++i) {
|
||||||
const XcursorImage *nativeCursorImage = images->images[i];
|
const XcursorImage *nativeCursorImage = images->images[i];
|
||||||
const qreal scale = std::max(qreal(1), qreal(nativeCursorImage->size) / desiredSize);
|
const qreal scale = std::max(qreal(1), qreal(nativeCursorImage->size) / desiredSize);
|
||||||
const QPoint hotspot(nativeCursorImage->xhot, nativeCursorImage->yhot);
|
const QPointF hotspot(nativeCursorImage->xhot, nativeCursorImage->yhot);
|
||||||
const std::chrono::milliseconds delay(nativeCursorImage->delay);
|
const std::chrono::milliseconds delay(nativeCursorImage->delay);
|
||||||
|
|
||||||
QImage data(nativeCursorImage->width, nativeCursorImage->height, QImage::Format_ARGB32_Premultiplied);
|
QImage data(nativeCursorImage->width, nativeCursorImage->height, QImage::Format_ARGB32_Premultiplied);
|
||||||
|
|
Loading…
Reference in a new issue