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"
50 /******************** Video Widget ****************/
51 class VideoWidget : public QFrame
54 friend class MainInterface;
57 VideoWidget( intf_thread_t * );
58 virtual ~VideoWidget();
60 void *request( vout_thread_t *, int *, int *,
61 unsigned int *, unsigned int * );
62 void release( void * );
63 int control( void *, int, va_list );
65 virtual QSize sizeHint() const;
67 intf_thread_t *p_intf;
73 void askVideoWidgetToShow( unsigned int, unsigned int );
76 void SetSizing( unsigned int, unsigned int );
79 virtual QPaintEngine *paintEngine() const
84 virtual void paintEvent(QPaintEvent *);
87 /******************** Background Widget ****************/
88 class BackgroundWidget : public QWidget
92 BackgroundWidget( intf_thread_t * );
93 virtual ~BackgroundWidget();
98 virtual void contextMenuEvent( QContextMenuEvent *event );
99 intf_thread_t *p_intf;
100 virtual void resizeEvent( QResizeEvent * event );
102 void toggle(){ TOGGLEV( this ); }
103 void updateArt( input_item_t* );
107 class VisualSelector : public QFrame
111 VisualSelector( intf_thread_t *);
112 virtual ~VisualSelector();
114 intf_thread_t *p_intf;
122 /* Advanced Button Bar */
124 class AdvControlsWidget : public QFrame
128 AdvControlsWidget( intf_thread_t *, bool );
129 virtual ~AdvControlsWidget();
131 void enableInput( bool );
132 void enableVideo( bool );
135 intf_thread_t *p_intf;
136 QPushButton *recordButton, *ABButton;
137 QPushButton *snapshotButton, *frameButton;
139 static mtime_t timeA, timeB;
149 void AtoBLoop( float, int, int );
160 class VolumeClickHandler;
162 class QAbstractSlider;
165 class ControlsWidget : public QFrame
169 /* p_intf, advanced control visible or not, blingbling or not */
170 ControlsWidget( intf_thread_t *_p_i, MainInterface *_p_mi,
171 bool b_advControls, bool b_shiny, bool b_fsCreation = false);
172 virtual ~ControlsWidget();
174 QPushButton *playlistButton;
175 void setStatus( int );
176 void enableInput( bool );
178 void setNavigation( int );
180 friend class MainInterface;
181 friend class VolumeClickHandler;
183 intf_thread_t *p_intf;
186 QGridLayout *controlLayout;
188 QPushButton *prevSectionButton, *nextSectionButton, *menuButton;
189 QPushButton *playButton, *fullscreenButton, *extSettingsButton;
190 QPushButton *telexTransparent, *telexOn;
192 QToolButton *slowerButton, *fasterButton;
193 QHBoxLayout *controlButLayout;
194 AdvControlsWidget *advControls;
195 QLabel *volMuteLabel;
196 QAbstractSlider *volumeSlider;
197 VolumeClickHandler *hVolLabel;
199 bool b_advancedVisible;
200 bool b_telexTransparent;
207 void updateVolume( int );
208 void updateVolume( void );
214 void toggleAdvanced();
215 void toggleTeletext();
216 void toggleTeletextTransparency();
217 void enableTeletext( bool );
218 void enableVideo( bool );
220 void advancedControlsToggled( bool );
223 /* on WIN32 hide() for fullscreen controller doesnt work, so it have to be
224 done by trick with setting the opacity of window */
229 /* to trying transparency with fullscreen controller on windows enable that */
230 /* it can be enabled on-non windows systems,
231 but it will be transparent only with composite manager */
233 #define HAVE_TRANSPARENCY 1
235 #define HAVE_TRANSPARENCY 0
238 /* Default value of opacity for FS controller */
239 #define DEFAULT_OPACITY 0.75
241 /***********************************
242 * Fullscreen controller
243 ***********************************/
244 class FullscreenControllerWidget : public ControlsWidget
248 FullscreenControllerWidget( intf_thread_t *, MainInterface*, bool, bool );
249 virtual ~FullscreenControllerWidget();
252 void attachVout( vout_thread_t *p_vout );
254 void fullscreenChanged( vout_thread_t *, bool b_fs, int i_timeout );
257 friend class MainInterface;
258 friend class VolumeClickHandler;
260 virtual void mouseMoveEvent( QMouseEvent *event );
261 virtual void mousePressEvent( QMouseEvent *event );
262 virtual void enterEvent( QEvent *event );
263 virtual void leaveEvent( QEvent *event );
264 virtual void keyPressEvent( QKeyEvent *event );
276 #if HAVE_TRANSPARENCY
277 QTimer *p_slowHideTimer;
285 bool b_slow_hide_begin;
286 int i_slow_hide_timeout;
292 virtual void customEvent( QEvent *event );
294 vout_thread_t *p_vout;
296 /* Shared variable between FSC and VLC (protected by a lock) */
299 int i_hide_timeout; /* FSC hiding timeout, same as mouse hiding timeout */
303 #define VOLUME_MAX 200
304 class VolumeClickHandler : public QObject
307 VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
308 {m = _m; p_intf = _p_intf; }
309 virtual ~VolumeClickHandler() {};
310 bool eventFilter( QObject *obj, QEvent *e )
312 if (e->type() == QEvent::MouseButtonPress )
314 aout_VolumeMute( p_intf, NULL );
315 audio_volume_t i_volume;
316 aout_VolumeGet( p_intf, &i_volume );
317 m->updateVolume( i_volume * VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
324 intf_thread_t *p_intf;
328 #include <QMouseEvent>
329 class TimeLabel : public QLabel
332 void mousePressEvent( QMouseEvent *event )
334 emit timeLabelClicked();
336 void mouseDoubleClickEvent( QMouseEvent *event )
338 emit timeLabelDoubleClicked();
341 void timeLabelClicked();
342 void timeLabelDoubleClicked();
345 class SpeedLabel : public QLabel
349 SpeedLabel( intf_thread_t *_p_intf, const QString text ): QLabel( text)
350 { p_intf = _p_intf; }
353 virtual void mouseDoubleClickEvent ( QMouseEvent * event )
355 THEMIM->getIM()->setRate( INPUT_RATE_DEFAULT );
358 intf_thread_t *p_intf;
361 /******************** Speed Control Widgets ****************/
362 class SpeedControlWidget : public QFrame
366 SpeedControlWidget( intf_thread_t *);
367 virtual ~SpeedControlWidget();
368 void updateControls( int );
370 intf_thread_t *p_intf;
371 QSlider *speedSlider;
373 void setEnable( bool );
375 void updateRate( int );
379 class CoverArtLabel : public QLabel
383 CoverArtLabel( QWidget *parent,
384 vlc_object_t *p_this,
385 input_item_t *p_input = NULL );
386 virtual ~CoverArtLabel()
387 { if( p_input ) vlc_gc_decref( p_input ); };
389 input_item_t *p_input;
390 vlc_object_t *p_this;
394 void requestUpdate() { emit updateRequested(); };
395 void update( input_item_t* p_item )
396 { if( p_input ) vlc_gc_decref( p_input );
397 if( ( p_input = p_item ) ) vlc_gc_incref( p_input );
402 void downloadCover();
405 void updateRequested();