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"
43 #define VOLUME_MAX 200
45 /* on WIN32 hide() for fullscreen controller doesnt work, so it have to be
46 done by trick with setting the opacity of window */
51 /* to trying transparency with fullscreen controller on windows enable that */
52 /* #define TRANSPARENCY */
54 /* it can be enabled on non windows systems,
55 but it will be transparent only with composite manager */
67 /******************** Video Widget ****************/
68 class VideoWidget : public QFrame
71 friend class MainInterface;
74 VideoWidget( intf_thread_t * );
75 virtual ~VideoWidget();
77 void *request( vout_thread_t *, int *, int *,
78 unsigned int *, unsigned int * );
79 void release( void * );
80 int control( void *, int, va_list );
82 virtual QSize sizeHint() const;
84 intf_thread_t *p_intf;
85 vout_thread_t *p_vout;
91 void askVideoWidgetToShow();
95 void SetSizing( unsigned int, unsigned int );
98 /******************** Background Widget ****************/
99 class BackgroundWidget : public QWidget
103 BackgroundWidget( intf_thread_t * );
104 virtual ~BackgroundWidget();
109 virtual void contextMenuEvent( QContextMenuEvent *event );
110 intf_thread_t *p_intf;
111 virtual void resizeEvent( QResizeEvent * event );
113 void toggle(){ TOGGLEV( this ); }
114 void updateArt( QString );
117 class VisualSelector : public QFrame
121 VisualSelector( intf_thread_t *);
122 virtual ~VisualSelector();
124 intf_thread_t *p_intf;
131 /* Advanced Button Bar */
133 class AdvControlsWidget : public QFrame
137 AdvControlsWidget( intf_thread_t *);
138 virtual ~AdvControlsWidget();
140 void enableInput( bool );
141 void enableVideo( bool );
144 intf_thread_t *p_intf;
145 QPushButton *recordButton, *ABButton;
146 QPushButton *snapshotButton, *frameButton;
148 mtime_t timeA, timeB;
157 void AtoBLoop( float, int, int );
164 class VolumeClickHandler;
166 class QAbstractSlider;
169 class ControlsWidget : public QFrame
173 /* p_intf, advanced control visible or not, blingbling or not */
174 ControlsWidget( intf_thread_t *_p_i, MainInterface *_p_mi,
175 bool b_advControls, bool b_shiny, bool b_fsCreation = false);
176 virtual ~ControlsWidget();
178 QPushButton *playlistButton;
179 void setStatus( int );
180 void enableInput( bool );
181 void enableVideo( bool );
183 void setNavigation( int );
185 friend class MainInterface;
186 friend class VolumeClickHandler;
188 intf_thread_t *p_intf;
191 QGridLayout *controlLayout;
193 QPushButton *prevSectionButton, *nextSectionButton, *menuButton;
194 QPushButton *playButton, *fullscreenButton, *extSettingsButton;
195 QToolButton *slowerButton, *fasterButton;
196 QHBoxLayout *controlButLayout;
197 AdvControlsWidget *advControls;
198 QLabel *volMuteLabel;
199 QAbstractSlider *volumeSlider;
200 VolumeClickHandler *hVolLabel;
202 bool b_advancedVisible;
208 void updateVolume( int );
209 void updateVolume( void );
215 void toggleAdvanced();
217 void advancedControlsToggled( bool );
220 /***********************************
221 * Fullscreen controller
222 ***********************************/
224 static int showFullscreenControllCallback(vlc_object_t *vlc_object, const char *variable, vlc_value_t old_val,
225 vlc_value_t new_val, void *data);
227 static int regMouseMoveCallback(vlc_object_t *vlc_object, const char *variable, vlc_value_t old_val,
228 vlc_value_t new_val, void *data);
230 class FullscreenControllerWidget : public ControlsWidget
234 FullscreenControllerWidget( intf_thread_t *, MainInterface*, bool, bool );
235 virtual ~FullscreenControllerWidget();
237 void SetHideTimeout( int hideTimeout ) { i_hideTimeout = hideTimeout; }
238 void regFullscreenCallback( vout_thread_t *p_vout );
243 void unregFullscreenCallback();
246 friend class MainInterface;
247 friend class VolumeClickHandler;
249 virtual void mouseMoveEvent( QMouseEvent *event );
250 virtual void mousePressEvent( QMouseEvent *event );
251 virtual void enterEvent( QEvent *event );
252 virtual void leaveEvent( QEvent *event );
253 virtual void keyPressEvent( QKeyEvent *event );
256 void hideFSControllerWidget();
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 );