mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Graphics item handler is bigger when overred
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include <QPainter>
|
||||
#include <QDebug>
|
||||
#include <utility>
|
||||
#include <QPropertyAnimation>
|
||||
|
||||
/**
|
||||
@brief QetGraphicsHandlerItem::QetGraphicsHandlerItem
|
||||
@@ -26,6 +27,7 @@
|
||||
*/
|
||||
QetGraphicsHandlerItem::QetGraphicsHandlerItem(qreal size)
|
||||
{
|
||||
setAcceptHoverEvents(true);
|
||||
setFlag(QGraphicsItem::ItemIgnoresTransformations);
|
||||
setSize(size);
|
||||
}
|
||||
@@ -33,9 +35,9 @@ QetGraphicsHandlerItem::QetGraphicsHandlerItem(qreal size)
|
||||
void QetGraphicsHandlerItem::setSize(qreal size)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
m_size = size;
|
||||
m_handler_rect.setRect(0-m_size/2, 0-m_size/2, m_size, m_size);
|
||||
m_br.setRect(-1-m_size/2, -1-m_size/2, m_size+2, m_size+2);
|
||||
m_current_size = m_original_size = size;
|
||||
m_handler_rect.setRect(0-m_current_size/2, 0-m_current_size/2, m_current_size, m_current_size);
|
||||
m_br.setRect(-1-m_current_size/2, -1-m_current_size/2, m_current_size+2, m_current_size+2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,6 +86,38 @@ void QetGraphicsHandlerItem::paint(QPainter *painter,
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void QetGraphicsHandlerItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
auto animation_ = new QPropertyAnimation(this, "currentSize");
|
||||
animation_->setStartValue(m_original_size);
|
||||
animation_->setEndValue(m_original_size*1.5);
|
||||
animation_->setDuration(200);
|
||||
animation_->setEasingCurve(QEasingCurve::OutBack);
|
||||
animation_->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
}
|
||||
|
||||
void QetGraphicsHandlerItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
auto animation_ = new QPropertyAnimation(this, "currentSize");
|
||||
animation_->setStartValue(m_current_size);
|
||||
animation_->setEndValue(m_original_size);
|
||||
animation_->setDuration(200);
|
||||
animation_->setEasingCurve(QEasingCurve::OutBack);
|
||||
animation_->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
}
|
||||
|
||||
void QetGraphicsHandlerItem::setCurrentSize(qreal size)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
m_current_size = size;
|
||||
m_handler_rect.setRect(0-m_current_size/2, 0-m_current_size/2, m_current_size, m_current_size);
|
||||
m_br.setRect(-1-m_current_size/2, -1-m_current_size/2, m_current_size+2, m_current_size+2);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QetGraphicsHandlerItem::handlerForPoint
|
||||
@param points
|
||||
|
||||
Reference in New Issue
Block a user