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 );
126 class VisualSelector : public QFrame
130 VisualSelector( intf_thread_t *);
131 virtual ~VisualSelector();
133 intf_thread_t *p_intf;
140 /* Advanced Button Bar */
142 class AdvControlsWidget : public QFrame
146 AdvControlsWidget( intf_thread_t *);
147 virtual ~AdvControlsWidget();
149 void enableInput( bool );
150 void enableVideo( bool );
153 intf_thread_t *p_intf;
154 QPushButton *recordButton, *ABButton;
155 QPushButton *snapshotButton, *frameButton;
157 mtime_t timeA, timeB;
166 void AtoBLoop( float, int, int );
173 class VolumeClickHandler;
175 class QAbstractSlider;
178 class ControlsWidget : public QFrame
182 /* p_intf, advanced control visible or not, blingbling or not */
183 ControlsWidget( intf_thread_t *_p_i, MainInterface *_p_mi,
184 bool b_advControls, bool b_shiny, bool b_fsCreation = false);
185 virtual ~ControlsWidget();
187 QPushButton *playlistButton;
188 void setStatus( int );
189 void enableInput( bool );
190 void enableVideo( bool );
192 void setNavigation( int );
194 friend class MainInterface;
195 friend class VolumeClickHandler;
197 intf_thread_t *p_intf;
200 QGridLayout *controlLayout;
202 QPushButton *prevSectionButton, *nextSectionButton, *menuButton;
203 QPushButton *playButton, *fullscreenButton, *extSettingsButton;
204 QPushButton *telexTransparent, *telexOn;
206 QToolButton *slowerButton, *fasterButton;
207 QHBoxLayout *controlButLayout;
208 AdvControlsWidget *advControls;
209 QLabel *volMuteLabel;
210 QAbstractSlider *volumeSlider;
211 VolumeClickHandler *hVolLabel;
213 bool b_advancedVisible;
214 bool b_telexTransparent;
221 void updateVolume( int );
222 void updateVolume( void );
228 void toggleAdvanced();
229 void toggleTeletext();
230 void toggleTeletextTransparency();
232 void advancedControlsToggled( bool );
235 /***********************************
236 * Fullscreen controller
237 ***********************************/
239 static int showFullscreenControllCallback(vlc_object_t *vlc_object, const char *variable, vlc_value_t old_val,
240 vlc_value_t new_val, void *data);
242 static int regMouseMoveCallback(vlc_object_t *vlc_object, const char *variable, vlc_value_t old_val,
243 vlc_value_t new_val, void *data);
245 class FullscreenControllerWidget : public ControlsWidget
249 FullscreenControllerWidget( intf_thread_t *, MainInterface*, bool, bool );
250 virtual ~FullscreenControllerWidget();
252 void setHideTimeout( int hideTimeout ) { i_hideTimeout = hideTimeout; }
253 void setIsFullscreen( bool isFS ) { b_isFullscreen = isFS; }
254 void regFullscreenCallback( vout_thread_t *p_vout );
259 void unregFullscreenCallback();
262 friend class MainInterface;
263 friend class VolumeClickHandler;
265 virtual void mouseMoveEvent( QMouseEvent *event );
266 virtual void mousePressEvent( QMouseEvent *event );
267 virtual void enterEvent( QEvent *event );
268 virtual void leaveEvent( QEvent *event );
269 virtual void keyPressEvent( QKeyEvent *event );
272 void hideFSControllerWidget();
278 #if HAVE_TRANSPARENCY
279 QTimer *p_slowHideTimer;
284 int i_hideTimeout; /* FSC hiding timeout, same as mouse hiding timeout */
292 virtual void customEvent( QEvent *event );
297 class VolumeClickHandler : public QObject
300 VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
301 {m = _m; p_intf = _p_intf; }
302 virtual ~VolumeClickHandler() {};
303 bool eventFilter( QObject *obj, QEvent *e )
305 if (e->type() == QEvent::MouseButtonPress )
307 aout_VolumeMute( p_intf, NULL );
308 audio_volume_t i_volume;
309 aout_VolumeGet( p_intf, &i_volume );
310 m->updateVolume( i_volume * VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
317 intf_thread_t *p_intf;
321 #include <QMouseEvent>
322 class TimeLabel : public QLabel
325 void mousePressEvent( QMouseEvent *event )
327 emit timeLabelClicked();
329 void mouseDoubleClickEvent( QMouseEvent *event )
331 emit timeLabelDoubleClicked();
334 void timeLabelClicked();
335 void timeLabelDoubleClicked();
338 class SpeedLabel : public QLabel
342 SpeedLabel( intf_thread_t *_p_intf, const QString text ): QLabel( text)
343 { p_intf = _p_intf; }
346 virtual void mouseDoubleClickEvent ( QMouseEvent * event )
348 THEMIM->getIM()->setRate( INPUT_RATE_DEFAULT );
351 intf_thread_t *p_intf;
354 /******************** Speed Control Widgets ****************/
355 class SpeedControlWidget : public QFrame
359 SpeedControlWidget( intf_thread_t *);
360 virtual ~SpeedControlWidget();
361 void updateControls( int );
363 intf_thread_t *p_intf;
364 QSlider *speedSlider;
366 void setEnable( bool );
368 void updateRate( int );