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"
35 #include "styles/seekstyle.hpp"
40 #define MSTRTIME_MAX_SIZE 22
47 class QPropertyAnimation;
50 /* Input Slider derived from QSlider */
51 class SeekSlider : public QSlider
54 Q_PROPERTY(qreal handleOpacity READ handleOpacity WRITE setHandleOpacity)
56 SeekSlider( Qt::Orientation q, QWidget *_parent = 0, bool _classic = false );
58 void setChapters( SeekPoints * );
61 virtual void mouseMoveEvent( QMouseEvent *event );
62 virtual void mousePressEvent( QMouseEvent* event );
63 virtual void mouseReleaseEvent( QMouseEvent *event );
64 virtual void wheelEvent( QWheelEvent *event );
65 virtual void enterEvent( QEvent * );
66 virtual void leaveEvent( QEvent * );
67 virtual void hideEvent( QHideEvent * );
69 virtual bool eventFilter( QObject *obj, QEvent *event );
71 virtual QSize sizeHint() const;
73 bool isAnimationRunning() const;
74 qreal handleOpacity() const;
75 void setHandleOpacity( qreal opacity );
79 bool isSliding; /* Whether we are currently sliding by user action */
80 bool isJumping; /* if we requested a jump to another chapter */
81 int inputLength; /* InputLength that can change */
82 char psz_length[MSTRTIME_MAX_SIZE]; /* Used for the ToolTip */
83 QTimer *seekLimitTimer;
84 TimeTooltip *mTimeTooltip;
91 /* Colors & gradients */
92 QSize gradientsTargetSize;
93 QLinearGradient backgroundGradient;
94 QLinearGradient foregroundGradient;
95 QLinearGradient handleGradient;
96 QColor tickpointForeground;
99 /* Handle's animation */
100 qreal mHandleOpacity;
101 QPropertyAnimation *animHandle;
102 QTimer *hideHandleTimer;
105 void setPosition( float, int64_t, int );
106 void setSeekable( bool b ) { b_seekable = b ; }
107 void updateBuffering( float );
111 void startSeekTimer();
115 void sliderDragged( float );
118 friend class SeekStyle;
121 /* Sound Slider inherited directly from QAbstractSlider */
124 class SoundSlider : public QAbstractSlider
128 SoundSlider( QWidget *_parent, int _i_step, char * );
129 void setMuted( bool ); /* Set Mute status */
132 const static int paddingL = 3;
133 const static int paddingR = 2;
135 virtual void paintEvent( QPaintEvent *);
136 virtual void wheelEvent( QWheelEvent *event );
137 virtual void mousePressEvent( QMouseEvent * );
138 virtual void mouseMoveEvent( QMouseEvent * );
139 virtual void mouseReleaseEvent( QMouseEvent * );
142 bool isSliding; /* Whether we are currently sliding by user action */
143 bool b_mouseOutside; /* Whether the mouse is outside or inside the Widget */
144 int i_oldvalue; /* Store the old Value before changing */
145 float f_step; /* How much do we increase each time we wheel */
148 QPixmap pixGradient; /* Gradient pix storage */
149 QPixmap pixGradient2; /* Muted Gradient pix storage */
150 QPixmap pixOutside; /* OutLine pix storage */
157 void changeValue( int x ); /* Function to modify the value from pixel x() */