diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2011-05-06 14:57:40 +0200 |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-05-09 09:31:09 +0200 |
commit | 3be92b70f5c737d336e3d9da96945ff8ba5cf3e5 (patch) | |
tree | dd148eeb0ea8d15460bdd92ca2f6147986bc1586 | |
parent | 81daa842a9b1bc84dce25f5a43205d809d24814d (diff) |
Add new hidden property in WaylandSurfaceItem to control visibility.
This lets us control visibility while still having the mouse events
working. We usually want to hide the surface item if it has a shader
effect item modifying its appearance (since otherwise both the source
and the shader effect items are shown, blended on top of each other).
4 files changed, 20 insertions, 8 deletions
diff --git a/examples/qml-compositor/qml/QmlCompositor/ShaderEffect.qml b/examples/qml-compositor/qml/QmlCompositor/ShaderEffect.qml index b1412f6b5..ffbe58cbd 100644 --- a/examples/qml-compositor/qml/QmlCompositor/ShaderEffect.qml +++ b/examples/qml-compositor/qml/QmlCompositor/ShaderEffect.qml @@ -47,7 +47,7 @@ ShaderEffectItem { onSourceChanged: { if (source != null) { - source.visible = false; + source.setHidden(true); vertexShader = source.isYInverted() ? vShaderInvertedY : vShader; } } diff --git a/examples/qml-compositor/qml/QmlCompositor/WindowChrome.qml b/examples/qml-compositor/qml/QmlCompositor/WindowChrome.qml index 9e6b0a807..3b6727d60 100644 --- a/examples/qml-compositor/qml/QmlCompositor/WindowChrome.qml +++ b/examples/qml-compositor/qml/QmlCompositor/WindowChrome.qml @@ -53,10 +53,4 @@ Item { window.takeFocus(); } } - - Binding { - target: window - property: "opacity" - value: 0.01 - } } diff --git a/src/qt-compositor/compositor_api/waylandsurfaceitem.cpp b/src/qt-compositor/compositor_api/waylandsurfaceitem.cpp index 150431699..813d4f58d 100644 --- a/src/qt-compositor/compositor_api/waylandsurfaceitem.cpp +++ b/src/qt-compositor/compositor_api/waylandsurfaceitem.cpp @@ -68,6 +68,7 @@ WaylandSurfaceItem::WaylandSurfaceItem(QSGItem *parent) : QSGItem(parent) , m_surface(0) , m_texture(0) + , m_hidden(false) { } @@ -75,6 +76,7 @@ WaylandSurfaceItem::WaylandSurfaceItem(WaylandSurface *surface, QSGItem *parent) : QSGItem(parent) , m_surface(0) , m_texture(0) + , m_hidden(false) { init(surface); } @@ -174,11 +176,22 @@ void WaylandSurfaceItem::surfaceDestroyed(QObject *) m_surface = 0; } +bool WaylandSurfaceItem::hidden() const +{ + return m_hidden; +} + +void WaylandSurfaceItem::setHidden(bool h) +{ + m_hidden = h; + update(); +} + QSGNode *WaylandSurfaceItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) { QSGSimpleTextureNode *node = static_cast<QSGSimpleTextureNode *>(oldNode); - if (!m_texture) { + if (!m_texture || m_hidden) { delete oldNode; return 0; } diff --git a/src/qt-compositor/compositor_api/waylandsurfaceitem.h b/src/qt-compositor/compositor_api/waylandsurfaceitem.h index 9f4ae16ae..1734b00bf 100644 --- a/src/qt-compositor/compositor_api/waylandsurfaceitem.h +++ b/src/qt-compositor/compositor_api/waylandsurfaceitem.h @@ -54,6 +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) public: WaylandSurfaceItem(QSGItem *parent = 0); @@ -68,6 +69,8 @@ public: QSGTexture *texture() const; const char *textureChangedSignal() const { return SIGNAL(textureChanged()); } + bool hidden() const; + protected: void mousePressEvent(QGraphicsSceneMouseEvent *event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event); @@ -78,6 +81,7 @@ protected: public slots: void takeFocus(); + void setHidden(bool hidden); private slots: void surfaceMapped(const QRect &rect); @@ -96,6 +100,7 @@ private: WaylandSurface *m_surface; QSGTexture *m_texture; + bool m_hidden; }; #endif |