1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - Initial contribution |
|
11 * |
|
12 * Contributors: |
|
13 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 // System includes |
|
23 #include <eikenv.h> |
|
24 #include <VideoEditorUiComponents.mbg> |
|
25 #include <akniconutils.h> |
|
26 #include <aknsdrawutils.h> |
|
27 #include <aknsdatacontext.h> |
|
28 #include <aknutils.h> |
|
29 #include <aknlayoutscalable_avkon.cdl.h> |
|
30 #include <aknlayoutscalable_apps.cdl.h> |
|
31 |
|
32 |
|
33 // User includes |
|
34 #include "VeiCutterBar.h" |
|
35 #include "VideoEditorUtils.h" |
|
36 |
|
37 |
|
38 EXPORT_C CVeiCutterBar* CVeiCutterBar::NewL( const CCoeControl* aParent, TBool aDrawBorder ) |
|
39 { |
|
40 CVeiCutterBar* self = CVeiCutterBar::NewLC( aParent, aDrawBorder ); |
|
41 CleanupStack::Pop(self); |
|
42 return self; |
|
43 } |
|
44 |
|
45 EXPORT_C CVeiCutterBar* CVeiCutterBar::NewLC( const CCoeControl* aParent, TBool aDrawBorder ) |
|
46 { |
|
47 CVeiCutterBar* self = new (ELeave) CVeiCutterBar; |
|
48 CleanupStack::PushL( self ); |
|
49 self->ConstructL( aParent, aDrawBorder ); |
|
50 return self; |
|
51 } |
|
52 |
|
53 void CVeiCutterBar::ConstructL( const CCoeControl* aParent, TBool aDrawBorder ) |
|
54 { |
|
55 SetContainerWindowL( *aParent ); |
|
56 |
|
57 TFileName mbmPath( VideoEditorUtils::IconFileNameAndPath(KVideoEditorUiComponentsIconFileId) ); |
|
58 |
|
59 if( !AknLayoutUtils::PenEnabled() ) |
|
60 { |
|
61 AknIconUtils::CreateIconL( iScissorsIcon, iScissorsIconMask, |
|
62 mbmPath, EMbmVideoeditoruicomponentsQgn_indi_vded_scissors, |
|
63 EMbmVideoeditoruicomponentsQgn_indi_vded_scissors_mask ); |
|
64 |
|
65 // left end of the slider when that part is unselected |
|
66 AknIconUtils::CreateIconL( iSliderLeftEndIcon, iSliderLeftEndIconMask, |
|
67 mbmPath, EMbmVideoeditoruicomponentsQgn_graf_nslider_vded_end_left, |
|
68 EMbmVideoeditoruicomponentsQgn_graf_nslider_vded_end_left_mask ); |
|
69 |
|
70 // middle part of the slider when that part is unselected |
|
71 // should be qgn_graf_nslider_vded_middle but that icon is currently incorrect |
|
72 AknIconUtils::CreateIconL( iSliderMiddleIcon, iSliderMiddleIconMask, |
|
73 mbmPath, EMbmVideoeditoruicomponentsQgn_graf_nslider_vded_end_middle, |
|
74 EMbmVideoeditoruicomponentsQgn_graf_nslider_vded_end_middle_mask ); |
|
75 |
|
76 // right end of the slider when that part is unselected |
|
77 AknIconUtils::CreateIconL( iSliderRightEndIcon, iSliderRightEndIconMask, |
|
78 mbmPath, EMbmVideoeditoruicomponentsQgn_graf_nslider_vded_end_right, |
|
79 EMbmVideoeditoruicomponentsQgn_graf_nslider_vded_end_right_mask ); |
|
80 |
|
81 // left end of the cut selection slider |
|
82 AknIconUtils::CreateIconL( iSliderSelectedLeftEndIcon, iSliderSelectedLeftEndIconMask, |
|
83 mbmPath, EMbmVideoeditoruicomponentsQgn_graf_nslider_vded_end_left_selected, |
|
84 EMbmVideoeditoruicomponentsQgn_graf_nslider_vded_end_left_selected_mask ); |
|
85 |
|
86 // middle part of the cut selection slider |
|
87 AknIconUtils::CreateIconL( iSliderSelectedMiddleIcon, iSliderSelectedMiddleIconMask, |
|
88 mbmPath, EMbmVideoeditoruicomponentsQgn_graf_nslider_vded_middle_selected, |
|
89 EMbmVideoeditoruicomponentsQgn_graf_nslider_vded_middle_selected_mask ); |
|
90 |
|
91 // right end of the cut selection slider |
|
92 AknIconUtils::CreateIconL( iSliderSelectedRightEndIcon, iSliderSelectedRightEndIconMask, |
|
93 mbmPath, EMbmVideoeditoruicomponentsQgn_graf_nslider_vded_end_right_selected, |
|
94 EMbmVideoeditoruicomponentsQgn_graf_nslider_vded_end_right_selected_mask ); |
|
95 |
|
96 // playhead |
|
97 AknIconUtils::CreateIconL( iPlayheadIcon, iPlayheadIconMask, |
|
98 mbmPath, EMbmVideoeditoruicomponentsQgn_indi_vded_playhead, |
|
99 EMbmVideoeditoruicomponentsQgn_indi_vded_playhead_mask ); |
|
100 |
|
101 // left/right border of cut selection slider |
|
102 AknIconUtils::CreateIconL( iCutAreaBorderIcon, iCutAreaBorderIconMask, |
|
103 mbmPath, EMbmVideoeditoruicomponentsQgn_indi_vded_timeline_selected, |
|
104 EMbmVideoeditoruicomponentsQgn_indi_vded_timeline_selected_mask ); |
|
105 } |
|
106 else |
|
107 { |
|
108 // left end of the slider when that part is unselected |
|
109 AknIconUtils::CreateIconL( iSliderLeftEndIcon, iSliderLeftEndIconMask, |
|
110 mbmPath, EMbmVideoeditoruicomponentsQgn_graf_nslider_vded2_end_left, |
|
111 EMbmVideoeditoruicomponentsQgn_graf_nslider_vded2_end_left_mask ); |
|
112 |
|
113 // middle part of the slider when that part is unselected |
|
114 // should be qgn_graf_nslider_vded_middle but that icon is currently incorrect |
|
115 AknIconUtils::CreateIconL( iSliderMiddleIcon, iSliderMiddleIconMask, |
|
116 mbmPath, EMbmVideoeditoruicomponentsQgn_graf_nslider_vded2_middle, |
|
117 EMbmVideoeditoruicomponentsQgn_graf_nslider_vded2_middle_mask ); |
|
118 |
|
119 // right end of the slider when that part is unselected |
|
120 AknIconUtils::CreateIconL( iSliderRightEndIcon, iSliderRightEndIconMask, |
|
121 mbmPath, EMbmVideoeditoruicomponentsQgn_graf_nslider_vded2_end_right, |
|
122 EMbmVideoeditoruicomponentsQgn_graf_nslider_vded2_end_right_mask ); |
|
123 |
|
124 // middle part of the cut selection slider |
|
125 AknIconUtils::CreateIconL( iSliderSelectedMiddleIcon, iSliderSelectedMiddleIconMask, |
|
126 mbmPath, EMbmVideoeditoruicomponentsQgn_graf_nslider_vded2_middle_selected, |
|
127 EMbmVideoeditoruicomponentsQgn_graf_nslider_vded2_middle_selected_mask ); |
|
128 |
|
129 // playhead |
|
130 AknIconUtils::CreateIconL( iPlayheadIcon, iPlayheadIconMask, |
|
131 mbmPath, EMbmVideoeditoruicomponentsQgn_indi_vded2_playhead, |
|
132 EMbmVideoeditoruicomponentsQgn_indi_vded2_playhead_mask ); |
|
133 |
|
134 // pressed playhead |
|
135 AknIconUtils::CreateIconL( iPlayheadIconPressed, iPlayheadIconPressedMask, |
|
136 mbmPath, EMbmVideoeditoruicomponentsQgn_indi_vded2_playhead_pressed, |
|
137 EMbmVideoeditoruicomponentsQgn_indi_vded2_playhead_pressed_mask ); |
|
138 |
|
139 // Start mark |
|
140 AknIconUtils::CreateIconL( iStartMarkIcon, iStartMarkIconMask, |
|
141 mbmPath, EMbmVideoeditoruicomponentsQgn_indi_vded2_start, |
|
142 EMbmVideoeditoruicomponentsQgn_indi_vded2_start_mask ); |
|
143 |
|
144 // Pressed Start mark |
|
145 AknIconUtils::CreateIconL( iStartMarkIconPressed, iStartMarkIconPressedMask, |
|
146 mbmPath, EMbmVideoeditoruicomponentsQgn_indi_vded2_start_pressed, |
|
147 EMbmVideoeditoruicomponentsQgn_indi_vded2_start_pressed_mask ); |
|
148 |
|
149 // End Mark |
|
150 AknIconUtils::CreateIconL( iEndMarkIcon, iEndMarkIconMask, |
|
151 mbmPath, EMbmVideoeditoruicomponentsQgn_indi_vded2_end, |
|
152 EMbmVideoeditoruicomponentsQgn_indi_vded2_end_mask ); |
|
153 |
|
154 // Pressed End Mark |
|
155 AknIconUtils::CreateIconL( iEndMarkIconPressed, iEndMarkIconPressedMask, |
|
156 mbmPath, EMbmVideoeditoruicomponentsQgn_indi_vded2_end_pressed, |
|
157 EMbmVideoeditoruicomponentsQgn_indi_vded2_end_pressed_mask ); |
|
158 } |
|
159 |
|
160 iDrawBorder = aDrawBorder; |
|
161 iInPoint = 0; |
|
162 iCurrentPoint = 0; |
|
163 iTotalDuration = 1; |
|
164 iDimmed = EFalse; |
|
165 iDrawPlayHead = ETrue; |
|
166 iOutPoint = 13; |
|
167 iFinished = ETrue; |
|
168 } |
|
169 |
|
170 EXPORT_C CVeiCutterBar::~CVeiCutterBar() |
|
171 { |
|
172 if (iScissorsIcon) |
|
173 { |
|
174 delete iScissorsIcon; |
|
175 delete iScissorsIconMask; |
|
176 } |
|
177 |
|
178 delete iSliderLeftEndIcon; |
|
179 delete iSliderLeftEndIconMask; |
|
180 delete iSliderMiddleIcon; |
|
181 delete iSliderMiddleIconMask; |
|
182 delete iSliderRightEndIcon; |
|
183 delete iSliderRightEndIconMask; |
|
184 |
|
185 if (iSliderSelectedLeftEndIcon) |
|
186 { |
|
187 delete iSliderSelectedLeftEndIcon; |
|
188 delete iSliderSelectedLeftEndIconMask; |
|
189 } |
|
190 |
|
191 delete iSliderSelectedMiddleIcon; |
|
192 delete iSliderSelectedMiddleIconMask; |
|
193 |
|
194 if (iSliderSelectedRightEndIcon) |
|
195 { |
|
196 delete iSliderSelectedRightEndIcon; |
|
197 delete iSliderSelectedRightEndIconMask; |
|
198 } |
|
199 |
|
200 delete iPlayheadIcon; |
|
201 delete iPlayheadIconMask; |
|
202 |
|
203 if (iPlayheadIconPressed) |
|
204 { |
|
205 delete iPlayheadIconPressed; |
|
206 delete iPlayheadIconPressedMask; |
|
207 } |
|
208 if (iStartMarkIcon) |
|
209 { |
|
210 delete iStartMarkIcon; |
|
211 delete iStartMarkIconMask; |
|
212 } |
|
213 if (iStartMarkIconPressed) |
|
214 { |
|
215 delete iStartMarkIconPressed; |
|
216 delete iStartMarkIconPressedMask; |
|
217 } |
|
218 if (iEndMarkIcon) |
|
219 { |
|
220 delete iEndMarkIcon; |
|
221 delete iEndMarkIconMask; |
|
222 } |
|
223 if (iEndMarkIconPressed) |
|
224 { |
|
225 delete iEndMarkIconPressed; |
|
226 delete iEndMarkIconPressedMask; |
|
227 } |
|
228 if (iCutAreaBorderIcon) |
|
229 { |
|
230 delete iCutAreaBorderIcon; |
|
231 delete iCutAreaBorderIconMask; |
|
232 } |
|
233 } |
|
234 |
|
235 TInt CVeiCutterBar::CountComponentControls() const |
|
236 { |
|
237 return 0; |
|
238 } |
|
239 |
|
240 void CVeiCutterBar::DrawCoordinate(TInt aX, TInt aY, TInt aData1, TInt aData2, const TDesC& aInfo) const |
|
241 { |
|
242 CWindowGc& gc = SystemGc(); |
|
243 TPoint writepoint(aX, aY); |
|
244 |
|
245 _LIT(KXY, "%S:(%d,%d)"); |
|
246 _LIT(KX, "%S:%d"); |
|
247 TBuf<200> buffer; |
|
248 if (aData2 > 0) |
|
249 { |
|
250 buffer.Format(KXY, &aInfo, aData1, aData2); |
|
251 } |
|
252 else |
|
253 { |
|
254 buffer.Format(KX, &aInfo, aData1); |
|
255 } |
|
256 const CFont* font = AknLayoutUtils::FontFromId( EAknLogicalFontSecondaryFont ); |
|
257 gc.UseFont( font ); |
|
258 |
|
259 // Get text color from skin |
|
260 TRgb textColor( KRgbBlack ); |
|
261 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
262 AknsUtils::GetCachedColor(skin, textColor, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 ); |
|
263 gc.SetPenColor( textColor ); |
|
264 |
|
265 gc.DrawText( buffer, writepoint ); |
|
266 |
|
267 gc.DiscardFont(); |
|
268 } |
|
269 |
|
270 |
|
271 void CVeiCutterBar::Draw( const TRect& /*aRect*/ ) const |
|
272 { |
|
273 CWindowGc& gc = SystemGc(); |
|
274 |
|
275 if( !AknLayoutUtils::PenEnabled() ) |
|
276 { |
|
277 gc.BitBltMasked(iScissorsIconRect.iTl, iScissorsIcon, iScissorsIconRect.Size(), |
|
278 iScissorsIconMask, EFalse ); |
|
279 } |
|
280 |
|
281 // The following three icons are visible only when the user has selected an area to be cut. |
|
282 // In the initial state, the whole slider is selected so these icons won't be shown. |
|
283 |
|
284 // draw left end of the slider |
|
285 gc.BitBltMasked(iSliderLeftEndIconRect.iTl, iSliderLeftEndIcon, iSliderLeftEndIconRect.Size(), |
|
286 iSliderLeftEndIconMask, EFalse ); |
|
287 |
|
288 // draw middle part of the slider |
|
289 gc.BitBltMasked(iSliderMiddleIconRect.iTl, iSliderMiddleIcon, iSliderMiddleIconRect.Size(), |
|
290 iSliderMiddleIconMask, EFalse ); |
|
291 |
|
292 // draw right end of the slider |
|
293 gc.BitBltMasked(iSliderRightEndIconRect.iTl, iSliderRightEndIcon, iSliderRightEndIconRect.Size(), |
|
294 iSliderRightEndIconMask, EFalse ); |
|
295 |
|
296 // the selected area of the slider is constructed from 3 icons: |
|
297 // |
|
298 // |<-------------- whole slider ------------------------>| |
|
299 // |
|
300 // |<-------- selected area ------------>| |
|
301 // |
|
302 // ----- -----a-------------------------b----- ---------- |
|
303 // | |left | middle |right| | |
|
304 // | |end | part |end | | |
|
305 // ----- ----- ------------------------- ----- ---------- |
|
306 |
|
307 TRect selectedArea(CalculateCutAreaRect()); |
|
308 |
|
309 if( !AknLayoutUtils::PenEnabled() ) |
|
310 { |
|
311 // if the start and end mark are close to each other, the width of the left and |
|
312 // right end icons has to be decreased |
|
313 TRect leftRect(iSliderSelectedLeftEndIconRect); |
|
314 TRect rightRect(iSliderSelectedRightEndIconRect); |
|
315 |
|
316 // the width of the selected area is smaller than the width of the left/right end |
|
317 if (selectedArea.Width() <= iSliderSelectedRightEndIconRect.Width()) |
|
318 { |
|
319 leftRect = selectedArea; |
|
320 rightRect = selectedArea; |
|
321 } |
|
322 |
|
323 // calculate point a |
|
324 TInt leftEndWidth = iSliderSelectedLeftEndIconRect.Width(); |
|
325 TInt xA = selectedArea.iTl.iX + leftEndWidth; |
|
326 TPoint pointA = TPoint(xA, selectedArea.iTl.iY); |
|
327 |
|
328 // calculate point b |
|
329 TInt rightEndWidth = rightRect.Width(); |
|
330 TInt xB = selectedArea.iBr.iX - rightEndWidth; |
|
331 TPoint pointB = TPoint(xB, selectedArea.iTl.iY); |
|
332 |
|
333 // calculate the size of the middle part |
|
334 TInt middlePartWidth = pointB.iX - pointA.iX; |
|
335 TSize middlePartSize = TSize(middlePartWidth, iSliderSelectedMiddleIconRect.Height()); |
|
336 |
|
337 // draw left end of the cut selection slider |
|
338 gc.BitBltMasked(selectedArea.iTl, iSliderSelectedLeftEndIcon, leftRect.Size(), |
|
339 iSliderSelectedLeftEndIconMask, EFalse ); |
|
340 |
|
341 // draw middle part of the cut selection slider |
|
342 gc.BitBltMasked(pointA, iSliderSelectedMiddleIcon, middlePartSize, |
|
343 iSliderSelectedMiddleIconMask, EFalse ); |
|
344 |
|
345 // draw right end of the cut selection slider |
|
346 gc.BitBltMasked(pointB, iSliderSelectedRightEndIcon, rightRect.Size(), |
|
347 iSliderSelectedRightEndIconMask, EFalse ); |
|
348 |
|
349 if ( iFinished && !iDimmed ) |
|
350 { |
|
351 // draw the left border of cut selection slider if the start mark has been set |
|
352 if ( iInPoint > 0 ) |
|
353 { |
|
354 gc.BitBltMasked(iStartMarkRect.iTl, iCutAreaBorderIcon, iCutAreaBorderIconRect.Size(), |
|
355 iCutAreaBorderIconMask, EFalse ); |
|
356 } |
|
357 |
|
358 // draw the right border of the cut selection slider if the end mark has been set |
|
359 if (iOutPoint < iTotalDuration) |
|
360 { |
|
361 gc.BitBltMasked(iEndMarkRect.iTl, iCutAreaBorderIcon, iCutAreaBorderIconRect.Size(), |
|
362 iCutAreaBorderIconMask, EFalse ); |
|
363 } |
|
364 } |
|
365 } |
|
366 else |
|
367 { |
|
368 // draw middle part of the cut selection slider |
|
369 gc.BitBltMasked(selectedArea.iTl, iSliderSelectedMiddleIcon, selectedArea.Size(), |
|
370 iSliderSelectedMiddleIconMask, EFalse ); |
|
371 |
|
372 if ( iFinished && !iDimmed ) |
|
373 { |
|
374 TPoint startPoint(selectedArea.iTl); |
|
375 startPoint.iX = startPoint.iX - iStartMarkRect.Width(); |
|
376 |
|
377 if( iPressedComponent == EPressedStartMarkTouch ) |
|
378 { |
|
379 gc.BitBltMasked(startPoint, iStartMarkIconPressed, iStartMarkRect.Size(), |
|
380 iStartMarkIconPressedMask, EFalse ); |
|
381 } |
|
382 else |
|
383 { |
|
384 gc.BitBltMasked(startPoint, iStartMarkIcon, iStartMarkRect.Size(), |
|
385 iStartMarkIconMask, EFalse ); |
|
386 } |
|
387 |
|
388 TPoint endPoint(selectedArea.iBr); |
|
389 endPoint.iY = iEndMarkRect.iTl.iY; |
|
390 |
|
391 if( iPressedComponent == EPressedEndMarkTouch ) |
|
392 { |
|
393 gc.BitBltMasked(endPoint, iEndMarkIconPressed, iEndMarkRect.Size(), |
|
394 iEndMarkIconPressedMask, EFalse ); |
|
395 } |
|
396 else |
|
397 { |
|
398 gc.BitBltMasked(endPoint, iEndMarkIcon, iEndMarkRect.Size(), |
|
399 iEndMarkIconMask, EFalse ); |
|
400 } |
|
401 |
|
402 } |
|
403 } |
|
404 |
|
405 // calculate the playhead position |
|
406 TUint width = iCutBarRect.Width(); |
|
407 TInt currentPointX = 0; |
|
408 if (iTotalDuration > 0) |
|
409 { |
|
410 currentPointX = iCurrentPoint * width / iTotalDuration + iCutBarRect.iTl.iX; |
|
411 |
|
412 // set the center of the playhead icon to the current position |
|
413 currentPointX = currentPointX - ( iPlayheadIconRect.Width()/2 ); |
|
414 } |
|
415 |
|
416 if( !AknLayoutUtils::PenEnabled() ) |
|
417 { |
|
418 // don't draw the playhead outside the cut bar area because it is not refreshed often enough |
|
419 if ( currentPointX < iCutBarRect.iTl.iX ) |
|
420 { |
|
421 currentPointX = iCutBarRect.iTl.iX; |
|
422 } |
|
423 else if ( currentPointX > iCutBarRect.iBr.iX ) |
|
424 { |
|
425 currentPointX = iCutBarRect.iBr.iX; |
|
426 } |
|
427 |
|
428 // draw playhead |
|
429 gc.BitBltMasked(TPoint(currentPointX,iCutBarRect.iTl.iY), iPlayheadIcon, iPlayheadIconRect.Size(), |
|
430 iPlayheadIconMask, EFalse ); |
|
431 } |
|
432 else |
|
433 { |
|
434 // draw playhead |
|
435 if( iPressedComponent == EPressedPlayheadTouch ) |
|
436 { |
|
437 gc.BitBltMasked(TPoint(currentPointX,iCutBarRect.iBr.iY - iPlayheadIconRect.Height()), iPlayheadIconPressed, |
|
438 iPlayheadIconRect.Size(), iPlayheadIconPressedMask, EFalse ); |
|
439 } |
|
440 else |
|
441 { |
|
442 gc.BitBltMasked(TPoint(currentPointX,iCutBarRect.iBr.iY - iPlayheadIconRect.Height()), iPlayheadIcon, iPlayheadIconRect.Size(), |
|
443 iPlayheadIconMask, EFalse ); |
|
444 } |
|
445 } |
|
446 } |
|
447 |
|
448 CCoeControl* CVeiCutterBar::ComponentControl( TInt /*aIndex*/ ) const |
|
449 { |
|
450 return NULL; |
|
451 } |
|
452 |
|
453 |
|
454 EXPORT_C void CVeiCutterBar::Dim( TBool aDimmed ) |
|
455 { |
|
456 iDimmed = aDimmed; |
|
457 DrawDeferred(); |
|
458 } |
|
459 |
|
460 EXPORT_C void CVeiCutterBar::SetPlayHeadVisible( TBool aVisible ) |
|
461 { |
|
462 iDrawPlayHead = aVisible; |
|
463 } |
|
464 |
|
465 void CVeiCutterBar::HandleControlEventL( CCoeControl* /*aControl*/, |
|
466 TCoeEvent /*aEventType*/ ) |
|
467 { |
|
468 DrawDeferred(); |
|
469 } |
|
470 |
|
471 void CVeiCutterBar::SizeChanged() |
|
472 { |
|
473 // the component rects are set in CVeiSimpleCutVideoContainer::SizeChanged(), |
|
474 // CVeiEditVideoContainer::SetCursorLocation() or CVeiCutVideoContainer::SizeChanged() |
|
475 |
|
476 // left end of the slider when that part is unselected |
|
477 AknIconUtils::SetSize( iSliderLeftEndIcon, iSliderLeftEndIconRect.Size(), EAspectRatioNotPreserved); |
|
478 |
|
479 // middle part of the slider when that part is unselected |
|
480 AknIconUtils::SetSize( iSliderMiddleIcon, iSliderMiddleIconRect.Size(), EAspectRatioNotPreserved); |
|
481 |
|
482 // right end of the slider when that part is unselected |
|
483 AknIconUtils::SetSize( iSliderRightEndIcon, iSliderRightEndIconRect.Size(), EAspectRatioNotPreserved); |
|
484 |
|
485 if( !AknLayoutUtils::PenEnabled() ) |
|
486 { |
|
487 // left end of the cut selection slider |
|
488 AknIconUtils::SetSize( iSliderSelectedLeftEndIcon, iSliderSelectedLeftEndIconRect.Size(), EAspectRatioNotPreserved); |
|
489 |
|
490 // middle part of the cut selection slider |
|
491 AknIconUtils::SetSize( iSliderSelectedMiddleIcon, iSliderSelectedMiddleIconRect.Size(), EAspectRatioNotPreserved); |
|
492 |
|
493 // right end of the cut selection slider |
|
494 AknIconUtils::SetSize( iSliderSelectedRightEndIcon, iSliderSelectedRightEndIconRect.Size(), EAspectRatioNotPreserved); |
|
495 |
|
496 // left/right border of cut selection slider |
|
497 AknIconUtils::SetSize( iCutAreaBorderIcon, iCutAreaBorderIconRect.Size(), EAspectRatioNotPreserved); |
|
498 |
|
499 AknIconUtils::SetSize( iScissorsIcon, iScissorsIconRect.Size(), EAspectRatioNotPreserved); |
|
500 |
|
501 iStartMarkRect = TRect(CalculateCutAreaRect().iTl, iCutAreaBorderIconRect.Size()); |
|
502 |
|
503 TInt xD = CalculateCutAreaRect().iBr.iX - iCutAreaBorderIconRect.Width(); |
|
504 TPoint pointD = TPoint (xD, iSliderSelectedLeftEndIconRect.iTl.iY); |
|
505 |
|
506 // set the end mark rect |
|
507 iEndMarkRect = TRect(pointD, iCutAreaBorderIconRect.Size()); |
|
508 } |
|
509 else |
|
510 { |
|
511 // middle part of the cut selection slider |
|
512 AknIconUtils::SetSize( iSliderSelectedMiddleIcon, TSize(iCutBarRect.Size().iWidth, iSliderSelectedMiddleIconRect.Size().iHeight), EAspectRatioNotPreserved); |
|
513 |
|
514 // left border of cut selection slider |
|
515 AknIconUtils::SetSize( iStartMarkIcon, iStartMarkRect.Size(), EAspectRatioNotPreserved); |
|
516 AknIconUtils::SetSize( iStartMarkIconPressed, iStartMarkRect.Size(), EAspectRatioNotPreserved); |
|
517 |
|
518 // right border of cut selection slider |
|
519 AknIconUtils::SetSize( iEndMarkIcon, iEndMarkRect.Size(), EAspectRatioNotPreserved); |
|
520 AknIconUtils::SetSize( iEndMarkIconPressed, iEndMarkRect.Size(), EAspectRatioNotPreserved); |
|
521 } |
|
522 |
|
523 // playhead |
|
524 AknIconUtils::SetSize( iPlayheadIcon, iPlayheadIconRect.Size(), EAspectRatioNotPreserved); |
|
525 AknIconUtils::SetSize( iPlayheadIconPressed, iPlayheadIconRect.Size(), EAspectRatioNotPreserved); |
|
526 } |
|
527 |
|
528 TKeyResponse CVeiCutterBar::OfferKeyEventL( const TKeyEvent& /*aKeyEvent*/, |
|
529 TEventCode /*aType*/ ) |
|
530 { |
|
531 return EKeyWasNotConsumed; |
|
532 } |
|
533 |
|
534 EXPORT_C void CVeiCutterBar::SetInPoint( const TTimeIntervalMicroSeconds& aIn ) |
|
535 { |
|
536 iInPoint = static_cast<TInt32>((aIn.Int64()/1000)); |
|
537 |
|
538 if( !AknLayoutUtils::PenEnabled() ) |
|
539 { |
|
540 iStartMarkRect = TRect(CalculateCutAreaRect().iTl, iCutAreaBorderIconRect.Size()); |
|
541 DrawDeferred(); |
|
542 return; |
|
543 } |
|
544 |
|
545 TInt xD = CalculateCutAreaRect().iTl.iX - iStartMarkRect.Width(); |
|
546 TPoint pointD = TPoint (xD, iStartMarkRect.iTl.iY); |
|
547 TInt delta = pointD.iX - iStartMarkRect.iTl.iX; |
|
548 iStartMarkTouchRect.iTl.iX += delta; |
|
549 iStartMarkTouchRect.iBr.iX += delta; |
|
550 |
|
551 // set the start mark rect |
|
552 iStartMarkRect = TRect(pointD, iStartMarkRect.Size()); |
|
553 DrawDeferred(); |
|
554 } |
|
555 |
|
556 EXPORT_C void CVeiCutterBar::SetOutPoint( const TTimeIntervalMicroSeconds& aOutPoint ) |
|
557 { |
|
558 iOutPoint = static_cast<TInt32>((aOutPoint.Int64()/1000)); |
|
559 |
|
560 // calculate the top left point (d in the picture below) for the end mark rect |
|
561 // for more clarification, see the picture in Draw function |
|
562 // |
|
563 // right |
|
564 // |<- end ->| |
|
565 // -----b-----d---c--------- |
|
566 // | |bor| |
|
567 // | |der| |
|
568 // ------------------------- |
|
569 |
|
570 if( !AknLayoutUtils::PenEnabled() ) |
|
571 { |
|
572 TInt xD = CalculateCutAreaRect().iBr.iX - iCutAreaBorderIconRect.Width(); |
|
573 TPoint pointD = TPoint (xD, iSliderSelectedLeftEndIconRect.iTl.iY); |
|
574 |
|
575 // set the end mark rect |
|
576 iEndMarkRect = TRect(pointD, iCutAreaBorderIconRect.Size()); |
|
577 } |
|
578 else |
|
579 { |
|
580 TPoint pointD = TPoint (CalculateCutAreaRect().iBr.iX, iEndMarkRect.iTl.iY); |
|
581 TInt delta = pointD.iX - iEndMarkRect.iTl.iX; |
|
582 iEndMarkTouchRect.iTl.iX += delta; |
|
583 iEndMarkTouchRect.iBr.iX += delta; |
|
584 |
|
585 iEndMarkRect = TRect(pointD, iEndMarkRect.Size()); |
|
586 } |
|
587 |
|
588 DrawDeferred(); |
|
589 } |
|
590 |
|
591 EXPORT_C void CVeiCutterBar::SetFinishedStatus( TBool aStatus ) |
|
592 { |
|
593 iFinished = aStatus; |
|
594 // iCurrentPoint = 0; |
|
595 SetCurrentPoint( 0 ); |
|
596 DrawDeferred(); |
|
597 } |
|
598 |
|
599 EXPORT_C void CVeiCutterBar::SetTotalDuration( const TTimeIntervalMicroSeconds& aDuration ) |
|
600 { |
|
601 TTimeIntervalMicroSeconds duration (aDuration); |
|
602 if ( duration.Int64() == 0 ) |
|
603 { |
|
604 duration = 1; |
|
605 } |
|
606 |
|
607 TInt64 i = duration.Int64(); |
|
608 for (;0 == (i/1000);i++) |
|
609 { |
|
610 ; |
|
611 } |
|
612 duration = i; |
|
613 |
|
614 iTotalDuration = static_cast<TInt32>((duration.Int64()/1000)); |
|
615 SetOutPoint(aDuration); |
|
616 // DrawDeferred(); |
|
617 } |
|
618 |
|
619 EXPORT_C void CVeiCutterBar::SetCurrentPoint( TInt aLocation ) |
|
620 { |
|
621 if( AknLayoutUtils::PenEnabled() ) |
|
622 { |
|
623 // calculate the playhead position |
|
624 TUint width = iCutBarRect.Width(); |
|
625 TInt currentPointX = 0; |
|
626 if (iTotalDuration > 0) |
|
627 { |
|
628 currentPointX = aLocation * width / iTotalDuration + iCutBarRect.iTl.iX; |
|
629 } |
|
630 currentPointX = currentPointX - ( iPlayheadTouchRect.Width()/2 ); |
|
631 iPlayheadTouchRect.iBr.iX = currentPointX + iPlayheadTouchRect.Width(); |
|
632 iPlayheadTouchRect.iTl.iX = currentPointX; |
|
633 } |
|
634 |
|
635 iCurrentPoint = aLocation; |
|
636 DrawDeferred(); |
|
637 } |
|
638 |
|
639 // ---------------------------------------------------------------------------- |
|
640 // CVeiCutterBar::ProgressBarRect |
|
641 // |
|
642 // ---------------------------------------------------------------------------- |
|
643 // |
|
644 EXPORT_C TRect CVeiCutterBar::ProgressBarRect() |
|
645 { |
|
646 return iCutBarRect; |
|
647 } |
|
648 |
|
649 // ---------------------------------------------------------------------------- |
|
650 // CVeiCutterBar::PlayHeadRect |
|
651 // |
|
652 // ---------------------------------------------------------------------------- |
|
653 // |
|
654 EXPORT_C TRect CVeiCutterBar::PlayHeadRect() |
|
655 { |
|
656 return iPlayheadTouchRect; |
|
657 } |
|
658 |
|
659 // ---------------------------------------------------------------------------- |
|
660 // CVeiCutterBar::StartMarkRect |
|
661 // |
|
662 // ---------------------------------------------------------------------------- |
|
663 // |
|
664 EXPORT_C TRect CVeiCutterBar::StartMarkRect() |
|
665 { |
|
666 if( AknLayoutUtils::PenEnabled() ) |
|
667 { |
|
668 return iStartMarkTouchRect; |
|
669 } |
|
670 |
|
671 TRect startMarkArea; |
|
672 |
|
673 // start mark has not been set |
|
674 if (iInPoint == 0) |
|
675 { |
|
676 startMarkArea = TRect(0,0,0,0); |
|
677 } |
|
678 else |
|
679 { |
|
680 startMarkArea = iStartMarkRect; |
|
681 } |
|
682 return startMarkArea; |
|
683 } |
|
684 |
|
685 // ---------------------------------------------------------------------------- |
|
686 // CVeiCutterBar::EndMarkRect |
|
687 // |
|
688 // ---------------------------------------------------------------------------- |
|
689 // |
|
690 EXPORT_C TRect CVeiCutterBar::EndMarkRect() |
|
691 { |
|
692 if( AknLayoutUtils::PenEnabled() ) |
|
693 { |
|
694 return iEndMarkTouchRect; |
|
695 } |
|
696 |
|
697 TRect endMarkArea; |
|
698 |
|
699 // end mark has not been set |
|
700 if (iOutPoint == iTotalDuration) |
|
701 { |
|
702 endMarkArea = TRect(0,0,0,0); |
|
703 } |
|
704 else |
|
705 { |
|
706 endMarkArea = iEndMarkRect; |
|
707 } |
|
708 return endMarkArea; |
|
709 } |
|
710 |
|
711 // ---------------------------------------------------------------------------- |
|
712 // CVeiCutterBar::StartMarkPoint |
|
713 // |
|
714 // ---------------------------------------------------------------------------- |
|
715 // |
|
716 EXPORT_C TUint CVeiCutterBar::StartMarkPoint() |
|
717 { |
|
718 // start mark hasn't been set |
|
719 if (iInPoint == 0) |
|
720 { |
|
721 return 0; |
|
722 } |
|
723 // start mark has been set |
|
724 else |
|
725 { |
|
726 TInt startPoint = iInPoint * iCutBarRect.Width() / iTotalDuration + iCutBarRect.iTl.iX; |
|
727 return startPoint; |
|
728 } |
|
729 } |
|
730 |
|
731 // ---------------------------------------------------------------------------- |
|
732 // CVeiCutterBar::EndMarkPoint |
|
733 // |
|
734 // ---------------------------------------------------------------------------- |
|
735 // |
|
736 EXPORT_C TUint CVeiCutterBar::EndMarkPoint() |
|
737 { |
|
738 // end mark hasn't been set |
|
739 if (iOutPoint == iTotalDuration) |
|
740 { |
|
741 return iCutBarRect.iBr.iX; |
|
742 } |
|
743 // end mark has been set |
|
744 else |
|
745 { |
|
746 TInt endPoint = iOutPoint * iCutBarRect.Width() / iTotalDuration + iCutBarRect.iTl.iX; |
|
747 return endPoint; |
|
748 } |
|
749 } |
|
750 |
|
751 |
|
752 // ---------------------------------------------------------------------------- |
|
753 // CVeiCutterBar::SetComponentRect |
|
754 // |
|
755 // ---------------------------------------------------------------------------- |
|
756 // |
|
757 EXPORT_C void CVeiCutterBar::SetComponentRect(TCutterBarComponent aComponentIndex, TRect aRect) |
|
758 { |
|
759 switch ( aComponentIndex ) |
|
760 { |
|
761 case EScissorsIcon: |
|
762 { |
|
763 iScissorsIconRect = aRect; |
|
764 break; |
|
765 } |
|
766 case EProgressBar: |
|
767 { |
|
768 iCutBarRect = aRect; |
|
769 break; |
|
770 } |
|
771 case ESliderLeftEndIcon: |
|
772 { |
|
773 iSliderLeftEndIconRect = aRect; |
|
774 break; |
|
775 } |
|
776 case ESliderMiddleIcon: |
|
777 { |
|
778 iSliderMiddleIconRect = aRect; |
|
779 break; |
|
780 } |
|
781 case ESliderRightEndIcon: |
|
782 { |
|
783 iSliderRightEndIconRect = aRect; |
|
784 break; |
|
785 } |
|
786 case ESliderSelectedLeftEndIcon: |
|
787 { |
|
788 iSliderSelectedLeftEndIconRect = aRect; |
|
789 break; |
|
790 } |
|
791 case ESliderSelectedMiddleIcon: |
|
792 { |
|
793 iSliderSelectedMiddleIconRect = aRect; |
|
794 break; |
|
795 } |
|
796 case ESliderSelectedRightEndIcon: |
|
797 { |
|
798 iSliderSelectedRightEndIconRect = aRect; |
|
799 break; |
|
800 } |
|
801 case EPlayheadIcon: |
|
802 { |
|
803 iPlayheadIconRect = aRect; |
|
804 break; |
|
805 } |
|
806 case ECutAreaBorderIcon: |
|
807 { |
|
808 iCutAreaBorderIconRect = aRect; |
|
809 break; |
|
810 } |
|
811 case EStartMarkIcon: |
|
812 { |
|
813 iStartMarkRect = aRect; |
|
814 break; |
|
815 } |
|
816 case EEndMarkIcon: |
|
817 { |
|
818 iEndMarkRect = aRect; |
|
819 break; |
|
820 } |
|
821 case EPlayheadTouch: |
|
822 { |
|
823 iPlayheadTouchRect = aRect; |
|
824 SetCurrentPoint(iCurrentPoint); |
|
825 break; |
|
826 } |
|
827 case EStartMarkTouch: |
|
828 { |
|
829 iStartMarkTouchRect = aRect; |
|
830 break; |
|
831 } |
|
832 case EEndMarkTouch: |
|
833 { |
|
834 iEndMarkTouchRect = aRect; |
|
835 break; |
|
836 } |
|
837 } |
|
838 } |
|
839 |
|
840 // ---------------------------------------------------------------------------- |
|
841 // CVeiCutterBar::SetPressedComponent |
|
842 // |
|
843 // ---------------------------------------------------------------------------- |
|
844 // |
|
845 EXPORT_C void CVeiCutterBar::SetPressedComponent(TCutterBarPressedIcon aComponentIndex) |
|
846 { |
|
847 iPressedComponent = aComponentIndex; |
|
848 } |
|
849 |
|
850 // ---------------------------------------------------------------------------- |
|
851 // CVeiCutterBar::CalculateCutAreaRect |
|
852 // |
|
853 // ---------------------------------------------------------------------------- |
|
854 // |
|
855 TRect CVeiCutterBar::CalculateCutAreaRect() const |
|
856 { |
|
857 |
|
858 TUint width = iCutBarRect.Width(); |
|
859 TInt inPointX = 0; |
|
860 TInt outPointX = 0; |
|
861 |
|
862 if (0 < iTotalDuration) |
|
863 { |
|
864 inPointX = iInPoint * width / iTotalDuration + iCutBarRect.iTl.iX; |
|
865 outPointX = iOutPoint * width / iTotalDuration + iCutBarRect.iTl.iX; |
|
866 } |
|
867 |
|
868 if ( outPointX > iCutBarRect.iBr.iX ) |
|
869 { |
|
870 outPointX = iCutBarRect.iBr.iX; |
|
871 } |
|
872 |
|
873 // area to be cut |
|
874 TRect selectedArea( iCutBarRect ); |
|
875 |
|
876 if ( iFinished && !iDimmed ) |
|
877 { |
|
878 selectedArea.iTl.iX = inPointX; |
|
879 selectedArea.iBr.iX = outPointX; |
|
880 } |
|
881 |
|
882 return selectedArea; |
|
883 |
|
884 } |
|
885 |
|
886 // End of File |
|