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 QPushButton *telexTransparent;
200 QToolButton *slowerButton, *fasterButton;
201 QHBoxLayout *controlButLayout;
202 AdvControlsWidget *advControls;
203 QLabel *volMuteLabel;
204 QAbstractSlider *volumeSlider;
205 VolumeClickHandler *hVolLabel;
207 bool b_advancedVisible;
208 bool b_telexTransparent;
215 void updateVolume( int );
216 void updateVolume( void );
222 void toggleAdvanced();
223 void toggleTeletext();
224 void toggleTeletextTransparency();
226 void advancedControlsToggled( bool );
229 /***********************************
230 * Fullscreen controller
231 ***********************************/
233 static int showFullscreenControllCallback(vlc_object_t *vlc_object, const char *variable, vlc_value_t old_val,
234 vlc_value_t new_val, void *data);
236 static int regMouseMoveCallback(vlc_object_t *vlc_object, const char *variable, vlc_value_t old_val,
237 vlc_value_t new_val, void *data);
239 class FullscreenControllerWidget : public ControlsWidget
243 FullscreenControllerWidget( intf_thread_t *, MainInterface*, bool, bool );
244 virtual ~FullscreenControllerWidget();
246 void SetHideTimeout( int hideTimeout ) { i_hideTimeout = hideTimeout; }
247 void regFullscreenCallback( vout_thread_t *p_vout );
252 void unregFullscreenCallback();
255 friend class MainInterface;
256 friend class VolumeClickHandler;
258 virtual void mouseMoveEvent( QMouseEvent *event );
259 virtual void mousePressEvent( QMouseEvent *event );
260 virtual void enterEvent( QEvent *event );
261 virtual void leaveEvent( QEvent *event );
262 virtual void keyPressEvent( QKeyEvent *event );
265 void hideFSControllerWidget();
271 #if HAVE_TRANSPARENCY
272 QTimer *p_slowHideTimer;
277 int i_hideTimeout; /* FSC hiding timeout, same as mouse hiding timeout */
284 virtual void customEvent( QEvent *event );
289 class VolumeClickHandler : public QObject
292 VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
293 {m = _m; p_intf = _p_intf; }
294 virtual ~VolumeClickHandler() {};
295 bool eventFilter( QObject *obj, QEvent *e )
297 if (e->type() == QEvent::MouseButtonPress )
299 aout_VolumeMute( p_intf, NULL );
300 audio_volume_t i_volume;
301 aout_VolumeGet( p_intf, &i_volume );
302 m->updateVolume( i_volume * VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
309 intf_thread_t *p_intf;
313 #include <QMouseEvent>
314 class TimeLabel : public QLabel
317 void mousePressEvent( QMouseEvent *event )
319 emit timeLabelClicked();
321 void mouseDoubleClickEvent( QMouseEvent *event )
323 emit timeLabelDoubleClicked();
326 void timeLabelClicked();
327 void timeLabelDoubleClicked();
330 class SpeedLabel : public QLabel
334 SpeedLabel( intf_thread_t *_p_intf, const QString text ): QLabel( text)
335 { p_intf = _p_intf; }
338 virtual void mouseDoubleClickEvent ( QMouseEvent * event )
340 THEMIM->getIM()->setRate( INPUT_RATE_DEFAULT );
343 intf_thread_t *p_intf;
346 /******************** Speed Control Widgets ****************/
347 class SpeedControlWidget : public QFrame
351 SpeedControlWidget( intf_thread_t *);
352 virtual ~SpeedControlWidget();
353 void updateControls( int );
355 intf_thread_t *p_intf;
356 QSlider *speedSlider;
358 void setEnable( bool );
360 void updateRate( int );