00001 #ifndef MAINWINDOW_H
00002 #define MAINWINDOW_H
00003
00004 #include <QAbstractTransition>
00005 #include <QGraphicsView>
00006 #include <QGraphicsWidget>
00007 #include <QMainWindow>
00008 #include <QParallelAnimationGroup>
00009 #include <QPixmap>
00010 #include <QStateMachine>
00011 #include "fractalPixmap.h"
00012 #include "settingsDialog.h"
00013
00014
00015 class View : public QGraphicsView
00016 {
00017 Q_OBJECT
00018 public:
00019 View(QGraphicsScene *scene) : QGraphicsView(scene) { }
00020 signals:
00021 void resized();
00022 protected:
00023 void resizeEvent(QResizeEvent *event);
00024 };
00025
00026
00027 class Button : public QGraphicsWidget
00028 {
00029 Q_OBJECT
00030 public:
00031 Button(const QPixmap &pixmap, const int buttonSize, int index=-1, QGraphicsItem *parent = 0);
00032 QRectF boundingRect() const;
00033 QPainterPath shape() const;
00034 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *);
00035
00036 signals:
00037 void pressed(int index, bool doShowDialog);
00038 void hoverEnter(int index=-1);
00039 void hoverLeave();
00040
00041 protected:
00042 void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
00043 void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);
00044 void hoverEnterEvent(QGraphicsSceneHoverEvent *);
00045 void hoverLeaveEvent(QGraphicsSceneHoverEvent *);
00046
00047 private:
00048 QPixmap _pix;
00049 int fractalTypeIndex;
00050 int size;
00051 };
00052
00053
00054 class MainWindow : public QMainWindow
00055 {
00056 Q_OBJECT
00057
00058 public:
00059 MainWindow(QWidget *parent = 0);
00060
00061
00062
00063 public slots:
00064 void setProgressRange(const int minimum, const int maximum);
00065 void setProgressValue(const int value);
00066 void start();
00067 void newFrac(const int typeIndex, const bool doShowDialog);
00068 void redrawGUI();
00069 void repositionFractals();
00070 void fractalClicked(int fractIndex);
00071 void showHint(int index);
00072 void hideHint();
00073
00074 private slots:
00075
00076 private:
00077 QAbstractTransition *trans;
00078 QGraphicsScene scene;
00079 QGraphicsItem *buttonParent;
00080 QList<CFractalPixmap *> fractalList;
00081
00082 QParallelAnimationGroup *animGroup;
00083
00084 QList<QState *> stateList;
00085 QState *rootState;
00086 QState *initialState;
00087 QStateMachine states;
00088
00089 QTimer timer;
00090
00091 QGraphicsLineItem *bottomLine;
00092 QPixmap hintPix;
00093 QGraphicsPixmapItem *hintItem;
00094 QGraphicsTextItem *hintText;
00095 int currentFractal;
00096
00097 Button *newFractalButtons[FRACTAL_TYPE_COUNT];
00098 View *view;
00099 };
00100
00101 #endif