1 /*****************************************************************************
2 * input_slider.hpp : VolumeSlider and SeekSlider
3 ****************************************************************************
4 * Copyright (C) 2006-2011 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Jean-Baptiste Kempf <jb@videolan.org>
9 * Ludovic Fauvet <etix@videolan.org>
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 Foundation,
23 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
26 #ifndef _INPUTSLIDER_H_
27 #define _INPUTSLIDER_H_
33 #include <vlc_common.h>
34 #include "timetooltip.hpp"
39 #define MSTRTIME_MAX_SIZE 22
46 class QPropertyAnimation;
48 /* Input Slider derived from QSlider */
49 class SeekSlider : public QSlider
52 Q_PROPERTY(qreal handleOpacity READ handleOpacity WRITE setHandleOpacity)
54 SeekSlider( Qt::Orientation q, QWidget *_parent = 0, bool _classic = false );
56 void setChapters( SeekPoints * );
59 virtual void mouseMoveEvent( QMouseEvent *event );
60 virtual void mousePressEvent( QMouseEvent* event );
61 virtual void mouseReleaseEvent( QMouseEvent *event );
62 virtual void wheelEvent( QWheelEvent *event );
63 virtual void enterEvent( QEvent * );
64 virtual void leaveEvent( QEvent * );
65 virtual void hideEvent( QHideEvent * );
67 virtual void paintEvent( QPaintEvent* event );
68 virtual bool eventFilter( QObject *obj, QEvent *event );
70 QSize handleSize() const;
71 virtual QSize sizeHint() const;
73 bool isAnimationRunning() const;
74 qreal handleOpacity() const;
75 void setHandleOpacity( qreal opacity );
78 bool isSliding; /* Whether we are currently sliding by user action */
79 bool isJumping; /* if we requested a jump to another chapter */
80 int inputLength; /* InputLength that can change */
81 char psz_length[MSTRTIME_MAX_SIZE]; /* Used for the ToolTip */
82 QTimer *seekLimitTimer;
83 TimeTooltip *mTimeTooltip;
88 /* Colors & gradients */
89 QSize gradientsTargetSize;
90 QLinearGradient backgroundGradient;
91 QLinearGradient foregroundGradient;
92 QLinearGradient handleGradient;
93 QColor tickpointForeground;
96 /* Handle's animation */
98 QPropertyAnimation *animHandle;
99 QTimer *hideHandleTimer;
102 void setPosition( float, int64_t, int );
103 void updateBuffering( float );
107 void startSeekTimer();
111 void sliderDragged( float );
115 /* Sound Slider inherited directly from QAbstractSlider */
118 class SoundSlider : public QAbstractSlider
122 SoundSlider( QWidget *_parent, int _i_step, bool b_softamp, char * );
123 void setMuted( bool ); /* Set Mute status */
126 const static int paddingL = 3;
127 const static int paddingR = 2;
129 virtual void paintEvent( QPaintEvent *);
130 virtual void wheelEvent( QWheelEvent *event );
131 virtual void mousePressEvent( QMouseEvent * );
132 virtual void mouseMoveEvent( QMouseEvent * );
133 virtual void mouseReleaseEvent( QMouseEvent * );
136 bool isSliding; /* Whether we are currently sliding by user action */
137 bool b_mouseOutside; /* Whether the mouse is outside or inside the Widget */
138 int i_oldvalue; /* Store the old Value before changing */
139 float f_step; /* How much do we increase each time we wheel */
142 QPixmap pixGradient; /* Gradient pix storage */
143 QPixmap pixGradient2; /* Muted Gradient pix storage */
144 QPixmap pixOutside; /* OutLine pix storage */
151 void changeValue( int x ); /* Function to modify the value from pixel x() */