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 #define HAVE_TRANSPARENCY 0
54 /* it can be enabled on-non windows systems,
55 but it will be transparent only with composite manager */
57 #define HAVE_TRANSPARENCY 1
60 /* Default value of opacity for FS controller */
61 #define DEFAULT_OPACITY 0.75
69 /******************** Video Widget ****************/
70 class VideoWidget : public QFrame
73 friend class MainInterface;
76 VideoWidget( intf_thread_t * );
77 virtual ~VideoWidget();
79 void *request( vout_thread_t *, int *, int *,
80 unsigned int *, unsigned int * );
81 void release( void * );
82 int control( void *, int, va_list );
84 virtual QSize sizeHint() const;
86 intf_thread_t *p_intf;
87 vout_thread_t *p_vout;
93 void askVideoWidgetToShow();
97 void SetSizing( unsigned int, unsigned int );
100 /******************** Background Widget ****************/
101 class BackgroundWidget : public QWidget
105 BackgroundWidget( intf_thread_t * );
106 virtual ~BackgroundWidget();
111 virtual void contextMenuEvent( QContextMenuEvent *event );
112 intf_thread_t *p_intf;
113 virtual void resizeEvent( QResizeEvent * event );
115 void toggle(){ TOGGLEV( this ); }
116 void updateArt( QString );
119 class VisualSelector : public QFrame
123 VisualSelector( intf_thread_t *);
124 virtual ~VisualSelector();
126 intf_thread_t *p_intf;
133 /* Advanced Button Bar */
135 class AdvControlsWidget : public QFrame
139 AdvControlsWidget( intf_thread_t *);
140 virtual ~AdvControlsWidget();
142 void enableInput( bool );
143 void enableVideo( bool );
146 intf_thread_t *p_intf;
147 QPushButton *recordButton, *ABButton;
148 QPushButton *snapshotButton, *frameButton;
150 mtime_t timeA, timeB;
159 void AtoBLoop( float, int, int );
166 class VolumeClickHandler;
168 class QAbstractSlider;
171 class ControlsWidget : public QFrame
175 /* p_intf, advanced control visible or not, blingbling or not */
176 ControlsWidget( intf_thread_t *_p_i, MainInterface *_p_mi,
177 bool b_advControls, bool b_shiny, bool b_fsCreation = false);
178 virtual ~ControlsWidget();
180 QPushButton *playlistButton;
181 void setStatus( int );
182 void enableInput( bool );
183 void enableVideo( bool );
185 void setNavigation( int );
187 friend class MainInterface;
188 friend class VolumeClickHandler;
190 intf_thread_t *p_intf;
193 QGridLayout *controlLayout;
195 QPushButton *prevSectionButton, *nextSectionButton, *menuButton;
196 QPushButton *playButton, *fullscreenButton, *extSettingsButton;
197 QToolButton *slowerButton, *fasterButton;
198 QHBoxLayout *controlButLayout;
199 AdvControlsWidget *advControls;
200 QLabel *volMuteLabel;
201 QAbstractSlider *volumeSlider;
202 VolumeClickHandler *hVolLabel;
204 bool b_advancedVisible;
210 void updateVolume( int );
211 void updateVolume( void );
217 void toggleAdvanced();
219 void advancedControlsToggled( bool );
222 /***********************************
223 * Fullscreen controller
224 ***********************************/
226 static int showFullscreenControllCallback(vlc_object_t *vlc_object, const char *variable, vlc_value_t old_val,
227 vlc_value_t new_val, void *data);
229 static int regMouseMoveCallback(vlc_object_t *vlc_object, const char *variable, vlc_value_t old_val,
230 vlc_value_t new_val, void *data);
232 class FullscreenControllerWidget : public ControlsWidget
236 FullscreenControllerWidget( intf_thread_t *, MainInterface*, bool, bool );
237 virtual ~FullscreenControllerWidget();
239 void SetHideTimeout( int hideTimeout ) { i_hideTimeout = hideTimeout; }
240 void regFullscreenCallback( vout_thread_t *p_vout );
245 void unregFullscreenCallback();
248 friend class MainInterface;
249 friend class VolumeClickHandler;
251 virtual void mouseMoveEvent( QMouseEvent *event );
252 virtual void mousePressEvent( QMouseEvent *event );
253 virtual void enterEvent( QEvent *event );
254 virtual void leaveEvent( QEvent *event );
255 virtual void keyPressEvent( QKeyEvent *event );
258 void hideFSControllerWidget();
264 #if HAVE_TRANSPARENCY
265 QTimer *p_slowHideTimer;
270 int i_hideTimeout; /* FSC hiding timeout, same as mouse hiding timeout */
277 virtual void customEvent( QEvent *event );
282 class VolumeClickHandler : public QObject
285 VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
286 {m = _m; p_intf = _p_intf; }
287 virtual ~VolumeClickHandler() {};
288 bool eventFilter( QObject *obj, QEvent *e )
290 if (e->type() == QEvent::MouseButtonPress )
292 aout_VolumeMute( p_intf, NULL );
293 audio_volume_t i_volume;
294 aout_VolumeGet( p_intf, &i_volume );
295 m->updateVolume( i_volume * VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
302 intf_thread_t *p_intf;
306 #include <QMouseEvent>
307 class TimeLabel : public QLabel
310 void mousePressEvent( QMouseEvent *event )
312 emit timeLabelClicked();
314 void mouseDoubleClickEvent( QMouseEvent *event )
316 emit timeLabelDoubleClicked();
319 void timeLabelClicked();
320 void timeLabelDoubleClicked();
323 class SpeedLabel : public QLabel
327 SpeedLabel( intf_thread_t *_p_intf, const QString text ): QLabel( text)
328 { p_intf = _p_intf; }
331 virtual void mouseDoubleClickEvent ( QMouseEvent * event )
333 THEMIM->getIM()->setRate( INPUT_RATE_DEFAULT );
336 intf_thread_t *p_intf;
339 /******************** Speed Control Widgets ****************/
340 class SpeedControlWidget : public QFrame
344 SpeedControlWidget( intf_thread_t *);
345 virtual ~SpeedControlWidget();
346 void updateControls( int );
348 intf_thread_t *p_intf;
349 QSlider *speedSlider;
351 void setEnable( bool );
353 void updateRate( int );