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;
137 QPushButton *recordButton;
139 QPushButton *ABButton;
140 QPushButton *snapshotButton, *frameButton;
142 static mtime_t timeA, timeB;
152 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 );
181 void setNavigation( int );
183 friend class MainInterface;
184 friend class VolumeClickHandler;
186 intf_thread_t *p_intf;
189 QGridLayout *controlLayout;
191 QPushButton *prevSectionButton, *nextSectionButton, *menuButton;
192 QPushButton *playButton, *fullscreenButton, *extSettingsButton;
193 QPushButton *telexTransparent, *telexOn;
195 QToolButton *slowerButton, *fasterButton;
196 QHBoxLayout *controlButLayout;
197 AdvControlsWidget *advControls;
198 QLabel *volMuteLabel;
199 QAbstractSlider *volumeSlider;
200 VolumeClickHandler *hVolLabel;
202 bool b_advancedVisible;
203 bool b_telexTransparent;
210 void updateVolume( int );
211 void updateVolume( void );
217 void toggleAdvanced();
218 void toggleTeletext();
219 void toggleTeletextTransparency();
220 void enableTeletext( bool );
221 void enableVideo( bool );
223 void advancedControlsToggled( bool );
226 /* on WIN32 hide() for fullscreen controller doesnt work, so it have to be
227 done by trick with setting the opacity of window */
232 /* to trying transparency with fullscreen controller on windows enable that */
233 /* it can be enabled on-non windows systems,
234 but it will be transparent only with composite manager */
236 #define HAVE_TRANSPARENCY 1
238 #define HAVE_TRANSPARENCY 0
241 /* Default value of opacity for FS controller */
242 #define DEFAULT_OPACITY 0.75
244 /***********************************
245 * Fullscreen controller
246 ***********************************/
247 class FullscreenControllerWidget : public ControlsWidget
251 FullscreenControllerWidget( intf_thread_t *, MainInterface*, bool, bool );
252 virtual ~FullscreenControllerWidget();
255 void attachVout( vout_thread_t *p_vout );
257 void fullscreenChanged( vout_thread_t *, bool b_fs, int i_timeout );
260 friend class MainInterface;
261 friend class VolumeClickHandler;
263 virtual void mouseMoveEvent( QMouseEvent *event );
264 virtual void mousePressEvent( QMouseEvent *event );
265 virtual void enterEvent( QEvent *event );
266 virtual void leaveEvent( QEvent *event );
267 virtual void keyPressEvent( QKeyEvent *event );
279 #if HAVE_TRANSPARENCY
280 QTimer *p_slowHideTimer;
288 bool b_slow_hide_begin;
289 int i_slow_hide_timeout;
295 virtual void customEvent( QEvent *event );
297 vout_thread_t *p_vout;
299 /* Shared variable between FSC and VLC (protected by a lock) */
302 int i_hide_timeout; /* FSC hiding timeout, same as mouse hiding timeout */
306 #define VOLUME_MAX 200
307 class VolumeClickHandler : public QObject
310 VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
311 {m = _m; p_intf = _p_intf; }
312 virtual ~VolumeClickHandler() {};
313 bool eventFilter( QObject *obj, QEvent *e )
315 if (e->type() == QEvent::MouseButtonPress )
317 aout_VolumeMute( p_intf, NULL );
318 audio_volume_t i_volume;
319 aout_VolumeGet( p_intf, &i_volume );
320 m->updateVolume( i_volume * VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
327 intf_thread_t *p_intf;
331 #include <QMouseEvent>
332 class TimeLabel : public QLabel
335 void mousePressEvent( QMouseEvent *event )
337 emit timeLabelClicked();
339 void mouseDoubleClickEvent( QMouseEvent *event )
341 emit timeLabelDoubleClicked();
344 void timeLabelClicked();
345 void timeLabelDoubleClicked();
348 class SpeedLabel : public QLabel
352 SpeedLabel( intf_thread_t *_p_intf, const QString text ): QLabel( text)
353 { p_intf = _p_intf; }
356 virtual void mouseDoubleClickEvent ( QMouseEvent * event )
358 THEMIM->getIM()->setRate( INPUT_RATE_DEFAULT );
361 intf_thread_t *p_intf;
364 /******************** Speed Control Widgets ****************/
365 class SpeedControlWidget : public QFrame
369 SpeedControlWidget( intf_thread_t *);
370 virtual ~SpeedControlWidget();
371 void updateControls( int );
373 intf_thread_t *p_intf;
374 QSlider *speedSlider;
376 void setEnable( bool );
378 void updateRate( int );
382 class CoverArtLabel : public QLabel
386 CoverArtLabel( QWidget *parent,
387 vlc_object_t *p_this,
388 input_item_t *p_input = NULL );
389 virtual ~CoverArtLabel()
390 { if( p_input ) vlc_gc_decref( p_input ); };
392 input_item_t *p_input;
393 vlc_object_t *p_this;
397 void requestUpdate() { emit updateRequested(); };
398 void update( input_item_t* p_item )
399 { if( p_input ) vlc_gc_decref( p_input );
400 if( ( p_input = p_item ) ) vlc_gc_incref( p_input );
405 void downloadCover();
408 void updateRequested();