Tulip  4.6.0
Better Visualization Through Research
library/tulip-gui/include/tulip/WorkspaceExposeWidget.h
00001 /*
00002  *
00003  * This file is part of Tulip (www.tulip-software.org)
00004  *
00005  * Authors: David Auber and the Tulip development Team
00006  * from LaBRI, University of Bordeaux
00007  *
00008  * Tulip is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License
00010  * as published by the Free Software Foundation, either version 3
00011  * of the License, or (at your option) any later version.
00012  *
00013  * Tulip is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  * See the GNU General Public License for more details.
00017  *
00018  */
00019 ///@cond DOXYGEN_HIDDEN
00020 
00021 
00022 #ifndef WORKSPACEEXPOSEWIDGET_H
00023 #define WORKSPACEEXPOSEWIDGET_H
00024 
00025 #include <QGraphicsObject>
00026 #include <QGraphicsView>
00027 
00028 #include <tulip/tulipconf.h>
00029 
00030 class QAbstractAnimation;
00031 
00032 namespace tlp {
00033 class WorkspacePanel;
00034 
00035 class PreviewItem: public QGraphicsObject {
00036   Q_OBJECT
00037 
00038   static QPixmap* _closeButtonPixmap;
00039   static QRect _closePixmapRect;
00040 
00041   QPixmap _pixmap;
00042   WorkspacePanel* _panel;
00043   bool _hovered;
00044   bool _closeButtonHovered;
00045 
00046   int textHeight() const;
00047 public:
00048   explicit PreviewItem(const QPixmap& pixmap, WorkspacePanel* panel, QGraphicsItem* parent = NULL);
00049   QRectF boundingRect() const;
00050   void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
00051   WorkspacePanel* panel() const;
00052   bool shouldClose(const QPointF&);
00053 protected:
00054   void hoverEnterEvent(QGraphicsSceneHoverEvent*);
00055   void hoverLeaveEvent(QGraphicsSceneHoverEvent*);
00056   void hoverMoveEvent(QGraphicsSceneHoverEvent*);
00057   void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*);
00058 signals:
00059   void opened();
00060 };
00061 
00062 
00063 class TLP_QT_SCOPE WorkspaceExposeWidget : public QGraphicsView {
00064   Q_OBJECT
00065 
00066   QAbstractAnimation* _positionAnimation;
00067   QList<PreviewItem*> _items;
00068   PreviewItem* _selectedItem;
00069   QGraphicsRectItem* _placeholderItem;
00070   bool _switchToSingleMode;
00071 
00072   int _currentPanelIndex;
00073 
00074   void updatePositions(bool resetScenePos=true);
00075   static const int MARGIN;
00076 
00077   void finish();
00078 
00079 public:
00080   static QSize previewSize();
00081 
00082   explicit WorkspaceExposeWidget(QWidget *parent = NULL);
00083   int currentPanelIndex() const;
00084   QVector<WorkspacePanel*> panels() const;
00085 
00086   bool isSwitchToSingleMode() const;
00087 
00088 public slots:
00089   void setData(const QVector<WorkspacePanel*>& panels, int currentPanelIndex);
00090 
00091 signals:
00092   void exposeFinished();
00093 
00094 protected:
00095   void resizeEvent(QResizeEvent *event);
00096   bool eventFilter(QObject *, QEvent *);
00097   bool event(QEvent*);
00098 
00099 protected slots:
00100   void updatePositionsAnimationFinished();
00101   void resetSceneRect();
00102   void itemOpened();
00103 };
00104 
00105 }
00106 
00107 #endif // WORKSPACEEXPOSEWIDGET_H
00108 
00109 ///@endcond
 All Classes Files Functions Variables Enumerations Enumerator Properties