Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_GalleryCanvas.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 #include <FBaseColArrayList.h>
18 #include <FGrpCanvas.h>
19 #include <FGrpFloatRectangle.h>
20 #include <FGrpPoint.h>
21 #include <FGrpRectangle.h>
22 #include <FUiAnimVisualElementPropertyAnimation.h>
23 #include <FBaseSysLog.h>
24 #include "FUiAnim_VisualElement.h"
25 #include "FUiCtrl_GalleryCanvas.h"
26 #include "FUiCtrl_GalleryBitmap.h"
27
28
29 using namespace Tizen::Base;
30 using namespace Tizen::Graphics;
31 using namespace Tizen::Ui;
32 using namespace Tizen::Ui::Animations;
33
34 namespace Tizen { namespace Ui { namespace Controls
35 {
36
37 _GalleryAnimationProvider::_GalleryAnimationProvider(void)
38         : __pAnimationDelegator(null)
39 {
40         __animationTiming.duration_ms = 0;
41         __animationTiming.timingFunction = GALLERY_ANIMATION_TIMING_FUNC_LINEAR;
42 }
43
44 _GalleryAnimationProvider::~_GalleryAnimationProvider(void)
45 {
46         // Do nothing
47 }
48
49 VisualElementAnimation*
50 _GalleryAnimationProvider::CreateAnimationForProperty(VisualElement& source, const String& property)
51 {
52         const IVisualElementAnimationTimingFunction* pTimingFunction = GetTimingFunc(__animationTiming.timingFunction);
53
54         VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(source, property);//dynamic_cast<VisualElementPropertyAnimation*>(visualElement.CreateAnimationForPropertyN(visualElement, VEPropTransform));
55         if (pAnimation != null)
56         {
57                 result r = pAnimation->SetDuration(__animationTiming.duration_ms);
58                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
59
60                 pAnimation->SetTimingFunction(pTimingFunction);
61                 pAnimation->SetVisualElementAnimationStatusEventListener(__pAnimationDelegator);
62         }
63
64         SetLastResult(E_SUCCESS);
65
66         return pAnimation;
67
68 CATCH:
69         delete pAnimation;
70
71         return null;
72 }
73
74 void
75 _GalleryAnimationProvider::SetAnimationDelegator(IVisualElementAnimationStatusEventListener* pAnimationDelegator)
76 {
77         __pAnimationDelegator = pAnimationDelegator;
78         return;
79 }
80
81 void
82 _GalleryAnimationProvider::SetGalleryAnimationTiming(_GalleryAnimationTiming animationTiming)
83 {
84         __animationTiming = animationTiming;
85         return;
86 }
87
88 const IVisualElementAnimationTimingFunction*
89 _GalleryAnimationProvider::GetTimingFunc(_GalleryAnimationTimingFunction timingFunction) const
90 {
91         const IVisualElementAnimationTimingFunction* pTimingFunc = null;
92         switch (timingFunction)
93         {
94         case GALLERY_ANIMATION_TIMING_FUNC_LINEAR:
95                 pTimingFunc = VisualElementAnimation::GetTimingFunctionByName("Linear");
96                 break;
97         case GALLERY_ANIMATION_TIMING_FUNC_EASEIN:
98                 pTimingFunc = VisualElementAnimation::GetTimingFunctionByName("EaseIn");
99                 break;
100         case GALLERY_ANIMATION_TIMING_FUNC_EASEOUT:
101                 pTimingFunc = VisualElementAnimation::GetTimingFunctionByName("EaseOut");
102                 break;
103         case GALLERY_ANIMATION_TIMING_FUNC_EASEINOUT:
104                 pTimingFunc = VisualElementAnimation::GetTimingFunctionByName("EaseInOut");
105                 break;
106         default:
107                 break;
108         }
109
110         return pTimingFunc;
111 }
112
113
114 // _GalleryCanvas
115 _GalleryCanvas*
116 _GalleryCanvas::CreateGalleryCanvasN(Rectangle& canvasBounds)
117 {
118         result r = E_SUCCESS;
119
120         _GalleryCanvas* pCanvas = new (std::nothrow) _GalleryCanvas();
121         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY,
122                                         "[E_OUT_OF_MEMORY] Failed to allocate the memory for the _GalleryCanvas.");
123
124         r = pCanvas->Construct(canvasBounds);
125         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
126
127         SetLastResult(E_SUCCESS);
128
129         return pCanvas;
130
131 CATCH:
132         delete pCanvas;
133
134         return null;
135 }
136
137 result
138 _GalleryCanvas::SetImage(const _GalleryBitmap* pImage, const Rectangle& viewBounds, _GalleryFittingType fittingType)
139 {
140         if (pImage == null)
141         {
142                 return E_SUCCESS;
143         }
144
145         Rectangle canvasBounds = GetBounds();
146         canvasBounds.width = viewBounds.width;
147         canvasBounds.height = viewBounds.height;
148         result r = SetBounds(canvasBounds);
149         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
150
151         _GalleryBitmap* pCanvasImage = _GalleryBitmap::CloneN(const_cast<_GalleryBitmap*>(pImage));
152         r = GetLastResult();
153         SysTryReturn(NID_UI_CTRL, pCanvasImage != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
154
155         delete __pImage;
156         __pImage = pCanvasImage;
157
158         if (__pImage->IsInitialize() == false || __visualElementBoundsChanged == true)
159         {
160                 result r = __pImage->Initialize(__pRootCanvas->GetControlSize(), fittingType);
161                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
162
163                 Dimension imageSize = __pImage->GetSize();
164                 Point position(0,0);
165                 if (__imageVerticalAlignment == GALLERY_VERTICAL_ALIGN_MIDDLE)
166                 {
167                         position.y = (__bounds.height - imageSize.height) >> 1;
168                 }
169                 else if (__imageVerticalAlignment == GALLERY_VERTICAL_ALIGN_BOTTOM)
170                 {
171                         position.y = (__bounds.height - imageSize.height);
172                 }
173                 if (__imageHorizontalAlignment == GALLERY_HORIZONTAL_ALIGN_CENTER)
174                 {
175                         position.x = (__bounds.width - imageSize.width) >> 1;
176                 }
177                 else if (__imageHorizontalAlignment == GALLERY_HORIZONTAL_ALIGN_RIGHT)
178                 {
179                         position.x = (__bounds.width - imageSize.width);
180                 }
181
182                 Rectangle visualElementBounds(position.x, position.y, imageSize.width, imageSize.height);
183                 r = SetVisualElementBounds(visualElementBounds);
184                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
185
186                 __originalImageBounds = visualElementBounds;
187                 SetImageBounds(GetBounds());
188
189                 __visualElementBoundsChanged = false;
190         }
191
192         SetNeedUpdateImage(true);
193
194         return E_SUCCESS;
195 }
196
197 _GalleryBitmap*
198 _GalleryCanvas::GetImage(void) const
199 {
200         return __pImage;
201 }
202
203 result
204 _GalleryCanvas::SetBounds(const Rectangle& bounds)
205 {
206         SysTryReturnResult(NID_UI_CTRL, bounds.width >= 0 && bounds.height >= 0, E_INVALID_ARG,
207                         "The bounds width or height is negative value.");
208         __bounds = bounds;
209         if (GetFrameVisualElement().IsClipChildrenEnabled() == true)
210         {
211                 FloatRectangle floatBounds(bounds.x, bounds.y, bounds.width, bounds.height);
212                 GetFrameVisualElement().SetBounds(floatBounds);
213         }
214         return E_SUCCESS;
215 }
216
217 const Rectangle&
218 _GalleryCanvas::GetBounds(void) const
219 {
220         return __bounds;
221 }
222
223 result
224 _GalleryCanvas::SetVisibility(bool visibility)
225 {
226         GetImageVisualElement().SetImplicitAnimationEnabled(false);
227         GetImageVisualElement().SetShowState(visibility);
228         GetFrameVisualElement().SetImplicitAnimationEnabled(false);
229         GetFrameVisualElement().SetShowState(visibility);
230
231         return E_SUCCESS;
232 }
233
234 bool
235 _GalleryCanvas::IsVisibility(void) const
236 {
237         return GetImageVisualElement().GetShowState();
238 }
239
240 result
241 _GalleryCanvas::RefreshCanvas(void)
242 {
243         return GetImageVisualElement().InvalidateRectangle(null);
244 }
245
246 result
247 _GalleryCanvas::LoadImage(void)
248 {
249         Canvas* pCanvas = null;
250         result r = E_SUCCESS;
251
252         if (IsNeedUpdateImage() == true)
253         {
254                 _GalleryBitmap* pImage = GetImage();
255                 if (pImage != null)
256                 {
257                         pCanvas = GetImageVisualElement().GetCanvasN();
258                         r = GetLastResult();
259                         SysTryCatch(NID_UI_CTRL, pCanvas != null, , r, "[%s] Propagating.", GetErrorMessage(r));
260
261                         r = pCanvas->DrawBitmap(Point(0, 0), *pImage->GetInternalBitmap());
262                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
263
264                         r = GetImageVisualElement().SetFlushNeeded();
265                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
266
267                         delete pCanvas;
268                 }
269                 SetNeedUpdateImage(false);
270         }
271
272         return E_SUCCESS;
273
274 CATCH:
275         delete pCanvas;
276         return r;
277 }
278
279 _GalleryCanvas::_GalleryCanvas(void)
280         : __pImageVisualElement(null)
281         , __pFrameVisualElement(null)
282         , __pAnimation(null)
283         , __bounds(0, 0, 0, 0)
284         , __pImage(null)
285         , __visableRegionOfImage(0, 0, 0, 0)
286         , __needUpdateImage(false)
287         , __visualElementBoundsChanged(false)
288         , __imageBounds(0, 0, 0, 0)
289         , __originalImageBounds(0, 0, 0, 0)
290         , __pRootCanvas(null)
291         , __factor(1.0)
292         , __imageAnchor(0, 0)
293         , __imageVerticalAlignment(GALLERY_VERTICAL_ALIGN_MIDDLE)
294         , __imageHorizontalAlignment(GALLERY_HORIZONTAL_ALIGN_CENTER)
295 {
296         // Do nothing
297 }
298
299 _GalleryCanvas::~_GalleryCanvas(void)
300 {
301         GetImageVisualElement().RemoveAllAnimations();
302
303         delete __pImage;
304         __pImage = null;
305
306         if (__pImageVisualElement != null)
307         {
308                 __pImageVisualElement->Destroy();
309         }
310
311         if (__pFrameVisualElement != null)
312         {
313                 __pFrameVisualElement->Destroy();
314         }
315 }
316
317 result
318 _GalleryCanvas::Construct(Rectangle& canvasBounds)
319 {
320         result r = E_SUCCESS;
321         _VisualElement* pImageVisualElement = null;
322         _VisualElement* pFrameVisualElement = null;
323         FloatRectangle floatBounds(canvasBounds.x, canvasBounds.y, canvasBounds.width, canvasBounds.height);
324
325         pImageVisualElement = new (std::nothrow) _VisualElement();
326         SysTryCatch(NID_UI_CTRL, pImageVisualElement != null, , E_OUT_OF_MEMORY,
327                                         "[E_OUT_OF_MEMORY] Failed to allocate the memory for the _VisualElement.");
328
329         r = pImageVisualElement->Construct();
330         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
331
332         pImageVisualElement->SetImplicitAnimationEnabled(false);
333         pImageVisualElement->SetBounds(floatBounds);
334
335         pImageVisualElement->SetShowState(true);
336
337         r = pImageVisualElement->SetSurfaceOpaque(false);
338         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
339
340         SetImageVisualElement(*pImageVisualElement);
341
342         pFrameVisualElement = new (std::nothrow) _VisualElement();
343         SysTryCatch(NID_UI_CTRL, pFrameVisualElement != null, , E_OUT_OF_MEMORY,
344                                         "[E_OUT_OF_MEMORY] Failed to allocate the memory for the _VisualElement.");
345         r = pFrameVisualElement->Construct();
346         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
347
348         pFrameVisualElement->SetImplicitAnimationEnabled(false);
349         pFrameVisualElement->SetBounds(floatBounds);
350
351         pFrameVisualElement->SetShowState(true);
352
353         SetFrameVisualElement(*pFrameVisualElement);
354
355         r = GetFrameVisualElement().AttachChild(GetImageVisualElement());
356         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
357
358         GetFrameVisualElement().SetClipChildrenEnabled(true);
359
360         return E_SUCCESS;
361
362 CATCH:
363         if (pImageVisualElement != null)
364         {
365                 pImageVisualElement->Destroy();
366         }
367
368         if (pFrameVisualElement != null)
369         {
370                 pFrameVisualElement->Destroy();
371         }
372         __pImageVisualElement = null;
373         __pFrameVisualElement = null;
374
375         return r;
376 }
377
378 void
379 _GalleryCanvas::SetImageVisualElement(_VisualElement& visualElement)
380 {
381         __pImageVisualElement = &visualElement;
382         return;
383 }
384
385 _VisualElement&
386 _GalleryCanvas::GetImageVisualElement(void) const
387 {
388         return *__pImageVisualElement;
389 }
390
391 void
392 _GalleryCanvas::SetFrameVisualElement(_VisualElement& visualElement)
393 {
394         __pFrameVisualElement = &visualElement;
395         return;
396 }
397
398 _VisualElement&
399 _GalleryCanvas::GetFrameVisualElement(void) const
400 {
401         return *__pFrameVisualElement;
402 }
403
404 void
405 _GalleryCanvas::SetAnimation(VisualElementPropertyAnimation& animation)
406 {
407         __pAnimation = &animation;
408         return;
409 }
410
411 VisualElementPropertyAnimation&
412 _GalleryCanvas::GetAnimation(void) const
413 {
414         return *__pAnimation;
415 }
416
417 void
418 _GalleryCanvas::SetNeedUpdateImage(bool needUpdate)
419 {
420         __needUpdateImage = needUpdate;
421         return;
422 }
423
424 bool
425 _GalleryCanvas::IsNeedUpdateImage(void) const
426 {
427         return __needUpdateImage;
428 }
429
430 void
431 _GalleryCanvas::SetCanvasFactor(float factor)
432 {
433         __factor = factor;
434         return;
435 }
436
437 float
438 _GalleryCanvas::GetCanvasFactor(void) const
439 {
440         return __factor;
441 }
442
443 result
444 _GalleryCanvas::SetVisualElementBounds(const Rectangle& bounds)
445 {
446         __visualElementBoundsChanged = true;
447         FloatRectangle floatBounds(bounds.x, bounds.y, bounds.width, bounds.height);
448         return GetImageVisualElement().SetBounds(floatBounds);
449 }
450
451 Rectangle
452 _GalleryCanvas::GetImageVisualElementBounds(void) const
453 {
454         FloatRectangle floatRect = GetImageVisualElement().GetBounds();
455         Rectangle bounds(floatRect.x, floatRect.y, floatRect.width, floatRect.height);
456
457         return bounds;
458 }
459
460 void
461 _GalleryCanvas::SetImageBounds(const Rectangle& canvasBounds)
462 {
463         float factor = GetCanvasFactor();
464         if (__visualElementBoundsChanged == true)
465         {
466                 factor = 1.0f;
467         }
468         __imageBounds.width = __originalImageBounds.width * factor;
469         __imageBounds.height = __originalImageBounds.height * factor;
470
471         if (__imageVerticalAlignment == GALLERY_VERTICAL_ALIGN_MIDDLE)
472         {
473                 __imageBounds.y = (canvasBounds.height - __imageBounds.height) >> 1;
474         }
475         else if (__imageVerticalAlignment == GALLERY_VERTICAL_ALIGN_BOTTOM)
476         {
477                 __imageBounds.y = (canvasBounds.height - __imageBounds.height);
478         }
479         if (__imageHorizontalAlignment == GALLERY_HORIZONTAL_ALIGN_CENTER)
480         {
481                 __imageBounds.x = (canvasBounds.width - __imageBounds.width) >> 1;
482         }
483         else if (__imageHorizontalAlignment == GALLERY_HORIZONTAL_ALIGN_RIGHT)
484         {
485                 __imageBounds.x = (canvasBounds.width - __imageBounds.width);
486         }
487
488         return;
489 }
490
491 Rectangle
492 _GalleryCanvas::GetOriginalImageBounds(void) const
493 {
494         return __originalImageBounds;
495 }
496
497 Rectangle
498 _GalleryCanvas::GetImageBounds(void) const
499 {
500         return __imageBounds;
501 }
502
503 result
504 _GalleryCanvas::SetAnimationDelegator(_GalleryAnimationProvider* pVEDelegator)
505 {
506         result r = GetImageVisualElement().SetAnimationProvider(pVEDelegator);
507         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
508
509         r = GetFrameVisualElement().SetAnimationProvider(pVEDelegator);
510         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
511
512         return E_SUCCESS;
513 }
514
515 void
516 _GalleryCanvas::SetRootCanvas(_GalleryRootCanvas& rootCanvas)
517 {
518         __pRootCanvas = &rootCanvas;
519         return;
520 }
521
522 void
523 _GalleryCanvas::SetImageAnchor(Tizen::Graphics::FloatPoint anchor)
524 {
525         __imageAnchor = anchor;
526         return;
527 }
528
529 FloatPoint
530 _GalleryCanvas::GetImageAnchor(void) const
531 {
532         return __imageAnchor;
533 }
534
535 Rectangle
536 _GalleryCanvas::GetAlignBoundary(void) const
537 {
538         Rectangle imageBounds = GetImageBounds();
539         if (__originalImageBounds.width != imageBounds.width || __originalImageBounds.height != imageBounds.height)
540         {
541                 imageBounds.x += GetBounds().x;
542                 imageBounds.y += GetBounds().y;
543                 return imageBounds;
544         }
545         else
546         {
547                 return Rectangle(-1, -1, -1, -1);
548         }
549 }
550
551 void
552 _GalleryCanvas::SetClippingOfFrameVisualElement(bool clipping)
553 {
554         GetFrameVisualElement().SetClipChildrenEnabled(clipping);
555 }
556
557 void
558 _GalleryCanvas::SetImageAlignment(_GalleryVerticalAlignment imageVerticalAlignment
559                                                                 , _GalleryHorizontalAlignment imageHorizontalAlignment)
560 {
561         __imageVerticalAlignment = imageVerticalAlignment;
562         __imageHorizontalAlignment = imageHorizontalAlignment;
563 }
564
565 void
566 _GalleryCanvas::GetImageAlignment(_GalleryVerticalAlignment& imageVerticalAlignment
567                                                                 , _GalleryHorizontalAlignment& imageHorizontalAlignment) const
568 {
569         imageVerticalAlignment = __imageVerticalAlignment;
570         imageHorizontalAlignment = __imageHorizontalAlignment;
571 }
572
573
574 // _GalleryRootCanvas
575 _GalleryRootCanvas*
576 _GalleryRootCanvas::CreateGalleryRootCanvasN(_Control& control)
577 {
578         _GalleryRootCanvas* pRootCanvas = new (std::nothrow) _GalleryRootCanvas(control);
579         SysTryReturn(NID_UI_CTRL, pRootCanvas != null, null, E_OUT_OF_MEMORY,
580                                         "[E_OUT_OF_MEMORY] Failed to allocate the memory for the _GalleryRootCanvas.");
581
582         SetLastResult(E_SUCCESS);
583
584         return pRootCanvas;
585 }
586
587 result
588 _GalleryRootCanvas::SetBackgroundImage(const _GalleryBitmap* pImage)
589 {
590         __pBackgroundImage = const_cast <_GalleryBitmap*>(pImage);
591         return E_SUCCESS;
592 }
593
594 _GalleryBitmap*
595 _GalleryRootCanvas::GetBackgroundImage(void) const
596 {
597         return __pBackgroundImage;
598 }
599
600 Color
601 _GalleryRootCanvas::GetBackgroundColor(void) const
602 {
603         return GetControl().GetBackgroundColor();
604 }
605
606 result
607 _GalleryRootCanvas::SetBounds(const Rectangle& bounds)
608 {
609         return GetControl().SetBounds(bounds);
610 }
611
612 Rectangle
613 _GalleryRootCanvas::GetBounds(void) const
614 {
615         return GetControl().GetBounds();
616 }
617
618 Dimension
619 _GalleryRootCanvas::GetControlSize(void) const
620 {
621         return GetControl().GetSize();
622 }
623
624 result
625 _GalleryRootCanvas::SetVisibility(bool visibility)
626 {
627         GetControl().SetVisibleState(visibility);
628
629         return E_SUCCESS;
630 }
631
632 bool
633 _GalleryRootCanvas::IsVisibility(void) const
634 {
635         return GetControl().GetVisibleState();
636 }
637
638 result
639 _GalleryRootCanvas::AddChildCanvas(_GalleryCanvas& canvas)
640 {
641         _VisualElement& childVisualElement = canvas.GetFrameVisualElement();
642         _VisualElement* pRootVisualElement = GetImageVisualElement();
643         SysTryReturn(NID_UI_CTRL, pRootVisualElement != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Root VisualElement is null.");
644
645         result r = pRootVisualElement->AttachChild(childVisualElement);
646         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
647
648         canvas.SetRootCanvas(*this);
649
650         return E_SUCCESS;
651 }
652
653 result
654 _GalleryRootCanvas::RemoveChildCanvas(_GalleryCanvas& canvas)
655 {
656         _VisualElement& childVisualElement = canvas.GetFrameVisualElement();
657         _VisualElement* pRootVisualElement = GetImageVisualElement();
658         SysTryReturn(NID_UI_CTRL, pRootVisualElement != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Root VisualElement is null.");
659
660         result r = pRootVisualElement->DetachChild(childVisualElement);
661         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
662
663         return E_SUCCESS;
664 }
665
666 result
667 _GalleryRootCanvas::RefreshCanvas(void)
668 {
669         //GetControl().Draw();
670         GetControl().Invalidate();
671         return E_SUCCESS;
672 }
673
674 _GalleryRootCanvas::_GalleryRootCanvas(_Control& control)
675         : __pControl(null)
676         , __bounds(0, 0, 0, 0)
677         , __pBackgroundImage(null)
678         , __needUpdateBackgroundImage(false)
679 {
680         SetControl(control);
681 }
682
683 _GalleryRootCanvas::~_GalleryRootCanvas(void)
684 {
685         // Do nothing
686 }
687
688 void
689 _GalleryRootCanvas::SetControl(_Control& control)
690 {
691         __pControl = &control;
692         return;
693 }
694
695 _Control&
696 _GalleryRootCanvas::GetControl(void) const
697 {
698         return *__pControl;
699 }
700
701 _VisualElement*
702 _GalleryRootCanvas::GetImageVisualElement(void) const
703 {
704         return GetControl().GetVisualElement();
705 }
706
707 }}} // Tizen::Ui::Controls