| 1 | /* smplayer, GUI front-end for mplayer.
|
|---|
| 2 | Copyright (C) 2006-2010 Ricardo Villalba <rvm@escomposlinux.org>
|
|---|
| 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 QToolBar;
|
|---|
| 26 |
|
|---|
| 27 | class FloatingWidget : public QWidget
|
|---|
| 28 | {
|
|---|
| 29 | Q_OBJECT
|
|---|
| 30 |
|
|---|
| 31 | public:
|
|---|
| 32 | enum Place { Top = 0, Bottom = 1 };
|
|---|
| 33 | enum Movement { Upward = 0, Downward = 1 };
|
|---|
| 34 |
|
|---|
| 35 | FloatingWidget(QWidget * parent = 0);
|
|---|
| 36 | ~FloatingWidget();
|
|---|
| 37 |
|
|---|
| 38 | //! Show the floating widget over the specified widget.
|
|---|
| 39 | void showOver(QWidget * widget, int size = 100, Place place = Bottom);
|
|---|
| 40 |
|
|---|
| 41 | void showAnimated(QPoint final_position, Movement movement);
|
|---|
| 42 |
|
|---|
| 43 | QToolBar * toolbar() { return tb; };
|
|---|
| 44 |
|
|---|
| 45 | bool isAnimated() { return _animated; };
|
|---|
| 46 | bool autoHide() { return auto_hide; };
|
|---|
| 47 | int margin() { return _margin; };
|
|---|
| 48 |
|
|---|
| 49 | public slots:
|
|---|
| 50 | void setAnimated(bool b) { _animated = b; };
|
|---|
| 51 | void setAutoHide(bool b);
|
|---|
| 52 | void setMargin(int margin) { _margin = margin; };
|
|---|
| 53 | #ifndef Q_OS_WIN
|
|---|
| 54 | void setBypassWindowManager(bool b);
|
|---|
| 55 | #endif
|
|---|
| 56 |
|
|---|
| 57 | protected:
|
|---|
| 58 | QToolBar * tb;
|
|---|
| 59 |
|
|---|
| 60 | private slots:
|
|---|
| 61 | void animate();
|
|---|
| 62 | void checkUnderMouse();
|
|---|
| 63 |
|
|---|
| 64 | private:
|
|---|
| 65 | // Animation variables
|
|---|
| 66 | bool _animated;
|
|---|
| 67 | QTimer * animation_timer;
|
|---|
| 68 | int final_y;
|
|---|
| 69 | int current_y;
|
|---|
| 70 | Movement current_movement;
|
|---|
| 71 |
|
|---|
| 72 | bool auto_hide;
|
|---|
| 73 | QTimer auto_hide_timer;
|
|---|
| 74 |
|
|---|
| 75 | int _margin;
|
|---|
| 76 | };
|
|---|
| 77 |
|
|---|
| 78 | #endif
|
|---|