Changed the API for hiding a surface from setHidden to setPaintEnabled.
authorSamuel Rødal <samuel.rodal@nokia.com>
Mon, 9 May 2011 07:25:23 +0000 (09:25 +0200)
committerSamuel Rødal <samuel.rodal@nokia.com>
Mon, 9 May 2011 07:31:09 +0000 (09:31 +0200)
This makes it more explicit that setHidden() isn't just the inverse of
setVisible(), but also still handles mouse events.

examples/qml-compositor/qml/QmlCompositor/ShaderEffect.qml
src/qt-compositor/compositor_api/waylandsurfaceitem.cpp
src/qt-compositor/compositor_api/waylandsurfaceitem.h

index ffbe58c..eb2f800 100644 (file)
@@ -47,7 +47,7 @@ ShaderEffectItem {
 
     onSourceChanged: {
         if (source != null) {
-            source.setHidden(true);
+            source.setPaintEnabled(false);
             vertexShader = source.isYInverted() ? vShaderInvertedY : vShader;
         }
     }
index 813d4f5..772fb31 100644 (file)
@@ -68,7 +68,7 @@ WaylandSurfaceItem::WaylandSurfaceItem(QSGItem *parent)
     : QSGItem(parent)
     , m_surface(0)
     , m_texture(0)
-    , m_hidden(false)
+    , m_paintEnabled(true)
 {
 }
 
@@ -76,7 +76,7 @@ WaylandSurfaceItem::WaylandSurfaceItem(WaylandSurface *surface, QSGItem *parent)
     : QSGItem(parent)
     , m_surface(0)
     , m_texture(0)
-    , m_hidden(false)
+    , m_paintEnabled(true)
 {
     init(surface);
 }
@@ -176,14 +176,14 @@ void WaylandSurfaceItem::surfaceDestroyed(QObject *)
     m_surface = 0;
 }
 
-bool WaylandSurfaceItem::hidden() const
+bool WaylandSurfaceItem::paintEnabled() const
 {
-    return m_hidden;
+    return m_paintEnabled;
 }
 
-void WaylandSurfaceItem::setHidden(bool h)
+void WaylandSurfaceItem::setPaintEnabled(bool enabled)
 {
-    m_hidden = h;
+    m_paintEnabled = enabled;
     update();
 }
 
@@ -191,7 +191,7 @@ QSGNode *WaylandSurfaceItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDa
 {
     QSGSimpleTextureNode *node = static_cast<QSGSimpleTextureNode *>(oldNode);
 
-    if (!m_texture || m_hidden) {
+    if (!m_texture || !m_paintEnabled) {
         delete oldNode;
         return 0;
     }
index 1734b00..10f771b 100644 (file)
@@ -54,7 +54,7 @@ class WaylandSurfaceItem : public QSGItem, public QSGTextureProvider
     Q_OBJECT
     Q_INTERFACES(QSGTextureProvider)
     Q_PROPERTY(WaylandSurface* surface READ surface WRITE setSurface)
-    Q_PROPERTY(bool hidden READ hidden WRITE setHidden)
+    Q_PROPERTY(bool paintEnabled READ paintEnabled WRITE setPaintEnabled)
 
 public:
     WaylandSurfaceItem(QSGItem *parent = 0);
@@ -69,7 +69,7 @@ public:
     QSGTexture *texture() const;
     const char *textureChangedSignal() const { return SIGNAL(textureChanged()); }
 
-    bool hidden() const;
+    bool paintEnabled() const;
 
 protected:
     void mousePressEvent(QGraphicsSceneMouseEvent *event);
@@ -81,7 +81,7 @@ protected:
 
 public slots:
     void takeFocus();
-    void setHidden(bool hidden);
+    void setPaintEnabled(bool paintEnabled);
 
 private slots:
     void surfaceMapped(const QRect &rect);
@@ -100,7 +100,7 @@ private:
 
     WaylandSurface *m_surface;
     QSGTexture *m_texture;
-    bool m_hidden;
+    bool m_paintEnabled;
 };
 
 #endif