| 1 | /* smplayer, GUI front-end for mplayer.
|
|---|
| 2 | Copyright (C) 2006-2012 Ricardo Villalba <rvm@users.sourceforge.net>
|
|---|
| 3 |
|
|---|
| 4 | This program is free software; you can redistribute it and/or modify
|
|---|
| 5 | it under the terms of the GNU General Public License as published by
|
|---|
| 6 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 7 | (at your option) any later version.
|
|---|
| 8 |
|
|---|
| 9 | This program is distributed in the hope that it will be useful,
|
|---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 12 | GNU General Public License for more details.
|
|---|
| 13 |
|
|---|
| 14 | You should have received a copy of the GNU General Public License
|
|---|
| 15 | along with this program; if not, write to the Free Software
|
|---|
| 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 17 | */
|
|---|
| 18 |
|
|---|
| 19 | #ifndef _FLOATING_WIDGET_H_
|
|---|
| 20 | #define _FLOATING_WIDGET_H_
|
|---|
| 21 |
|
|---|
| 22 | #include <QWidget>
|
|---|
| 23 | #include <QTimer>
|
|---|
| 24 |
|
|---|
| 25 | class EditableToolbar;
|
|---|
| 26 |
|
|---|
| 27 | #if QT_VERSION < 0x040600
|
|---|
| 28 | #define OLD_ANIMATION
|
|---|
| 29 | #endif
|
|---|
| 30 |
|
|---|
| 31 | #ifndef OLD_ANIMATION
|
|---|
| 32 | class QPropertyAnimation;
|
|---|
| 33 | #endif
|
|---|
| 34 |
|
|---|
| 35 | class FloatingWidget : public QWidget
|
|---|
| 36 | {
|
|---|
| 37 | Q_OBJECT
|
|---|
| 38 |
|
|---|
| 39 | public:
|
|---|
| 40 | enum Place { Top = 0, Bottom = 1 };
|
|---|
| 41 | enum Movement { Upward = 0, Downward = 1 };
|
|---|
| 42 |
|
|---|
| 43 | FloatingWidget(QWidget * parent = 0);
|
|---|
| 44 | ~FloatingWidget();
|
|---|
| 45 |
|
|---|
| 46 | //! Show the floating widget over the specified widget.
|
|---|
| 47 | void showOver(QWidget * widget, int size = 100, Place place = Bottom);
|
|---|
| 48 |
|
|---|
| 49 | void showAnimated(QPoint final_position, Movement movement);
|
|---|
| 50 |
|
|---|
| 51 | EditableToolbar * toolbar() { return tb; };
|
|---|
| 52 |
|
|---|
| 53 | bool isAnimated() { return _animated; };
|
|---|
| 54 | bool autoHide() { return auto_hide; };
|
|---|
| 55 | int margin() { return _margin; };
|
|---|
| 56 |
|
|---|
| 57 | public slots:
|
|---|
| 58 | void setAnimated(bool b) { _animated = b; };
|
|---|
| 59 | void setAutoHide(bool b);
|
|---|
| 60 | void setMargin(int margin) { _margin = margin; };
|
|---|
| 61 | #ifndef Q_OS_WIN
|
|---|
| 62 | void setBypassWindowManager(bool b);
|
|---|
| 63 | #endif
|
|---|
| 64 |
|
|---|
| 65 | protected:
|
|---|
| 66 | EditableToolbar * tb;
|
|---|
| 67 |
|
|---|
| 68 | private slots:
|
|---|
| 69 | #ifdef OLD_ANIMATION
|
|---|
| 70 | void animate();
|
|---|
| 71 | #endif
|
|---|
| 72 | void checkUnderMouse();
|
|---|
| 73 |
|
|---|
| 74 | private:
|
|---|
| 75 | // Animation variables
|
|---|
| 76 | bool _animated;
|
|---|
| 77 | #ifdef OLD_ANIMATION
|
|---|
| 78 | QTimer * animation_timer;
|
|---|
| 79 | #endif
|
|---|
| 80 | int final_y;
|
|---|
| 81 | int current_y;
|
|---|
| 82 | Movement current_movement;
|
|---|
| 83 |
|
|---|
| 84 | bool auto_hide;
|
|---|
| 85 | QTimer auto_hide_timer;
|
|---|
| 86 |
|
|---|
| 87 | int _margin;
|
|---|
| 88 |
|
|---|
| 89 | #ifndef OLD_ANIMATION
|
|---|
| 90 | QPropertyAnimation * animation;
|
|---|
| 91 | #endif
|
|---|
| 92 |
|
|---|
| 93 | };
|
|---|
| 94 |
|
|---|
| 95 | #endif
|
|---|