eglfs: Improve cursors and hotspots

Improvements
 * Cursor atlas has been recreated using 32x32 cursors which avoids
   artifacts introduced from downscaling of the busy cursor
 * A white outline has been added to the cursors to improve visibility
   on black backgrounds
 * Hot spot positions have been tweaked; in particular,
   Qt::PointingHandCursor now has a correct hot spot at the tip of the
   index finger instead of the center

The assert which checks that the number of hot spots equals the number
of cursors had an off-by-one error as the first cursor is
Qt::ArrowCursor which has an enum value of 0. To determine the number
of cursors, 1 needs to be added to Qt::LastCursor.

Change-Id: I266b6d4cc47d42219854aa5b7e2d8344eb3a920a
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
This commit is contained in:
Jonathan Liu 2014-02-25 23:37:06 +11:00 committed by The Qt Project
parent cea3f4d535
commit 66e5f8e9dc
3 changed files with 23 additions and 23 deletions

View File

@ -210,7 +210,7 @@ void QEGLPlatformCursor::initCursorAtlas()
m_cursorAtlas.cursorsPerRow = cursorsPerRow;
const QJsonArray hotSpots = object.value(QLatin1String("hotSpots")).toArray();
Q_ASSERT(hotSpots.count() == Qt::LastCursor);
Q_ASSERT(hotSpots.count() == Qt::LastCursor + 1);
for (int i = 0; i < hotSpots.count(); i++) {
QPoint hotSpot(hotSpots[i].toArray()[0].toDouble(), hotSpots[i].toArray()[1].toDouble());
m_cursorAtlas.hotSpots << hotSpot;
@ -218,7 +218,7 @@ void QEGLPlatformCursor::initCursorAtlas()
QImage image = QImage(atlas).convertToFormat(QImage::Format_ARGB32_Premultiplied);
m_cursorAtlas.cursorWidth = image.width() / m_cursorAtlas.cursorsPerRow;
m_cursorAtlas.cursorHeight = image.height() / ((Qt::LastCursor + cursorsPerRow - 1) / cursorsPerRow);
m_cursorAtlas.cursorHeight = image.height() / ((Qt::LastCursor + cursorsPerRow) / cursorsPerRow);
m_cursorAtlas.width = image.width();
m_cursorAtlas.height = image.height();
m_cursorAtlas.image = image;

BIN
src/plugins/platforms/eglfs/cursor-atlas.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -3,26 +3,26 @@
"cursorsPerRow": 8,
"hotSpots": [
[7, 2],
[13, 3],
[13, 13],
[13, 13],
[14, 15],
[13, 13],
[13, 13],
[13, 13],
[13, 13],
[13, 13],
[13, 13],
[13, 13],
[13, 13],
[13, 13],
[13, 13],
[10, 1],
[13, 13],
[0, 0],
[0, 0],
[13, 13],
[13, 13]
[12, 3],
[12, 12],
[12, 12],
[12, 12],
[12, 12],
[12, 12],
[12, 12],
[12, 12],
[11, 11],
[12, 12],
[12, 12],
[12, 12],
[9, 1],
[12, 12],
[1, 1],
[1, 1],
[12, 12],
[12, 12],
[12, 12],
[12, 12],
[12, 12]
]
}