summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-09 14:48:13 (UTC)
committer simon <simon>2002-12-09 14:48:13 (UTC)
commit9ab8a657b23fd1871c4a376fdd097732c14392e0 (patch) (unidiff)
tree5e507bf74fad84ae6da1ed1facc689fd89de167d
parent174c4a427750a3829ffd81a87454be8abf61ee30 (diff)
downloadopie-9ab8a657b23fd1871c4a376fdd097732c14392e0.zip
opie-9ab8a657b23fd1871c4a376fdd097732c14392e0.tar.gz
opie-9ab8a657b23fd1871c4a376fdd097732c14392e0.tar.bz2
- migrating from a button vector to a button map
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp10
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h4
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp21
3 files changed, 18 insertions, 17 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index c148820..12f91a9 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -119,9 +119,9 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
119 line[x] = i + 1; 119 line[x] = i + 1;
120 } 120 }
121 } 121 }
122 122
123 buttons.push_back( button ); 123 buttons.insert( i, button );
124 } 124 }
125 125
126 setBackgroundPixmap( pixBg ); 126 setBackgroundPixmap( pixBg );
127 127
@@ -207,9 +207,9 @@ void AudioWidget::resizeEvent( QResizeEvent * ) {
207 207
208 QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); 208 QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p );
209 QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); 209 QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p );
210 210
211 for ( uint i = 0; i < buttons.size(); i++ ) { 211 for ( uint i = 0; i < buttons.count(); i++ ) {
212 if ( !buttons[i].mask.isNull() ) { 212 if ( !buttons[i].mask.isNull() ) {
213 buttons[i].pixUp = maskPixToMask( pixUp, buttons[i].mask ); 213 buttons[i].pixUp = maskPixToMask( pixUp, buttons[i].mask );
214 buttons[i].pixDown = maskPixToMask( pixDn, buttons[i].mask ); 214 buttons[i].pixDown = maskPixToMask( pixDn, buttons[i].mask );
215 } 215 }
@@ -350,9 +350,9 @@ void AudioWidget::timerEvent( QTimerEvent * ) {
350} 350}
351 351
352 352
353void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 353void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
354 for ( unsigned int i = 0; i < buttons.size(); i++ ) { 354 for ( unsigned int i = 0; i < buttons.count(); i++ ) {
355 if ( event->state() == QMouseEvent::LeftButton ) { 355 if ( event->state() == QMouseEvent::LeftButton ) {
356 // The test to see if the mouse click is inside the button or not 356 // The test to see if the mouse click is inside the button or not
357 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); 357 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i );
358 358
@@ -413,15 +413,15 @@ void AudioWidget::paintEvent( QPaintEvent * pe ) {
413 QPixmap pix( pe->rect().size() ); 413 QPixmap pix( pe->rect().size() );
414 QPainter p( &pix ); 414 QPainter p( &pix );
415 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 415 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
416 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); 416 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() );
417 for ( unsigned int i = 0; i < buttons.size(); i++ ) 417 for ( unsigned int i = 0; i < buttons.count(); i++ )
418 paintButton( p, i ); 418 paintButton( p, i );
419 QPainter p2( this ); 419 QPainter p2( this );
420 p2.drawPixmap( pe->rect().topLeft(), pix ); 420 p2.drawPixmap( pe->rect().topLeft(), pix );
421 } else { 421 } else {
422 QPainter p( this ); 422 QPainter p( this );
423 for ( unsigned int i = 0; i < buttons.size(); i++ ) 423 for ( unsigned int i = 0; i < buttons.count(); i++ )
424 paintButton( p, i ); 424 paintButton( p, i );
425 } 425 }
426} 426}
427 427
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 504b705..49bf024 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -50,8 +50,10 @@ public:
50 QPixmap pixUp; 50 QPixmap pixUp;
51 QPixmap pixDown; 51 QPixmap pixDown;
52 }; 52 };
53 typedef std::vector<Button> ButtonVector; 53 typedef std::vector<Button> ButtonVector;
54 // when the transition is done this should be Command -> Button
55 typedef QMap<int, Button> ButtonMap;
54 56
55 struct SkinButtonInfo 57 struct SkinButtonInfo
56 { 58 {
57 Command command; 59 Command command;
@@ -90,9 +92,9 @@ protected:
90 92
91 MediaPlayerState &mediaPlayerState; 93 MediaPlayerState &mediaPlayerState;
92 PlayListWidget &playList; 94 PlayListWidget &playList;
93 95
94 ButtonVector buttons; 96 ButtonMap buttons;
95 97
96 QImage buttonMask; 98 QImage buttonMask;
97 99
98 QPoint upperLeftOfButtonMask; 100 QPoint upperLeftOfButtonMask;
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 380c703..7d85d63 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -73,16 +73,15 @@ VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
73 Button defaultButton; 73 Button defaultButton;
74 Button toggleButton = defaultButton; 74 Button toggleButton = defaultButton;
75 toggleButton.type = ToggleButton; 75 toggleButton.type = ToggleButton;
76 76
77 buttons.reserve( 7 ); 77 buttons.insert( 0, toggleButton ); // play
78 buttons.push_back( toggleButton ); // play 78 buttons.insert( 1, toggleButton ); // stop
79 buttons.push_back( defaultButton ); // stop 79 buttons.insert( 2, toggleButton ); // next
80 buttons.push_back( defaultButton ); // next 80 buttons.insert( 3, toggleButton ); // previous
81 buttons.push_back( defaultButton ); // previous 81 buttons.insert( 4, toggleButton ); // volUp
82 buttons.push_back( defaultButton ); // volUp 82 buttons.insert( 5, toggleButton ); // volDown
83 buttons.push_back( defaultButton ); // volDown 83 buttons.insert( 6, toggleButton ); // fullscreen
84 buttons.push_back( toggleButton ); //fullscreen
85 84
86 videoFrame = new XineVideoWidget ( this, "Video frame" ); 85 videoFrame = new XineVideoWidget ( this, "Video frame" );
87 86
88 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 87 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
@@ -270,9 +269,9 @@ void VideoWidget::paintButton( QPainter &p, int i ) {
270 } 269 }
271} 270}
272 271
273void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 272void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
274 for ( unsigned int i = 0; i < buttons.size(); i++ ) { 273 for ( unsigned int i = 0; i < buttons.count(); i++ ) {
275 if ( event->state() == QMouseEvent::LeftButton ) { 274 if ( event->state() == QMouseEvent::LeftButton ) {
276 // The test to see if the mouse click is inside the button or not 275 // The test to see if the mouse click is inside the button or not
277 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); 276 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i );
278 277
@@ -412,16 +411,16 @@ void VideoWidget::paintEvent( QPaintEvent * pe) {
412 QPixmap pix( pe->rect().size() ); 411 QPixmap pix( pe->rect().size() );
413 QPainter p( &pix ); 412 QPainter p( &pix );
414 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 413 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
415 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); 414 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() );
416 for ( unsigned int i = 0; i < buttons.size(); i++ ) { 415 for ( unsigned int i = 0; i < buttons.count(); i++ ) {
417 paintButton( p, i ); 416 paintButton( p, i );
418 } 417 }
419 QPainter p2( this ); 418 QPainter p2( this );
420 p2.drawPixmap( pe->rect().topLeft(), pix ); 419 p2.drawPixmap( pe->rect().topLeft(), pix );
421 } else { 420 } else {
422 QPainter p( this ); 421 QPainter p( this );
423 for ( unsigned int i = 0; i < buttons.size(); i++ ) 422 for ( unsigned int i = 0; i < buttons.count(); i++ )
424 paintButton( p, i ); 423 paintButton( p, i );
425 } 424 }
426 //slider->repaint( TRUE ); 425 //slider->repaint( TRUE );
427 } 426 }