|
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 * Header file for RedEyeReduction plugin control class. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 #ifndef IMAGEEDITORCROPCONTROL_H |
|
23 #define IMAGEEDITORCROPCONTROL_H |
|
24 |
|
25 // INCLUDES |
|
26 #include <coecntrl.h> |
|
27 #include "PreviewControlBase.h" |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 class CAknView; |
|
31 class CFbsBitmap; |
|
32 class CPluginInfo; |
|
33 class CSystemParameters; |
|
34 class CAknInfoPopupNoteController; |
|
35 |
|
36 #ifdef RD_TACTILE_FEEDBACK |
|
37 class MTouchFeedback; |
|
38 #endif /* RD_TACTILE_FEEDBACK */ |
|
39 |
|
40 /* CLASS: CImageEditorRedEyeReductionControl |
|
41 * |
|
42 * CImageEditorRedEyeReductionControl is a control for red eye reduction plug-in. |
|
43 * |
|
44 */ |
|
45 class CImageEditorRedEyeReductionControl : public CPreviewControlBase |
|
46 { |
|
47 |
|
48 public: |
|
49 |
|
50 /** @name Methods:*/ |
|
51 //@{ |
|
52 |
|
53 /** NewL factory method, pops cleanupstack |
|
54 * |
|
55 * @param aRect - control rectangle |
|
56 * @param aParent - pointer to window owning control |
|
57 * @return pointer to created CImageEditorRedEyeReductionControl object |
|
58 */ |
|
59 static CImageEditorRedEyeReductionControl * NewL ( |
|
60 const TRect & aRect, |
|
61 CCoeControl * aParent |
|
62 ); |
|
63 |
|
64 /** DancingAntzCallback |
|
65 * |
|
66 * Static callback for rotating dancing ants. |
|
67 * |
|
68 * @param aPtr - parameter given for TCallBack |
|
69 * @return TInt |
|
70 */ |
|
71 static TInt DancingAntzCallback (TAny * aPtr); |
|
72 |
|
73 /** FastKeyCallback |
|
74 * |
|
75 * Static callback for triggering keys faster. |
|
76 * |
|
77 * @param aPtr - parameter given for TCallBack |
|
78 * @return TInt |
|
79 */ |
|
80 static TInt FastKeyCallback (TAny * aPtr); |
|
81 |
|
82 /** Destructor |
|
83 * |
|
84 * @param - |
|
85 * @return - |
|
86 */ |
|
87 virtual ~CImageEditorRedEyeReductionControl (); |
|
88 |
|
89 /* Setter for view reference |
|
90 * |
|
91 * @see CImageEditorControlBase |
|
92 * |
|
93 */ |
|
94 virtual void SetView (CAknView * aView); |
|
95 |
|
96 /* SetSelectedUiItemL |
|
97 * |
|
98 * @see CImageEditorControlBase |
|
99 * |
|
100 */ |
|
101 virtual void SetSelectedUiItemL (CPluginInfo * aItem); |
|
102 |
|
103 /** PrepareL |
|
104 * |
|
105 * @see CImageEditorControlBase |
|
106 * |
|
107 */ |
|
108 virtual void PrepareL (); |
|
109 |
|
110 /* OfferKeyEventL |
|
111 * |
|
112 * @see CImageEditorControlBase |
|
113 * |
|
114 */ |
|
115 virtual TKeyResponse OfferKeyEventL ( |
|
116 const TKeyEvent & aKeyEvent, |
|
117 TEventCode aType |
|
118 ); |
|
119 |
|
120 /* HandlePluginCommandL |
|
121 * |
|
122 * @see CImageEditorControlBase |
|
123 * |
|
124 */ |
|
125 virtual void HandlePluginCommandL (const TInt aCommand); |
|
126 |
|
127 /* GetDimmedMenuItems |
|
128 * |
|
129 * @see CImageEditorControlBase |
|
130 */ |
|
131 virtual TBitField GetDimmedMenuItems(); |
|
132 |
|
133 /* GetSoftkeyIndexL |
|
134 * |
|
135 * @see CImageEditorControlBase |
|
136 */ |
|
137 virtual TInt GetSoftkeyIndexL(); |
|
138 |
|
139 /* GetNaviPaneTextL |
|
140 * |
|
141 * @see CImageEditorControlBase |
|
142 */ |
|
143 virtual TPtrC GetNaviPaneTextL ( |
|
144 TBool& aLeftNaviPaneScrollButtonVisibile, |
|
145 TBool& aRightNaviPaneScrollButtonVisible); |
|
146 |
|
147 /* GetParam |
|
148 * |
|
149 * Gets pointer to the parameter struct. |
|
150 * |
|
151 * @param - |
|
152 * @return - pointer to MIA parameter struct |
|
153 */ |
|
154 TRect GetParam (); |
|
155 |
|
156 /* SetSysteParameters |
|
157 * |
|
158 * Sets reference to system parameters to plug-in. |
|
159 * |
|
160 * @param aSysPars - System parameters instance |
|
161 * @return - |
|
162 */ |
|
163 void SetSystemParameters (const CSystemParameters * aSysPars); |
|
164 |
|
165 /** IsReadyToRender |
|
166 * |
|
167 * Return ETrue if all parameters have valid value and filter |
|
168 * can be rendered. |
|
169 * |
|
170 * @param - |
|
171 * @return - ETrue if ready to render, otherwise EFalse |
|
172 */ |
|
173 TBool IsReadyToRender() const; |
|
174 |
|
175 /* GetHelpContext |
|
176 * |
|
177 * @see CCoeControl |
|
178 * |
|
179 */ |
|
180 virtual void GetHelpContext(TCoeHelpContext& aContext) const; |
|
181 |
|
182 |
|
183 //@} |
|
184 |
|
185 protected: |
|
186 |
|
187 /** @name Methods:*/ |
|
188 //@{ |
|
189 /* SizeChanged |
|
190 * |
|
191 * @see CImageEditorControlBase |
|
192 * |
|
193 */ |
|
194 virtual void SizeChanged(); |
|
195 |
|
196 /* HandlePointerEventL |
|
197 * |
|
198 * @see CImageEditorControlBase |
|
199 * |
|
200 */ |
|
201 virtual void HandlePointerEventL( const TPointerEvent &aPointerEvent ); |
|
202 |
|
203 |
|
204 //@} |
|
205 |
|
206 /** @name Members:*/ |
|
207 //@{ |
|
208 |
|
209 //@} |
|
210 |
|
211 private: |
|
212 |
|
213 /** @name Methods:*/ |
|
214 //@{ |
|
215 |
|
216 /** Default constructor |
|
217 * |
|
218 * @param - |
|
219 * @return - |
|
220 */ |
|
221 CImageEditorRedEyeReductionControl (); |
|
222 |
|
223 /** Second phase constructor |
|
224 * |
|
225 * @see CImageEditorControlBase |
|
226 * |
|
227 */ |
|
228 virtual void ConstructL ( |
|
229 const TRect & aRect, |
|
230 CCoeControl * aParent |
|
231 ); |
|
232 |
|
233 /** Draw |
|
234 * |
|
235 * @see CImageEditorControlBase |
|
236 * |
|
237 */ |
|
238 virtual void Draw (const TRect & aRect) const; |
|
239 |
|
240 /** DrawDancingAntz |
|
241 * |
|
242 * Drawing function for dancing ants selection border. |
|
243 * |
|
244 * @param aRect - control rectangle in need of refreshing |
|
245 * @return - |
|
246 */ |
|
247 void DrawDancingAntz (const TRect & aRect) const; |
|
248 |
|
249 /** NaviDown |
|
250 * |
|
251 * Handles navi key down event. |
|
252 * |
|
253 * @param - |
|
254 * @return - |
|
255 */ |
|
256 void NaviDown(); |
|
257 |
|
258 /** NaviUp |
|
259 * |
|
260 * Handles nave key up event. |
|
261 * |
|
262 * @param - |
|
263 * @return - |
|
264 */ |
|
265 void NaviUp(); |
|
266 |
|
267 /** NaviRight |
|
268 * |
|
269 * Handles nave key right event. |
|
270 * |
|
271 * @param - |
|
272 * @return - |
|
273 */ |
|
274 void NaviRight(); |
|
275 |
|
276 /** NaviLeft |
|
277 * |
|
278 * Handles navi key left event. |
|
279 * |
|
280 * @param - |
|
281 * @return - |
|
282 */ |
|
283 void NaviLeft(); |
|
284 |
|
285 /** KeyOkL |
|
286 * |
|
287 * Handles OK key event. |
|
288 * |
|
289 * @param - |
|
290 * @return - |
|
291 */ |
|
292 void KeyOkL(); |
|
293 |
|
294 /** CancelPluginL |
|
295 * |
|
296 * Handles the cancel command; Undo all the filters |
|
297 * except for the first; the plugin manager takes care of that. |
|
298 * |
|
299 * @param - |
|
300 * @return - |
|
301 */ |
|
302 void CancelPluginL(); |
|
303 |
|
304 /** ToMoveState |
|
305 * |
|
306 * Handles transition to Move state. |
|
307 * |
|
308 * @param - |
|
309 * @return - |
|
310 */ |
|
311 void ToMoveStateL(); |
|
312 |
|
313 /** ToResizeState |
|
314 * |
|
315 * Handles transition to Resize state. |
|
316 * |
|
317 * @param - |
|
318 * @return - |
|
319 */ |
|
320 void ToResizeStateL(); |
|
321 |
|
322 /** CursorLocation |
|
323 * |
|
324 * Calculates the selection point in real coordinates |
|
325 * relative to the preview image. |
|
326 * |
|
327 * @param - |
|
328 * @return TPoint |
|
329 */ |
|
330 TPoint CursorLocation() const; |
|
331 |
|
332 /** SelectionRect |
|
333 * |
|
334 * Calculates a rectangle from the current coordinates and selection radius, |
|
335 * in real coordinates relative to the preview image. |
|
336 * |
|
337 * @param aCenter centerpoint in real coordinates |
|
338 * @return TRect |
|
339 */ |
|
340 TRect SelectionRect( const TPoint& aCenter ) const; |
|
341 |
|
342 /** ComputeParams |
|
343 * |
|
344 * Calculates the filter parameters and |
|
345 * updates them to the engine parameter struct. |
|
346 * |
|
347 * @param - |
|
348 * @return - |
|
349 */ |
|
350 void ComputeParams(); |
|
351 |
|
352 /** AddFilterToEngineL |
|
353 * |
|
354 * |
|
355 * |
|
356 * |
|
357 * @param - |
|
358 * @return - |
|
359 */ |
|
360 void AddFilterToEngineL(); |
|
361 |
|
362 /** UndoL |
|
363 * |
|
364 * Undo one step of the red-eye reduction process. |
|
365 * (The scope is different from the global undo.) |
|
366 * |
|
367 * @param - |
|
368 * @return - |
|
369 */ |
|
370 void UndoL(); |
|
371 |
|
372 /** StartDancingAntzTimer |
|
373 * |
|
374 * Starts dancing ants timer. |
|
375 * |
|
376 * @param - |
|
377 * @return - |
|
378 */ |
|
379 void StartDancingAntzTimer(); |
|
380 |
|
381 /** StartFastKeyTimer |
|
382 * |
|
383 * Starts fast key timer. |
|
384 * |
|
385 * @param - |
|
386 * @return - |
|
387 */ |
|
388 void StartFastKeyTimer(); |
|
389 |
|
390 /** OnDancingAntzCallBack |
|
391 * |
|
392 * Timer event handler for dancing ants. |
|
393 * |
|
394 * @param - |
|
395 * @return - |
|
396 */ |
|
397 void OnDancingAntzCallBack(); |
|
398 |
|
399 /** OnFastKeyCallBackL |
|
400 * |
|
401 * Timer event handler for fast keys. |
|
402 * |
|
403 * @param - |
|
404 * @return - |
|
405 */ |
|
406 void OnFastKeyCallBackL(); |
|
407 |
|
408 /** Copy constructor, disabled |
|
409 */ |
|
410 CImageEditorRedEyeReductionControl (const CImageEditorRedEyeReductionControl & rhs); |
|
411 |
|
412 /** Assignment operator, disabled |
|
413 */ |
|
414 CImageEditorRedEyeReductionControl & operator= (const CImageEditorRedEyeReductionControl & rhs); |
|
415 |
|
416 /** ClipPosition |
|
417 * |
|
418 * Clips clipart position after screen mode change. |
|
419 * |
|
420 * @param - |
|
421 * @return - |
|
422 */ |
|
423 void ClipPosition(); |
|
424 |
|
425 /** SetCursorPosition |
|
426 * |
|
427 * Sets the cursor to a position given as a parameter |
|
428 * |
|
429 * @param aNewPosition a point where to set the cursor |
|
430 * @return - |
|
431 */ |
|
432 void SetCursorPosition( TPoint aNewPosition ); |
|
433 |
|
434 /** CrossHairCursorRect |
|
435 * |
|
436 * Returns the rect of Cross hair cursor |
|
437 * |
|
438 * @param - |
|
439 * @return TRect cursor rect |
|
440 */ |
|
441 TRect CrossHairCursorRect() const; |
|
442 |
|
443 /** CursorTapped |
|
444 * |
|
445 * Gets a point as an parameter and returns whether |
|
446 * current cursor rect includes that point |
|
447 * |
|
448 * @param aTappedPosition a point that was tapped by pen |
|
449 * @return TBool ETrue if cursor includes tapped point |
|
450 * EFalse otherwise |
|
451 */ |
|
452 TBool CursorTapped( TPoint aTappedPosition ) const; |
|
453 |
|
454 /** ShowTooltip |
|
455 * |
|
456 * Show tooltip text on the screen. Tooltip text is set based |
|
457 * on the current state. |
|
458 * |
|
459 * @param - |
|
460 * @return - |
|
461 */ |
|
462 void ShowTooltip(); |
|
463 |
|
464 /** CalculateResize |
|
465 * |
|
466 * Function is used to calculate a new redius value for outline circle |
|
467 * when circle is resized with touch. The value is calculated based on |
|
468 * dragging start and end points. |
|
469 * |
|
470 * @param - aStartPoint - A position where dragging started |
|
471 * @param - aEndPoint - A position where dragging ended |
|
472 * @return - TBool - ETrue if radius value is changed in the function |
|
473 */ |
|
474 TBool CalculateResize( TPoint aStartPoint, TPoint aEndPoint ); |
|
475 |
|
476 //@} |
|
477 |
|
478 /** @name Typedefs:*/ |
|
479 //@{ |
|
480 /** UI state |
|
481 */ |
|
482 enum TRedEyeReductionStateState |
|
483 { |
|
484 // Invalid |
|
485 ERedEyeReductionStateMin = 0, |
|
486 // Move |
|
487 ERedEyeReductionStateMoveCrosshair, |
|
488 // Resize |
|
489 ERedEyeReductionStateResizeSelection, |
|
490 // Done - preparing to close |
|
491 ERedEyeReductionStateDone, |
|
492 // Invalid |
|
493 ERedEyeReductionStateMax |
|
494 } iState; |
|
495 //@} |
|
496 |
|
497 |
|
498 /** @name Members:*/ |
|
499 //@{ |
|
500 /// Editor view |
|
501 CAknView * iEditorView; |
|
502 /// Cross hair icon |
|
503 CFbsBitmap * iCrossHair; |
|
504 CFbsBitmap * iCrossHairMask; |
|
505 /// Visible image rect |
|
506 const TRect* iVisibleImageRectPrev; |
|
507 /// Viewport rect (the original image) |
|
508 const TRect* iVisibleImageRect; |
|
509 /// Plug-in info |
|
510 CPluginInfo * iItem; |
|
511 /// Navigation pane text |
|
512 TBuf<64> iNaviPaneText; |
|
513 /// Relative X position of the crosshair |
|
514 TReal iX; |
|
515 /// Relative Y position of the crosshair |
|
516 TReal iY; |
|
517 /// Relative selection radius |
|
518 TReal iR; |
|
519 /// Array of already selected red eye locations |
|
520 RArray<TRect> iUndoArray; |
|
521 /// Periodic timer for dancing ants and fast key events |
|
522 CPeriodic * iTimer; |
|
523 /// Dancing ants flag |
|
524 TBool iAntFlag; |
|
525 /// Pressed key event code |
|
526 TInt iPressedKeyScanCode; |
|
527 /// Are event keys handled |
|
528 TBool iHandleEventKeys; |
|
529 /// Number of ticks since timer start |
|
530 TInt iTickCount; |
|
531 /// Multiplier to control the navigation movement speed |
|
532 TInt iNaviStepMultiplier; |
|
533 /// Ready to render |
|
534 TBool iReadyToRender; |
|
535 /// Red-eye removal region |
|
536 TRect iRedEyeRect; |
|
537 /// If the flag is set, return empty paraeters |
|
538 TBool iDoNotUpdateParameters; |
|
539 /// Selection point on image, used when changing modes |
|
540 TPoint iLockPoint; |
|
541 /// System parameters |
|
542 const CSystemParameters * iSysPars; |
|
543 // Popup controller |
|
544 CAknInfoPopupNoteController* iPopupController; |
|
545 // Tooltip texts |
|
546 HBufC * iTooltipLocate; |
|
547 HBufC * iTooltipOutline; |
|
548 |
|
549 // Cursor can be dragged or not with pen |
|
550 TBool iCursorDragEnabled; |
|
551 |
|
552 // Tapped position |
|
553 TPoint iPointerPosition; |
|
554 |
|
555 // Feedback for screen touch: |
|
556 #ifdef RD_TACTILE_FEEDBACK |
|
557 MTouchFeedback* iTouchFeedBack; |
|
558 #endif /* RD_TACTILE_FEEDBACK */ |
|
559 //@} |
|
560 |
|
561 }; |
|
562 |
|
563 |
|
564 #endif |