[PATCH 3/4] Profile: improve tooltip animation

Lubomir I. Ivanov neolit123 at gmail.com
Fri Jul 5 05:33:50 PDT 2013


From: "Lubomir I. Ivanov" <neolit123 at gmail.com>

Remove a couple of expand() calls(?). Also store the last
expanded rectangle size in the private variable nextRectangle
and use that in collapse() animation. Patch prevents a small
jump/resize glitch if the user quickly hovers over and out
of the profile while the tooltip is still resizing.

Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
 qt-ui/profilegraphics.cpp | 6 +-----
 qt-ui/profilegraphics.h   | 1 +
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp
index 512b715..43562f5 100644
--- a/qt-ui/profilegraphics.cpp
+++ b/qt-ui/profilegraphics.cpp
@@ -1198,8 +1198,6 @@ void ToolTipItem::removeToolTip(const QString& toolTip)
 		t.second->setPos(SPACING + ICON_SMALL + SPACING, yValue);
 		toolTipIndex++;
 	}
-
-	expand();
 }
 
 void ToolTipItem::refresh(struct graphics_context *gc, QPointF pos)
@@ -1225,7 +1223,6 @@ void ToolTipItem::clear()
 		delete t.second;
 	}
 	toolTips.clear();
-	expand();
 }
 
 void ToolTipItem::setRect(const QRectF& r)
@@ -1266,7 +1263,7 @@ void ToolTipItem::collapse()
 {
 	QPropertyAnimation *animation = new QPropertyAnimation(this, "rect");
 	animation->setDuration(100);
-	animation->setStartValue(boundingRect());
+	animation->setStartValue(nextRectangle);
 	animation->setEndValue(QRect(0, 0, ICON_SMALL, ICON_SMALL));
 	animation->start(QAbstractAnimation::DeleteWhenStopped);
 	clear();
@@ -1281,7 +1278,6 @@ void ToolTipItem::expand()
 		return;
 	}
 
-	QRectF nextRectangle;
 	double width = 0, height = title->boundingRect().height() + SPACING;
 	Q_FOREACH(ToolTip t, toolTips) {
 		if (t.second->boundingRect().width() > width)
diff --git a/qt-ui/profilegraphics.h b/qt-ui/profilegraphics.h
index 48c88aa..b6df52d 100644
--- a/qt-ui/profilegraphics.h
+++ b/qt-ui/profilegraphics.h
@@ -54,6 +54,7 @@ private:
 	Status status;
 	QRectF rectangle;
 	bool dragging;
+	QRectF nextRectangle;
 };
 
 class EventItem : public QGraphicsPolygonItem
-- 
1.7.11.msysgit.0



More information about the subsurface mailing list