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();
98 void SetSizing( unsigned int, unsigned int );
101 /******************** Background Widget ****************/
102 class BackgroundWidget : public QWidget
106 BackgroundWidget( intf_thread_t * );
107 virtual ~BackgroundWidget();
112 virtual void contextMenuEvent( QContextMenuEvent *event );
113 intf_thread_t *p_intf;
114 virtual void resizeEvent( QResizeEvent * event );
116 void toggle(){ TOGGLEV( this ); }
117 void updateArt( QString );
120 class VisualSelector : public QFrame
124 VisualSelector( intf_thread_t *);
125 virtual ~VisualSelector();
127 intf_thread_t *p_intf;
134 /* Advanced Button Bar */
136 class AdvControlsWidget : public QFrame
140 AdvControlsWidget( intf_thread_t *);
141 virtual ~AdvControlsWidget();
143 void enableInput( bool );
144 void enableVideo( bool );
147 intf_thread_t *p_intf;
148 QPushButton *recordButton, *ABButton;
149 QPushButton *snapshotButton, *frameButton;
151 mtime_t timeA, timeB;
160 void AtoBLoop( float, int, int );
167 class VolumeClickHandler;
169 class QAbstractSlider;
172 class ControlsWidget : public QFrame
176 /* p_intf, advanced control visible or not, blingbling or not */
177 ControlsWidget( intf_thread_t *_p_i, MainInterface *_p_mi,
178 bool b_advControls, bool b_shiny, bool b_fsCreation = false);
179 virtual ~ControlsWidget();
181 QPushButton *playlistButton;
182 void setStatus( int );
183 void enableInput( bool );
184 void enableVideo( bool );
186 void setNavigation( int );
188 friend class MainInterface;
189 friend class VolumeClickHandler;
191 intf_thread_t *p_intf;
194 QGridLayout *controlLayout;
196 QPushButton *prevSectionButton, *nextSectionButton, *menuButton;
197 QPushButton *playButton, *fullscreenButton, *extSettingsButton;
198 QToolButton *slowerButton, *fasterButton;
199 QHBoxLayout *controlButLayout;
200 AdvControlsWidget *advControls;
201 QLabel *volMuteLabel;
202 QAbstractSlider *volumeSlider;
203 VolumeClickHandler *hVolLabel;
205 bool b_advancedVisible;
211 void updateVolume( int );
212 void updateVolume( void );
218 void toggleAdvanced();
220 void advancedControlsToggled( bool );
223 /***********************************
224 * Fullscreen controller
225 ***********************************/
227 static int showFullscreenControllCallback(vlc_object_t *vlc_object, const char *variable, vlc_value_t old_val,
228 vlc_value_t new_val, void *data);
230 static int regMouseMoveCallback(vlc_object_t *vlc_object, const char *variable, vlc_value_t old_val,
231 vlc_value_t new_val, void *data);
233 class FullscreenControllerWidget : public ControlsWidget
237 FullscreenControllerWidget( intf_thread_t *, MainInterface*, bool, bool );
238 virtual ~FullscreenControllerWidget();
240 void SetHideTimeout( int hideTimeout ) { i_hideTimeout = hideTimeout; }
241 void regFullscreenCallback( vout_thread_t *p_vout );
246 void unregFullscreenCallback();
249 friend class MainInterface;
250 friend class VolumeClickHandler;
252 virtual void mouseMoveEvent( QMouseEvent *event );
253 virtual void mousePressEvent( QMouseEvent *event );
254 virtual void enterEvent( QEvent *event );
255 virtual void leaveEvent( QEvent *event );
256 virtual void keyPressEvent( QKeyEvent *event );
259 void hideFSControllerWidget();
265 #if HAVE_TRANSPARENCY
266 QTimer *p_slowHideTimer;
271 int i_hideTimeout; /* FSC hiding timeout, same as mouse hiding timeout */
278 virtual void customEvent( QEvent *event );
283 class VolumeClickHandler : public QObject
286 VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
287 {m = _m; p_intf = _p_intf; }
288 virtual ~VolumeClickHandler() {};
289 bool eventFilter( QObject *obj, QEvent *e )
291 if (e->type() == QEvent::MouseButtonPress )
293 aout_VolumeMute( p_intf, NULL );
294 audio_volume_t i_volume;
295 aout_VolumeGet( p_intf, &i_volume );
296 m->updateVolume( i_volume * VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
303 intf_thread_t *p_intf;
307 #include <QMouseEvent>
308 class TimeLabel : public QLabel
311 void mousePressEvent( QMouseEvent *event )
313 emit timeLabelClicked();
315 void mouseDoubleClickEvent( QMouseEvent *event )
317 emit timeLabelDoubleClicked();
320 void timeLabelClicked();
321 void timeLabelDoubleClicked();
324 class SpeedLabel : public QLabel
328 SpeedLabel( intf_thread_t *_p_intf, const QString text ): QLabel( text)
329 { p_intf = _p_intf; }
332 virtual void mouseDoubleClickEvent ( QMouseEvent * event )
334 THEMIM->getIM()->setRate( INPUT_RATE_DEFAULT );
337 intf_thread_t *p_intf;
340 /******************** Speed Control Widgets ****************/
341 class SpeedControlWidget : public QFrame
345 SpeedControlWidget( intf_thread_t *);
346 virtual ~SpeedControlWidget();
347 void updateControls( int );
349 intf_thread_t *p_intf;
350 QSlider *speedSlider;
352 void setEnable( bool );
354 void updateRate( int );