]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/controller.hpp
Calculate fullscreencotnrollers position only when screen has changed
[vlc] / modules / gui / qt4 / components / controller.hpp
1 /*****************************************************************************
2  * interface_widgets.hpp : Custom widgets for the main interface
3  ****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Clément Stenac <zorglub@videolan.org>
8  *          Jean-Baptiste Kempf <jb@videolan.org>
9  *          Rafaël Carré <funman@videolanorg>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25
26 #ifndef _CONTROLLER_H_
27 #define _CONTROLLER_H_
28
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #include <vlc_common.h>
34 #include <vlc_interface.h>
35
36 #include "qt4.hpp"
37 #include "main_interface.hpp"
38 #include "input_manager.hpp"
39
40 #include <QWidget>
41 #include <QFrame>
42 #include <QToolButton>
43
44 class QPixmap;
45 class QLabel;
46 class QGridLayout;
47
48 class InputSlider;
49 class QAbstractSlider;
50
51 class QAbstractButton;
52
53 class VolumeClickHandler;
54 class QSignalMapper;
55
56 typedef enum buttonType_e
57 {
58     PLAY_BUTTON,
59     PAUSE_BUTTON,
60     STOP_BUTTON,
61     OPEN_BUTTON,
62     PREVIOUS_BUTTON,
63     NEXT_BUTTON,
64     SLOWER_BUTTON,
65     FASTER_BUTTON,
66     FULLSCREEN_BUTTON,
67     EXTENDED_BUTTON,
68     PLAYLIST_BUTTON,
69     SNAPSHOT_BUTTON,
70     RECORD_BUTTON,
71     ATOB_BUTTON,
72 #if 0
73     FRAME_BUTTON,
74 #endif
75     INPUT_SLIDER,
76     VOLUME_SLIDER,
77     MENU_BUTTONS,
78     TELETEXT_BUTTONS,
79     VOLUME,
80 } buttonType_e;
81
82 typedef enum actionType_e
83 {
84     PLAY_ACTION,
85     PAUSE_ACTION,
86     STOP_ACTION,
87     PREVIOUS_ACTION,
88     NEXT_ACTION,
89     SLOWER_ACTION,
90     FASTER_ACTION,
91     FULLSCREEN_ACTION,
92     EXTENDED_ACTION,
93     PLAYLIST_ACTION,
94     SNAPSHOT_ACTION,
95     RECORD_ACTION,
96     ATOB_ACTION
97 } actionType_e;
98
99 class AbstractController : public QFrame
100 {
101     Q_OBJECT
102 public:
103     AbstractController( intf_thread_t  *_p_i );
104     virtual ~AbstractController()  {};
105
106 protected:
107     intf_thread_t       *p_intf;
108
109     QSignalMapper       *toolbarActionsMapper;
110     QGridLayout         *controlLayout;
111
112     QWidget *createWidget( buttonType_e, bool b_flat = false,
113                            bool b_big = false, bool b_shiny = false );
114     void setupButton( QAbstractButton * );
115
116 private:
117     QWidget *discFrame();
118     QWidget *telexFrame();
119
120 private slots:
121     void doAction( int );
122
123 protected slots:
124     void play();
125     void stop();
126     void prev();
127     void next();
128     void fullscreen();
129     void extSettings();
130     void faster();
131     void slower();
132     void playlist();
133     void snapshot();
134     void record();
135 #if 0
136     void frame();
137 #endif
138
139     virtual void setStatus( int );
140
141 signals:
142     void inputExists( bool ); /// This might be usefull in the IM ?
143     void inputPlaying( bool ); /// This might be usefull in the IM ?
144     void inputIsRecordable( bool ); /// same ?
145 };
146
147 class PlayButton : public QToolButton
148 {
149     Q_OBJECT
150 private slots:
151     void updateButton( bool );
152 };
153
154 class AtoB_Button : public QToolButton
155 {
156     Q_OBJECT
157 private slots:
158     void setIcons( bool, bool );
159 };
160
161 class TeletextController : public QWidget
162 {
163     Q_OBJECT
164     friend class AbstractController;
165 private:
166     QToolButton         *telexTransparent, *telexOn;
167     QSpinBox            *telexPage;
168
169 private slots:
170     void enableTeletextButtons( bool );
171     void toggleTeletextTransparency( bool );
172 };
173
174 class SoundWidget : public QWidget
175 {
176     Q_OBJECT
177     friend class VolumeClickHandler;
178
179 public:
180     SoundWidget( intf_thread_t  *_p_i, bool );
181
182 private:
183     intf_thread_t       *p_intf;
184     QLabel              *volMuteLabel;
185     QAbstractSlider     *volumeSlider;
186     VolumeClickHandler  *hVolLabel;
187     bool                 b_my_volume;
188
189 protected slots:
190     void updateVolume( int );
191     void updateVolume( void );
192 };
193
194 /* Advanced Button Bar */
195 class AdvControlsWidget : public AbstractController
196 {
197     Q_OBJECT
198 public:
199     AdvControlsWidget( intf_thread_t * );
200     virtual ~AdvControlsWidget();
201 };
202
203 /* Button Bar */
204 class ControlsWidget : public AbstractController
205 {
206     Q_OBJECT
207 public:
208     /* p_intf, advanced control visible or not, blingbling or not */
209     ControlsWidget( intf_thread_t *_p_i, bool b_advControls );
210     virtual ~ControlsWidget();
211
212 protected:
213     friend class MainInterface;
214
215     AdvControlsWidget   *advControls;
216     bool                 b_advancedVisible;
217
218 protected slots:
219     void toggleAdvanced();
220
221 signals:
222     void advancedControlsToggled( bool );
223 };
224
225 /* on WIN32 hide() for fullscreen controller doesnt work, so it have to be
226    done by trick with setting the opacity of window */
227 #ifdef WIN32
228     #define WIN32TRICK
229 #endif
230
231 /* to trying transparency with fullscreen controller on windows enable that */
232 /* it can be enabled on-non windows systems,
233    but it will be transparent only with composite manager */
234 #ifndef WIN32
235     #define HAVE_TRANSPARENCY 1
236 #else
237     #define HAVE_TRANSPARENCY 0
238 #endif
239
240 /* Default value of opacity for FS controller */
241 #define DEFAULT_OPACITY 0.75
242
243 /***********************************
244  * Fullscreen controller
245  ***********************************/
246 class FullscreenControllerWidget : public AbstractController
247 {
248     Q_OBJECT
249 public:
250     FullscreenControllerWidget( intf_thread_t * );
251     virtual ~FullscreenControllerWidget();
252
253     /* Vout */
254     vout_thread_t *p_vout;
255     void attachVout( vout_thread_t *p_vout );
256     void detachVout();
257     void fullscreenChanged( vout_thread_t *, bool b_fs, int i_timeout );
258
259     int i_mouse_last_move_x;
260     int i_mouse_last_move_y;
261
262 protected:
263     friend class MainInterface;
264
265     virtual void mouseMoveEvent( QMouseEvent *event );
266     virtual void mousePressEvent( QMouseEvent *event );
267     virtual void enterEvent( QEvent *event );
268     virtual void leaveEvent( QEvent *event );
269     virtual void keyPressEvent( QKeyEvent *event );
270
271 private slots:
272     void showFSC();
273     void planHideFSC();
274     void hideFSC();
275     void slowHideFSC();
276
277 private:
278     virtual void customEvent( QEvent *event );
279
280     QTimer *p_hideTimer;
281 #if HAVE_TRANSPARENCY
282     QTimer *p_slowHideTimer;
283     bool b_slow_hide_begin;
284     int  i_slow_hide_timeout;
285 #endif
286
287     int i_mouse_last_x, i_mouse_last_y;
288     bool b_mouse_over;
289     int i_screennumber;
290
291 #ifdef WIN32TRICK
292     bool b_fscHidden;
293 #endif
294
295     /* Shared variable between FSC and VLC (protected by a lock) */
296     vlc_mutex_t lock;
297     bool        b_fullscreen;
298     int         i_hide_timeout;  /* FSC hiding timeout, same as mouse hiding timeout */
299 };
300
301 #endif