]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/interface_widgets.hpp
Try to fix the win32 compile.
[vlc] / modules / gui / qt4 / components / interface_widgets.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 _INTFWIDGETS_H_
27 #define _INTFWIDGETS_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 #include <vlc_aout.h>
36
37 #include "qt4.hpp"
38 #include "main_interface.hpp"
39 #include "input_manager.hpp"
40
41 #include <QWidget>
42 #include <QFrame>
43
44 #define VOLUME_MAX 200
45
46 /* on WIN32 hide() for fullscreen controller doesnt work, so it have to be
47    done by trick with setting the opacity of window */
48 #ifdef WIN32
49     #define WIN32TRICK
50 #endif
51
52 /* to trying transparency with fullscreen controller on windows enable that */
53 #define HAVE_TRANSPARENCY 0
54 /* it can be enabled on-non windows systems,
55    but it will be transparent only with composite manager */
56 #ifndef WIN32
57     #define HAVE_TRANSPARENCY 1
58 #endif
59
60 class ResizeEvent;
61 class QPalette;
62 class QPixmap;
63 class QLabel;
64 class QHBoxLayout;
65
66 /******************** Video Widget ****************/
67 class VideoWidget : public QFrame
68 {
69     Q_OBJECT
70 friend class MainInterface;
71
72 public:
73     VideoWidget( intf_thread_t * );
74     virtual ~VideoWidget();
75
76     void *request( vout_thread_t *, int *, int *,
77                    unsigned int *, unsigned int * );
78     void  release( void * );
79     int   control( void *, int, va_list );
80
81     virtual QSize sizeHint() const;
82 private:
83     intf_thread_t *p_intf;
84     vout_thread_t *p_vout;
85
86     vlc_mutex_t lock;
87     QSize videoSize;
88
89 signals:
90     void askVideoWidgetToShow();
91     //void askResize();
92
93 public slots:
94     void SetSizing( unsigned int, unsigned int );
95 };
96
97 /******************** Background Widget ****************/
98 class BackgroundWidget : public QWidget
99 {
100     Q_OBJECT
101 public:
102     BackgroundWidget( intf_thread_t * );
103     virtual ~BackgroundWidget();
104
105 private:
106     QPalette plt;
107     QLabel *label;
108     virtual void contextMenuEvent( QContextMenuEvent *event );
109     intf_thread_t *p_intf;
110     virtual void resizeEvent( QResizeEvent * event );
111 public slots:
112     void toggle(){ TOGGLEV( this ); }
113     void updateArt( QString );
114 };
115
116 class VisualSelector : public QFrame
117 {
118     Q_OBJECT
119 public:
120     VisualSelector( intf_thread_t *);
121     virtual ~VisualSelector();
122 private:
123     intf_thread_t *p_intf;
124     QLabel *current;
125 private slots:
126     void prev();
127     void next();
128 };
129
130 /* Advanced Button Bar */
131 class QPushButton;
132 class AdvControlsWidget : public QFrame
133 {
134     Q_OBJECT
135 public:
136     AdvControlsWidget( intf_thread_t *);
137     virtual ~AdvControlsWidget();
138
139     void enableInput( bool );
140     void enableVideo( bool );
141
142 private:
143     intf_thread_t *p_intf;
144     QPushButton *recordButton, *ABButton;
145     QPushButton *snapshotButton, *frameButton;
146
147     mtime_t timeA, timeB;
148
149 private slots:
150     void snapshot();
151 #if 0
152     void frame();
153 #endif
154     void fromAtoB();
155     void record();
156     void AtoBLoop( float, int, int );
157 };
158
159 /* Button Bar */
160 class InputSlider;
161 class QSlider;
162 class QGridLayout;
163 class VolumeClickHandler;
164 class SoundSlider;
165 class QAbstractSlider;
166 class QToolButton;
167
168 class ControlsWidget : public QFrame
169 {
170     Q_OBJECT
171 public:
172     /* p_intf, advanced control visible or not, blingbling or not */
173     ControlsWidget( intf_thread_t *_p_i, MainInterface *_p_mi,
174         bool b_advControls, bool b_shiny, bool b_fsCreation = false);
175     virtual ~ControlsWidget();
176
177     QPushButton *playlistButton;
178     void setStatus( int );
179     void enableInput( bool );
180     void enableVideo( bool );
181 public slots:
182     void setNavigation( int );
183 protected:
184     friend class MainInterface;
185     friend class VolumeClickHandler;
186 protected:
187     intf_thread_t       *p_intf;
188     QWidget             *discFrame;
189     QWidget             *telexFrame;
190     QGridLayout         *controlLayout;
191     InputSlider         *slider;
192     QPushButton         *prevSectionButton, *nextSectionButton, *menuButton;
193     QPushButton         *playButton, *fullscreenButton, *extSettingsButton;
194     QToolButton         *slowerButton, *fasterButton;
195     QHBoxLayout         *controlButLayout;
196     AdvControlsWidget   *advControls;
197     QLabel              *volMuteLabel;
198     QAbstractSlider     *volumeSlider;
199     VolumeClickHandler  *hVolLabel;
200
201     bool                 b_advancedVisible;
202 protected slots:
203     void play();
204     void stop();
205     void prev();
206     void next();
207     void updateVolume( int );
208     void updateVolume( void );
209     void updateInput();
210     void fullscreen();
211     void extSettings();
212     void faster();
213     void slower();
214     void toggleAdvanced();
215 signals:
216     void advancedControlsToggled( bool );
217 };
218
219 /***********************************
220  * Fullscreen controller
221  ***********************************/
222
223 static int showFullscreenControllCallback(vlc_object_t *vlc_object, const char *variable, vlc_value_t old_val,
224     vlc_value_t new_val, void *data);
225
226 static int regMouseMoveCallback(vlc_object_t *vlc_object, const char *variable, vlc_value_t old_val,
227     vlc_value_t new_val, void *data);
228
229 class FullscreenControllerWidget : public ControlsWidget
230 {
231     Q_OBJECT
232 public:
233     FullscreenControllerWidget( intf_thread_t *, MainInterface*, bool, bool );
234     virtual ~FullscreenControllerWidget();
235
236     void SetHideTimeout( int hideTimeout ) { i_hideTimeout = hideTimeout; }
237     void regFullscreenCallback( vout_thread_t *p_vout );
238
239     bool isFSCHidden();
240
241 public slots:
242     void unregFullscreenCallback();
243
244 protected:
245     friend class MainInterface;
246     friend class VolumeClickHandler;
247
248     virtual void mouseMoveEvent( QMouseEvent *event );
249     virtual void mousePressEvent( QMouseEvent *event );
250     virtual void enterEvent( QEvent *event );
251     virtual void leaveEvent( QEvent *event );
252     virtual void keyPressEvent( QKeyEvent *event );
253
254 private slots:
255     void hideFSControllerWidget();
256     void slowHideFSC();
257
258 private:
259     QTimer *p_hideTimer;
260
261 #if HAVE_TRANSPARENCY
262     QTimer *p_slowHideTimer;
263 #endif
264
265     int i_lastPosX;
266     int i_lastPosY;
267     int i_hideTimeout;  /* FSC hiding timeout, same as mouse hiding timeout */
268     bool b_mouseIsOver;
269
270 #ifdef WIN32TRICK
271     bool fscHidden;
272 #endif
273
274     virtual void customEvent( QEvent *event );
275 };
276
277
278
279 class VolumeClickHandler : public QObject
280 {
281 public:
282     VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
283     {m = _m; p_intf = _p_intf; }
284     virtual ~VolumeClickHandler() {};
285     bool eventFilter( QObject *obj, QEvent *e )
286     {
287         if (e->type() == QEvent::MouseButtonPress  )
288         {
289             aout_VolumeMute( p_intf, NULL );
290             audio_volume_t i_volume;
291             aout_VolumeGet( p_intf, &i_volume );
292             m->updateVolume( i_volume *  VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
293             return true;
294         }
295         return false;
296     }
297 private:
298     ControlsWidget *m;
299     intf_thread_t *p_intf;
300 };
301
302 #include <QLabel>
303 #include <QMouseEvent>
304 class TimeLabel : public QLabel
305 {
306     Q_OBJECT
307     void mousePressEvent( QMouseEvent *event )
308     {
309         emit timeLabelClicked();
310     }
311     void mouseDoubleClickEvent( QMouseEvent *event )
312     {
313         emit timeLabelDoubleClicked();
314     }
315 signals:
316     void timeLabelClicked();
317     void timeLabelDoubleClicked();
318 };
319
320 class SpeedLabel : public QLabel
321 {
322     Q_OBJECT
323 public:
324     SpeedLabel( intf_thread_t *_p_intf, const QString text ): QLabel( text)
325     { p_intf = _p_intf; }
326
327 protected:
328     virtual void mouseDoubleClickEvent ( QMouseEvent * event )
329     {
330         THEMIM->getIM()->setRate( INPUT_RATE_DEFAULT );
331     }
332 private:
333     intf_thread_t *p_intf;
334 };
335
336 /******************** Speed Control Widgets ****************/
337 class SpeedControlWidget : public QFrame
338 {
339     Q_OBJECT
340 public:
341     SpeedControlWidget( intf_thread_t *);
342     virtual ~SpeedControlWidget();
343     void updateControls( int );
344 private:
345     intf_thread_t *p_intf;
346     QSlider *speedSlider;
347 public slots:
348     void setEnable( bool );
349 private slots:
350     void updateRate( int );
351     void resetRate();
352 };
353
354 #endif