1 /*****************************************************************************
2 * interface_widgets.hpp : Custom widgets for the main interface
3 ****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Jean-Baptiste Kempf <jb@videolan.org>
9 * Rafaël Carré <funman@videolanorg>
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.
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.
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 *****************************************************************************/
26 #ifndef _INTFWIDGETS_H_
27 #define _INTFWIDGETS_H_
33 #include <vlc_common.h>
34 #include <vlc_interface.h>
38 #include "main_interface.hpp"
39 #include "input_manager.hpp"
44 #include <QWaitCondition>
46 #define VOLUME_MAX 200
48 /* on WIN32 hide() for fullscreen controller doesnt work, so it have to be
49 done by trick with setting the opacity of window */
54 /* to trying transparency with fullscreen controller on windows enable that */
55 /* it can be enabled on-non windows systems,
56 but it will be transparent only with composite manager */
58 #define HAVE_TRANSPARENCY 1
60 #define HAVE_TRANSPARENCY 0
63 /* Default value of opacity for FS controller */
64 #define DEFAULT_OPACITY 0.75
72 /******************** Video Widget ****************/
73 class VideoWidget : public QFrame
76 friend class MainInterface;
79 VideoWidget( intf_thread_t * );
80 virtual ~VideoWidget();
82 void *request( vout_thread_t *, int *, int *,
83 unsigned int *, unsigned int * );
84 void release( void * );
85 int control( void *, int, va_list );
87 virtual QSize sizeHint() const;
89 intf_thread_t *p_intf;
90 vout_thread_t *p_vout;
95 QWaitCondition handleWait;
99 void askVideoWidgetToShow();
103 void SetSizing( unsigned int, unsigned int );
106 virtual QPaintEngine *paintEngine() const
111 virtual void paintEvent(QPaintEvent *);
114 /******************** Background Widget ****************/
115 class BackgroundWidget : public QWidget
119 BackgroundWidget( intf_thread_t * );
120 virtual ~BackgroundWidget();
125 virtual void contextMenuEvent( QContextMenuEvent *event );
126 intf_thread_t *p_intf;
127 virtual void resizeEvent( QResizeEvent * event );
129 void toggle(){ TOGGLEV( this ); }
130 void updateArt( QString );
133 class VisualSelector : public QFrame
137 VisualSelector( intf_thread_t *);
138 virtual ~VisualSelector();
140 intf_thread_t *p_intf;
147 /* Advanced Button Bar */
149 class AdvControlsWidget : public QFrame
153 AdvControlsWidget( intf_thread_t *);
154 virtual ~AdvControlsWidget();
156 void enableInput( bool );
157 void enableVideo( bool );
160 intf_thread_t *p_intf;
161 QPushButton *recordButton, *ABButton;
162 QPushButton *snapshotButton, *frameButton;
164 mtime_t timeA, timeB;
173 void AtoBLoop( float, int, int );
180 class VolumeClickHandler;
182 class QAbstractSlider;
185 class ControlsWidget : public QFrame
189 /* p_intf, advanced control visible or not, blingbling or not */
190 ControlsWidget( intf_thread_t *_p_i, MainInterface *_p_mi,
191 bool b_advControls, bool b_shiny, bool b_fsCreation = false);
192 virtual ~ControlsWidget();
194 QPushButton *playlistButton;
195 void setStatus( int );
196 void enableInput( bool );
197 void enableVideo( bool );
199 void setNavigation( int );
201 friend class MainInterface;
202 friend class VolumeClickHandler;
204 intf_thread_t *p_intf;
207 QGridLayout *controlLayout;
209 QPushButton *prevSectionButton, *nextSectionButton, *menuButton;
210 QPushButton *playButton, *fullscreenButton, *extSettingsButton;
211 QPushButton *telexTransparent;
213 QToolButton *slowerButton, *fasterButton;
214 QHBoxLayout *controlButLayout;
215 AdvControlsWidget *advControls;
216 QLabel *volMuteLabel;
217 QAbstractSlider *volumeSlider;
218 VolumeClickHandler *hVolLabel;
220 bool b_advancedVisible;
221 bool b_telexTransparent;
228 void updateVolume( int );
229 void updateVolume( void );
235 void toggleAdvanced();
236 void toggleTeletext();
237 void toggleTeletextTransparency();
239 void advancedControlsToggled( bool );
242 /***********************************
243 * Fullscreen controller
244 ***********************************/
246 static int showFullscreenControllCallback(vlc_object_t *vlc_object, const char *variable, vlc_value_t old_val,
247 vlc_value_t new_val, void *data);
249 static int regMouseMoveCallback(vlc_object_t *vlc_object, const char *variable, vlc_value_t old_val,
250 vlc_value_t new_val, void *data);
252 class FullscreenControllerWidget : public ControlsWidget
256 FullscreenControllerWidget( intf_thread_t *, MainInterface*, bool, bool );
257 virtual ~FullscreenControllerWidget();
259 void SetHideTimeout( int hideTimeout ) { i_hideTimeout = hideTimeout; }
260 void regFullscreenCallback( vout_thread_t *p_vout );
265 void unregFullscreenCallback();
268 friend class MainInterface;
269 friend class VolumeClickHandler;
271 virtual void mouseMoveEvent( QMouseEvent *event );
272 virtual void mousePressEvent( QMouseEvent *event );
273 virtual void enterEvent( QEvent *event );
274 virtual void leaveEvent( QEvent *event );
275 virtual void keyPressEvent( QKeyEvent *event );
278 void hideFSControllerWidget();
284 #if HAVE_TRANSPARENCY
285 QTimer *p_slowHideTimer;
290 int i_hideTimeout; /* FSC hiding timeout, same as mouse hiding timeout */
297 virtual void customEvent( QEvent *event );
302 class VolumeClickHandler : public QObject
305 VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
306 {m = _m; p_intf = _p_intf; }
307 virtual ~VolumeClickHandler() {};
308 bool eventFilter( QObject *obj, QEvent *e )
310 if (e->type() == QEvent::MouseButtonPress )
312 aout_VolumeMute( p_intf, NULL );
313 audio_volume_t i_volume;
314 aout_VolumeGet( p_intf, &i_volume );
315 m->updateVolume( i_volume * VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
322 intf_thread_t *p_intf;
326 #include <QMouseEvent>
327 class TimeLabel : public QLabel
330 void mousePressEvent( QMouseEvent *event )
332 emit timeLabelClicked();
334 void mouseDoubleClickEvent( QMouseEvent *event )
336 emit timeLabelDoubleClicked();
339 void timeLabelClicked();
340 void timeLabelDoubleClicked();
343 class SpeedLabel : public QLabel
347 SpeedLabel( intf_thread_t *_p_intf, const QString text ): QLabel( text)
348 { p_intf = _p_intf; }
351 virtual void mouseDoubleClickEvent ( QMouseEvent * event )
353 THEMIM->getIM()->setRate( INPUT_RATE_DEFAULT );
356 intf_thread_t *p_intf;
359 /******************** Speed Control Widgets ****************/
360 class SpeedControlWidget : public QFrame
364 SpeedControlWidget( intf_thread_t *);
365 virtual ~SpeedControlWidget();
366 void updateControls( int );
368 intf_thread_t *p_intf;
369 QSlider *speedSlider;
371 void setEnable( bool );
373 void updateRate( int );