summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-11 13:46:15 (UTC)
committer simon <simon>2002-12-11 13:46:15 (UTC)
commit2b3c450378c1da0a2175c91d652ce2eae5614ff8 (patch) (unidiff)
tree4c11c70dbf487725f6e443f5db4c5a0a0c964e61
parentcd5e96b40ceae9158e5cb01e71769e895ea7a3c1 (diff)
downloadopie-2b3c450378c1da0a2175c91d652ce2eae5614ff8.zip
opie-2b3c450378c1da0a2175c91d652ce2eae5614ff8.tar.gz
opie-2b3c450378c1da0a2175c91d652ce2eae5614ff8.tar.bz2
- less code duplication. code from resizeEvent is now shared as well as
the image composing method and the pixmap mask helper
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp13
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp33
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h5
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp32
4 files changed, 42 insertions, 41 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index bb686f1..bb07882 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -132,3 +132,3 @@ QPixmap maskPixToMask( QPixmap pix, QBitmap mask ) {
132 132
133void AudioWidget::resizeEvent( QResizeEvent * ) { 133void AudioWidget::resizeEvent( QResizeEvent *e ) {
134 int h = height(); 134 int h = height();
@@ -144,13 +144,4 @@ void AudioWidget::resizeEvent( QResizeEvent * ) {
144 upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10; 144 upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10;
145 QPoint p = upperLeftOfButtonMask;
146 145
147 QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, p ); 146 MediaWidget::resizeEvent( e );
148 QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, p );
149
150 for ( uint i = 0; i < buttons.size(); i++ ) {
151 if ( !buttons[i].mask.isNull() ) {
152 buttons[i].pixUp = maskPixToMask( pixUp, buttons[i].mask );
153 buttons[i].pixDown = maskPixToMask( pixDn, buttons[i].mask );
154 }
155 }
156} 147}
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index ab23aa8..ab2ec50 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -111,2 +111,19 @@ void MediaWidget::paintEvent( QPaintEvent *pe )
111 111
112void MediaWidget::resizeEvent( QResizeEvent *e )
113{
114 QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask );
115 QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask );
116
117 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
118 Button &button = *it;
119
120 if ( button.mask.isNull() )
121 continue;
122 button.pixUp = addMaskToPixmap( pixUp, button.mask );
123 button.pixDown = addMaskToPixmap( pixDn, button.mask );
124 }
125
126 QWidget::resizeEvent( e );
127}
128
112MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) 129MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position )
@@ -232,2 +249,18 @@ void MediaWidget::toggleButton( Button &button )
232 249
250QPixmap MediaWidget::combineImageWithBackground( const QImage &image, const QPixmap &background, const QPoint &offset )
251{
252 QPixmap pix( image.size() );
253 QPainter p( &pix );
254 p.drawTiledPixmap( pix.rect(), background, offset );
255 p.drawImage( 0, 0, image );
256 return pix;
257}
258
259QPixmap MediaWidget::addMaskToPixmap( const QPixmap &pix, const QBitmap &mask )
260{
261 QPixmap result( pix );
262 result.setMask( mask );
263 return result;
264}
265
233/* vim: et sw=4 ts=4 266/* vim: et sw=4 ts=4
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 9f13677..4599637 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -114,2 +114,4 @@ protected:
114 114
115 virtual void resizeEvent( QResizeEvent *e );
116
115 Button *buttonAt( const QPoint &position ); 117 Button *buttonAt( const QPoint &position );
@@ -145,2 +147,5 @@ protected:
145 QImage buttonDownImage; 147 QImage buttonDownImage;
148
149 static QPixmap combineImageWithBackground( const QImage &background, const QPixmap &pixmap, const QPoint &offset );
150 static QPixmap addMaskToPixmap( const QPixmap &pix, const QBitmap &mask );
146}; 151};
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index bc47717..a8ff540 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -101,17 +101,3 @@ VideoWidget::~VideoWidget()
101 101
102QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 102void VideoWidget::resizeEvent( QResizeEvent *e ) {
103 QPixmap pix( img.width(), img.height() );
104 QPainter p( &pix );
105 p.drawTiledPixmap( pix.rect(), bg, offset );
106 p.drawImage( 0, 0, img );
107 return new QPixmap( pix );
108}
109
110QPixmap maskVPixToMask( QPixmap pix, QBitmap mask ) {
111 QPixmap pixmap( pix );
112 pixmap.setMask( mask );
113 return pixmap;
114}
115
116void VideoWidget::resizeEvent( QResizeEvent * ) {
117 int h = height(); 103 int h = height();
@@ -132,18 +118,4 @@ void VideoWidget::resizeEvent( QResizeEvent * ) {
132 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; 118 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10;
133 QPoint p = upperLeftOfButtonMask;
134
135 QPixmap *pixUp = combineVImageWithBackground( buttonUpImage, backgroundPixmap, p );
136 QPixmap *pixDn = combineVImageWithBackground( buttonDownImage, backgroundPixmap, p );
137
138 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
139 Button &button = *it;
140
141 if ( !button.mask.isNull() ) {
142 button.pixUp = maskVPixToMask( *pixUp, button.mask );
143 button.pixDown = maskVPixToMask( *pixDn, button.mask );
144 }
145 }
146 119
147 delete pixUp; 120 MediaWidget::resizeEvent( e );
148 delete pixDn;
149} 121}