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
66 /******************** Video Widget ****************/
67 class VideoWidget : public QFrame
70 friend class MainInterface;
73 VideoWidget( intf_thread_t * );
74 virtual ~VideoWidget();
76 void *request( vout_thread_t *, int *, int *,
77 unsigned int *, unsigned int * );
78 void release( void * );
79 int control( void *, int, va_list );
81 virtual QSize sizeHint() const;
83 intf_thread_t *p_intf;
84 vout_thread_t *p_vout;
90 void askVideoWidgetToShow();
94 void SetSizing( unsigned int, unsigned int );
97 /******************** Background Widget ****************/
98 class BackgroundWidget : public QWidget
102 BackgroundWidget( intf_thread_t * );
103 virtual ~BackgroundWidget();
108 virtual void contextMenuEvent( QContextMenuEvent *event );
109 intf_thread_t *p_intf;
110 virtual void resizeEvent( QResizeEvent * event );
112 void toggle(){ TOGGLEV( this ); }
113 void updateArt( QString );
116 class VisualSelector : public QFrame
120 VisualSelector( intf_thread_t *);
121 virtual ~VisualSelector();
123 intf_thread_t *p_intf;
130 /* Advanced Button Bar */
132 class AdvControlsWidget : public QFrame
136 AdvControlsWidget( intf_thread_t *);
137 virtual ~AdvControlsWidget();
139 void enableInput( bool );
140 void enableVideo( bool );
143 intf_thread_t *p_intf;
144 QPushButton *recordButton, *ABButton;
145 QPushButton *snapshotButton, *frameButton;
147 mtime_t timeA, timeB;
156 void AtoBLoop( float, int, int );
163 class VolumeClickHandler;
165 class QAbstractSlider;
168 class ControlsWidget : public QFrame
172 /* p_intf, advanced control visible or not, blingbling or not */
173 ControlsWidget( intf_thread_t *_p_i, MainInterface *_p_mi,
174 bool b_advControls, bool b_shiny, bool b_fsCreation = false);
175 virtual ~ControlsWidget();
177 QPushButton *playlistButton;
178 void setStatus( int );
179 void enableInput( bool );
180 void enableVideo( bool );
182 void setNavigation( int );
184 friend class MainInterface;
185 friend class VolumeClickHandler;
187 intf_thread_t *p_intf;
190 QGridLayout *controlLayout;
192 QPushButton *prevSectionButton, *nextSectionButton, *menuButton;
193 QPushButton *playButton, *fullscreenButton, *extSettingsButton;
194 QToolButton *slowerButton, *fasterButton;
195 QHBoxLayout *controlButLayout;
196 AdvControlsWidget *advControls;
197 QLabel *volMuteLabel;
198 QAbstractSlider *volumeSlider;
199 VolumeClickHandler *hVolLabel;
201 bool b_advancedVisible;
207 void updateVolume( int );
208 void updateVolume( void );
214 void toggleAdvanced();
216 void advancedControlsToggled( bool );
219 /***********************************
220 * Fullscreen controller
221 ***********************************/
223 static int showFullscreenControllCallback(vlc_object_t *vlc_object, const char *variable, vlc_value_t old_val,
224 vlc_value_t new_val, void *data);
226 static int regMouseMoveCallback(vlc_object_t *vlc_object, const char *variable, vlc_value_t old_val,
227 vlc_value_t new_val, void *data);
229 class FullscreenControllerWidget : public ControlsWidget
233 FullscreenControllerWidget( intf_thread_t *, MainInterface*, bool, bool );
234 virtual ~FullscreenControllerWidget();
236 void SetHideTimeout( int hideTimeout ) { i_hideTimeout = hideTimeout; }
237 void regFullscreenCallback( vout_thread_t *p_vout );
242 void unregFullscreenCallback();
245 friend class MainInterface;
246 friend class VolumeClickHandler;
248 virtual void mouseMoveEvent( QMouseEvent *event );
249 virtual void mousePressEvent( QMouseEvent *event );
250 virtual void enterEvent( QEvent *event );
251 virtual void leaveEvent( QEvent *event );
252 virtual void keyPressEvent( QKeyEvent *event );
255 void hideFSControllerWidget();
261 #if HAVE_TRANSPARENCY
262 QTimer *p_slowHideTimer;
267 int i_hideTimeout; /* FSC hiding timeout, same as mouse hiding timeout */
274 virtual void customEvent( QEvent *event );
279 class VolumeClickHandler : public QObject
282 VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
283 {m = _m; p_intf = _p_intf; }
284 virtual ~VolumeClickHandler() {};
285 bool eventFilter( QObject *obj, QEvent *e )
287 if (e->type() == QEvent::MouseButtonPress )
289 aout_VolumeMute( p_intf, NULL );
290 audio_volume_t i_volume;
291 aout_VolumeGet( p_intf, &i_volume );
292 m->updateVolume( i_volume * VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
299 intf_thread_t *p_intf;
303 #include <QMouseEvent>
304 class TimeLabel : public QLabel
307 void mousePressEvent( QMouseEvent *event )
309 emit timeLabelClicked();
311 void mouseDoubleClickEvent( QMouseEvent *event )
313 emit timeLabelDoubleClicked();
316 void timeLabelClicked();
317 void timeLabelDoubleClicked();
320 class SpeedLabel : public QLabel
324 SpeedLabel( intf_thread_t *_p_intf, const QString text ): QLabel( text)
325 { p_intf = _p_intf; }
328 virtual void mouseDoubleClickEvent ( QMouseEvent * event )
330 THEMIM->getIM()->setRate( INPUT_RATE_DEFAULT );
333 intf_thread_t *p_intf;
336 /******************** Speed Control Widgets ****************/
337 class SpeedControlWidget : public QFrame
341 SpeedControlWidget( intf_thread_t *);
342 virtual ~SpeedControlWidget();
343 void updateControls( int );
345 intf_thread_t *p_intf;
346 QSlider *speedSlider;
348 void setEnable( bool );
350 void updateRate( int );