interface_widgets.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * interface_widgets.hpp : Custom widgets for the main interface
00003  ****************************************************************************
00004  * Copyright (C) 2006 the VideoLAN team
00005  * $Id$
00006  *
00007  * Authors: Clément Stenac <zorglub@videolan.org>
00008  *          Jean-Baptiste Kempf <jb@videolan.org>
00009  *          Rafaël Carré <funman@videolanorg>
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00024  *****************************************************************************/
00025 
00026 #ifndef _INTFWIDGETS_H_
00027 #define _INTFWIDGETS_H_
00028 
00029 #ifdef HAVE_CONFIG_H
00030 # include "config.h"
00031 #endif
00032 
00033 #include <vlc_common.h>
00034 #include <vlc_interface.h>
00035 #include <vlc_aout.h>
00036 
00037 #include "qt4.hpp"
00038 #include "main_interface.hpp"
00039 #include "input_manager.hpp"
00040 
00041 #include <QWidget>
00042 #include <QFrame>
00043 
00044 #define VOLUME_MAX 200
00045 
00046 /* on WIN32 hide() for fullscreen controller doesnt work, so it have to be
00047    done by trick with setting the opacity of window */
00048 #ifdef WIN32
00049     #define WIN32TRICK
00050 #endif
00051 
00052 /* to trying transparency with fullscreen controller on windows enable that */
00053 /* it can be enabled on-non windows systems,
00054    but it will be transparent only with composite manager */
00055 #ifndef WIN32
00056     #define HAVE_TRANSPARENCY 1
00057 #else
00058     #define HAVE_TRANSPARENCY 0
00059 #endif
00060 
00061 /* Default value of opacity for FS controller */
00062 #define DEFAULT_OPACITY 0.75
00063 
00064 class ResizeEvent;
00065 class QPalette;
00066 class QPixmap;
00067 class QLabel;
00068 class QHBoxLayout;
00069 
00070 /******************** Video Widget ****************/
00071 class VideoWidget : public QFrame
00072 {
00073     Q_OBJECT
00074 friend class MainInterface;
00075 
00076 public:
00077     VideoWidget( intf_thread_t * );
00078     virtual ~VideoWidget();
00079 
00080     void *request( vout_thread_t *, int *, int *,
00081                    unsigned int *, unsigned int * );
00082     void  release( void * );
00083     int   control( void *, int, va_list );
00084 
00085     virtual QSize sizeHint() const;
00086 private:
00087     intf_thread_t *p_intf;
00088     int i_vout;
00089 
00090     QSize videoSize;
00091 
00092 signals:
00093     void askVideoWidgetToShow( unsigned int, unsigned int );
00094 
00095 public slots:
00096     void SetSizing( unsigned int, unsigned int );
00097 
00098 protected:
00099     virtual QPaintEngine *paintEngine() const
00100     {
00101         return NULL;
00102     }
00103 
00104     virtual void paintEvent(QPaintEvent *);
00105 };
00106 
00107 /******************** Background Widget ****************/
00108 class BackgroundWidget : public QWidget
00109 {
00110     Q_OBJECT
00111 public:
00112     BackgroundWidget( intf_thread_t * );
00113     virtual ~BackgroundWidget();
00114 
00115 private:
00116     QPalette plt;
00117     QLabel *label;
00118     virtual void contextMenuEvent( QContextMenuEvent *event );
00119     intf_thread_t *p_intf;
00120     virtual void resizeEvent( QResizeEvent * event );
00121 public slots:
00122     void toggle(){ TOGGLEV( this ); }
00123     void updateArt( QString );
00124 };
00125 
00126 #if 0
00127 class VisualSelector : public QFrame
00128 {
00129     Q_OBJECT
00130 public:
00131     VisualSelector( intf_thread_t *);
00132     virtual ~VisualSelector();
00133 private:
00134     intf_thread_t *p_intf;
00135     QLabel *current;
00136 private slots:
00137     void prev();
00138     void next();
00139 };
00140 #endif
00141 
00142 /* Advanced Button Bar */
00143 class QPushButton;
00144 class AdvControlsWidget : public QFrame
00145 {
00146     Q_OBJECT
00147 public:
00148     AdvControlsWidget( intf_thread_t *, bool );
00149     virtual ~AdvControlsWidget();
00150 
00151     void enableInput( bool );
00152     void enableVideo( bool );
00153 
00154 private:
00155     intf_thread_t *p_intf;
00156     QPushButton *recordButton, *ABButton;
00157     QPushButton *snapshotButton, *frameButton;
00158 
00159     static mtime_t timeA, timeB;
00160 
00161 private slots:
00162     void snapshot();
00163 #if 0
00164     void frame();
00165 #endif
00166     void fromAtoB();
00167     void record();
00168     void AtoBLoop( float, int, int );
00169     void setIcon();
00170 
00171 signals:
00172     void timeChanged();
00173 };
00174 
00175 /* Button Bar */
00176 class InputSlider;
00177 class QSlider;
00178 class QGridLayout;
00179 class VolumeClickHandler;
00180 class SoundSlider;
00181 class QAbstractSlider;
00182 class QToolButton;
00183 
00184 class ControlsWidget : public QFrame
00185 {
00186     Q_OBJECT
00187 public:
00188     /* p_intf, advanced control visible or not, blingbling or not */
00189     ControlsWidget( intf_thread_t *_p_i, MainInterface *_p_mi,
00190         bool b_advControls, bool b_shiny, bool b_fsCreation = false);
00191     virtual ~ControlsWidget();
00192 
00193     QPushButton *playlistButton;
00194     void setStatus( int );
00195     void enableInput( bool );
00196     void enableVideo( bool );
00197 public slots:
00198     void setNavigation( int );
00199 protected:
00200     friend class MainInterface;
00201     friend class VolumeClickHandler;
00202 protected:
00203     intf_thread_t       *p_intf;
00204     QWidget             *discFrame;
00205     QWidget             *telexFrame;
00206     QGridLayout         *controlLayout;
00207     InputSlider         *slider;
00208     QPushButton         *prevSectionButton, *nextSectionButton, *menuButton;
00209     QPushButton         *playButton, *fullscreenButton, *extSettingsButton;
00210     QPushButton         *telexTransparent, *telexOn;
00211     QSpinBox            *telexPage;
00212     QToolButton         *slowerButton, *fasterButton;
00213     QHBoxLayout         *controlButLayout;
00214     AdvControlsWidget   *advControls;
00215     QLabel              *volMuteLabel;
00216     QAbstractSlider     *volumeSlider;
00217     VolumeClickHandler  *hVolLabel;
00218 
00219     bool                 b_advancedVisible;
00220     bool                 b_telexTransparent;
00221     bool                 b_telexEnabled;
00222 protected slots:
00223     void play();
00224     void stop();
00225     void prev();
00226     void next();
00227     void updateVolume( int );
00228     void updateVolume( void );
00229     void updateInput();
00230     void fullscreen();
00231     void extSettings();
00232     void faster();
00233     void slower();
00234     void toggleAdvanced();
00235     void toggleTeletext();
00236     void toggleTeletextTransparency();
00237     void enableTeletext( bool );
00238 signals:
00239     void advancedControlsToggled( bool );
00240 };
00241 
00242 /***********************************
00243  * Fullscreen controller
00244  ***********************************/
00245 class FullscreenControllerWidget : public ControlsWidget
00246 {
00247     Q_OBJECT
00248 public:
00249     FullscreenControllerWidget( intf_thread_t *, MainInterface*, bool, bool );
00250     virtual ~FullscreenControllerWidget();
00251 
00252     /* */
00253     void attachVout( vout_thread_t *p_vout );
00254     void detachVout();
00255     void fullscreenChanged( vout_thread_t *, bool b_fs, int i_timeout );
00256 
00257 protected:
00258     friend class MainInterface;
00259     friend class VolumeClickHandler;
00260 
00261     virtual void mouseMoveEvent( QMouseEvent *event );
00262     virtual void mousePressEvent( QMouseEvent *event );
00263     virtual void enterEvent( QEvent *event );
00264     virtual void leaveEvent( QEvent *event );
00265     virtual void keyPressEvent( QKeyEvent *event );
00266 
00267 private slots:
00268     void showFSC();
00269     void planHideFSC();
00270     void hideFSC();
00271 
00272     void slowHideFSC();
00273 
00274 
00275 private:
00276     QTimer *p_hideTimer;
00277 #if HAVE_TRANSPARENCY
00278     QTimer *p_slowHideTimer;
00279 #endif
00280 
00281     int i_mouse_last_x;
00282     int i_mouse_last_y;
00283 
00284     bool b_mouse_over;
00285 
00286     bool b_slow_hide_begin;
00287     int  i_slow_hide_timeout;
00288 
00289 #ifdef WIN32TRICK
00290     bool fscHidden;
00291 #endif
00292 
00293     virtual void customEvent( QEvent *event );
00294 
00295     vout_thread_t *p_vout;
00296 
00297     /* Shared variable between FSC and VLC (protected by a lock) */
00298     vlc_mutex_t lock;
00299     bool        b_fullscreen;
00300     int         i_hide_timeout;  /* FSC hiding timeout, same as mouse hiding timeout */
00301 };
00302 
00303 
00304 
00305 class VolumeClickHandler : public QObject
00306 {
00307 public:
00308     VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
00309     {m = _m; p_intf = _p_intf; }
00310     virtual ~VolumeClickHandler() {};
00311     bool eventFilter( QObject *obj, QEvent *e )
00312     {
00313         if (e->type() == QEvent::MouseButtonPress  )
00314         {
00315             aout_VolumeMute( p_intf, NULL );
00316             audio_volume_t i_volume;
00317             aout_VolumeGet( p_intf, &i_volume );
00318             m->updateVolume( i_volume *  VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
00319             return true;
00320         }
00321         return false;
00322     }
00323 private:
00324     ControlsWidget *m;
00325     intf_thread_t *p_intf;
00326 };
00327 
00328 #include <QLabel>
00329 #include <QMouseEvent>
00330 class TimeLabel : public QLabel
00331 {
00332     Q_OBJECT
00333     void mousePressEvent( QMouseEvent *event )
00334     {
00335         emit timeLabelClicked();
00336     }
00337     void mouseDoubleClickEvent( QMouseEvent *event )
00338     {
00339         emit timeLabelDoubleClicked();
00340     }
00341 signals:
00342     void timeLabelClicked();
00343     void timeLabelDoubleClicked();
00344 };
00345 
00346 class SpeedLabel : public QLabel
00347 {
00348     Q_OBJECT
00349 public:
00350     SpeedLabel( intf_thread_t *_p_intf, const QString text ): QLabel( text)
00351     { p_intf = _p_intf; }
00352 
00353 protected:
00354     virtual void mouseDoubleClickEvent ( QMouseEvent * event )
00355     {
00356         THEMIM->getIM()->setRate( INPUT_RATE_DEFAULT );
00357     }
00358 private:
00359     intf_thread_t *p_intf;
00360 };
00361 
00362 /******************** Speed Control Widgets ****************/
00363 class SpeedControlWidget : public QFrame
00364 {
00365     Q_OBJECT
00366 public:
00367     SpeedControlWidget( intf_thread_t *);
00368     virtual ~SpeedControlWidget();
00369     void updateControls( int );
00370 private:
00371     intf_thread_t *p_intf;
00372     QSlider *speedSlider;
00373 public slots:
00374     void setEnable( bool );
00375 private slots:
00376     void updateRate( int );
00377     void resetRate();
00378 };
00379 
00380 #endif

Generated on Wed Aug 13 08:02:37 2008 for VLC by  doxygen 1.5.1