summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-09 15:04:10 (UTC)
committer simon <simon>2002-12-09 15:04:10 (UTC)
commitdcc1922ecb8c6816e4ae9ba7973f8653e482b2aa (patch) (unidiff)
tree5ff73aaf1ac1c59cde2e9ddafe8cebcddb162158
parentd3451a94e3a4425f9f1b1dcc3999259270780631 (diff)
downloadopie-dcc1922ecb8c6816e4ae9ba7973f8653e482b2aa.zip
opie-dcc1922ecb8c6816e4ae9ba7973f8653e482b2aa.tar.gz
opie-dcc1922ecb8c6816e4ae9ba7973f8653e482b2aa.tar.bz2
- getting rid of the buttonPixUp/Down arrays, reuse the Button structure
instead
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp32
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h2
2 files changed, 12 insertions, 22 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 089ef6a..3baa087 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -109,64 +109,56 @@ VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
109 QImage imgMask = button.mask.convertToImage(); 109 QImage imgMask = button.mask.convertToImage();
110 uchar **dest = buttonMask.jumpTable(); 110 uchar **dest = buttonMask.jumpTable();
111 for ( int y = 0; y < imgUp.height(); y++ ) { 111 for ( int y = 0; y < imgUp.height(); y++ ) {
112 uchar *line = dest[y]; 112 uchar *line = dest[y];
113 for ( int x = 0; x < imgUp.width(); x++ ) { 113 for ( int x = 0; x < imgUp.width(); x++ ) {
114 if ( !qRed( imgMask.pixel( x, y ) ) ) 114 if ( !qRed( imgMask.pixel( x, y ) ) )
115 line[x] = i + 1; 115 line[x] = i + 1;
116 } 116 }
117 } 117 }
118 } 118 }
119 } 119 }
120 120
121 for ( int i = 0; i < 7; i++ ) {
122 buttonPixUp[i] = NULL;
123 buttonPixDown[i] = NULL;
124 }
125
126 setBackgroundPixmap( pixBg ); 121 setBackgroundPixmap( pixBg );
127 122
128 slider = new QSlider( Qt::Horizontal, this ); 123 slider = new QSlider( Qt::Horizontal, this );
129 slider->setMinValue( 0 ); 124 slider->setMinValue( 0 );
130 slider->setMaxValue( 1 ); 125 slider->setMaxValue( 1 );
131 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 126 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
132 //slider->setFocusPolicy( QWidget::NoFocus ); 127 //slider->setFocusPolicy( QWidget::NoFocus );
133 128
134 resizeEvent( NULL ); 129 resizeEvent( NULL );
135 130
136 setLength( mediaPlayerState.length() ); 131 setLength( mediaPlayerState.length() );
137 setPosition( mediaPlayerState.position() ); 132 setPosition( mediaPlayerState.position() );
138 setFullscreen( mediaPlayerState.isFullscreen() ); 133 setFullscreen( mediaPlayerState.isFullscreen() );
139 setPlaying( mediaPlayerState.isPlaying() ); 134 setPlaying( mediaPlayerState.isPlaying() );
140} 135}
141 136
142 137
143VideoWidget::~VideoWidget() { 138VideoWidget::~VideoWidget()
144 for ( int i = 0; i < 7; i++ ) { 139{
145 delete buttonPixUp[i];
146 delete buttonPixDown[i];
147 }
148} 140}
149 141
150QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 142QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
151 QPixmap pix( img.width(), img.height() ); 143 QPixmap pix( img.width(), img.height() );
152 QPainter p( &pix ); 144 QPainter p( &pix );
153 p.drawTiledPixmap( pix.rect(), bg, offset ); 145 p.drawTiledPixmap( pix.rect(), bg, offset );
154 p.drawImage( 0, 0, img ); 146 p.drawImage( 0, 0, img );
155 return new QPixmap( pix ); 147 return new QPixmap( pix );
156} 148}
157 149
158QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { 150QPixmap maskVPixToMask( QPixmap pix, QBitmap mask ) {
159 QPixmap *pixmap = new QPixmap( pix ); 151 QPixmap pixmap( pix );
160 pixmap->setMask( mask ); 152 pixmap.setMask( mask );
161 return pixmap; 153 return pixmap;
162} 154}
163 155
164void VideoWidget::resizeEvent( QResizeEvent * ) { 156void VideoWidget::resizeEvent( QResizeEvent * ) {
165 int h = height(); 157 int h = height();
166 int w = width(); 158 int w = width();
167 //int Vh = 160; 159 //int Vh = 160;
168 //int Vw = 220; 160 //int Vw = 220;
169 161
170 slider->setFixedWidth( w - 20 ); 162 slider->setFixedWidth( w - 20 );
171 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 163 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
172 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 164 slider->setBackgroundOrigin( QWidget::ParentOrigin );
@@ -178,28 +170,26 @@ void VideoWidget::resizeEvent( QResizeEvent * ) {
178 upperLeftOfButtonMask.ry() = 0; 170 upperLeftOfButtonMask.ry() = 0;
179 else 171 else
180 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; 172 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10;
181 QPoint p = upperLeftOfButtonMask; 173 QPoint p = upperLeftOfButtonMask;
182 174
183 QPixmap *pixUp = combineVImageWithBackground( imgUp, pixBg, p ); 175 QPixmap *pixUp = combineVImageWithBackground( imgUp, pixBg, p );
184 QPixmap *pixDn = combineVImageWithBackground( imgDn, pixBg, p ); 176 QPixmap *pixDn = combineVImageWithBackground( imgDn, pixBg, p );
185 177
186 for ( int i = 0; i < 7; i++ ) { 178 for ( int i = 0; i < 7; i++ ) {
187 Button &button = buttons[ i ]; 179 Button &button = buttons[ i ];
188 180
189 if ( !button.mask.isNull() ) { 181 if ( !button.mask.isNull() ) {
190 delete buttonPixUp[i]; 182 button.pixUp = maskVPixToMask( *pixUp, button.mask );
191 delete buttonPixDown[i]; 183 button.pixDown = maskVPixToMask( *pixDn, button.mask );
192 buttonPixUp[i] = maskVPixToMask( *pixUp, button.mask );
193 buttonPixDown[i] = maskVPixToMask( *pixDn, button.mask );
194 } 184 }
195 } 185 }
196 186
197 delete pixUp; 187 delete pixUp;
198 delete pixDn; 188 delete pixDn;
199} 189}
200 190
201static bool videoSliderBeingMoved = FALSE; 191static bool videoSliderBeingMoved = FALSE;
202 192
203void VideoWidget::sliderPressed() { 193void VideoWidget::sliderPressed() {
204 videoSliderBeingMoved = TRUE; 194 videoSliderBeingMoved = TRUE;
205} 195}
@@ -251,28 +241,30 @@ void VideoWidget::updateSlider( long i, long max ) {
251 } 241 }
252 } 242 }
253} 243}
254 244
255void VideoWidget::setToggleButton( int i, bool down ) { 245void VideoWidget::setToggleButton( int i, bool down ) {
256 if ( down != buttons[i].isDown ) { 246 if ( down != buttons[i].isDown ) {
257 toggleButton( i ); 247 toggleButton( i );
258 } 248 }
259} 249}
260 250
261void VideoWidget::paintButton( QPainter &p, int i ) { 251void VideoWidget::paintButton( QPainter &p, int i ) {
262 252
263 if ( buttons[i].isDown ) { 253 Button &button = buttons[ i ];
264 p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] ); 254
255 if ( button.isDown ) {
256 p.drawPixmap( upperLeftOfButtonMask, button.pixDown );
265 } else { 257 } else {
266 p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] ); 258 p.drawPixmap( upperLeftOfButtonMask, button.pixUp );
267 } 259 }
268} 260}
269 261
270void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 262void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
271 for ( unsigned int i = 0; i < buttons.count(); i++ ) { 263 for ( unsigned int i = 0; i < buttons.count(); i++ ) {
272 if ( event->state() == QMouseEvent::LeftButton ) { 264 if ( event->state() == QMouseEvent::LeftButton ) {
273 // The test to see if the mouse click is inside the button or not 265 // The test to see if the mouse click is inside the button or not
274 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); 266 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i );
275 267
276 if ( isOnButton && !buttons[i].isHeld ) { 268 if ( isOnButton && !buttons[i].isHeld ) {
277 buttons[i].isHeld = TRUE; 269 buttons[i].isHeld = TRUE;
278 toggleButton(i); 270 toggleButton(i);
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index fd301f9..aeb6429 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -91,26 +91,24 @@ protected:
91 void paintEvent( QPaintEvent *pe ); 91 void paintEvent( QPaintEvent *pe );
92 void showEvent( QShowEvent *se ); 92 void showEvent( QShowEvent *se );
93 void mouseMoveEvent( QMouseEvent *event ); 93 void mouseMoveEvent( QMouseEvent *event );
94 void mousePressEvent( QMouseEvent *event ); 94 void mousePressEvent( QMouseEvent *event );
95 void mouseReleaseEvent( QMouseEvent *event ); 95 void mouseReleaseEvent( QMouseEvent *event );
96 void keyReleaseEvent( QKeyEvent *e); 96 void keyReleaseEvent( QKeyEvent *e);
97 97
98private: 98private:
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 QPixmap *buttonPixUp[7];
104 QPixmap *buttonPixDown[7];
105 QString skin; 103 QString skin;
106 104
107 105
108 virtual void paintButton( QPainter &p, int i ); 106 virtual void paintButton( QPainter &p, int i );
109 void setToggleButton( int, bool ); 107 void setToggleButton( int, bool );
110 108
111 QString backgroundPix; 109 QString backgroundPix;
112 QSlider *slider; 110 QSlider *slider;
113 QPixmap *pixmaps[3]; 111 QPixmap *pixmaps[3];
114 QImage *currentFrame; 112 QImage *currentFrame;
115 int scaledWidth; 113 int scaledWidth;
116 int scaledHeight; 114 int scaledHeight;