mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Subtle animation when the picture gets hovered with the mouse.
This patch adds a subtle animation when the picture gets hovered with the mouse, and restored to it's original size when mouse exits the image area. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
38ac6ed35f
commit
e14a15e61c
4 changed files with 37 additions and 3 deletions
|
@ -1,5 +1,27 @@
|
||||||
#include "divepixmapitem.h"
|
#include "divepixmapitem.h"
|
||||||
|
#include "animationfunctions.h"
|
||||||
DivePixmapItem::DivePixmapItem(QObject *parent) : QObject(parent), QGraphicsPixmapItem()
|
DivePixmapItem::DivePixmapItem(QObject *parent) : QObject(parent), QGraphicsPixmapItem()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DivePictureItem::DivePictureItem(QObject *parent): DivePixmapItem(parent)
|
||||||
|
{
|
||||||
|
setAcceptsHoverEvents(true);
|
||||||
|
setScale(0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivePictureItem::setPixmap(const QPixmap &pix)
|
||||||
|
{
|
||||||
|
DivePixmapItem::setPixmap(pix);
|
||||||
|
setTransformOriginPoint(boundingRect().width()/2, boundingRect().height()/2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivePictureItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
Animations::scaleTo(this, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivePictureItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
Animations::scaleTo(this, 0.2);
|
||||||
|
}
|
||||||
|
|
|
@ -14,4 +14,15 @@ public:
|
||||||
DivePixmapItem(QObject *parent = 0);
|
DivePixmapItem(QObject *parent = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DivePictureItem : public DivePixmapItem {
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(qreal scale WRITE setScale READ scale)
|
||||||
|
public:
|
||||||
|
DivePictureItem(QObject *parent = 0);
|
||||||
|
void setPixmap(const QPixmap& pix);
|
||||||
|
protected:
|
||||||
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
};
|
||||||
|
|
||||||
#endif // DIVEPIXMAPITEM_H
|
#endif // DIVEPIXMAPITEM_H
|
||||||
|
|
|
@ -1309,7 +1309,7 @@ void ProfileWidget2::plotPictures()
|
||||||
// information area.
|
// information area.
|
||||||
if (!pic->timestamp)
|
if (!pic->timestamp)
|
||||||
continue;
|
continue;
|
||||||
DivePixmapItem *item = new DivePixmapItem();
|
DivePictureItem *item = new DivePictureItem();
|
||||||
item->setPixmap(m->index(i,0).data(Qt::DecorationRole).value<QPixmap>());
|
item->setPixmap(m->index(i,0).data(Qt::DecorationRole).value<QPixmap>());
|
||||||
// TODO: put the item in the correct place. use the pic.timestamp to find where it belongs on the dive.
|
// TODO: put the item in the correct place. use the pic.timestamp to find where it belongs on the dive.
|
||||||
item->setPos(10 ,10);
|
item->setPos(10 ,10);
|
||||||
|
|
|
@ -43,6 +43,7 @@ class AbstractProfilePolygonItem;
|
||||||
class DiveHandler;
|
class DiveHandler;
|
||||||
class QGraphicsSimpleTextItem;
|
class QGraphicsSimpleTextItem;
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
|
class DivePictureItem;
|
||||||
|
|
||||||
class ProfileWidget2 : public QGraphicsView {
|
class ProfileWidget2 : public QGraphicsView {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -160,7 +161,7 @@ private:
|
||||||
//specifics for ADD and PLAN
|
//specifics for ADD and PLAN
|
||||||
QList<DiveHandler *> handles;
|
QList<DiveHandler *> handles;
|
||||||
QList<QGraphicsSimpleTextItem *> gases;
|
QList<QGraphicsSimpleTextItem *> gases;
|
||||||
QList<DivePixmapItem*> pictures;
|
QList<DivePictureItem*> pictures;
|
||||||
void repositionDiveHandlers();
|
void repositionDiveHandlers();
|
||||||
int fixHandlerIndex(DiveHandler *activeHandler);
|
int fixHandlerIndex(DiveHandler *activeHandler);
|
||||||
friend class DiveHandler;
|
friend class DiveHandler;
|
||||||
|
|
Loading…
Reference in a new issue