-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 14 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 16 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 1 |
5 files changed, 17 insertions, 17 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 022aa82..4301a67 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp @@ -186,67 +186,67 @@ AudioWidget::~AudioWidget() { // mediaPlayerState->setPlaying(false); } namespace { QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { QPixmap pix( img.width(), img.height() ); QPainter p( &pix ); p.drawTiledPixmap( pix.rect(), bg, offset ); p.drawImage( 0, 0, img ); return pix; } QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { QPixmap *pixmap = new QPixmap( pix ); pixmap->setMask( mask ); return pixmap; } }; void AudioWidget::resizeEvent( QResizeEvent * ) { int h = height(); int w = width(); songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); slider.setFixedWidth( w - 110 ); slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); slider.setBackgroundOrigin( QWidget::ParentOrigin ); time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); - xoff = ( w - imgUp.width() ) / 2; - yoff = (( h - imgUp.height() ) / 2) - 10; - QPoint p( xoff, yoff ); + upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2; + upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10; + QPoint p = upperLeftOfButtonMask; QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); for ( int i = 0; i < 10; i++ ) { if ( !masks[i]->isNull() ) { delete buttonPixUp[i]; delete buttonPixDown[i]; buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] ); buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] ); } } } static bool audioSliderBeingMoved = FALSE; void AudioWidget::sliderPressed() { audioSliderBeingMoved = TRUE; } void AudioWidget::sliderReleased() { audioSliderBeingMoved = FALSE; if ( slider.width() == 0 ) return; long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); mediaPlayerState.setPosition( val ); } void AudioWidget::setPosition( long i ) { // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); @@ -313,105 +313,105 @@ void AudioWidget::updateSlider( long i, long max ) { // Scale to something reasonable int width = slider.width(); int val = int((double)i * width / max); if ( !audioSliderBeingMoved ) { if ( slider.value() != val ) { slider.setValue( val ); } if ( slider.maxValue() != width ) { slider.setMaxValue( width ); } } } void AudioWidget::setToggleButton( int i, bool down ) { qDebug("setToggleButton %d", i); if ( down != buttons[i].isDown ) { toggleButton( i ); } } void AudioWidget::toggleButton( int i ) { buttons[i].isDown = !buttons[i].isDown; QPainter p(this); paintButton ( &p, i ); } void AudioWidget::paintButton( QPainter *p, int i ) { if ( buttons[i].isDown ) { - p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); + p->drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] ); } else { - p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); + p->drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] ); } } void AudioWidget::skipFor() { skipDirection = +1; startTimer( 50 ); mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); } void AudioWidget::skipBack() { skipDirection = -1; startTimer( 50 ); mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); } void AudioWidget::stopSkip() { killTimers(); } void AudioWidget::timerEvent( QTimerEvent * ) { if ( skipDirection == +1 ) { mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); } else if ( skipDirection == -1 ) { mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); } } void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { for ( unsigned int i = 0; i < buttons.size(); i++ ) { if ( event->state() == QMouseEvent::LeftButton ) { // The test to see if the mouse click is inside the button or not - int x = event->pos().x() - xoff; - int y = event->pos().y() - yoff; + int x = event->pos().x() - upperLeftOfButtonMask.x(); + int y = event->pos().y() - upperLeftOfButtonMask.y(); bool isOnButton = ( x > 0 && y > 0 && x < buttonMask.width() && y < buttonMask.height() && buttonMask.pixelIndex( x, y ) == i + 1 ); if ( isOnButton && !buttons[i].isHeld ) { buttons[i].isHeld = TRUE; toggleButton(i); switch (i) { case VolumeUp: emit moreClicked(); return; case VolumeDown: emit lessClicked(); return; case Forward: emit forwardClicked(); return; case Back: emit backClicked(); return; } } else if ( !isOnButton && buttons[i].isHeld ) { buttons[i].isHeld = FALSE; toggleButton(i); } } else { if ( buttons[i].isHeld ) { buttons[i].isHeld = FALSE; if ( !buttons[i].isToggle ) { setToggleButton( i, FALSE ); } diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index da22946..acf2dda 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h @@ -78,39 +78,38 @@ signals: protected: void doBlank(); void doUnblank(); void paintEvent( QPaintEvent *pe ); void showEvent( QShowEvent *se ); void resizeEvent( QResizeEvent *re ); void mouseMoveEvent( QMouseEvent *event ); void mousePressEvent( QMouseEvent *event ); void mouseReleaseEvent( QMouseEvent *event ); void timerEvent( QTimerEvent *event ); void keyReleaseEvent( QKeyEvent *e); private slots: void skipFor(); void skipBack(); void stopSkip(); private: void toggleButton( int ); void setToggleButton( int, bool ); void paintButton( QPainter *p, int i ); int skipDirection; QString skin; QPixmap pixBg; QImage imgUp; QImage imgDn; QBitmap *masks[10]; QPixmap *buttonPixUp[10]; QPixmap *buttonPixDown[10]; QPixmap *pixmaps[4]; OTicker songInfo; QSlider slider; QLineEdit time; - int xoff, yoff; bool isStreaming : 1; }; #endif // AUDIO_WIDGET_H diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index 044ab6c..7e6cb3b 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h @@ -42,37 +42,39 @@ public: bool isToggle : 1; bool isHeld : 1; bool isDown : 1; }; typedef std::vector<Button> ButtonVector; MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); virtual ~MediaWidget(); public slots: virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; virtual void setLength( long length ) = 0; virtual void setPlaying( bool playing ) = 0; signals: void moreReleased(); void lessReleased(); void forwardReleased(); void backReleased(); protected: virtual void closeEvent( QCloseEvent * ); void handleCommand( Command command, bool buttonDown ); MediaPlayerState &mediaPlayerState; PlayListWidget &playList; ButtonVector buttons; QImage buttonMask; + + QPoint upperLeftOfButtonMask; }; #endif // MEDIAWIDGET_H /* vim: et sw=4 ts=4 */ diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 459f592..6ab6d7b 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp @@ -151,70 +151,70 @@ VideoWidget::~VideoWidget() { for ( int i = 0; i < 7; i++ ) { delete masks[i]; } } QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { QPixmap pix( img.width(), img.height() ); QPainter p( &pix ); p.drawTiledPixmap( pix.rect(), bg, offset ); p.drawImage( 0, 0, img ); return new QPixmap( pix ); } QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { QPixmap *pixmap = new QPixmap( pix ); pixmap->setMask( mask ); return pixmap; } void VideoWidget::resizeEvent( QResizeEvent * ) { int h = height(); int w = width(); //int Vh = 160; //int Vw = 220; slider->setFixedWidth( w - 20 ); slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); slider->setBackgroundOrigin( QWidget::ParentOrigin ); slider->setFocusPolicy( QWidget::NoFocus ); slider->setBackgroundPixmap( pixBg ); - xoff = 0;// ( imgUp->width() ) / 2; + upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; if(w>h) - yoff = 0; + upperLeftOfButtonMask.ry() = 0; else - yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; - QPoint p( xoff, yoff ); + upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; + QPoint p = upperLeftOfButtonMask; QPixmap *pixUp = combineVImageWithBackground( imgUp, pixBg, p ); QPixmap *pixDn = combineVImageWithBackground( imgDn, pixBg, p ); for ( int i = 0; i < 7; i++ ) { if ( !masks[i]->isNull() ) { delete buttonPixUp[i]; delete buttonPixDown[i]; buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); } } delete pixUp; delete pixDn; } static bool videoSliderBeingMoved = FALSE; void VideoWidget::sliderPressed() { videoSliderBeingMoved = TRUE; } void VideoWidget::sliderReleased() { videoSliderBeingMoved = FALSE; if ( slider->width() == 0 ) { return; } long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); mediaPlayerState.setPosition( val ); } @@ -243,76 +243,76 @@ void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) void VideoWidget::updateSlider( long i, long max ) { // Will flicker too much if we don't do this if ( max == 0 ) { return; } int width = slider->width(); int val = int((double)i * width / max); if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { if ( slider->value() != val ) { slider->setValue( val ); } if ( slider->maxValue() != width ) { slider->setMaxValue( width ); } } } void VideoWidget::setToggleButton( int i, bool down ) { if ( down != buttons[i].isDown ) { toggleButton( i ); } } void VideoWidget::toggleButton( int i ) { buttons[i].isDown = !buttons[i].isDown; QPainter p(this); paintButton ( &p, i ); } void VideoWidget::paintButton( QPainter *p, int i ) { if ( buttons[i].isDown ) { - p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); + p->drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] ); } else { - p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); + p->drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] ); } } void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { for ( unsigned int i = 0; i < buttons.size(); i++ ) { if ( event->state() == QMouseEvent::LeftButton ) { // The test to see if the mouse click is inside the button or not - int x = event->pos().x() - xoff; - int y = event->pos().y() - yoff; + int x = event->pos().x() - upperLeftOfButtonMask.x(); + int y = event->pos().y() - upperLeftOfButtonMask.y(); bool isOnButton = ( x > 0 && y > 0 && x < buttonMask.width() && y < buttonMask.height() && buttonMask.pixelIndex( x, y ) == i + 1 ); if ( isOnButton && !buttons[i].isHeld ) { buttons[i].isHeld = TRUE; toggleButton(i); switch (i) { case VideoVolUp: emit moreClicked(); return; case VideoVolDown: emit lessClicked(); return; } } else if ( !isOnButton && buttons[i].isHeld ) { buttons[i].isHeld = FALSE; toggleButton(i); } } else { if ( buttons[i].isHeld ) { buttons[i].isHeld = FALSE; if ( !buttons[i].isToggle ) { setToggleButton( i, FALSE ); } switch(i) { case VideoPlay: { diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index a5500d7..2a9f1e0 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h @@ -76,52 +76,51 @@ public: virtual void setPlaying( bool b); virtual void setLength( long ); virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); signals: void moreClicked(); void lessClicked(); void moreReleased(); void lessReleased(); void sliderMoved( long ); void videoResized ( const QSize &s ); protected: void resizeEvent( QResizeEvent * ); void paintEvent( QPaintEvent *pe ); void showEvent( QShowEvent *se ); void mouseMoveEvent( QMouseEvent *event ); void mousePressEvent( QMouseEvent *event ); void mouseReleaseEvent( QMouseEvent *event ); void keyReleaseEvent( QKeyEvent *e); private: // Ticker songInfo; QPixmap pixBg; QImage imgUp; QImage imgDn; QBitmap *masks[7]; QPixmap *buttonPixUp[7]; QPixmap *buttonPixDown[7]; QString skin; // QPixmap *pixmaps[4]; - int xoff, yoff; void paintButton( QPainter *p, int i ); void toggleButton( int ); void setToggleButton( int, bool ); QString backgroundPix; QSlider *slider; QPixmap *pixmaps[3]; QImage *currentFrame; int scaledWidth; int scaledHeight; XineVideoWidget* videoFrame; }; #endif // VIDEO_WIDGET_H |