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;
88 vout_thread_t *p_vout;
94 void askVideoWidgetToShow( unsigned int, unsigned int );
97 void SetSizing( unsigned int, unsigned int );
100 virtual QPaintEngine *paintEngine() const
105 virtual void paintEvent(QPaintEvent *);
108 /******************** Background Widget ****************/
109 class BackgroundWidget : public QWidget
113 BackgroundWidget( intf_thread_t * );
114 virtual ~BackgroundWidget();
119 virtual void contextMenuEvent( QContextMenuEvent *event );
120 intf_thread_t *p_intf;
121 virtual void resizeEvent( QResizeEvent * event );
123 void toggle(){ TOGGLEV( this ); }
124 void updateArt( QString );
127 class VisualSelector : public QFrame
131 VisualSelector( intf_thread_t *);
132 virtual ~VisualSelector();
134 intf_thread_t *p_intf;
141 /* Advanced Button Bar */
143 class AdvControlsWidget : public QFrame
147 AdvControlsWidget( intf_thread_t *);
148 virtual ~AdvControlsWidget();
150 void enableInput( bool );
151 void enableVideo( bool );
154 intf_thread_t *p_intf;
155 QPushButton *recordButton, *ABButton;
156 QPushButton *snapshotButton, *frameButton;
158 mtime_t timeA, timeB;
167 void AtoBLoop( float, int, int );
174 class VolumeClickHandler;
176 class QAbstractSlider;
179 class ControlsWidget : public QFrame
183 /* p_intf, advanced control visible or not, blingbling or not */
184 ControlsWidget( intf_thread_t *_p_i, MainInterface *_p_mi,
185 bool b_advControls, bool b_shiny, bool b_fsCreation = false);
186 virtual ~ControlsWidget();
188 QPushButton *playlistButton;
189 void setStatus( int );
190 void enableInput( bool );
191 void enableVideo( bool );
193 void setNavigation( int );
195 friend class MainInterface;
196 friend class VolumeClickHandler;
198 intf_thread_t *p_intf;
201 QGridLayout *controlLayout;
203 QPushButton *prevSectionButton, *nextSectionButton, *menuButton;
204 QPushButton *playButton, *fullscreenButton, *extSettingsButton;
205 QPushButton *telexTransparent, *telexOn;
207 QToolButton *slowerButton, *fasterButton;
208 QHBoxLayout *controlButLayout;
209 AdvControlsWidget *advControls;
210 QLabel *volMuteLabel;
211 QAbstractSlider *volumeSlider;
212 VolumeClickHandler *hVolLabel;
214 bool b_advancedVisible;
215 bool b_telexTransparent;
222 void updateVolume( int );
223 void updateVolume( void );
229 void toggleAdvanced();
230 void toggleTeletext();
231 void toggleTeletextTransparency();
233 void advancedControlsToggled( bool );
236 /***********************************
237 * Fullscreen controller
238 ***********************************/
240 static int showFullscreenControllCallback(vlc_object_t *vlc_object, const char *variable, vlc_value_t old_val,
241 vlc_value_t new_val, void *data);
243 static int regMouseMoveCallback(vlc_object_t *vlc_object, const char *variable, vlc_value_t old_val,
244 vlc_value_t new_val, void *data);
246 class FullscreenControllerWidget : public ControlsWidget
250 FullscreenControllerWidget( intf_thread_t *, MainInterface*, bool, bool );
251 virtual ~FullscreenControllerWidget();
253 void setHideTimeout( int hideTimeout ) { i_hideTimeout = hideTimeout; }
254 void setIsFullscreen( bool isFS ) { b_isFullscreen = isFS; }
255 void regFullscreenCallback( vout_thread_t *p_vout );
260 void unregFullscreenCallback();
263 friend class MainInterface;
264 friend class VolumeClickHandler;
266 virtual void mouseMoveEvent( QMouseEvent *event );
267 virtual void mousePressEvent( QMouseEvent *event );
268 virtual void enterEvent( QEvent *event );
269 virtual void leaveEvent( QEvent *event );
270 virtual void keyPressEvent( QKeyEvent *event );
273 void hideFSControllerWidget();
279 #if HAVE_TRANSPARENCY
280 QTimer *p_slowHideTimer;
285 int i_hideTimeout; /* FSC hiding timeout, same as mouse hiding timeout */
293 virtual void customEvent( QEvent *event );
298 class VolumeClickHandler : public QObject
301 VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
302 {m = _m; p_intf = _p_intf; }
303 virtual ~VolumeClickHandler() {};
304 bool eventFilter( QObject *obj, QEvent *e )
306 if (e->type() == QEvent::MouseButtonPress )
308 aout_VolumeMute( p_intf, NULL );
309 audio_volume_t i_volume;
310 aout_VolumeGet( p_intf, &i_volume );
311 m->updateVolume( i_volume * VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
318 intf_thread_t *p_intf;
322 #include <QMouseEvent>
323 class TimeLabel : public QLabel
326 void mousePressEvent( QMouseEvent *event )
328 emit timeLabelClicked();
330 void mouseDoubleClickEvent( QMouseEvent *event )
332 emit timeLabelDoubleClicked();
335 void timeLabelClicked();
336 void timeLabelDoubleClicked();
339 class SpeedLabel : public QLabel
343 SpeedLabel( intf_thread_t *_p_intf, const QString text ): QLabel( text)
344 { p_intf = _p_intf; }
347 virtual void mouseDoubleClickEvent ( QMouseEvent * event )
349 THEMIM->getIM()->setRate( INPUT_RATE_DEFAULT );
352 intf_thread_t *p_intf;
355 /******************** Speed Control Widgets ****************/
356 class SpeedControlWidget : public QFrame
360 SpeedControlWidget( intf_thread_t *);
361 virtual ~SpeedControlWidget();
362 void updateControls( int );
364 intf_thread_t *p_intf;
365 QSlider *speedSlider;
367 void setEnable( bool );
369 void updateRate( int );