input_slider.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * input_slider.hpp : A slider that controls an input
00003  ****************************************************************************
00004  * Copyright (C) 2006 the VideoLAN team
00005  * $Id: 08800f1ded9f986890322bee77405fe1fd6816ef $
00006  *
00007  * Authors: Clément Stenac <zorglub@videolan.org>
00008  *          Jean-Baptiste Kempf <jb@videolan.org>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00023  *****************************************************************************/
00024 
00025 #ifndef _INPUTSLIDER_H_
00026 #define _INPUTSLIDER_H_
00027 
00028 #include "qt4.hpp"
00029 
00030 #include <QSlider>
00031 
00032 #include <QMouseEvent>
00033 #include <QWheelEvent>
00034 #include <QTimer>
00035 
00036 /* Input Slider derived from QSlider */
00037 class InputSlider : public QSlider
00038 {
00039     Q_OBJECT
00040 public:
00041     InputSlider( QWidget *_parent );
00042     InputSlider( Qt::Orientation q, QWidget *_parent );
00043     virtual ~InputSlider() {};
00044 protected:
00045     virtual void mouseMoveEvent(QMouseEvent *event);
00046     virtual void mousePressEvent(QMouseEvent* event);
00047     virtual void mouseReleaseEvent(QMouseEvent* event);
00048     virtual void wheelEvent(QWheelEvent *event);
00049 private:
00050     bool b_isSliding; /* Whether we are currently sliding by user action */
00051     int inputLength;  /* InputLength that can change */
00052     char psz_length[MSTRTIME_MAX_SIZE]; /* Used for the ToolTip */
00053     int lastSeeked;
00054     QTimer *timer;
00055 
00056 public slots:
00057     void setPosition( float, int64_t, int );
00058 private slots:
00059     void userDrag( int );
00060     void seekTick();
00061 
00062 signals:
00063     void sliderDragged( float );
00064 };
00065 
00066 
00067 /* Sound Slider inherited directly from QAbstractSlider */
00068 class QPaintEvent;
00069 
00070 class SoundSlider : public QAbstractSlider
00071 {
00072     Q_OBJECT
00073 public:
00074     SoundSlider( QWidget *_parent, int _i_step, bool b_softamp, char * );
00075     virtual ~SoundSlider() {};
00076     void setMuted( bool ); /* Set Mute status */
00077 
00078 protected:
00079     const static int paddingL = 3;
00080     const static int paddingR = 2;
00081 
00082     virtual void paintEvent(QPaintEvent *);
00083     virtual void wheelEvent( QWheelEvent *event );
00084     virtual void mousePressEvent( QMouseEvent * );
00085     virtual void mouseMoveEvent( QMouseEvent * );
00086     virtual void mouseReleaseEvent( QMouseEvent * );
00087 
00088 private:
00089     bool b_isSliding; /* Whether we are currently sliding by user action */
00090     bool b_mouseOutside; /* Whether the mouse is outside or inside the Widget */
00091     int i_oldvalue; /* Store the old Value before changing */
00092     float f_step; /* How much do we increase each time we wheel */
00093     bool b_isMuted;
00094 
00095     QPixmap pixGradient; /* Gradient pix storage */
00096     QPixmap pixGradient2; /* Muted Gradient pix storage */
00097     QPixmap pixOutside; /* OutLine pix storage */
00098 
00099     void changeValue( int x ); /* Function to modify the value from pixel x() */
00100 };
00101 
00102 #endif

Generated on Tue May 25 08:04:58 2010 for VLC by  doxygen 1.5.6