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 #define VOLUME_MAX 200
46 /* on WIN32 hide() for fullscreen controller doesnt work, so it have to be
47 done by trick with setting the opacity of window */
52 /* to trying transparency with fullscreen controller on windows enable that */
53 /* it can be enabled on-non windows systems,
54 but it will be transparent only with composite manager */
56 #define HAVE_TRANSPARENCY 1
58 #define HAVE_TRANSPARENCY 0
61 /* Default value of opacity for FS controller */
62 #define DEFAULT_OPACITY 0.75
70 /******************** Video Widget ****************/
71 class VideoWidget : public QFrame
74 friend class MainInterface;
77 VideoWidget( intf_thread_t * );
78 virtual ~VideoWidget();
80 void *request( vout_thread_t *, int *, int *,
81 unsigned int *, unsigned int * );
82 void release( void * );
83 int control( void *, int, va_list );
85 virtual QSize sizeHint() const;
87 intf_thread_t *p_intf;
93 void askVideoWidgetToShow( unsigned int, unsigned int );
96 void SetSizing( unsigned int, unsigned int );
99 virtual QPaintEngine *paintEngine() const
104 virtual void paintEvent(QPaintEvent *);
107 /******************** Background Widget ****************/
108 class BackgroundWidget : public QWidget
112 BackgroundWidget( intf_thread_t * );
113 virtual ~BackgroundWidget();
118 virtual void contextMenuEvent( QContextMenuEvent *event );
119 intf_thread_t *p_intf;
120 virtual void resizeEvent( QResizeEvent * event );
122 void toggle(){ TOGGLEV( this ); }
123 void updateArt( QString );
127 class VisualSelector : public QFrame
131 VisualSelector( intf_thread_t *);
132 virtual ~VisualSelector();
134 intf_thread_t *p_intf;
142 /* Advanced Button Bar */
144 class AdvControlsWidget : public QFrame
148 AdvControlsWidget( intf_thread_t *, bool );
149 virtual ~AdvControlsWidget();
151 void enableInput( bool );
152 void enableVideo( bool );
155 intf_thread_t *p_intf;
156 QPushButton *recordButton, *ABButton;
157 QPushButton *snapshotButton, *frameButton;
159 static mtime_t timeA, timeB;
169 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, *telexOn;
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();
238 void enableTeletext( bool );
240 void advancedControlsToggled( bool );
243 /***********************************
244 * Fullscreen controller
245 ***********************************/
246 class FullscreenControllerWidget : public ControlsWidget
250 FullscreenControllerWidget( intf_thread_t *, MainInterface*, bool, bool );
251 virtual ~FullscreenControllerWidget();
254 void attachVout( vout_thread_t *p_vout );
256 void fullscreenChanged( vout_thread_t *, bool b_fs, int i_timeout );
259 friend class MainInterface;
260 friend class VolumeClickHandler;
262 virtual void mouseMoveEvent( QMouseEvent *event );
263 virtual void mousePressEvent( QMouseEvent *event );
264 virtual void enterEvent( QEvent *event );
265 virtual void leaveEvent( QEvent *event );
266 virtual void keyPressEvent( QKeyEvent *event );
278 #if HAVE_TRANSPARENCY
279 QTimer *p_slowHideTimer;
287 bool b_slow_hide_begin;
288 int i_slow_hide_timeout;
294 virtual void customEvent( QEvent *event );
296 vout_thread_t *p_vout;
298 /* Shared variable between FSC and VLC (protected by a lock) */
301 int i_hide_timeout; /* FSC hiding timeout, same as mouse hiding timeout */
306 class VolumeClickHandler : public QObject
309 VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
310 {m = _m; p_intf = _p_intf; }
311 virtual ~VolumeClickHandler() {};
312 bool eventFilter( QObject *obj, QEvent *e )
314 if (e->type() == QEvent::MouseButtonPress )
316 aout_VolumeMute( p_intf, NULL );
317 audio_volume_t i_volume;
318 aout_VolumeGet( p_intf, &i_volume );
319 m->updateVolume( i_volume * VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
326 intf_thread_t *p_intf;
330 #include <QMouseEvent>
331 class TimeLabel : public QLabel
334 void mousePressEvent( QMouseEvent *event )
336 emit timeLabelClicked();
338 void mouseDoubleClickEvent( QMouseEvent *event )
340 emit timeLabelDoubleClicked();
343 void timeLabelClicked();
344 void timeLabelDoubleClicked();
347 class SpeedLabel : public QLabel
351 SpeedLabel( intf_thread_t *_p_intf, const QString text ): QLabel( text)
352 { p_intf = _p_intf; }
355 virtual void mouseDoubleClickEvent ( QMouseEvent * event )
357 THEMIM->getIM()->setRate( INPUT_RATE_DEFAULT );
360 intf_thread_t *p_intf;
363 /******************** Speed Control Widgets ****************/
364 class SpeedControlWidget : public QFrame
368 SpeedControlWidget( intf_thread_t *);
369 virtual ~SpeedControlWidget();
370 void updateControls( int );
372 intf_thread_t *p_intf;
373 QSlider *speedSlider;
375 void setEnable( bool );
377 void updateRate( int );