author | llornkcor <llornkcor> | 2002-08-10 17:41:15 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-08-10 17:41:15 (UTC) |
commit | b488752cf2149443dcebcc8f7ad21c1ba47070fa (patch) (unidiff) | |
tree | 461adc8345f14d495466e5082f36651a844bde67 /noncore/multimedia/opieplayer2/xinevideowidget.cpp | |
parent | fb46a101bab9348ebfb68094b7c6cf54e56ea774 (diff) | |
download | opie-b488752cf2149443dcebcc8f7ad21c1ba47070fa.zip opie-b488752cf2149443dcebcc8f7ad21c1ba47070fa.tar.gz opie-b488752cf2149443dcebcc8f7ad21c1ba47070fa.tar.bz2 |
added skins to videowidget, fixed fullscreen menu. Still needs work on buttonmask.
Diffstat (limited to 'noncore/multimedia/opieplayer2/xinevideowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.cpp | 323 |
1 files changed, 162 insertions, 161 deletions
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp index 98446a0..d65006b 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp +++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <qgfx_qws.h> | 39 | #include <qgfx_qws.h> |
40 | #include <qsize.h> | 40 | #include <qsize.h> |
41 | #include <qapplication.h> | 41 | #include <qapplication.h> |
42 | #include <qpainter.h> | ||
42 | 43 | ||
43 | #include <qpe/resource.h> | 44 | #include <qpe/resource.h> |
44 | 45 | ||
@@ -47,221 +48,221 @@ | |||
47 | 48 | ||
48 | static inline void memcpy_rev ( void *dst, void *src, size_t len ) | 49 | static inline void memcpy_rev ( void *dst, void *src, size_t len ) |
49 | { | 50 | { |
50 | ((char *) src ) += len; | 51 | ((char *) src ) += len; |
51 | 52 | ||
52 | len >>= 1; | 53 | len >>= 1; |
53 | while ( len-- ) | 54 | while ( len-- ) |
54 | *((short int *) dst )++ = *--((short int *) src ); | 55 | *((short int *) dst )++ = *--((short int *) src ); |
55 | } | 56 | } |
56 | 57 | ||
57 | static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) | 58 | static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) |
58 | { | 59 | { |
59 | len >>= 1; | 60 | len >>= 1; |
60 | while ( len-- ) { | 61 | while ( len-- ) { |
61 | *((short int *) dst )++ = *((short int *) src ); | 62 | *((short int *) dst )++ = *((short int *) src ); |
62 | ((char *) src ) += step; | 63 | ((char *) src ) += step; |
63 | } | 64 | } |
64 | } | 65 | } |
65 | 66 | ||
66 | static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) | 67 | static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) |
67 | { | 68 | { |
68 | len >>= 1; | 69 | len >>= 1; |
69 | 70 | ||
70 | ((char *) src ) += ( len * step ); | 71 | ((char *) src ) += ( len * step ); |
71 | 72 | ||
72 | while ( len-- ) { | 73 | while ( len-- ) { |
73 | ((char *) src ) -= step; | 74 | ((char *) src ) -= step; |
74 | *((short int *) dst )++ = *((short int *) src ); | 75 | *((short int *) dst )++ = *((short int *) src ); |
75 | } | 76 | } |
76 | } | 77 | } |
77 | 78 | ||
78 | 79 | ||
79 | XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) | 80 | XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) |
80 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) | 81 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) |
81 | { | 82 | { |
82 | setBackgroundMode ( NoBackground ); | 83 | setBackgroundMode ( NoBackground ); |
83 | 84 | ||
84 | m_image = 0; | 85 | m_image = 0; |
85 | m_buff = 0; | 86 | m_buff = 0; |
86 | m_bytes_per_line_fb = qt_screen-> linestep ( ); | 87 | m_bytes_per_line_fb = qt_screen-> linestep ( ); |
87 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; | 88 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; |
88 | m_rotation = 0; | 89 | m_rotation = 0; |
89 | } | 90 | } |
90 | 91 | ||
91 | 92 | ||
92 | XineVideoWidget::~XineVideoWidget ( ) | 93 | XineVideoWidget::~XineVideoWidget ( ) |
93 | { | 94 | { |
94 | delete m_image; | 95 | delete m_image; |
95 | } | 96 | } |
96 | 97 | ||
97 | void XineVideoWidget::clear ( ) | 98 | void XineVideoWidget::clear ( ) |
98 | { | 99 | { |
99 | m_buff = 0; | 100 | m_buff = 0; |
100 | repaint ( false ); | 101 | repaint ( false ); |
101 | } | 102 | } |
102 | 103 | ||
103 | void XineVideoWidget::paintEvent ( QPaintEvent * ) | 104 | void XineVideoWidget::paintEvent ( QPaintEvent * ) |
104 | { | 105 | { |
105 | //qWarning( "painting <<<" ); | 106 | //qWarning( "painting <<<" ); |
106 | if ( m_buff == 0 ) { | 107 | if ( m_buff == 0 ) { |
107 | QPainter p ( this ); | 108 | QPainter p ( this ); |
108 | p. fillRect ( rect ( ), black ); | 109 | p. fillRect ( rect ( ), black ); |
109 | if ( m_image ) | 110 | if ( m_image ) |
110 | p. drawImage ( 0, 0, *m_image ); | 111 | p. drawImage ( 0, 0, *m_image ); |
111 | //qWarning ( "logo\n" ); | 112 | //qWarning ( "logo\n" ); |
112 | } | 113 | } |
113 | else { | 114 | else { |
114 | // qWarning ( "paintevent\n" ); | 115 | // qWarning ( "paintevent\n" ); |
115 | 116 | ||
116 | QArray <QRect> qt_bug_workaround_clip_rects; | 117 | QArray <QRect> qt_bug_workaround_clip_rects; |
117 | 118 | ||
118 | { | 119 | { |
119 | QDirectPainter dp ( this ); | 120 | QDirectPainter dp ( this ); |
120 | 121 | ||
121 | int rot = dp. transformOrientation ( ) + m_rotation; | 122 | int rot = dp. transformOrientation ( ) + m_rotation; |
122 | 123 | ||
123 | uchar *fb = dp. frameBuffer ( ); | 124 | uchar *fb = dp. frameBuffer ( ); |
124 | uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame; | 125 | uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame; |
125 | 126 | ||
126 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 127 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); |
127 | 128 | ||
128 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); | 129 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); |
129 | 130 | ||
130 | for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { | 131 | for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { |
131 | const QRect &clip = dp. rect ( i ); | 132 | const QRect &clip = dp. rect ( i ); |
132 | 133 | ||
133 | qt_bug_workaround_clip_rects [i] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 134 | qt_bug_workaround_clip_rects [i] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); |
134 | 135 | ||
135 | uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); | 136 | uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); |
136 | uchar *src = frame; | 137 | uchar *src = frame; |
137 | 138 | ||
138 | switch ( rot ) { | 139 | switch ( rot ) { |
139 | case 0: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) ); break; | 140 | case 0: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) ); break; |
140 | case 1: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel ) ); break; | 141 | case 1: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel ) ); break; |
141 | case 2: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame ) ); break; | 142 | case 2: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame ) ); break; |
142 | case 3: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) ); break; | 143 | case 3: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) ); break; |
143 | } | 144 | } |
144 | 145 | ||
145 | uint leftfill = 0; | 146 | uint leftfill = 0; |
146 | uint framefill = 0; | 147 | uint framefill = 0; |
147 | uint rightfill = 0; | 148 | uint rightfill = 0; |
148 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; | 149 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; |
149 | 150 | ||
150 | if ( clip. left ( ) < framerect. left ( )) | 151 | if ( clip. left ( ) < framerect. left ( )) |
151 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; | 152 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; |
152 | if ( clip. right ( ) > framerect. right ( )) | 153 | if ( clip. right ( ) > framerect. right ( )) |
153 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; | 154 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; |
154 | 155 | ||
155 | framefill = clipwidth - ( leftfill + rightfill ); | 156 | framefill = clipwidth - ( leftfill + rightfill ); |
156 | 157 | ||
157 | for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { | 158 | for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { |
158 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { | 159 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { |
159 | memset ( dst, 0, clipwidth ); | 160 | memset ( dst, 0, clipwidth ); |
160 | } | 161 | } |
161 | else { | 162 | else { |
162 | if ( leftfill ) | 163 | if ( leftfill ) |
163 | memset ( dst, 0, leftfill ); | 164 | memset ( dst, 0, leftfill ); |
164 | 165 | ||
165 | if ( framefill ) { | 166 | if ( framefill ) { |
166 | switch ( rot ) { | 167 | switch ( rot ) { |
167 | case 0: memcpy ( dst + leftfill, src, framefill ); break; | 168 | case 0: memcpy ( dst + leftfill, src, framefill ); break; |
168 | case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; | 169 | case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; |
169 | case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; | 170 | case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; |
170 | case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; | 171 | case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; |
171 | } | 172 | } |
172 | } | 173 | } |
173 | if ( rightfill ) | 174 | if ( rightfill ) |
174 | memset ( dst + leftfill + framefill, 0, rightfill ); | 175 | memset ( dst + leftfill + framefill, 0, rightfill ); |
175 | } | 176 | } |
176 | 177 | ||
177 | dst += m_bytes_per_line_fb; | 178 | dst += m_bytes_per_line_fb; |
178 | 179 | ||
179 | switch ( rot ) { | 180 | switch ( rot ) { |
180 | case 0: src += m_bytes_per_line_frame; break; | 181 | case 0: src += m_bytes_per_line_frame; break; |
181 | case 1: src -= m_bytes_per_pixel; break; | 182 | case 1: src -= m_bytes_per_pixel; break; |
182 | case 2: src -= m_bytes_per_line_frame; break; | 183 | case 2: src -= m_bytes_per_line_frame; break; |
183 | case 3: src += m_bytes_per_pixel; break; | 184 | case 3: src += m_bytes_per_pixel; break; |
184 | } | 185 | } |
185 | } | 186 | } |
186 | } | 187 | } |
187 | } | 188 | } |
188 | //qWarning ( " ||| painting |||" ); | 189 | //qWarning ( " ||| painting |||" ); |
189 | { | 190 | { |
190 | // QVFB hack by MArtin Jones | 191 | // QVFB hack by MArtin Jones |
191 | QPainter p ( this ); | 192 | QPainter p ( this ); |
192 | 193 | ||
193 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { | 194 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { |
194 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) ); | 195 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) ); |
195 | } | 196 | } |
196 | } | 197 | } |
197 | } | 198 | } |
198 | //qWarning( "painting >>>" ); | 199 | //qWarning( "painting >>>" ); |
199 | } | 200 | } |
200 | 201 | ||
201 | 202 | ||
202 | void XineVideoWidget::setImage ( QImage* image ) | 203 | void XineVideoWidget::setImage ( QImage* image ) |
203 | { | 204 | { |
204 | delete m_image; | 205 | delete m_image; |
205 | m_image = image; | 206 | m_image = image; |
206 | } | 207 | } |
207 | 208 | ||
208 | void XineVideoWidget::setImage ( uchar* img, int w, int h, int bpl ) | 209 | void XineVideoWidget::setImage ( uchar* img, int w, int h, int bpl ) |
209 | { | 210 | { |
210 | bool rot90 = (( -m_rotation ) & 1 ); | 211 | bool rot90 = (( -m_rotation ) & 1 ); |
211 | 212 | ||
212 | if ( rot90 ) { | 213 | if ( rot90 ) { |
213 | int d = w; | 214 | int d = w; |
214 | w = h; | 215 | w = h; |
215 | h = d; | 216 | h = d; |
216 | } | 217 | } |
217 | 218 | ||
218 | m_lastframe = m_thisframe; | 219 | m_lastframe = m_thisframe; |
219 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); | 220 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); |
220 | 221 | ||
221 | //qDebug ( "Frame: %d,%d - %dx%d", ( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); | 222 | // qDebug ( "Frame: %d,%d - %dx%d", ( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); |
222 | 223 | ||
223 | m_buff = img; | 224 | m_buff = img; |
224 | m_bytes_per_line_frame = bpl; | 225 | m_bytes_per_line_frame = bpl; |
225 | 226 | ||
226 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); | 227 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); |
227 | } | 228 | } |
228 | 229 | ||
229 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) | 230 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) |
230 | { | 231 | { |
231 | QSize s = size ( ); | 232 | QSize s = size ( ); |
232 | bool fs = ( s == qApp-> desktop ( )-> size ( )); | 233 | bool fs = ( s == qApp-> desktop ( )-> size ( )); |
233 | 234 | ||
234 | m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; | 235 | m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; |
235 | 236 | ||
236 | if ( fs && qt_screen-> isTransformed ( )) { | 237 | if ( fs && qt_screen-> isTransformed ( )) { |
237 | s = qt_screen-> mapToDevice ( s ); | 238 | s = qt_screen-> mapToDevice ( s ); |
238 | } | 239 | } |
239 | 240 | ||
240 | //qDebug ( "\n\nResize: %dx%d, Rot: %d", s.width(),s.height(),m_rotation ); | 241 | // qDebug ( "\n\nResize: %dx%d, Rot: %d", s.width(),s.height(),m_rotation ); |
241 | 242 | ||
242 | emit videoResized ( s ); | 243 | emit videoResized ( s ); |
243 | } | 244 | } |
244 | 245 | ||
245 | 246 | ||
246 | void XineVideoWidget::mousePressEvent ( QMouseEvent *me ) | 247 | void XineVideoWidget::mousePressEvent ( QMouseEvent *me ) |
247 | { | 248 | { |
248 | QWidget *p = parentWidget ( ); | 249 | QWidget *p = parentWidget ( ); |
249 | 250 | ||
250 | if ( p ) { | 251 | if ( p ) { |
251 | QMouseEvent pme ( QEvent::MouseButtonPress, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); | 252 | QMouseEvent pme ( QEvent::MouseButtonPress, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); |
252 | 253 | ||
253 | QApplication::sendEvent ( p, &pme ); | 254 | QApplication::sendEvent ( p, &pme ); |
254 | } | 255 | } |
255 | } | 256 | } |
256 | 257 | ||
257 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent *me ) | 258 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent *me ) |
258 | { | 259 | { |
259 | QWidget *p = parentWidget ( ); | 260 | QWidget *p = parentWidget ( ); |
260 | 261 | ||
261 | if ( p ) { | 262 | if ( p ) { |
262 | QMouseEvent pme ( QEvent::MouseButtonRelease, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); | 263 | QMouseEvent pme ( QEvent::MouseButtonRelease, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); |
263 | 264 | ||
264 | QApplication::sendEvent ( p, &pme ); | 265 | QApplication::sendEvent ( p, &pme ); |
265 | } | 266 | } |
266 | } | 267 | } |
267 | 268 | ||