]> git.sven.stormbind.net Git - sven/vym.git/blobdiff - src/winter.h
New upstream version 2.9.22
[sven/vym.git] / src / winter.h
diff --git a/src/winter.h b/src/winter.h
new file mode 100644 (file)
index 0000000..9667541
--- /dev/null
@@ -0,0 +1,62 @@
+#ifndef WINTER_H
+#define WINTER_H
+
+#include <QGraphicsItem>
+#include <QObject>
+#include <QRectF>
+#include <QTimer>
+
+class QGraphicsView;
+class QGraphicsScene;
+
+class SnowFlake : public QGraphicsItem {
+  public:
+    enum SnowType { Smilla, Disc, Egg };
+
+    SnowFlake(QGraphicsScene *scene, SnowType type);
+    ~SnowFlake();
+    QRectF boundingRect() const;
+    void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+    void animate();
+    void blow(const QPointF &v);
+
+  private:
+    SnowType type;
+    int size;
+    QList<QGraphicsLineItem *> lines;
+    QGraphicsEllipseItem *disc;
+    QPointF dv;
+    QPointF dblow;
+    qreal da;
+};
+
+class Winter : public QObject {
+    Q_OBJECT
+  public:
+    Winter(QGraphicsView *view);
+    ~Winter();
+    void updateView();
+    void setObstacles(QList<QRectF> obslist);
+
+  public slots:
+    void animate();
+    void makeSnow();
+
+  private:
+    QGraphicsView *view;
+    QList<SnowFlake *> fallingSnow;
+    QList<SnowFlake *> frozenSnow;
+    int maxFlakes;
+    QTimer *animTimer;
+    QTimer *snowTimer;
+    QList<QRectF> obstacles;
+
+    SnowFlake::SnowType type;
+    int maxFalling;
+    int maxUnfreeze;
+    // QGraphicsRectItem *test;
+
+    QRectF viewRect;
+};
+
+#endif