[gegl-qt] Widgets: Pass viewport geometry to implementation



commit 1b9fbe0f6e7b9d13e2e7c98ff4c801418a0bf20b
Author: Jon Nordby <jononor gmail com>
Date:   Sun Jul 31 21:12:21 2011 +0200

    Widgets: Pass viewport geometry to implementation
    
    TEMP: Is this actually needed? Or can we do everything we want
    in ::paint?

 gegl-qt/geglqtdeclarativeview.cpp    |    8 ++++++++
 gegl-qt/geglqtdeclarativeview.h      |    1 +
 gegl-qt/geglqtgraphicswidgetview.cpp |    9 +++++++++
 gegl-qt/geglqtgraphicswidgetview.h   |    1 +
 gegl-qt/geglqtview.cpp               |    4 ++++
 gegl-qt/geglqtview.h                 |    1 +
 gegl-qt/geglqtviewimplementation.cpp |    7 +++++++
 gegl-qt/geglqtviewimplementation.h   |    4 ++++
 8 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/gegl-qt/geglqtdeclarativeview.cpp b/gegl-qt/geglqtdeclarativeview.cpp
index 35973ca..8b3fd50 100644
--- a/gegl-qt/geglqtdeclarativeview.cpp
+++ b/gegl-qt/geglqtdeclarativeview.cpp
@@ -62,3 +62,11 @@ GeglQtDeclarativeView::paint(QPainter *painter,
     qDebug() << __PRETTY_FUNCTION__ << rect;
     priv->paint(painter, rect);
 }
+
+void
+GeglQtDeclarativeView::geometryChanged(const QRectF & newGeometry,
+                                       const QRectF & oldGeometry)
+{
+    QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
+    priv->viewportSizeChanged(newGeometry.size());
+}
diff --git a/gegl-qt/geglqtdeclarativeview.h b/gegl-qt/geglqtdeclarativeview.h
index d21e833..01d0001 100644
--- a/gegl-qt/geglqtdeclarativeview.h
+++ b/gegl-qt/geglqtdeclarativeview.h
@@ -23,6 +23,7 @@ public:
     Q_INVOKABLE GeglQtViewOptions *options() const;
 
     //! reimpl
+    void geometryChanged(const QRectF & newGeometry, const QRectF & oldGeometry);
     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
     //! reimpl end
 
diff --git a/gegl-qt/geglqtgraphicswidgetview.cpp b/gegl-qt/geglqtgraphicswidgetview.cpp
index b7b9f35..ea81622 100644
--- a/gegl-qt/geglqtgraphicswidgetview.cpp
+++ b/gegl-qt/geglqtgraphicswidgetview.cpp
@@ -25,6 +25,9 @@ GeglQtGraphicsWidgetView::GeglQtGraphicsWidgetView(QGraphicsItem * parent)
 {
     connect(priv, SIGNAL(viewAreaChanged(QRectF)),
             this, SLOT(invalidate(QRectF)));
+
+    connect(this, SIGNAL(geometryChanged()),
+            this, SLOT(handleGeometryChange));
 }
 
 
@@ -75,3 +78,9 @@ GeglQtGraphicsWidgetView::paint(QPainter *painter,
     qDebug() << __PRETTY_FUNCTION__ << rect;
     priv->paint(painter, rect);
 }
+
+void
+GeglQtGraphicsWidgetView::handleGeometryChange()
+{
+    priv->viewportSizeChanged(geometry().size());
+}
diff --git a/gegl-qt/geglqtgraphicswidgetview.h b/gegl-qt/geglqtgraphicswidgetview.h
index 3965ee4..11e63a5 100644
--- a/gegl-qt/geglqtgraphicswidgetview.h
+++ b/gegl-qt/geglqtgraphicswidgetview.h
@@ -43,6 +43,7 @@ public:
 
 private Q_SLOTS:
     void invalidate(QRectF rect);
+    void handleGeometryChange();
 
 private:
     GeglQtViewImplementation *priv;
diff --git a/gegl-qt/geglqtview.cpp b/gegl-qt/geglqtview.cpp
index 668bc1d..5087f28 100644
--- a/gegl-qt/geglqtview.cpp
+++ b/gegl-qt/geglqtview.cpp
@@ -86,3 +86,7 @@ GeglQtView::paintEvent(QPaintEvent *event)
     priv->paint(&painter, QRectF(event->rect()));
 }
 
+void GeglQtView::resizeEvent(QResizeEvent *event)
+{
+    priv->viewportSizeChanged(event->size());
+}
diff --git a/gegl-qt/geglqtview.h b/gegl-qt/geglqtview.h
index 46ffb48..09fd536 100644
--- a/gegl-qt/geglqtview.h
+++ b/gegl-qt/geglqtview.h
@@ -42,6 +42,7 @@ public:
 
     //! \reimpl
     virtual void paintEvent(QPaintEvent *event);
+    virtual void resizeEvent(QResizeEvent *event);
     //! \reimpl end
 
 private Q_SLOTS:
diff --git a/gegl-qt/geglqtviewimplementation.cpp b/gegl-qt/geglqtviewimplementation.cpp
index f701047..5a83232 100644
--- a/gegl-qt/geglqtviewimplementation.cpp
+++ b/gegl-qt/geglqtviewimplementation.cpp
@@ -167,6 +167,13 @@ GeglQtViewImplementation::transformationChanged()
     Q_EMIT viewAreaChanged(invalidRect); // Redraws everything
 }
 
+/* */
+void
+GeglQtViewImplementation::viewportSizeChanged(QSizeF newSize)
+{
+    mViewportSize = newSize;
+}
+
 /* An area in the GeglNode has been invalidated,
  * process it to compute the contents. */
 void
diff --git a/gegl-qt/geglqtviewimplementation.h b/gegl-qt/geglqtviewimplementation.h
index e52e47a..e458f02 100644
--- a/gegl-qt/geglqtviewimplementation.h
+++ b/gegl-qt/geglqtviewimplementation.h
@@ -40,6 +40,9 @@ public:
 
     void paint(QPainter *painter, const QRectF & viewRect);
 
+public Q_SLOTS:
+    void viewportSizeChanged(QSizeF newSize);
+
 public: // Only public because invalidate_event and computed_event needs them.
     void nodeInvalidated(GeglRectangle *rect);
     void nodeComputed(GeglRectangle *rect);
@@ -59,6 +62,7 @@ private:
     GeglProcessor *processor; // Used to process the GeglNode when invalidated.
     QTimer *timer; // Used to defer operations to the mainloop.
     GeglQtViewOptions *mOptions;
+    QSizeF mViewportSize;
 };
 
 #endif // GEGLQTVIEWIMPLEMENTATION_H



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]