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 *);
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 mtime_t timeA, timeB;
168 void AtoBLoop( float, int, int );
175 class VolumeClickHandler;
177 class QAbstractSlider;
180 class ControlsWidget : public QFrame
184 /* p_intf, advanced control visible or not, blingbling or not */
185 ControlsWidget( intf_thread_t *_p_i, MainInterface *_p_mi,
186 bool b_advControls, bool b_shiny, bool b_fsCreation = false);
187 virtual ~ControlsWidget();
189 QPushButton *playlistButton;
190 void setStatus( int );
191 void enableInput( bool );
192 void enableVideo( bool );
194 void setNavigation( int );
196 friend class MainInterface;
197 friend class VolumeClickHandler;
199 intf_thread_t *p_intf;
202 QGridLayout *controlLayout;
204 QPushButton *prevSectionButton, *nextSectionButton, *menuButton;
205 QPushButton *playButton, *fullscreenButton, *extSettingsButton;
206 QPushButton *telexTransparent, *telexOn;
208 QToolButton *slowerButton, *fasterButton;
209 QHBoxLayout *controlButLayout;
210 AdvControlsWidget *advControls;
211 QLabel *volMuteLabel;
212 QAbstractSlider *volumeSlider;
213 VolumeClickHandler *hVolLabel;
215 bool b_advancedVisible;
216 bool b_telexTransparent;
223 void updateVolume( int );
224 void updateVolume( void );
230 void toggleAdvanced();
231 void toggleTeletext();
232 void toggleTeletextTransparency();
233 void enableTeletext( bool );
235 void advancedControlsToggled( bool );
238 /***********************************
239 * Fullscreen controller
240 ***********************************/
241 class FullscreenControllerWidget : public ControlsWidget
245 FullscreenControllerWidget( intf_thread_t *, MainInterface*, bool, bool );
246 virtual ~FullscreenControllerWidget();
249 void attachVout( vout_thread_t *p_vout );
250 void detachVout( vout_thread_t *p_vout );
251 void fullscreenChanged( vout_thread_t *, bool b_fs, int i_timeout );
254 friend class MainInterface;
255 friend class VolumeClickHandler;
257 virtual void mouseMoveEvent( QMouseEvent *event );
258 virtual void mousePressEvent( QMouseEvent *event );
259 virtual void enterEvent( QEvent *event );
260 virtual void leaveEvent( QEvent *event );
261 virtual void keyPressEvent( QKeyEvent *event );
273 #if HAVE_TRANSPARENCY
274 QTimer *p_slowHideTimer;
282 bool b_slow_hide_begin;
283 int i_slow_hide_timeout;
289 virtual void customEvent( QEvent *event );
291 /* Shared variable between FSC and VLC (protected by a lock) */
294 int i_hide_timeout; /* FSC hiding timeout, same as mouse hiding timeout */
299 class VolumeClickHandler : public QObject
302 VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
303 {m = _m; p_intf = _p_intf; }
304 virtual ~VolumeClickHandler() {};
305 bool eventFilter( QObject *obj, QEvent *e )
307 if (e->type() == QEvent::MouseButtonPress )
309 aout_VolumeMute( p_intf, NULL );
310 audio_volume_t i_volume;
311 aout_VolumeGet( p_intf, &i_volume );
312 m->updateVolume( i_volume * VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
319 intf_thread_t *p_intf;
323 #include <QMouseEvent>
324 class TimeLabel : public QLabel
327 void mousePressEvent( QMouseEvent *event )
329 emit timeLabelClicked();
331 void mouseDoubleClickEvent( QMouseEvent *event )
333 emit timeLabelDoubleClicked();
336 void timeLabelClicked();
337 void timeLabelDoubleClicked();
340 class SpeedLabel : public QLabel
344 SpeedLabel( intf_thread_t *_p_intf, const QString text ): QLabel( text)
345 { p_intf = _p_intf; }
348 virtual void mouseDoubleClickEvent ( QMouseEvent * event )
350 THEMIM->getIM()->setRate( INPUT_RATE_DEFAULT );
353 intf_thread_t *p_intf;
356 /******************** Speed Control Widgets ****************/
357 class SpeedControlWidget : public QFrame
361 SpeedControlWidget( intf_thread_t *);
362 virtual ~SpeedControlWidget();
363 void updateControls( int );
365 intf_thread_t *p_intf;
366 QSlider *speedSlider;
368 void setEnable( bool );
370 void updateRate( int );