diff options
author | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2011-05-26 18:23:16 (GMT) |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2011-05-30 14:43:18 (GMT) |
commit | 0b4e028ec294992df01430bdf978982835c7df5c (patch) | |
tree | dab76ad782b9e7ab2f93310862e2609244f3a97c /src/plugins | |
parent | 206ebd5af21d94c3f3b49d2cb645105a63e6f5fb (diff) | |
download | Qt-0b4e028ec294992df01430bdf978982835c7df5c.zip Qt-0b4e028ec294992df01430bdf978982835c7df5c.tar.gz Qt-0b4e028ec294992df01430bdf978982835c7df5c.tar.bz2 |
DeclarativeObserver: Don't fade in the highlight edge
It feels more responsive when the highlight is immediately visible.
Change-Id: Ie3dd0693ecc38f33b001c86970b220b45b37fdfc
Reviewed-by: Kai Koehne
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.cpp | 61 | ||||
-rw-r--r-- | src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter_p.h | 7 |
2 files changed, 10 insertions, 58 deletions
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.cpp index 8e551d2..3f95005 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.cpp @@ -52,10 +52,6 @@ QT_BEGIN_NAMESPACE -const qreal AnimDelta = 0.025f; -const int AnimInterval = 30; -const int AnimFrames = 10; - BoundingBox::BoundingBox(QGraphicsObject *itemToHighlight, QGraphicsItem *parentItem, QObject *parent) : QObject(parent), @@ -93,12 +89,8 @@ int BoundingBoxPolygonItem::type() const BoundingRectHighlighter::BoundingRectHighlighter(QDeclarativeViewInspector *view) : LiveLayerItem(view->declarativeView()->scene()), - m_view(view), - m_animFrame(0) + m_view(view) { - m_animTimer = new QTimer(this); - m_animTimer->setInterval(AnimInterval); - connect(m_animTimer, SIGNAL(timeout()), SLOT(animTimeout())); } BoundingRectHighlighter::~BoundingRectHighlighter() @@ -106,37 +98,17 @@ BoundingRectHighlighter::~BoundingRectHighlighter() } -void BoundingRectHighlighter::animTimeout() -{ - ++m_animFrame; - if (m_animFrame == AnimFrames) { - m_animTimer->stop(); - } - - qreal alpha = m_animFrame / float(AnimFrames); - - foreach (BoundingBox *box, m_boxes) { - box->highlightPolygonEdge->setOpacity(alpha); - } -} - void BoundingRectHighlighter::clear() { - if (m_boxes.length()) { - m_animTimer->stop(); - - foreach (BoundingBox *box, m_boxes) { - freeBoundingBox(box); - } - } + foreach (BoundingBox *box, m_boxes) + freeBoundingBox(box); } BoundingBox *BoundingRectHighlighter::boxFor(QGraphicsObject *item) const { foreach (BoundingBox *box, m_boxes) { - if (box->highlightedObject.data() == item) { + if (box->highlightedObject.data() == item) return box; - } } return 0; } @@ -146,15 +118,11 @@ void BoundingRectHighlighter::highlight(QList<QGraphicsObject*> items) if (items.isEmpty()) return; - bool animate = false; - QList<BoundingBox *> newBoxes; foreach (QGraphicsObject *itemToHighlight, items) { BoundingBox *box = boxFor(itemToHighlight); - if (!box) { + if (!box) box = createBoundingBox(itemToHighlight); - animate = true; - } newBoxes << box; } @@ -165,7 +133,7 @@ void BoundingRectHighlighter::highlight(QList<QGraphicsObject*> items) m_boxes << newBoxes; } - highlightAll(animate); + highlightAll(); } void BoundingRectHighlighter::highlight(QGraphicsObject* itemToHighlight) @@ -173,17 +141,14 @@ void BoundingRectHighlighter::highlight(QGraphicsObject* itemToHighlight) if (!itemToHighlight) return; - bool animate = false; - BoundingBox *box = boxFor(itemToHighlight); if (!box) { box = createBoundingBox(itemToHighlight); m_boxes << box; - animate = true; qSort(m_boxes); } - highlightAll(animate); + highlightAll(); } BoundingBox *BoundingRectHighlighter::createBoundingBox(QGraphicsObject *itemToHighlight) @@ -244,7 +209,7 @@ void BoundingRectHighlighter::itemDestroyed(QObject *obj) } } -void BoundingRectHighlighter::highlightAll(bool animate) +void BoundingRectHighlighter::highlightAll() { foreach (BoundingBox *box, m_boxes) { if (box && box->highlightedObject.isNull()) { @@ -262,21 +227,13 @@ void BoundingRectHighlighter::highlightAll(bool animate) box->highlightPolygon->setPolygon(QPolygonF(bboxRect)); box->highlightPolygonEdge->setPolygon(QPolygonF(edgeRect)); - - if (animate) - box->highlightPolygonEdge->setOpacity(0); - } - - if (animate) { - m_animFrame = 0; - m_animTimer->start(); } } void BoundingRectHighlighter::refresh() { if (!m_boxes.isEmpty()) - highlightAll(true); + highlightAll(); } QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter_p.h index 89a9cf2..e2928f7 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter_p.h +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter_p.h @@ -74,12 +74,11 @@ public: private slots: void refresh(); - void animTimeout(); void itemDestroyed(QObject *); private: BoundingBox *boxFor(QGraphicsObject *item) const; - void highlightAll(bool animate); + void highlightAll(); BoundingBox *createBoundingBox(QGraphicsObject *itemToHighlight); void removeBoundingBox(BoundingBox *box); void freeBoundingBox(BoundingBox *box); @@ -90,10 +89,6 @@ private: QDeclarativeViewInspector *m_view; QList<BoundingBox* > m_boxes; QList<BoundingBox* > m_freeBoxes; - QTimer *m_animTimer; - qreal m_animScale; - int m_animFrame; - }; class BoundingBox : public QObject |