Debugger: Changes made for selection using Inspect Tool
authorSimjees Abraham <simjees.abraham@nokia.com>
Tue, 17 Apr 2012 13:28:23 +0000 (15:28 +0200)
committerQt by Nokia <qt-info@nokia.com>
Thu, 19 Apr 2012 07:23:08 +0000 (09:23 +0200)
The selected item is shown in black transparent background.

Change-Id: Ifc9d2892cc000041df6d9585f5c5adcca07abfb5
Reviewed-by: Aurindam Jana <aurindam.jana@nokia.com>
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
src/plugins/qmltooling/qmldbg_qtquick2/highlight.cpp
src/plugins/qmltooling/qmldbg_qtquick2/highlight.h

index d014dd4..f886978 100644 (file)
 namespace QmlJSDebugger {
 namespace QtQuick2 {
 
+Highlight::Highlight(QQuickItem *parent) : QQuickPaintedItem(parent)
+{
+    initRenderDetails();
+}
+
 Highlight::Highlight(QQuickItem *item, QQuickItem *parent)
     : QQuickPaintedItem(parent)
 {
+    initRenderDetails();
     setItem(item);
 }
 
+void Highlight::initRenderDetails()
+{
+    setRenderTarget(QQuickPaintedItem::FramebufferObject);
+    setPerformanceHint(QQuickPaintedItem::FastFBOResizing, true);
+}
+
 void Highlight::setItem(QQuickItem *item)
 {
     if (m_item)
@@ -79,6 +91,7 @@ void Highlight::setItem(QQuickItem *item)
                 SLOT(adjust()));
     }
     m_item = item;
+    setContentsSize(view->size());
     adjust();
 }
 
@@ -105,7 +118,6 @@ void Highlight::adjust()
     // takes care of it.
     parentItem()->setScale(1/scaleFactor);
     setPos(originOffset);
-    setContentsSize(view->size());
     update();
 }
 
@@ -127,20 +139,14 @@ void SelectionHighlight::paint(QPainter *painter)
 {
     if (!item())
         return;
-
     painter->save();
+    painter->fillRect(QRectF(0,0,contentsSize().width(), contentsSize().height()),
+                      QColor(0,0,0,127));
     painter->setTransform(transform());
-    if (item()->height() >= 10 && item()->width() >= 10) {
-        QColor colorHighlight = Qt::green;
-        painter->fillRect(QRectF(0, 0, item()->width(), 5), colorHighlight);
-        painter->fillRect(QRectF(0, item()->height()-5, item()->width(), 5), colorHighlight);
-        painter->fillRect(QRectF(0, 5, 5, item()->height() - 10), colorHighlight);
-        painter->fillRect(QRectF(item()->width()-5, 5, 5, item()->height() - 10), colorHighlight);
-    }
-    painter->setPen(QPen(QColor(0, 22, 159)));
-    painter->drawRect(QRect(1, 1, item()->width() - 3, item()->height() - 3));
-    painter->setPen(QColor(158, 199, 255));
-    painter->drawRect(QRect(0, 0, item()->width() - 1, item()->height() - 1));
+    // Setting the composition mode such that the transparency will
+    // be erased as per the selected item.
+    painter->setCompositionMode(QPainter::CompositionMode_Clear);
+    painter->fillRect(0, 0, item()->width(), item()->height(), Qt::black);
     painter->restore();
 }
 
index 3dbd109..2900b9c 100644 (file)
@@ -55,7 +55,7 @@ class Highlight : public QQuickPaintedItem
     Q_OBJECT
 
 public:
-    Highlight(QQuickItem *parent) : QQuickPaintedItem(parent) {}
+    Highlight(QQuickItem *parent);
     Highlight(QQuickItem *item, QQuickItem *parent);
 
     void setItem(QQuickItem *item);
@@ -64,6 +64,9 @@ public:
 protected:
     QTransform transform() {return m_transform;}
 
+private:
+    void initRenderDetails();
+
 private slots:
     void adjust();