author | simon <simon> | 2002-12-08 22:39:53 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-08 22:39:53 (UTC) |
commit | 8b72df0bb25ca5a0791756b2444fc6a1ce361082 (patch) (unidiff) | |
tree | 19a7b23fe1d5256d461fe988ba82c359d75a8caf | |
parent | bada5d6377a428a96527d465903df7fbabc9d337 (diff) | |
download | opie-8b72df0bb25ca5a0791756b2444fc6a1ce361082.zip opie-8b72df0bb25ca5a0791756b2444fc6a1ce361082.tar.gz opie-8b72df0bb25ca5a0791756b2444fc6a1ce361082.tar.bz2 |
- merged xoff/yoff into a QPointe member variable, shared in the base class
-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 | |||
@@ -206,27 +206,27 @@ QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { | |||
206 | }; | 206 | }; |
207 | 207 | ||
208 | void AudioWidget::resizeEvent( QResizeEvent * ) { | 208 | void AudioWidget::resizeEvent( QResizeEvent * ) { |
209 | int h = height(); | 209 | int h = height(); |
210 | int w = width(); | 210 | int w = width(); |
211 | 211 | ||
212 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); | 212 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); |
213 | slider.setFixedWidth( w - 110 ); | 213 | slider.setFixedWidth( w - 110 ); |
214 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 214 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
215 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 215 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
216 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 216 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
217 | 217 | ||
218 | xoff = ( w - imgUp.width() ) / 2; | 218 | upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2; |
219 | yoff = (( h - imgUp.height() ) / 2) - 10; | 219 | upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10; |
220 | QPoint p( xoff, yoff ); | 220 | QPoint p = upperLeftOfButtonMask; |
221 | 221 | ||
222 | QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); | 222 | QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); |
223 | QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); | 223 | QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); |
224 | 224 | ||
225 | for ( int i = 0; i < 10; i++ ) { | 225 | for ( int i = 0; i < 10; i++ ) { |
226 | if ( !masks[i]->isNull() ) { | 226 | if ( !masks[i]->isNull() ) { |
227 | delete buttonPixUp[i]; | 227 | delete buttonPixUp[i]; |
228 | delete buttonPixDown[i]; | 228 | delete buttonPixDown[i]; |
229 | buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] ); | 229 | buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] ); |
230 | buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] ); | 230 | buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] ); |
231 | } | 231 | } |
232 | } | 232 | } |
@@ -333,27 +333,27 @@ void AudioWidget::setToggleButton( int i, bool down ) { | |||
333 | } | 333 | } |
334 | 334 | ||
335 | 335 | ||
336 | void AudioWidget::toggleButton( int i ) { | 336 | void AudioWidget::toggleButton( int i ) { |
337 | buttons[i].isDown = !buttons[i].isDown; | 337 | buttons[i].isDown = !buttons[i].isDown; |
338 | QPainter p(this); | 338 | QPainter p(this); |
339 | paintButton ( &p, i ); | 339 | paintButton ( &p, i ); |
340 | } | 340 | } |
341 | 341 | ||
342 | 342 | ||
343 | void AudioWidget::paintButton( QPainter *p, int i ) { | 343 | void AudioWidget::paintButton( QPainter *p, int i ) { |
344 | if ( buttons[i].isDown ) { | 344 | if ( buttons[i].isDown ) { |
345 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 345 | p->drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] ); |
346 | } else { | 346 | } else { |
347 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 347 | p->drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] ); |
348 | } | 348 | } |
349 | } | 349 | } |
350 | 350 | ||
351 | 351 | ||
352 | void AudioWidget::skipFor() { | 352 | void AudioWidget::skipFor() { |
353 | skipDirection = +1; | 353 | skipDirection = +1; |
354 | startTimer( 50 ); | 354 | startTimer( 50 ); |
355 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 355 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
356 | } | 356 | } |
357 | 357 | ||
358 | void AudioWidget::skipBack() { | 358 | void AudioWidget::skipBack() { |
359 | skipDirection = -1; | 359 | skipDirection = -1; |
@@ -372,26 +372,26 @@ void AudioWidget::timerEvent( QTimerEvent * ) { | |||
372 | if ( skipDirection == +1 ) { | 372 | if ( skipDirection == +1 ) { |
373 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 373 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
374 | } else if ( skipDirection == -1 ) { | 374 | } else if ( skipDirection == -1 ) { |
375 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 375 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
376 | } | 376 | } |
377 | } | 377 | } |
378 | 378 | ||
379 | 379 | ||
380 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 380 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
381 | for ( unsigned int i = 0; i < buttons.size(); i++ ) { | 381 | for ( unsigned int i = 0; i < buttons.size(); i++ ) { |
382 | if ( event->state() == QMouseEvent::LeftButton ) { | 382 | if ( event->state() == QMouseEvent::LeftButton ) { |
383 | // The test to see if the mouse click is inside the button or not | 383 | // The test to see if the mouse click is inside the button or not |
384 | int x = event->pos().x() - xoff; | 384 | int x = event->pos().x() - upperLeftOfButtonMask.x(); |
385 | int y = event->pos().y() - yoff; | 385 | int y = event->pos().y() - upperLeftOfButtonMask.y(); |
386 | 386 | ||
387 | bool isOnButton = ( x > 0 && y > 0 && x < buttonMask.width() | 387 | bool isOnButton = ( x > 0 && y > 0 && x < buttonMask.width() |
388 | && y < buttonMask.height() | 388 | && y < buttonMask.height() |
389 | && buttonMask.pixelIndex( x, y ) == i + 1 ); | 389 | && buttonMask.pixelIndex( x, y ) == i + 1 ); |
390 | 390 | ||
391 | if ( isOnButton && !buttons[i].isHeld ) { | 391 | if ( isOnButton && !buttons[i].isHeld ) { |
392 | buttons[i].isHeld = TRUE; | 392 | buttons[i].isHeld = TRUE; |
393 | toggleButton(i); | 393 | toggleButton(i); |
394 | switch (i) { | 394 | switch (i) { |
395 | case VolumeUp: | 395 | case VolumeUp: |
396 | emit moreClicked(); | 396 | emit moreClicked(); |
397 | return; | 397 | return; |
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 | |||
@@ -98,19 +98,18 @@ private: | |||
98 | QString skin; | 98 | QString skin; |
99 | QPixmap pixBg; | 99 | QPixmap pixBg; |
100 | QImage imgUp; | 100 | QImage imgUp; |
101 | QImage imgDn; | 101 | QImage imgDn; |
102 | QBitmap *masks[10]; | 102 | QBitmap *masks[10]; |
103 | QPixmap *buttonPixUp[10]; | 103 | QPixmap *buttonPixUp[10]; |
104 | QPixmap *buttonPixDown[10]; | 104 | QPixmap *buttonPixDown[10]; |
105 | 105 | ||
106 | QPixmap *pixmaps[4]; | 106 | QPixmap *pixmaps[4]; |
107 | OTicker songInfo; | 107 | OTicker songInfo; |
108 | QSlider slider; | 108 | QSlider slider; |
109 | QLineEdit time; | 109 | QLineEdit time; |
110 | int xoff, yoff; | ||
111 | bool isStreaming : 1; | 110 | bool isStreaming : 1; |
112 | }; | 111 | }; |
113 | 112 | ||
114 | 113 | ||
115 | #endif // AUDIO_WIDGET_H | 114 | #endif // AUDIO_WIDGET_H |
116 | 115 | ||
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 | |||
@@ -62,17 +62,19 @@ signals: | |||
62 | 62 | ||
63 | protected: | 63 | protected: |
64 | virtual void closeEvent( QCloseEvent * ); | 64 | virtual void closeEvent( QCloseEvent * ); |
65 | 65 | ||
66 | void handleCommand( Command command, bool buttonDown ); | 66 | void handleCommand( Command command, bool buttonDown ); |
67 | 67 | ||
68 | MediaPlayerState &mediaPlayerState; | 68 | MediaPlayerState &mediaPlayerState; |
69 | PlayListWidget &playList; | 69 | PlayListWidget &playList; |
70 | 70 | ||
71 | ButtonVector buttons; | 71 | ButtonVector buttons; |
72 | 72 | ||
73 | QImage buttonMask; | 73 | QImage buttonMask; |
74 | |||
75 | QPoint upperLeftOfButtonMask; | ||
74 | }; | 76 | }; |
75 | 77 | ||
76 | #endif // MEDIAWIDGET_H | 78 | #endif // MEDIAWIDGET_H |
77 | /* vim: et sw=4 ts=4 | 79 | /* vim: et sw=4 ts=4 |
78 | */ | 80 | */ |
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 | |||
@@ -171,30 +171,30 @@ QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { | |||
171 | void VideoWidget::resizeEvent( QResizeEvent * ) { | 171 | void VideoWidget::resizeEvent( QResizeEvent * ) { |
172 | int h = height(); | 172 | int h = height(); |
173 | int w = width(); | 173 | int w = width(); |
174 | //int Vh = 160; | 174 | //int Vh = 160; |
175 | //int Vw = 220; | 175 | //int Vw = 220; |
176 | 176 | ||
177 | slider->setFixedWidth( w - 20 ); | 177 | slider->setFixedWidth( w - 20 ); |
178 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 178 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
179 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 179 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
180 | slider->setFocusPolicy( QWidget::NoFocus ); | 180 | slider->setFocusPolicy( QWidget::NoFocus ); |
181 | slider->setBackgroundPixmap( pixBg ); | 181 | slider->setBackgroundPixmap( pixBg ); |
182 | 182 | ||
183 | xoff = 0;// ( imgUp->width() ) / 2; | 183 | upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; |
184 | if(w>h) | 184 | if(w>h) |
185 | yoff = 0; | 185 | upperLeftOfButtonMask.ry() = 0; |
186 | else | 186 | else |
187 | yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; | 187 | upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; |
188 | QPoint p( xoff, yoff ); | 188 | QPoint p = upperLeftOfButtonMask; |
189 | 189 | ||
190 | QPixmap *pixUp = combineVImageWithBackground( imgUp, pixBg, p ); | 190 | QPixmap *pixUp = combineVImageWithBackground( imgUp, pixBg, p ); |
191 | QPixmap *pixDn = combineVImageWithBackground( imgDn, pixBg, p ); | 191 | QPixmap *pixDn = combineVImageWithBackground( imgDn, pixBg, p ); |
192 | 192 | ||
193 | for ( int i = 0; i < 7; i++ ) { | 193 | for ( int i = 0; i < 7; i++ ) { |
194 | if ( !masks[i]->isNull() ) { | 194 | if ( !masks[i]->isNull() ) { |
195 | delete buttonPixUp[i]; | 195 | delete buttonPixUp[i]; |
196 | delete buttonPixDown[i]; | 196 | delete buttonPixDown[i]; |
197 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); | 197 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); |
198 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); | 198 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); |
199 | } | 199 | } |
200 | } | 200 | } |
@@ -263,36 +263,36 @@ void VideoWidget::setToggleButton( int i, bool down ) { | |||
263 | } | 263 | } |
264 | } | 264 | } |
265 | 265 | ||
266 | void VideoWidget::toggleButton( int i ) { | 266 | void VideoWidget::toggleButton( int i ) { |
267 | buttons[i].isDown = !buttons[i].isDown; | 267 | buttons[i].isDown = !buttons[i].isDown; |
268 | QPainter p(this); | 268 | QPainter p(this); |
269 | paintButton ( &p, i ); | 269 | paintButton ( &p, i ); |
270 | } | 270 | } |
271 | 271 | ||
272 | void VideoWidget::paintButton( QPainter *p, int i ) { | 272 | void VideoWidget::paintButton( QPainter *p, int i ) { |
273 | 273 | ||
274 | if ( buttons[i].isDown ) { | 274 | if ( buttons[i].isDown ) { |
275 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 275 | p->drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] ); |
276 | } else { | 276 | } else { |
277 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 277 | p->drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] ); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | 280 | ||
281 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 281 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
282 | for ( unsigned int i = 0; i < buttons.size(); i++ ) { | 282 | for ( unsigned int i = 0; i < buttons.size(); i++ ) { |
283 | if ( event->state() == QMouseEvent::LeftButton ) { | 283 | if ( event->state() == QMouseEvent::LeftButton ) { |
284 | // The test to see if the mouse click is inside the button or not | 284 | // The test to see if the mouse click is inside the button or not |
285 | int x = event->pos().x() - xoff; | 285 | int x = event->pos().x() - upperLeftOfButtonMask.x(); |
286 | int y = event->pos().y() - yoff; | 286 | int y = event->pos().y() - upperLeftOfButtonMask.y(); |
287 | 287 | ||
288 | bool isOnButton = ( x > 0 && y > 0 && x < buttonMask.width() | 288 | bool isOnButton = ( x > 0 && y > 0 && x < buttonMask.width() |
289 | && y < buttonMask.height() | 289 | && y < buttonMask.height() |
290 | && buttonMask.pixelIndex( x, y ) == i + 1 ); | 290 | && buttonMask.pixelIndex( x, y ) == i + 1 ); |
291 | 291 | ||
292 | if ( isOnButton && !buttons[i].isHeld ) { | 292 | if ( isOnButton && !buttons[i].isHeld ) { |
293 | buttons[i].isHeld = TRUE; | 293 | buttons[i].isHeld = TRUE; |
294 | toggleButton(i); | 294 | toggleButton(i); |
295 | 295 | ||
296 | switch (i) { | 296 | switch (i) { |
297 | case VideoVolUp: | 297 | case VideoVolUp: |
298 | emit moreClicked(); | 298 | emit moreClicked(); |
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 | |||
@@ -96,25 +96,24 @@ protected: | |||
96 | void keyReleaseEvent( QKeyEvent *e); | 96 | void keyReleaseEvent( QKeyEvent *e); |
97 | 97 | ||
98 | private: | 98 | private: |
99 | // Ticker songInfo; | 99 | // Ticker songInfo; |
100 | QPixmap pixBg; | 100 | QPixmap pixBg; |
101 | QImage imgUp; | 101 | QImage imgUp; |
102 | QImage imgDn; | 102 | QImage imgDn; |
103 | QBitmap *masks[7]; | 103 | QBitmap *masks[7]; |
104 | QPixmap *buttonPixUp[7]; | 104 | QPixmap *buttonPixUp[7]; |
105 | QPixmap *buttonPixDown[7]; | 105 | QPixmap *buttonPixDown[7]; |
106 | QString skin; | 106 | QString skin; |
107 | // QPixmap *pixmaps[4]; | 107 | // QPixmap *pixmaps[4]; |
108 | int xoff, yoff; | ||
109 | 108 | ||
110 | 109 | ||
111 | void paintButton( QPainter *p, int i ); | 110 | void paintButton( QPainter *p, int i ); |
112 | void toggleButton( int ); | 111 | void toggleButton( int ); |
113 | void setToggleButton( int, bool ); | 112 | void setToggleButton( int, bool ); |
114 | 113 | ||
115 | QString backgroundPix; | 114 | QString backgroundPix; |
116 | QSlider *slider; | 115 | QSlider *slider; |
117 | QPixmap *pixmaps[3]; | 116 | QPixmap *pixmaps[3]; |
118 | QImage *currentFrame; | 117 | QImage *currentFrame; |
119 | int scaledWidth; | 118 | int scaledWidth; |
120 | int scaledHeight; | 119 | int scaledHeight; |