X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fgui%2Fqt4%2Futil%2Finput_slider.cpp;h=59f205f3f40f16d0c42673641c366ad051d1d4d1;hb=f673748bdc97383b10aa5667202e15052807e291;hp=ff3dbdfb594990bf2809abf4357929c5f19f4308;hpb=72f13c9d9548e84e49e57f3ee707ad641854ac15;p=vlc diff --git a/modules/gui/qt4/util/input_slider.cpp b/modules/gui/qt4/util/input_slider.cpp index ff3dbdfb59..59f205f3f4 100644 --- a/modules/gui/qt4/util/input_slider.cpp +++ b/modules/gui/qt4/util/input_slider.cpp @@ -26,8 +26,9 @@ #include #include - +#include #include + InputSlider::InputSlider( QWidget *_parent ) : DirectSlider( _parent ) { InputSlider::InputSlider( Qt::Horizontal, _parent ); @@ -75,40 +76,45 @@ void InputSlider::mouseMoveEvent(QMouseEvent *event) } #define WLENGTH 100 // px -#define WHEIGHT 25 // px +#define WHEIGHT 28 // px #define SOUNDMIN 0 // % #define SOUNDMAX 200 // % OR 400 ? -#define SOUNDSTEP 5 // % -SoundSlider::SoundSlider( QWidget *_parent, bool b_hard ) : QAbstractSlider( _parent ) +SoundSlider::SoundSlider( QWidget *_parent, int _i_step, bool b_hard ) + : QAbstractSlider( _parent ) { - padding = 5; + padding = 3; + + f_step = ( _i_step * 100 ) / AOUT_VOLUME_MAX ; setRange( SOUNDMIN, b_hard ? (2 * SOUNDMAX) : SOUNDMAX ); - pixGradient = QPixmap( QSize( WLENGTH, WHEIGHT ) ); -// QBixmap mask = QBitmap( QPixmap ); + pixOutside = QPixmap( ":/pixmaps/volume-slider-outside.png" ); + + const QPixmap temp( ":/pixmaps/volume-slider-inside.png" ); + const QBitmap mask( temp.createHeuristicMask() ); + + setMinimumSize( pixOutside.size() ); + + pixGradient = QPixmap( mask.size() ); QPainter p( &pixGradient ); - QLinearGradient gradient( 0, 0, WLENGTH, WHEIGHT ); + QLinearGradient gradient( padding, 2, WLENGTH , 2 ); gradient.setColorAt( 0.0, Qt::white ); - gradient.setColorAt( 1.0, Qt::blue ); + gradient.setColorAt( 0.2, QColor( 20, 226, 20 ) ); + gradient.setColorAt( 0.5, QColor( 255, 176, 15 ) ); + gradient.setColorAt( 1.0, QColor( 235, 30, 20 ) ); p.setPen( Qt::NoPen ); p.setBrush( gradient ); -//static const QPointF points[3] = { QPointF( 0.0, WHEIGHT ), - // QPointF( WLENGTH, WHEIGHT ), QPointF( WLENGTH, 0.0 ) }; - - // p.drawConvexPolygon( points, 3 ); - p.drawRect( pixGradient.rect() ); p.end(); - // pixGradient.setMask( mask ); + pixGradient.setMask( mask ); } void SoundSlider::wheelEvent( QWheelEvent *event ) { - int newvalue = value() + event->delta() / ( 8 * 15 ) * SOUNDSTEP; + int newvalue = value() + event->delta() / ( 8 * 15 ) * f_step; setValue( __MIN( __MAX( minimum(), newvalue ), maximum() ) ); emit sliderReleased(); @@ -144,7 +150,7 @@ void SoundSlider::mouseMoveEvent( QMouseEvent *event ) if( b_sliding ) { QRect rect( padding - 15, padding - 1, - WLENGTH + 15 * 2, WHEIGHT + 2 ); + WLENGTH + 15 * 2, WHEIGHT + 4 ); if( !rect.contains( event->pos() ) ) { /* We are outside */ if ( !b_outside ) @@ -172,21 +178,13 @@ void SoundSlider::paintEvent(QPaintEvent *e) { QPainter painter( this ); const int offset = int( double( ( width() - 2 * padding ) * value() ) / maximum() ); - const QRectF boundsG( padding, 0, offset , pixGradient.height() ); + + const QRectF boundsG( 0, 0, offset , pixGradient.height() ); painter.drawPixmap( boundsG, pixGradient, boundsG ); - painter.end(); -/* QPainter painter( this ); - printf( "%i\n", value() ); - - QLinearGradient gradient( 0.0, 0.0, WLENGTH, WHEIGHT ); - gradient.setColorAt( 0.0, Qt::white ); - gradient.setColorAt( 1.0, Qt::blue ); + const QRectF boundsO( 0, 0, pixOutside.width(), pixOutside.height() ); + painter.drawPixmap( boundsO, pixOutside, boundsO ); - painter.setPen( QPen( QBrush( Qt::black ), 0, Qt::SolidLine, Qt::RoundCap ) ); - painter.setBrush( gradient ); - painter.setRenderHint( QPainter::Antialiasing ); - - painter.end();*/ + painter.end(); }