2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.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
9 // http://www.apache.org/licenses/LICENSE-2.0/
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.
19 * @file FUiAnim_VisualElementImpl.cpp
20 * @brief This file contains implementation of _VisualElementImpl class
22 * This file contains implementation _VisualElementImpl class.
26 #include <unique_ptr.h>
27 #include <FBaseString.h>
28 #include <FBaseSysLog.h>
29 #include <FGrpFloatPoint.h>
30 #include <FGrpFloatDimension.h>
31 #include <FGrpFloatRectangle.h>
32 #include <FGrpFloatMatrix4.h>
33 #include <FGrpFloatPoint3.h>
34 #include <FGrpBufferInfo.h>
35 #include <FBaseByteBuffer.h>
36 #include <FGrp_CanvasImpl.h>
37 #include <FGrp_BitmapImpl.h>
38 #include <FUiAnimIVisualElementAnimationStatusEventListener.h>
39 #include <FUiAnimVisualElementPropertyAnimation.h>
40 #include <FUiAnimVisualElementAnimationGroup.h>
41 #include <FUiAnimVisualElementSurface.h>
43 #include <FUiAnimVisualElement.h>
45 #include "FUi_Rectanglef.h"
46 #include "FUi_CoordinateSystemUtils.h"
48 #include "FUiAnim_VisualElementImpl.h"
49 #include "FUiAnim_VisualElementCanvas.h"
51 #include "FUiAnim_VisualElementAnimationImpl.h"
52 #include "FUiAnim_VisualElementAnimationGroupImpl.h"
53 #include "FUiAnim_VisualElementValueAnimationImpl.h"
54 #include "FUiAnim_VisualElementPropertyAnimationImpl.h"
55 #include "FUiAnim_AnimationManager.h"
56 #include "FUiAnim_VisualElementSharedData.h"
57 #include "FUiAnim_RootVisualElement.h"
58 #include "FUiAnim_ControlVisualElement.h"
59 #include "FUiAnim_MatrixUtil.h"
60 #include "FUiAnim_Debug.h"
61 #include "FUiAnim_EflNode.h"
62 #include "FUiAnim_VisualElementSurfaceImpl.h"
63 #include "FUiAnim_EflVisualElementSurfaceImpl.h"
64 #include "FUiAnim_DisplayManager.h"
68 using namespace Tizen::Base;
69 using namespace Tizen::Base::Collection;
70 using namespace Tizen::Graphics;
71 using namespace Tizen::Ui;
73 #define LAZY_EVALUATION // lazy updating and reconfiguring.
74 #define IMPLICIT_ANIMATION_IMPL //prototyping implicit animation.
75 //#define MANUAL_PROPERTY_CHANGE_NOTIFICATION
77 #define IS_INTERNAL_CLASS(_PUBLIC) (likely(typeid(*(_PUBLIC)) == VeTypeId) || likely(typeid(*(_PUBLIC)) == internalVeTypeId) || likely(typeid(*(_PUBLIC)) == controlVeTypeId) || likely(typeid(*(_PUBLIC)) == rootVeTypeId))
78 #define IS_NEEDED_UPDATE_PRESENTATION(__MODEL) (((__MODEL)->__isPropertyPropagationEnabled) && ((__MODEL)->__pPresentation))
81 static const char* STR_ERROR_INVALID_VARIANT_ARG_TYPE = "[E_INVALID_ARG] Invalid argument(s) is used. Variant type is invalid.";
84 CalculateBoundingBox(const float x[4], const float y[4], Tizen::Graphics::FloatRectangle& rectangle)
90 for (int i = 1; i < 4; i++)
107 rectangle.width = maxX - minX;
108 rectangle.height = maxY - minY;
114 namespace Tizen { namespace Ui { namespace Animations
116 // rules of visual element.
118 // 1. almost controlling pSharedData occurred in the PRESENTATION layer.
119 // 2. almost Delegate's methods occurred in the MODEL layer.
122 #define SHOWOPACITY_VISIBLE(so) \
125 #define VE_VISIBLE(o) \
126 SHOWOPACITY_VISIBLE((o)->__showOpacity)
128 #define HAVE_SURFACE(o) \
129 (likely((o)->GetSharedData().pSurface))
131 //TODO: require further examination : __NeedSurface() instead of NEED_SURFACE() macro
132 #define NEED_SURFACE(o) \
133 (likely((o)->GetSharedData().needSurface))
135 #define IS_ATTACHED(o) \
136 ((o)->GetRoot() != null)
138 #define IS_PRESENTATION(o) \
139 ((o)->__pPresentation == (o))
141 #define IS_MODEL(o) \
142 ((o)->__pModel == (o))
144 #define VE_DELEGATE(target, func, ...) \
145 (target)->func(__VA_ARGS__)
149 static const std::type_info& VeTypeId = typeid(VisualElement);
150 static const std::type_info& rootVeTypeId = typeid(_RootVisualElement);
151 static const std::type_info& internalVeTypeId = typeid(_VisualElement);
152 static const std::type_info& controlVeTypeId = typeid(_ControlVisualElement);
154 // declared AnimationEventListener for implicit animation
155 class _VisualElementImplicitAnimationEventListener
156 : public IVisualElementAnimationStatusEventListener
157 , virtual public Tizen::Base::Runtime::IEventListener
160 _VisualElementImplicitAnimationEventListener(void) {}
161 virtual ~_VisualElementImplicitAnimationEventListener(void) {}
163 virtual void OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target) {}
164 virtual void OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount) {}
165 virtual void OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally)
172 IMPLEMENT_PROPERTY(_VisualElementImpl);
174 _VisualElementImpl::_VisualElementImpl(VisualElement& element)
175 : _zOrderGroup(Z_ORDER_GROUP_NORMAL)
176 , __pSharedData(null)
179 , __pPresentation(null)
183 , __showOpacity(0.0f)
184 , __needRecreateSurface(false)
185 , __bounds(0.0f, 0.0f, 0.0f, 0.0f)
186 , __alignedSize(0.0f, 0.0f)
187 , __contentBounds(0.0f, 0.0f, 1.0f, 1.0f)
188 , __useContentBounds(false)
190 , __contentOpacity(1.0f)
192 , __anchor(0.5f, 0.5f)
195 , __decomposedTransform()
196 , __childrenTransform()
197 , __decomposedChildrenTransform()
198 , __childrenNeedsUpdateProps(HIERARCHY_PROPERTY_MASK)
199 , __invalidatedProps(HIERARCHY_PROPERTY_MASK)
200 , __matrixFromTopValid(false)
201 , __matrixFromTopInvertible(true)
202 , __matrixToSuperValid(false)
203 , __matrixToTopValid(false)
204 , __matrixToClipSourceValid(false)
205 , __boundingBoxValid(false)
206 , __visibleRectValid(false)
207 , __needTransform(false)
208 , __needClipForUntransformed(false)
209 , __isImplicitAnimationEnabled(true)
210 , __isClipChildren(false)
211 , __boundingBox(0.0f, 0.0f, 0.0f, 0.0f)
212 , __pClipSource(null)
213 , __visibleRect(0.0f, 0.0f, 0.0f, 0.0f)
214 , __isPropertyPropagationEnabled(true)
215 , __isDestroying(false)
216 , __isHidingParent(false)
217 , __isInternal(false)
218 , __isAllowedTreeModification(true)
219 , __pPublicInstance(&element)
221 , __renderOperation(VisualElement::RENDER_OPERATION_BLEND)
222 , __pBoundsChangedCallback(null)
223 , __pBoundsChangedCallbackData(null)
224 , __pDestroyedCallback(null)
225 , __pDestroyedCallbackData(null)
229 __children.Construct();
232 _VisualElementImpl::_VisualElementImpl(VisualElement& presentation, _VisualElementImpl& modelImpl)
233 : _zOrderGroup(modelImpl._zOrderGroup)
234 , __pSharedData(null)
237 , __pPresentation(null)
239 , __isRoot(modelImpl.__isRoot)
240 , __isVisible(modelImpl.__isVisible)
241 , __showOpacity(modelImpl.__showOpacity)
242 , __needRecreateSurface(false)
243 , __bounds(modelImpl.__bounds)
244 , __alignedSize(modelImpl.__alignedSize)
245 , __contentBounds(modelImpl.__contentBounds)
246 , __useContentBounds(modelImpl.__useContentBounds)
247 , __zPosition(modelImpl.__zPosition)
248 , __contentOpacity(modelImpl.__contentOpacity)
249 , __opacity(modelImpl.__opacity)
250 , __anchor(modelImpl.__anchor)
251 , __anchorZ(modelImpl.__anchorZ)
252 , __transform(modelImpl.__transform)
253 , __decomposedTransform(modelImpl.__decomposedTransform)
254 , __childrenTransform(modelImpl.__childrenTransform)
255 , __decomposedChildrenTransform(modelImpl.__decomposedChildrenTransform)
256 , __childrenNeedsUpdateProps(HIERARCHY_PROPERTY_MASK)
257 , __invalidatedProps(HIERARCHY_PROPERTY_MASK)
258 , __matrixFromTopValid(false)
259 , __matrixFromTopInvertible(true)
260 , __matrixToSuperValid(false)
261 , __matrixToTopValid(false)
262 , __matrixToClipSourceValid(false)
263 , __boundingBoxValid(false)
264 , __visibleRectValid(false)
265 , __needTransform(modelImpl.__needTransform)
266 , __needClipForUntransformed(modelImpl.__needClipForUntransformed)
267 , __isImplicitAnimationEnabled(modelImpl.__isImplicitAnimationEnabled)
268 , __isClipChildren(modelImpl.__isClipChildren)
269 , __boundingBox(0.0f, 0.0f, 0.0f, 0.0f)
270 , __pClipSource(null)
271 , __visibleRect(0.0f, 0.0f, 0.0f, 0.0f)
272 , __isPropertyPropagationEnabled(false) // it differs from the property of MODEL object
273 , __isDestroying(false)
274 , __isHidingParent(modelImpl.__isHidingParent)
275 , __isInternal(modelImpl.__isInternal)
276 , __isAllowedTreeModification(true)
277 , __pPublicInstance(&presentation)
278 , __imageFilePath(modelImpl.__imageFilePath)
279 , __renderOperation(modelImpl.__renderOperation)
280 , __pBoundsChangedCallback(modelImpl.__pBoundsChangedCallback)
281 , __pBoundsChangedCallbackData(modelImpl.__pBoundsChangedCallbackData)
282 , __pDestroyedCallback(modelImpl.__pDestroyedCallback)
283 , __pDestroyedCallbackData(modelImpl.__pDestroyedCallbackData)
287 __children.Construct();
290 _VisualElementImpl::~_VisualElementImpl(void)
293 // clear data after detaching children
294 if (likely(__pSharedData))
296 __pSharedData->Release();
297 __pSharedData = null;
300 // remove public instance
301 __pPublicInstance = null;
303 if (__pDestroyedCallback != null)
305 __pDestroyedCallback(__pDestroyedCallbackData);
310 _VisualElementImpl::Destroy(void)
312 //SysLog(NID_UI_ANIM, "destruct[%x]-->begin", this);
314 if (unlikely(__isDestroying))
319 __isDestroying = true;
323 // Destroy and its callback will be called from the leaf of hiearchy tree first.
324 // That is, this method first destroys children(Destroy and OnDestructing), and it destroys itself later.
326 while (__children.GetCount() > 0)
328 _VisualElementImpl* pChild = __children.GetChildAt(0);
331 //pChild->RemoveFromParent();
333 if (likely(pChild->__pPublicInstance))
335 pChild->__pPublicInstance->Destroy();
339 SysAssertf(false, "VisualElement does not have public instance.");
345 SysAssertf(false, "VisualElement has no child.");
352 // Is this right place for invoking 'OnDestructing' ?
353 // OnConstructed will be called from public instance.
355 if (!IS_PRESENTATION(this))
357 VE_DELEGATE(this, InvokeOnDestructing);
366 if (likely(__pPresentation))
368 __pPresentation->__pPublicInstance->Destroy();
370 __pPresentation = null;
374 _AnimationManager* pManager = _AnimationManager::GetInstance();
377 pManager->RemoveAllAnimations(*__pPublicInstance);
387 _VisualElementImpl::Construct(void)
389 result r = E_SUCCESS;
390 __pSharedData = new (std::nothrow) _VisualElementSharedData;
391 SysTryCatch(NID_UI_ANIM, __pSharedData, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
392 SysTryCatch(NID_UI_ANIM, GetSharedData().Construct() == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] failed in shared data constructing.");
395 __pPresentation = null;
396 //SysLog(NID_UI_ANIM, "Created(efl=%p)", GetSharedData().pNativeNode);
398 #if 0 // REMOVED : We should invoke property observer method manually.
399 if (__isPropertyPropagationEnabled)
401 AddPropertyChangeEventListener(_VisualElementModelObserver::GetInstance());
405 //VE_DELEGATE(this, InvokeOnConstructed);
411 if (likely(__pSharedData))
413 GetSharedData().Release();
414 __pSharedData = null;
420 IVisualElementAnimationProvider*
421 _VisualElementImpl::GetAnimationProvider(void) const
424 SysTryReturn(NID_UI_ANIM, IS_MODEL(this), null, E_INVALID_OPERATION, "[E_INVALID_OPERATION] VisualElement is not Model object.");
426 return GetSharedData().pAnimationProvider;
430 _VisualElementImpl::SetAnimationProvider(IVisualElementAnimationProvider* pProvider)
432 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
434 GetSharedData().pAnimationProvider = pProvider;
439 IVisualElementContentProvider*
440 _VisualElementImpl::GetContentProvider(void) const
443 SysTryReturn(NID_UI_ANIM, IS_MODEL(this), null, E_INVALID_OPERATION, "[E_INVALID_OPERATION] VisualElement is not Model object.");
445 return GetSharedData().pContentProvider;
449 _VisualElementImpl::SetContentProvider(IVisualElementContentProvider* pProvider)
451 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
453 GetSharedData().pContentProvider = pProvider;
458 IVisualElementEventListener*
459 _VisualElementImpl::GetVisualElementEventListener(void) const
462 SysTryReturn(NID_UI_ANIM, IS_MODEL(this), null, E_INVALID_OPERATION, "[E_INVALID_OPERATION] VisualElement is not Model object.");
464 return GetSharedData().pEventListener;
468 _VisualElementImpl::SetVisualElementEventListener(IVisualElementEventListener* pListener)
470 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
472 GetSharedData().pEventListener = pListener;
478 _VisualElementImpl::FlushI(void)
480 #ifdef VE_VSYNC_UPDATE
481 _DisplayManager::GetInstance()->RenderAll();
484 return _DisplayManager::GetInstance()->Flush();
488 _VisualElementImpl::CreateImplicitAnimationIfNeeded( const String& property,
489 const Variant& newValue, const Variant& currentPresentationValue, const String** pSubProperties)
493 _AnimationManager* pAnimationManager = _AnimationManager::GetInstance();
495 if (likely(GetRoot())
496 && likely(GetSharedData().needSurface)
497 && (unlikely(pAnimationManager->IsImplicitAnimationEnabled() && __isImplicitAnimationEnabled)) )
500 // For performance, following must be done only when oldValue != newValue.
501 VisualElementAnimation* pAnimation = InvokeCreateAnimationForProperty(property);
503 // user can make other type animation like aAnimationGroup or ValueAnimation
504 // in this case pPropertyAnimation will have a null value.
505 VisualElementPropertyAnimation* pPropertyAnimation = dynamic_cast< VisualElementPropertyAnimation* >(pAnimation);
506 if (likely(pPropertyAnimation))
508 if (pPropertyAnimation->GetEndValue().IsEmpty())
510 pPropertyAnimation->SetEndValue(newValue);
513 if (pPropertyAnimation->GetStartValue().IsEmpty())
515 pPropertyAnimation->SetStartValue(currentPresentationValue);
520 { // remove sub property
521 for(int i = 0 ; pSubProperties[i] != NULL ; i++)
523 pAnimationManager->RemoveAnimationByProperty(*__pPublicInstance, *pSubProperties[i]);
526 if (unlikely(pAnimation))
529 // Adding property animation causes previous animation for same property to be removed in Animation Manager.
530 if (unlikely(IsFailed(AddAnimation(null, *pAnimation))))
532 pAnimationManager->RemoveAnimationByProperty(*__pPresentation->__pPublicInstance, property);
541 // Remove previous animation even when trying to change the property without animation.
542 pAnimationManager->RemoveAnimationByProperty(*__pPresentation->__pPublicInstance, property);
548 pAnimationManager->RemoveAnimationByProperty(*__pPresentation->__pPublicInstance, property);
556 _VisualElementImpl::SetRenderOperation(VisualElement::RenderOperation renderOperation)
558 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
560 result r = InvokeOnSetPropertyRequested(*pVePropRenderOperation, Variant(static_cast< int >(renderOperation)));
561 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
566 VisualElement::RenderOperation
567 _VisualElementImpl::GetRenderOperation(void) const
572 int renderOperation = InvokeOnGetPropertyRequested(*pVePropRenderOperation).ToInt();
573 if (GetLastResult() != E_SUCCESS)
575 return VisualElement::RENDER_OPERATION_BLEND;
578 return static_cast< VisualElement::RenderOperation >(renderOperation);
580 return __renderOperation;
585 _VisualElementImpl::GetRenderOperationProperty(void) const
589 return Variant(static_cast< int >(__renderOperation));
593 _VisualElementImpl::SetRenderOperationProperty(const Variant& v)
595 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_INT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
597 VisualElement::RenderOperation renderOperation = static_cast< VisualElement::RenderOperation >(v.ToInt());
598 if (likely(__renderOperation != renderOperation))
602 renderOperation >= VisualElement::RENDER_OPERATION_BLEND && renderOperation <= VisualElement::RENDER_OPERATION_COPY,
604 "Invalid argument(s) is used. The given render operation is out of range."
607 __renderOperation = renderOperation;
608 InvalidateHierarchyProps(HIERARCHY_PROPERTY_OPACITY, false, false);
610 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
612 __pPresentation->SetRenderOperationProperty(__renderOperation);
619 _VisualElementImpl::GetBackBufferEnabled(void) const
623 return GetSharedData().needSurface;
627 _VisualElementImpl::SetBackBufferEnabled(bool enabled)
629 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
631 if (likely(GetSharedData().needSurface != enabled))
634 // Need to check transform matrix if the transform matrix is complex(generic). In this case, disabling Backing-Buffer
635 // should not be allowed !
637 if (likely(NEED_SURFACE(this))) // may be redundant checking.... (or using !enabled). Check if this needs surface currently.
640 // __transform.Optimize();
641 // SysTryReturnResult(NID_UI_ANIM, !__transform.IsGeneric(), E_INVALID_STATE, "VisualElement cannot release back-buffer if transform isn't identity or translation.");
643 Matrix4Type matrixType = _GetMatrix4Type(__transform);
646 matrixType == MATRIX4_Identity || matrixType == MATRIX4_Translation,
648 "VisualElement cannot release back-buffer if transform isn't identity nor translation."
652 GetSharedData().needSurface = enabled;
654 if (NEED_SURFACE(this))
656 ExposeRectangle(null, true);
660 InvalidateVisibleRectToRenderTarget(null);
670 _VisualElementImpl::GetRedrawOnResizeEnabled(void) const
674 return GetSharedData().redrawOnResize;
678 _VisualElementImpl::SetRedrawOnResizeEnabled(bool enabled)
680 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
682 GetSharedData().redrawOnResize = enabled;
688 _VisualElementImpl::GetPropertyPropagationEnabled(void) const
692 // TBD: forward using property or direct return ?
694 bool isPropertyPropagationEnabled = InvokeOnGetPropertyRequested(*pVePropPropertyPropagationEnabled).ToBool();
695 if (GetLastResult() != E_SUCCESS)
700 return isPropertyPropagationEnabled;
702 return __isPropertyPropagationEnabled;
707 _VisualElementImpl::SetPropertyPropagationEnabledI(bool enable)
709 if (unlikely(enable == __isPropertyPropagationEnabled))
714 __isPropertyPropagationEnabled = enable;
716 // if (IS_MODEL(this))
718 // if (__isPropertyPropagationEnabled)
720 // AddPropertyChangeEventListener(_VisualElementModelObserver::GetInstance());
724 // RemovePropertyChangeEventListener(_VisualElementModelObserver::GetInstance());
732 _VisualElementImpl::SetPropertyPropagationEnabled(bool enable)
734 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
735 if (enable == __isPropertyPropagationEnabled)
738 result r = InvokeOnSetPropertyRequested(*pVePropPropertyPropagationEnabled, Variant(enable));
739 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
745 _VisualElementImpl::GetPropertyPropagationProperty(void) const
749 return Variant(__isPropertyPropagationEnabled);
753 _VisualElementImpl::SetPropertyPropagationProperty(const Variant& v)
756 // Remove this from property. It is used as a property because of _ControlVisualElement when a control was made up of three VEs.
757 if (IS_PRESENTATION(this))
760 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
762 return SetPropertyPropagationEnabledI(v.ToBool());
766 _VisualElementImpl::IsSurfaceNeeded(void) const
768 // TBD: root VE must have surface always...
769 if (unlikely(!__pParent))
775 const _VisualElementImpl* pCurrent;
780 if (!pCurrent->__pSharedData)
785 if (!pCurrent->GetSharedData().needSurface)
790 pCurrent = pCurrent->__pParent;
795 return GetSharedData().needSurface;
800 _VisualElementImpl::RebuildSurfaces(void)
802 if (unlikely(!IS_PRESENTATION(this)) || unlikely(!IS_ATTACHED(this)))
807 ResetSurfaceIfNeeded();
809 int count = __children.GetCount();
810 for (int i = 0; i < count; i++)
812 __children.GetChildAt(i)->RebuildSurfaces();
817 _VisualElementImpl::ResetSurfaceIfNeeded(void)
819 if (unlikely(!__needRecreateSurface))
824 __needRecreateSurface = false;
826 if (unlikely(HAVE_SURFACE(this)) && unlikely(GetSharedData().fixedSurfaceSize))
832 _VisualElementImpl* pPresentation = null;
834 if (likely(__pPresentation))
836 pPresentation = __pPresentation;
840 pPresentation = this;
843 if (likely(IsSurfaceNeeded()))
847 _RootVisualElement* pRoot = dynamic_cast<_RootVisualElement*>(GetRoot()->GetPublic());
849 if (pRoot && pRoot->GetNativeLayer())
851 GetSharedData().fixedSurfaceSize = false;
853 float surfaceWidth = __bounds.width;
854 float surfaceHeight = __bounds.height;
856 if (likely(GetSharedData().CreateSurface(FloatDimension(surfaceWidth, surfaceHeight), *pRoot->GetNativeLayer()) == E_SUCCESS))
858 if (unlikely(!HAVE_SURFACE(this)))
860 pPresentation->InvalidateVisibleRectToRenderTarget(null);
868 else // surface not needed, so remove Surface
870 if (unlikely(HAVE_SURFACE(this)))
872 GetSharedData().RemoveSurface(*pPresentation);
879 _VisualElementImpl::GetRenderTarget(void) const
881 _VisualElementImpl* pRenderTarget = const_cast< _VisualElementImpl* >(this);
883 while (likely(pRenderTarget))
885 if (likely(NEED_SURFACE(pRenderTarget)))
887 return pRenderTarget;
890 pRenderTarget = pRenderTarget->__pParent;
896 VisualElementSurface*
897 _VisualElementImpl::GetSurfaceN(void) const
899 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
900 pThis->RebuildHierarchyProps(0, true, true);
902 SysTryReturn(NID_UI_ANIM, pThis->IsSurfaceNeeded() && HAVE_SURFACE(pThis), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Realizing back-buffer surface failed.");
904 VisualElementSurface* pSurface = new (std::nothrow) VisualElementSurface(*pThis->GetSharedData().pSurface);
905 SysTryReturn(NID_UI_ANIM, pSurface, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
913 _VisualElementImpl::SetSurface(const VisualElementSurface* pSurface)
915 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
916 SysTryReturnResult(NID_UI_ANIM, NEED_SURFACE(this), E_INVALID_OPERATION, "A surface cannot be set if VisualElement need no back-buffer.");
918 if (unlikely(pSurface == GetSharedData().pSurface))
923 if (likely(pSurface) && likely(GetSharedData().pSurface))
925 if (unlikely(pSurface->Equals(*GetSharedData().pSurface)))
929 if (likely(pSurface))
931 unique_ptr<VisualElementSurface> pTempSurface(new (std::nothrow) VisualElementSurface(*pSurface));
932 SysTryReturnResult(NID_UI_ANIM, pTempSurface, E_OUT_OF_MEMORY, "Memory allocation failed.");
934 // Delete the old surface
935 if (GetSharedData().pSurface)
937 delete GetSharedData().pSurface;
940 GetSharedData().pSurface = pTempSurface.release();
941 GetSharedData().fixedSurfaceSize = true;
943 // Clear invalidated region if newly fixed-size surface is attached which do not need(inhibit) redrawing
944 GetSharedData().invalidatedRegion.SetBounds(0.0f, 0.0f, __bounds.width, __bounds.height);
948 // Delete the old surface
949 if (GetSharedData().pSurface)
951 delete GetSharedData().pSurface;
954 __needRecreateSurface = true;
956 GetSharedData().pSurface = null;
957 GetSharedData().fixedSurfaceSize = false;
959 // Fully invalidate because new surface should be allocated and redrawn
960 GetSharedData().invalidatedRegion.SetBounds(0.0f, 0.0f, __bounds.width, __bounds.height);
970 _VisualElementImpl::SetImageSource(const String& filePath)
972 result r = E_SUCCESS;
974 // Delete the old surface
975 if (GetSharedData().pSurface)
977 delete GetSharedData().pSurface;
980 __needRecreateSurface = true;
982 GetSharedData().pSurface = null;
983 GetSharedData().fixedSurfaceSize = false;
985 // Fully invalidate because new surface should be allocated and redrawn
986 GetSharedData().invalidatedRegion.SetBounds(0.0f, 0.0f, __bounds.width, __bounds.height);
989 RebuildHierarchyProps(0, true, true);
991 SysTryReturnResult(NID_UI_ANIM, HAVE_SURFACE(this), E_SYSTEM, "Realizing back-buffer surface failed.");
993 if (!filePath.IsEmpty())
995 r = GetSharedData().SetImage(filePath);
996 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
999 __imageFilePath = filePath;
1005 _VisualElementImpl::SetSurfaceChanged(void)
1007 GetSharedData().surfaceChanged = true;
1009 if (likely(!IS_PRESENTATION(this)))
1013 _VisualElementImpl* pElement = __pPresentation;
1016 pElement->GetSharedData().childrenSurfaceChanged = true;
1017 pElement = pElement->__pParent;
1023 _VisualElementImpl* pElement = this;
1026 pElement->GetSharedData().childrenSurfaceChanged = true;
1027 pElement = pElement->__pParent;
1033 _VisualElementImpl::SetContentBoundsI(const FloatRectangle& contentBounds)
1035 // const Dimension& surfaceSize = GetSharedData().pSurface->GetSize();
1036 // SysTryReturn(NID_UI_ANIM,
1037 // contentBounds.x >= 0 && contentBounds.y >= 0 && contentBounds.width >= 0 && contentBounds.height >= 0 &&
1038 // contentBounds.x + contentBounds.width <= surfaceSize.width && contentBounds.y + contentBounds.height <= surfaceSize.height,
1041 // "[E_INVALID_ARG] Invalid content bounds.(%f,%f,%f,%f)", contentBounds.x, contentBounds.y, contentBounds.width, contentBounds.height
1044 if (unlikely(RectUtilIsEqual(__contentBounds, contentBounds)))
1047 SysTryReturnResult(NID_UI_ANIM, contentBounds.width > 0.0f && contentBounds.height > 0.0f, E_INVALID_ARG, "Invalid argument(s) is used. The size of contents bounds must be greater than or equal to 0.0f.");
1049 __contentBounds = contentBounds;
1050 __useContentBounds = (__contentBounds.x != 0.0f || __contentBounds.y != 0.0f || __contentBounds.width != 1.0f || __contentBounds.height != 1.0f);
1052 InvalidateHierarchyProps(HIERARCHY_PROPERTY_CONTENTBOUNDS, false, false);
1054 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1056 FloatRectangle currentValue = __pPresentation->__contentBounds;
1058 if(CreateImplicitAnimationIfNeeded(*pVePropContentBounds, __contentBounds, currentValue, NULL) == false)
1060 __pPresentation->SetContentBoundsProperty(__contentBounds);
1068 _VisualElementImpl::SetContentBounds(const FloatRectangle& contentBounds)
1070 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1071 result r = InvokeOnSetPropertyRequested(*pVePropContentBounds, Variant(contentBounds));
1072 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1078 _VisualElementImpl::GetContentBounds(void) const
1082 return __contentBounds;
1086 _VisualElementImpl::GetContentBoundsProperty(void) const
1090 return Variant(__contentBounds);
1094 _VisualElementImpl::SetContentBoundsProperty(const Variant& v)
1096 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_RECTANGLE, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1098 return SetContentBoundsI(v.ToFloatRectangle());
1103 _VisualElementImpl::GetImplicitAnimationEnabled(void) const
1107 return __isImplicitAnimationEnabled;
1111 _VisualElementImpl::SetImplicitAnimationEnabled(bool enable)
1113 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1114 result r = InvokeOnSetPropertyRequested(*pVePropImplicitAnimationEnabled, Variant(enable));
1115 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1121 _VisualElementImpl::GetImplicitAnimationProperty(void) const
1125 return Variant(__isImplicitAnimationEnabled);
1129 _VisualElementImpl::SetImplicitAnimationProperty(const Variant& v)
1131 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1133 bool isImplicitAnimationEnabled = v.ToBool();
1134 if (isImplicitAnimationEnabled != __isImplicitAnimationEnabled)
1136 __isImplicitAnimationEnabled = isImplicitAnimationEnabled;
1138 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1140 __pPresentation->SetImplicitAnimationProperty(__isImplicitAnimationEnabled);
1147 _VisualElementImpl::GetBoundingBox(void) const
1151 return GetBoundingBoxI();
1155 _VisualElementImpl::GetBounds(void) const
1163 _VisualElementImpl::SetBoundsI(const FloatRectangle& bounds)
1165 _Rectanglef boundsAdjusted(bounds);
1166 FloatRectangle oldValue(__bounds);
1168 result r = E_SUCCESS;
1169 bool sizeChanged = false;
1171 if (unlikely(GetSharedData().pEventListener != null))
1173 if (IS_MODEL(this)) // CHECKME: checking need??
1175 FloatRectangle tmpBounds(bounds);
1176 r = VE_DELEGATE(this, InvokeOnBoundsChanging, tmpBounds);
1178 boundsAdjusted = tmpBounds;
1182 if (likely(boundsAdjusted != __bounds))
1184 float newWidth = boundsAdjusted.Width();
1185 if (unlikely(newWidth < 0.0f))
1190 float newHeight = boundsAdjusted.Height();
1191 if (unlikely(newHeight < 0.0f))
1196 if (unlikely(newWidth != __bounds.width) || unlikely(newHeight != __bounds.height))
1201 // Adjust logical bounds(size) to sync. with that of surface(physical)
1203 float alignedWidth = newWidth;
1204 float alignedHeight = newHeight;
1206 __needRecreateSurface = true;
1208 _VisualElementCoordinateSystem::ConvertDimensionToPhysicalIntegral(alignedWidth, alignedHeight);
1210 if (likely(GetSharedData().pSurface))
1212 FloatDimension surfaceSize(GetSharedData().pSurface->GetSizeF());
1214 _VisualElementCoordinateSystem::ConvertDimensionToPhysicalIntegral(surfaceSize.width, surfaceSize.height);
1215 if (likely(alignedWidth == surfaceSize.width) && likely(alignedHeight == surfaceSize.height))
1217 __needRecreateSurface = false;
1221 _VisualElementCoordinateSystem::ConvertDimensionToLogical(alignedWidth, alignedHeight);
1223 if (newWidth > 0.0f && alignedWidth == 0.0f)
1225 _VisualElementCoordinateSystem::MakeLogicalWidthForPhysicalOne(alignedWidth);
1228 if (newHeight > 0.0f && alignedHeight == 0.0f)
1230 _VisualElementCoordinateSystem::MakeLogicalHeightForPhysicalOne(alignedHeight);
1233 __alignedSize.width = alignedWidth;
1234 __alignedSize.height = alignedHeight;
1237 // TODO: Need to optimize dirty rectangle.
1239 // invalidate with previous bounds
1240 if (unlikely(!NEED_SURFACE(this)))
1241 InvalidateVisibleRectToRenderTarget(null);
1243 __bounds.x = boundsAdjusted.Left();
1244 __bounds.y = boundsAdjusted.Top();
1245 __bounds.width = newWidth;
1246 __bounds.height = newHeight;
1248 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false);
1250 // TBD: Recreating surface may have to be done in presentation layer (thread!)
1253 // Even when 'no redrawOnResize', it is needed to invalidate for redrawing if surface is not created yet.
1255 if (unlikely(sizeChanged))
1257 if (unlikely(!NEED_SURFACE(this)) || unlikely(GetSharedData().redrawOnResize))
1258 ExposeRectangle(null, true);
1261 // Shrink invalidated region to bounds
1262 RectUtilIntersect(GetSharedData().invalidatedRegion, FloatRectangle(0.0f, 0.0f, __bounds.width, __bounds.height));
1266 if (unlikely(!NEED_SURFACE(this)))
1267 ExposeRectangle(null, true);
1272 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1274 FloatRectangle currentValue = __pPresentation->__bounds;
1276 static const String* subProperties[] = { pVeSubPropBoundsSize, pVeSubPropBoundsPosition, NULL };
1277 if(CreateImplicitAnimationIfNeeded(*pVePropBounds, __bounds, currentValue, subProperties ) == false)
1279 __pPresentation->SetBoundsProperty(__bounds);
1282 VE_DELEGATE(this, InvokeOnBoundsChanged, oldValue);
1284 if(__pBoundsChangedCallback && sizeChanged == true)
1286 (*__pBoundsChangedCallback)(__pBoundsChangedCallbackData);
1296 _VisualElementImpl::SetBounds(const FloatRectangle& bounds)
1298 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1299 result r = E_SUCCESS;
1301 if (IS_INTERNAL_CLASS(__pPublicInstance))
1303 r = SetBoundsI(bounds);
1307 r = InvokeOnSetPropertyRequested(*pVePropBounds, Variant(bounds));
1309 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1315 _VisualElementImpl::GetBoundsProperty(void) const
1319 return Variant(__bounds);
1323 _VisualElementImpl::SetBoundsProperty(const Variant& v)
1325 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_RECTANGLE, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1327 return SetBoundsI(v.ToFloatRectangle());
1331 _VisualElementImpl::GetBoundsPositionSubProperty(void) const
1335 return Variant(__bounds.GetTopLeft());
1339 _VisualElementImpl::SetBoundsPositionSubProperty(const Variant& v)
1341 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1343 const FloatPoint& position = v.ToFloatPoint();
1344 return SetBoundsProperty(Variant(FloatRectangle(position.x, position.y, __bounds.width, __bounds.height)));
1348 _VisualElementImpl::GetBoundsSizeSubProperty(void) const
1352 return Variant(FloatDimension(__bounds.width, __bounds.height));
1356 _VisualElementImpl::SetBoundsSizeSubProperty(const Variant& v)
1358 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_DIMENSION, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1360 const FloatDimension& size = v.ToFloatDimension();
1361 return SetBoundsProperty(Variant(FloatRectangle(__bounds.x, __bounds.y, size.width, size.height)));
1365 _VisualElementImpl::GetZPosition(void) const
1373 _VisualElementImpl::SetZPositionI(float zPosition)
1375 if (likely(zPosition != __zPosition))
1377 __zPosition = zPosition;
1378 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false); // lazy evaluation: property changed flag
1381 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1383 float currentValue = __pPresentation->__zPosition;
1385 if(CreateImplicitAnimationIfNeeded(*pVePropZPosition, __zPosition, currentValue, NULL) == false)
1387 __pPresentation->SetZPositionProperty(__zPosition);
1396 _VisualElementImpl::SetZPosition(float zPosition)
1398 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1399 result r = E_SUCCESS;
1401 if (IS_INTERNAL_CLASS(__pPublicInstance))
1403 r = SetZPositionI(zPosition);
1407 r = InvokeOnSetPropertyRequested(*pVePropZPosition, Variant(zPosition));
1410 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1418 _VisualElementImpl::GetZPositionProperty(void) const
1422 return Variant(__zPosition);
1426 _VisualElementImpl::SetZPositionProperty(const Variant& v)
1428 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1430 return SetZPositionI(v.ToFloat());
1434 _VisualElementImpl::SetZOrderGroupI(int zOrderGroup)
1436 result r = E_SUCCESS;
1438 if (likely(__pParent))
1440 r= __pParent->ChangeZOrder(*this, null, true, zOrderGroup);
1444 _zOrderGroup = zOrderGroup;
1447 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1449 __pPresentation->SetZOrderGroupProperty(_zOrderGroup);
1455 _VisualElementImpl::SetZOrderGroup(int zOrderGroup)
1457 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1458 result r = E_SUCCESS;
1460 if (IS_INTERNAL_CLASS(__pPublicInstance))
1462 r = SetZOrderGroupI(zOrderGroup);
1466 r = InvokeOnSetPropertyRequested(*pVePropZOrderGroup, Variant(zOrderGroup));
1469 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1475 _VisualElementImpl::GetZOrderGroup(void) const
1479 return _zOrderGroup;
1483 _VisualElementImpl::GetZOrderGroupProperty(void) const
1487 return Variant(_zOrderGroup);
1491 _VisualElementImpl::SetZOrderGroupProperty(const Variant& v)
1493 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_INT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1495 return SetZOrderGroupI(v.ToInt());
1499 _VisualElementImpl::IsVisible(void) const
1503 return IsVisibleI();
1507 _VisualElementImpl::GetShowState(void) const
1511 return VE_VISIBLE(this);
1515 _VisualElementImpl::SetShowOpacityI(float showOpacity)
1517 bool oldShowState = SHOWOPACITY_VISIBLE(__showOpacity);
1519 if (unlikely(showOpacity < 0.0f))
1523 else if (unlikely(showOpacity > 1.0f))
1528 if (likely(__showOpacity != showOpacity))
1531 bool showStateChanged = (oldShowState != SHOWOPACITY_VISIBLE(showOpacity));
1533 __showOpacity = showOpacity;
1535 if (likely(showStateChanged))
1540 // Coordinates are calculated using visibleRect which is empty when invisible state.
1541 // Show-Recalculation is needed when being visible !
1542 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES | HIERARCHY_PROPERTY_SHOWSTATE | HIERARCHY_PROPERTY_OPACITY, true, false);
1544 if (unlikely(!NEED_SURFACE(this)))
1546 ExposeRectangle(null, true);
1551 InvalidateHierarchyProps(HIERARCHY_PROPERTY_SHOWSTATE | HIERARCHY_PROPERTY_OPACITY, true, false);
1553 if (unlikely(!NEED_SURFACE(this)))
1555 InvalidateVisibleRectToRenderTarget(null);
1562 // showOpacity is applicable only for surfaces
1563 if (likely(NEED_SURFACE(this)))
1565 InvalidateHierarchyProps(HIERARCHY_PROPERTY_OPACITY, true, false);
1570 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1572 bool needPresentationUpdate = true;
1573 const String& property = *pVePropShowState;
1574 _AnimationManager* pAnimationManager = _AnimationManager::GetInstance();
1576 if (likely(GetRoot()) && (unlikely(pAnimationManager->IsImplicitAnimationEnabled() && __isImplicitAnimationEnabled)))
1579 // For performance, following must be done only when oldValue != newValue.
1580 VisualElementAnimation* pAnimation = InvokeCreateAnimationForProperty(property);
1581 VisualElementPropertyAnimation* pPropertyAnimation = NULL;
1584 pPropertyAnimation = new (std::nothrow) VisualElementPropertyAnimation();
1585 if(pPropertyAnimation)
1587 pPropertyAnimation->SetPropertyName(*pVePrivPropShowOpacity);
1588 needPresentationUpdate = true;
1593 pPropertyAnimation = dynamic_cast< VisualElementPropertyAnimation* >(pAnimation);
1596 if (likely(pPropertyAnimation))
1598 if (pPropertyAnimation->GetEndValue().IsEmpty())
1600 pPropertyAnimation->SetEndValue(__showOpacity);
1603 if (pPropertyAnimation->GetStartValue().IsEmpty())
1605 pPropertyAnimation->SetStartValue(__pPresentation->__showOpacity);
1609 if (unlikely(pPropertyAnimation))
1612 // Adding property animation causes previous animation for same property to be removed in Animation Manager.
1613 if (unlikely(IsFailed(AddAnimation(null, *pPropertyAnimation))))
1615 needPresentationUpdate = true;
1616 //pAnimationManager->RemoveAnimationByProperty(*presentation.GetPublic(), property);
1619 delete pPropertyAnimation;
1624 // Remove previous animation even when trying to change the property without animation.
1625 pAnimationManager->RemoveAnimationByProperty(*__pPresentation->__pPublicInstance, property);
1626 pAnimationManager->RemoveAnimationByProperty(*__pPresentation->__pPublicInstance, *pVePrivPropShowOpacity);
1627 needPresentationUpdate = true;
1632 pAnimationManager->RemoveAnimationByProperty(*__pPresentation->__pPublicInstance, property);
1633 pAnimationManager->RemoveAnimationByProperty(*__pPresentation->__pPublicInstance, *pVePrivPropShowOpacity);
1634 needPresentationUpdate = true;
1637 if(needPresentationUpdate)
1639 __pPresentation->SetShowStateProperty(SHOWOPACITY_VISIBLE(__showOpacity));
1641 InvokeOnShowStateChanged(oldShowState);
1649 _VisualElementImpl::SetShowStateI(bool show)
1651 return SetShowOpacityI(show ? 1.0f : 0.0f);
1655 _VisualElementImpl::SetShowState(bool show)
1657 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1658 result r = E_SUCCESS;
1660 if (IS_INTERNAL_CLASS(__pPublicInstance))
1662 r = SetShowOpacityI(show ? 1.0f : 0.0f);
1666 r = InvokeOnSetPropertyRequested(*pVePropShowState, Variant(show));
1669 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1675 _VisualElementImpl::GetShowStateProperty(void) const
1679 return Variant(VE_VISIBLE(this));
1683 _VisualElementImpl::SetShowStateProperty(const Variant& v)
1685 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1687 bool showState = v.ToBool();
1689 return SetShowOpacityI(showState ? 1.0f : 0.0f);
1693 _VisualElementImpl::GetShowOpacityPrivateProperty(void) const
1697 return Variant(__showOpacity);
1701 _VisualElementImpl::SetShowOpacityPrivateProperty(const Variant& v)
1703 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1705 return SetShowOpacityI(v.ToFloat());
1709 _VisualElementImpl::GetContentOpacity(void) const
1713 return __contentOpacity;
1717 _VisualElementImpl::SetContentOpacityI(float contentOpacity)
1719 if (unlikely(contentOpacity == __contentOpacity)) // do not take care of float-error !!
1724 SysTryReturnResult(NID_UI_ANIM, contentOpacity >= 0.0f && contentOpacity <= 1.0f, E_INVALID_ARG, "Invalid argument(s) is used. Invalid opacity range.");
1726 __contentOpacity = contentOpacity;
1728 InvalidateHierarchyProps(HIERARCHY_PROPERTY_CONTENTOPACITY, false, false); //don't have to apply the changed opacity to children.
1730 #ifndef LAZY_EVALUATION
1731 if (IS_PRESENTATION(this) && likely(__pSharedData) && likely(GetSharedData().pNativeNode))
1733 GetSharedData().NodeReconfigure(*this);
1737 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1739 float currentValue = __pPresentation->__contentOpacity;
1741 if(CreateImplicitAnimationIfNeeded(*pVePropContentOpacity, __contentOpacity, currentValue, NULL) == false)
1743 __pPresentation->SetContentOpacityProperty(__contentOpacity);
1751 _VisualElementImpl::SetContentOpacity(float contentOpacity)
1753 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1754 result r = E_SUCCESS;
1756 // PROPERTY_PROCESS(SetContentOpacityI, GetContentOpacityProperty, SetContentOpacityProperty, pVePropContentOpacity, __contentOpacity, contentOpacity);
1757 if (IS_INTERNAL_CLASS(__pPublicInstance))
1759 r = SetContentOpacityI(contentOpacity);
1763 r = InvokeOnSetPropertyRequested(*pVePropContentOpacity, Variant(contentOpacity));
1766 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1773 _VisualElementImpl::GetContentOpacityProperty(void) const
1777 return Variant(__contentOpacity);
1781 _VisualElementImpl::SetContentOpacityProperty(const Variant& v)
1783 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1785 return SetContentOpacityI(v.ToFloat());
1789 _VisualElementImpl::GetOpacity(void) const
1797 _VisualElementImpl::SetOpacityI(float opacity)
1799 if (likely(opacity != __opacity)) // do not take care of float-error !!
1801 if (unlikely(opacity > 1.0f))
1805 else if (unlikely(opacity < 0.0f))
1810 __opacity = opacity;
1812 InvalidateHierarchyProps(HIERARCHY_PROPERTY_OPACITY, true, false);
1815 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1817 float currentValue = __pPresentation->__opacity;
1819 if(CreateImplicitAnimationIfNeeded(*pVePropOpacity, __opacity, currentValue, NULL) == false)
1821 __pPresentation->SetOpacityProperty(__opacity);
1828 _VisualElementImpl::SetOpacity(float opacity)
1830 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1831 result r = E_SUCCESS;
1833 // PROPERTY_PROCESS(SetOpacityI, GetOpacityProperty, SetOpacityProperty, pVePropOpacity, __opacity, opacity);
1834 if (IS_INTERNAL_CLASS(__pPublicInstance))
1836 r = SetOpacityI(opacity);
1840 r = InvokeOnSetPropertyRequested(*pVePropOpacity, Variant(opacity));
1843 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1849 _VisualElementImpl::GetOpacityProperty(void) const
1853 return Variant(__opacity);
1857 _VisualElementImpl::SetOpacityProperty(const Variant& v)
1859 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1861 return SetOpacityI(v.ToFloat());
1865 _VisualElementImpl::GetAnchor(void) const
1873 _VisualElementImpl::SetAnchorI(const FloatPoint& anchor)
1875 if (likely(anchor != __anchor))
1880 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false);
1882 // VE with surface will be exposed automatically on rebuilding coordinates...
1883 if (unlikely(!HAVE_SURFACE(this)))
1885 ExposeRectangle(null, true); // CHECKME: needed ???
1889 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1891 FloatPoint currentValue = __pPresentation->__anchor;
1893 if(CreateImplicitAnimationIfNeeded(*pVePropAnchor, __anchor, currentValue, NULL) == false)
1895 __pPresentation->SetAnchorProperty(__anchor);
1903 _VisualElementImpl::SetAnchor(const FloatPoint& anchor)
1905 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1906 result r = E_SUCCESS;
1908 // PROPERTY_PROCESS(SetAnchorI, GetAnchorProperty, SetAnchorProperty, pVePropAnchor, __anchor, anchor);
1909 if (IS_INTERNAL_CLASS(__pPublicInstance))
1911 r = SetAnchorI(anchor);
1915 r = InvokeOnSetPropertyRequested(*pVePropAnchor, Variant(anchor));
1918 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1925 _VisualElementImpl::GetAnchorProperty(void) const
1929 return Variant(__anchor);
1933 _VisualElementImpl::SetAnchorProperty(const Variant& v)
1935 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1937 return SetAnchorI(v.ToFloatPoint());
1941 _VisualElementImpl::GetAnchorZ(void) const
1949 _VisualElementImpl::SetAnchorZI(float anchorZ)
1951 if (likely(anchorZ != __anchorZ))
1953 __anchorZ = anchorZ;
1955 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false);
1957 // VE with surface will be exposed automatically on rebuilding coordinates...
1958 if (unlikely(!HAVE_SURFACE(this)))
1960 ExposeRectangle(null, true); // CHECKME: needed ???
1964 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1966 float currentValue = __pPresentation->__anchorZ;
1968 if(CreateImplicitAnimationIfNeeded(*pVePropAnchorZ, __anchorZ, currentValue, NULL) == false)
1970 __pPresentation->SetAnchorZProperty(__anchorZ);
1978 _VisualElementImpl::SetAnchorZ(float anchorZ)
1980 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1981 result r = E_SUCCESS;
1983 // PROPERTY_PROCESS(SetAnchorZI, GetAnchorZProperty, SetAnchorZProperty, pVePropAnchorZ, __anchorZ, anchorZ);
1984 if (IS_INTERNAL_CLASS(__pPublicInstance))
1986 r = SetAnchorZI(anchorZ);
1990 r = InvokeOnSetPropertyRequested(*pVePropAnchorZ, Variant(anchorZ));
1993 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
2001 _VisualElementImpl::GetAnchorZProperty(void) const
2005 return Variant(__anchorZ);
2009 _VisualElementImpl::SetAnchorZProperty(const Variant& v)
2011 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2013 return SetAnchorZI(v.ToFloat());
2017 _VisualElementImpl::GetTransformMatrix(void) const
2025 _VisualElementImpl::SetTransformMatrixI(const FloatMatrix4& xform, bool updateDecomposed)
2028 result r = E_SUCCESS;
2030 FloatMatrix4 oldValue(__transform);
2032 FloatMatrix4 matrixAdjusted(xform);
2034 if (unlikely(GetSharedData().pEventListener != null))
2036 if (IS_MODEL(this)) // CHECKME: checking need??
2038 r = VE_DELEGATE(this, InvokeOnTransformMatrixChanging, matrixAdjusted);
2042 if (r == E_SUCCESS && likely(matrixAdjusted != __transform)) // check again because delegate may change the transform matrix
2044 // render target updates for previous bounds
2045 if (unlikely(!NEED_SURFACE(this)))
2047 InvalidateVisibleRectToRenderTarget(null);
2051 MatrixUtilCopy(__transform, matrixAdjusted);
2053 if (unlikely(updateDecomposed))
2055 __decomposedTransform.SetTransformMatrix(__transform);
2058 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false);
2060 // VE with surface will be exposed automatically on rebuilding coordinates...
2061 if (unlikely(!NEED_SURFACE(this)))
2063 ExposeRectangle(null, true); // CHECKME: needed ???
2067 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
2069 FloatMatrix4 currentValue = __pPresentation->__transform;
2071 static const String* subProperties[] = { pVeSubPropTransformRotationX,
2072 pVeSubPropTransformRotationY,
2073 pVeSubPropTransformRotationZ,
2074 pVeSubPropTransformScaleX,
2075 pVeSubPropTransformScaleY,
2076 pVeSubPropTransformScaleZ,
2077 pVeSubPropTransformTranslationX,
2078 pVeSubPropTransformTranslationY,
2079 pVeSubPropTransformTranslationZ,
2080 pVeSubPropTransformRotationAnchorX,
2081 pVeSubPropTransformRotationAnchorY,
2082 pVeSubPropTransformRotationAnchorZ,
2083 pVeSubPropTransformScaleAnchorX,
2084 pVeSubPropTransformScaleAnchorY,
2085 pVeSubPropTransformScaleAnchorZ,
2088 if(CreateImplicitAnimationIfNeeded(*pVePropTransform, __transform, currentValue, subProperties ) == false)
2090 __pPresentation->SetTransformMatrixProperty(__transform);
2093 VE_DELEGATE(this, InvokeOnTransformMatrixChanged, oldValue);
2099 _VisualElementImpl::SetTransformMatrix(const FloatMatrix4& xform)
2101 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
2102 result r = E_SUCCESS;
2104 // PROPERTY_PROCESS(SetTransformMatrixI, GetTransformMatrixProperty, SetTransformMatrixProperty, pVePropTransform, __transform, xform);
2105 if (IS_INTERNAL_CLASS(__pPublicInstance))
2107 r = SetTransformMatrixI(xform);
2111 r = InvokeOnSetPropertyRequested(*pVePropTransform, Variant(xform));
2114 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
2122 _VisualElementImpl::GetTransformMatrixProperty(void) const
2126 return Variant(__transform);
2131 _VisualElementImpl::SetTransformMatrixProperty(const Variant& v)
2133 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_MATRIX4, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2135 return SetTransformMatrixI(v.ToFloatMatrix4(), true);
2139 _VisualElementImpl::GetTransformRotationXSubProperty(void) const
2143 float angleX = 0.0f;
2144 float angleY = 0.0f;
2145 float angleZ = 0.0f;
2146 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2148 return Variant(angleX);
2152 _VisualElementImpl::SetTransformRotationXSubProperty(const Variant& v)
2154 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2156 float angleX = 0.0f;
2157 float angleY = 0.0f;
2158 float angleZ = 0.0f;
2159 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2160 __decomposedTransform.UpdateRotationFromEulerAngles(v.ToFloat(), angleY, angleZ);
2162 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2166 _VisualElementImpl::GetTransformRotationYSubProperty(void) const
2170 float angleX = 0.0f;
2171 float angleY = 0.0f;
2172 float angleZ = 0.0f;
2173 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2175 return Variant(angleY);
2179 _VisualElementImpl::SetTransformRotationYSubProperty(const Variant& v)
2181 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2183 float angleX = 0.0f;
2184 float angleY = 0.0f;
2185 float angleZ = 0.0f;
2186 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2187 __decomposedTransform.UpdateRotationFromEulerAngles(angleX, v.ToFloat(), angleZ);
2189 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2193 _VisualElementImpl::GetTransformRotationZSubProperty(void) const
2197 float angleX = 0.0f;
2198 float angleY = 0.0f;
2199 float angleZ = 0.0f;
2200 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2202 return Variant(angleZ);
2206 _VisualElementImpl::SetTransformRotationZSubProperty(const Variant& v)
2208 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2210 float angleX = 0.0f;
2211 float angleY = 0.0f;
2212 float angleZ = 0.0f;
2213 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2214 __decomposedTransform.UpdateRotationFromEulerAngles(angleX, angleY, v.ToFloat());
2216 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2220 _VisualElementImpl::GetTransformRotationXYSubProperty(void) const
2224 float angleX = 0.0f;
2225 float angleY = 0.0f;
2226 float angleZ = 0.0f;
2227 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2229 return Variant(FloatPoint(angleX, angleY));
2233 _VisualElementImpl::SetTransformRotationXYSubProperty(const Variant& v)
2235 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2237 const FloatPoint& point = v.ToFloatPoint();
2239 float angleX = 0.0f;
2240 float angleY = 0.0f;
2241 float angleZ = 0.0f;
2242 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2243 __decomposedTransform.UpdateRotationFromEulerAngles(point.x, point.y, angleZ);
2245 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2249 _VisualElementImpl::GetTransformRotationAnchorXSubProperty(void) const
2253 float anchorX = 0.0f;
2254 float anchorY = 0.0f;
2255 float anchorZ = 0.0f;
2256 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2258 return Variant(anchorX);
2262 _VisualElementImpl::SetTransformRotationAnchorXSubProperty(const Variant& v)
2264 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2266 float anchorX = 0.0f;
2267 float anchorY = 0.0f;
2268 float anchorZ = 0.0f;
2269 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2270 __decomposedTransform.SetRotationAnchor(v.ToFloat(), anchorY, anchorZ);
2272 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2276 _VisualElementImpl::GetTransformRotationAnchorYSubProperty(void) const
2280 float anchorX = 0.0f;
2281 float anchorY = 0.0f;
2282 float anchorZ = 0.0f;
2283 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2285 return Variant(anchorY);
2289 _VisualElementImpl::SetTransformRotationAnchorYSubProperty(const Variant& v)
2291 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2293 float anchorX = 0.0f;
2294 float anchorY = 0.0f;
2295 float anchorZ = 0.0f;
2296 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2297 __decomposedTransform.SetRotationAnchor(anchorX, v.ToFloat(), anchorZ);
2299 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2303 _VisualElementImpl::GetTransformRotationAnchorZSubProperty(void) const
2307 float anchorX = 0.0f;
2308 float anchorY = 0.0f;
2309 float anchorZ = 0.0f;
2310 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2312 return Variant(anchorZ);
2316 _VisualElementImpl::SetTransformRotationAnchorZSubProperty(const Variant& v)
2318 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2320 float anchorX = 0.0f;
2321 float anchorY = 0.0f;
2322 float anchorZ = 0.0f;
2323 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2324 __decomposedTransform.SetRotationAnchor(anchorX, anchorY, v.ToFloat());
2326 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2330 _VisualElementImpl::GetTransformRotationAnchorXYSubProperty(void) const
2334 float anchorX = 0.0f;
2335 float anchorY = 0.0f;
2336 float anchorZ = 0.0f;
2337 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2339 return Variant(FloatPoint(anchorX, anchorY));
2343 _VisualElementImpl::SetTransformRotationAnchorXYSubProperty(const Variant& v)
2345 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2347 const FloatPoint& point = v.ToFloatPoint();
2349 float anchorX = 0.0f;
2350 float anchorY = 0.0f;
2351 float anchorZ = 0.0f;
2352 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2353 __decomposedTransform.SetRotationAnchor(point.x, point.y, anchorZ);
2355 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2359 _VisualElementImpl::GetTransformScaleXSubProperty(void) const
2363 float scaleX = 1.0f;
2364 float scaleY = 1.0f;
2365 float scaleZ = 1.0f;
2366 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2368 return Variant(scaleX);
2372 _VisualElementImpl::SetTransformScaleXSubProperty(const Variant& v)
2374 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2376 float scaleX = 1.0f;
2377 float scaleY = 1.0f;
2378 float scaleZ = 1.0f;
2379 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2380 __decomposedTransform.SetScaleFactors(v.ToFloat(), scaleY, scaleZ);
2382 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2386 _VisualElementImpl::GetTransformScaleYSubProperty(void) const
2390 float scaleX = 1.0f;
2391 float scaleY = 1.0f;
2392 float scaleZ = 1.0f;
2393 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2395 return Variant(scaleY);
2399 _VisualElementImpl::SetTransformScaleYSubProperty(const Variant& v)
2401 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2403 float scaleX = 1.0f;
2404 float scaleY = 1.0f;
2405 float scaleZ = 1.0f;
2406 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2407 __decomposedTransform.SetScaleFactors(scaleX, v.ToFloat(), scaleZ);
2409 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2413 _VisualElementImpl::GetTransformScaleZSubProperty(void) const
2417 float scaleX = 1.0f;
2418 float scaleY = 1.0f;
2419 float scaleZ = 1.0f;
2420 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2422 return Variant(scaleZ);
2426 _VisualElementImpl::SetTransformScaleZSubProperty(const Variant& v)
2428 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2430 float scaleX = 1.0f;
2431 float scaleY = 1.0f;
2432 float scaleZ = 1.0f;
2433 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2434 __decomposedTransform.SetScaleFactors(scaleX, scaleY, v.ToFloat());
2436 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2440 _VisualElementImpl::GetTransformScaleXYSubProperty(void) const
2444 float scaleX = 1.0f;
2445 float scaleY = 1.0f;
2446 float scaleZ = 1.0f;
2447 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2449 return Variant(FloatPoint(scaleX, scaleY));
2453 _VisualElementImpl::SetTransformScaleXYSubProperty(const Variant& v)
2455 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2457 const FloatPoint& point = v.ToFloatPoint();
2459 float scaleX = 1.0f;
2460 float scaleY = 1.0f;
2461 float scaleZ = 1.0f;
2462 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2463 if (unlikely(scaleX == point.x) && unlikely(scaleY == point.y))
2468 __decomposedTransform.SetScaleFactors(point.x, point.y, scaleZ);
2470 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2474 _VisualElementImpl::GetTransformScaleAnchorXSubProperty(void) const
2478 float anchorX = 0.0f;
2479 float anchorY = 0.0f;
2480 float anchorZ = 0.0f;
2481 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2483 return Variant(anchorX);
2487 _VisualElementImpl::SetTransformScaleAnchorXSubProperty(const Variant& v)
2489 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2491 float anchorX = 0.0f;
2492 float anchorY = 0.0f;
2493 float anchorZ = 0.0f;
2494 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2495 __decomposedTransform.SetScaleAnchor(v.ToFloat(), anchorY, anchorZ);
2497 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2501 _VisualElementImpl::GetTransformScaleAnchorYSubProperty(void) const
2505 float anchorX = 0.0f;
2506 float anchorY = 0.0f;
2507 float anchorZ = 0.0f;
2508 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2510 return Variant(anchorY);
2514 _VisualElementImpl::SetTransformScaleAnchorYSubProperty(const Variant& v)
2516 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2518 float anchorX = 0.0f;
2519 float anchorY = 0.0f;
2520 float anchorZ = 0.0f;
2521 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2522 __decomposedTransform.SetScaleAnchor(anchorX, v.ToFloat(), anchorZ);
2524 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2528 _VisualElementImpl::GetTransformScaleAnchorZSubProperty(void) const
2532 float anchorX = 0.0f;
2533 float anchorY = 0.0f;
2534 float anchorZ = 0.0f;
2535 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2537 return Variant(anchorZ);
2541 _VisualElementImpl::SetTransformScaleAnchorZSubProperty(const Variant& v)
2543 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2545 float anchorX = 0.0f;
2546 float anchorY = 0.0f;
2547 float anchorZ = 0.0f;
2548 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2549 __decomposedTransform.SetScaleAnchor(anchorX, anchorY, v.ToFloat());
2551 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2555 _VisualElementImpl::GetTransformScaleAnchorXYSubProperty(void) const
2559 float anchorX = 0.0f;
2560 float anchorY = 0.0f;
2561 float anchorZ = 0.0f;
2562 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2564 return Variant(FloatPoint(anchorX, anchorY));
2568 _VisualElementImpl::SetTransformScaleAnchorXYSubProperty(const Variant& v)
2570 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2572 const FloatPoint& point = v.ToFloatPoint();
2574 float anchorX = 0.0f;
2575 float anchorY = 0.0f;
2576 float anchorZ = 0.0f;
2577 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2578 __decomposedTransform.SetScaleAnchor(point.x, point.y, anchorZ);
2580 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2584 _VisualElementImpl::GetTransformTranslationXSubProperty(void) const
2588 float translateX = 0.0f;
2589 float translateY = 0.0f;
2590 float translateZ = 0.0f;
2591 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2593 return Variant(translateX);
2597 _VisualElementImpl::SetTransformTranslationXSubProperty(const Variant& v)
2599 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2601 float translateX = 0.0f;
2602 float translateY = 0.0f;
2603 float translateZ = 0.0f;
2604 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2605 __decomposedTransform.SetTranslationFactors(v.ToFloat(), translateY, translateZ);
2607 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2611 _VisualElementImpl::GetTransformTranslationYSubProperty(void) const
2615 float translateX = 0.0f;
2616 float translateY = 0.0f;
2617 float translateZ = 0.0f;
2618 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2620 return Variant(translateY);
2624 _VisualElementImpl::SetTransformTranslationYSubProperty(const Variant& v)
2626 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2628 float translateX = 0.0f;
2629 float translateY = 0.0f;
2630 float translateZ = 0.0f;
2631 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2632 __decomposedTransform.SetTranslationFactors(translateX, v.ToFloat(), translateZ);
2634 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2638 _VisualElementImpl::GetTransformTranslationZSubProperty(void) const
2642 float translateX = 0.0f;
2643 float translateY = 0.0f;
2644 float translateZ = 0.0f;
2645 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2647 return Variant(translateZ);
2651 _VisualElementImpl::SetTransformTranslationZSubProperty(const Variant& v)
2653 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2655 float translateX = 0.0f;
2656 float translateY = 0.0f;
2657 float translateZ = 0.0f;
2658 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2659 __decomposedTransform.SetTranslationFactors(translateX, translateY, v.ToFloat());
2661 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2665 _VisualElementImpl::GetTransformTranslationXYSubProperty(void) const
2669 float translateX = 0.0f;
2670 float translateY = 0.0f;
2671 float translateZ = 0.0f;
2672 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2674 return Variant(FloatPoint(translateX, translateY));
2678 _VisualElementImpl::SetTransformTranslationXYSubProperty(const Variant& v)
2680 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2682 const FloatPoint& point = v.ToFloatPoint();
2684 float translateX = 0.0f;
2685 float translateY = 0.0f;
2686 float translateZ = 0.0f;
2687 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2688 __decomposedTransform.SetTranslationFactors(point.x, point.y, translateZ);
2690 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2694 _VisualElementImpl::GetChildrenTransformMatrix(void) const
2698 return __childrenTransform;
2703 _VisualElementImpl::SetChildrenTransformMatrixI(const FloatMatrix4& xform, bool updateDecomposed)
2705 FloatMatrix4 matrixAdjusted(xform);
2706 FloatMatrix4 oldValue(__childrenTransform);
2707 result r = E_SUCCESS;
2709 if (unlikely(GetSharedData().pEventListener != null))
2711 if (IS_MODEL(this)) // CHECKME: checking need??
2713 r = VE_DELEGATE(this, InvokeOnChildrenTransformMatrixChanging, matrixAdjusted);
2718 if (r == E_SUCCESS && likely(matrixAdjusted != __childrenTransform)) // check again because delegate may change the transform matrix
2721 // May be un-needed from now...... (no support for VE without surface or shared-canvas)
2722 if (!IS_PRESENTATION(this))
2724 int count = __children.GetCount();
2725 for (int i = 0; i < count; i++)
2727 // VE with surface will be exposed automatically on rebuilding coordinates...
2728 _VisualElementImpl* pVe = __children.GetChildAt(i);
2729 if (pVe && !NEED_SURFACE(pVe))
2731 pVe->ExposeRectangle(null, true);
2733 // render target update for previous bounds
2734 pVe->InvalidateVisibleRectToRenderTarget(null);
2739 MatrixUtilCopy(__childrenTransform, matrixAdjusted);
2741 if (unlikely(updateDecomposed))
2743 __decomposedChildrenTransform.SetTransformMatrix(__childrenTransform);
2746 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false);
2749 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
2751 FloatMatrix4 currentValue = __pPresentation->__childrenTransform;
2752 static const String* subProperties[] = {
2753 pVeSubPropChildrenTransformRotationX,
2754 pVeSubPropChildrenTransformRotationY,
2755 pVeSubPropChildrenTransformRotationZ,
2756 pVeSubPropChildrenTransformScaleX,
2757 pVeSubPropChildrenTransformScaleY,
2758 pVeSubPropChildrenTransformScaleZ,
2759 pVeSubPropChildrenTransformTranslationX,
2760 pVeSubPropChildrenTransformTranslationY,
2761 pVeSubPropChildrenTransformTranslationZ,
2762 pVeSubPropChildrenTransformRotationAnchorX,
2763 pVeSubPropChildrenTransformRotationAnchorY,
2764 pVeSubPropChildrenTransformRotationAnchorZ,
2765 pVeSubPropChildrenTransformScaleAnchorX,
2766 pVeSubPropChildrenTransformScaleAnchorY,
2767 pVeSubPropChildrenTransformScaleAnchorZ,
2770 if(CreateImplicitAnimationIfNeeded(*pVePropChildrenTransform, __childrenTransform, currentValue, subProperties ) == false)
2772 __pPresentation->SetChildrenTransformMatrixProperty(__childrenTransform);
2775 VE_DELEGATE(this, InvokeOnChildrenTransformMatrixChanged, oldValue);
2782 _VisualElementImpl::SetChildrenTransformMatrix(const FloatMatrix4& xform)
2784 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
2785 result r = E_SUCCESS;
2787 //PROPERTY_PROCESS(SetChildrenTransformMatrixI, GetChildrenTransformMatrixProperty, SetChildrenTransformMatrixProperty, pVePropChildrenTransform, __childrenTransform, xform);
2788 if (IS_INTERNAL_CLASS(__pPublicInstance))
2790 r = SetChildrenTransformMatrixI(xform);
2794 r = InvokeOnSetPropertyRequested(*pVePropChildrenTransform, Variant(xform));
2797 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
2803 _VisualElementImpl::GetChildrenTransformMatrixProperty(void) const
2807 return Variant(__childrenTransform);
2812 _VisualElementImpl::SetChildrenTransformMatrixProperty(const Variant& v)
2814 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_MATRIX4, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2816 return SetChildrenTransformMatrixI(v.ToFloatMatrix4(), true);
2820 _VisualElementImpl::GetChildrenTransformRotationXSubProperty(void) const
2824 float angleX = 0.0f;
2825 float angleY = 0.0f;
2826 float angleZ = 0.0f;
2827 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
2829 return Variant(angleX);
2833 _VisualElementImpl::SetChildrenTransformRotationXSubProperty(const Variant& v)
2835 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2837 float angleX = 0.0f;
2838 float angleY = 0.0f;
2839 float angleZ = 0.0f;
2840 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
2841 __decomposedChildrenTransform.UpdateRotationFromEulerAngles(v.ToFloat(), angleY, angleZ);
2843 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
2847 _VisualElementImpl::GetChildrenTransformRotationYSubProperty(void) const
2851 float angleX = 0.0f;
2852 float angleY = 0.0f;
2853 float angleZ = 0.0f;
2854 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
2856 return Variant(angleY);
2860 _VisualElementImpl::SetChildrenTransformRotationYSubProperty(const Variant& v)
2862 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2864 float angleX = 0.0f;
2865 float angleY = 0.0f;
2866 float angleZ = 0.0f;
2867 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
2868 __decomposedChildrenTransform.UpdateRotationFromEulerAngles(angleX, v.ToFloat(), angleZ);
2870 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
2874 _VisualElementImpl::GetChildrenTransformRotationZSubProperty(void) const
2878 float angleX = 0.0f;
2879 float angleY = 0.0f;
2880 float angleZ = 0.0f;
2881 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
2883 return Variant(angleZ);
2887 _VisualElementImpl::SetChildrenTransformRotationZSubProperty(const Variant& v)
2889 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2891 float angleX = 0.0f;
2892 float angleY = 0.0f;
2893 float angleZ = 0.0f;
2894 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
2895 __decomposedChildrenTransform.UpdateRotationFromEulerAngles(angleX, angleY, v.ToFloat());
2897 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
2901 _VisualElementImpl::GetChildrenTransformRotationXYSubProperty(void) const
2905 float angleX = 0.0f;
2906 float angleY = 0.0f;
2907 float angleZ = 0.0f;
2908 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
2910 return Variant(FloatPoint(angleX, angleY));
2914 _VisualElementImpl::SetChildrenTransformRotationXYSubProperty(const Variant& v)
2916 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2918 const FloatPoint& point = v.ToFloatPoint();
2920 float angleX = 0.0f;
2921 float angleY = 0.0f;
2922 float angleZ = 0.0f;
2923 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
2924 __decomposedChildrenTransform.UpdateRotationFromEulerAngles(point.x, point.y, angleZ);
2926 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
2930 _VisualElementImpl::GetChildrenTransformRotationAnchorXSubProperty(void) const
2934 float anchorX = 0.0f;
2935 float anchorY = 0.0f;
2936 float anchorZ = 0.0f;
2937 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2939 return Variant(anchorX);
2943 _VisualElementImpl::SetChildrenTransformRotationAnchorXSubProperty(const Variant& v)
2945 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2947 float anchorX = 0.0f;
2948 float anchorY = 0.0f;
2949 float anchorZ = 0.0f;
2950 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2951 __decomposedChildrenTransform.SetRotationAnchor(v.ToFloat(), anchorY, anchorZ);
2953 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
2957 _VisualElementImpl::GetChildrenTransformRotationAnchorYSubProperty(void) const
2961 float anchorX = 0.0f;
2962 float anchorY = 0.0f;
2963 float anchorZ = 0.0f;
2964 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2966 return Variant(anchorY);
2970 _VisualElementImpl::SetChildrenTransformRotationAnchorYSubProperty(const Variant& v)
2972 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2974 float anchorX = 0.0f;
2975 float anchorY = 0.0f;
2976 float anchorZ = 0.0f;
2977 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2978 __decomposedChildrenTransform.SetRotationAnchor(anchorX, v.ToFloat(), anchorZ);
2980 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
2984 _VisualElementImpl::GetChildrenTransformRotationAnchorZSubProperty(void) const
2988 float anchorX = 0.0f;
2989 float anchorY = 0.0f;
2990 float anchorZ = 0.0f;
2991 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2993 return Variant(anchorZ);
2997 _VisualElementImpl::SetChildrenTransformRotationAnchorZSubProperty(const Variant& v)
2999 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3001 float anchorX = 0.0f;
3002 float anchorY = 0.0f;
3003 float anchorZ = 0.0f;
3004 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
3005 __decomposedChildrenTransform.SetRotationAnchor(anchorX, anchorY, v.ToFloat());
3007 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3011 _VisualElementImpl::GetChildrenTransformRotationAnchorXYSubProperty(void) const
3015 float anchorX = 0.0f;
3016 float anchorY = 0.0f;
3017 float anchorZ = 0.0f;
3018 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
3020 return Variant(FloatPoint(anchorX, anchorY));
3024 _VisualElementImpl::SetChildrenTransformRotationAnchorXYSubProperty(const Variant& v)
3026 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3028 const FloatPoint& point = v.ToFloatPoint();
3030 float anchorX = 0.0f;
3031 float anchorY = 0.0f;
3032 float anchorZ = 0.0f;
3033 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
3034 __decomposedChildrenTransform.SetRotationAnchor(point.x, point.y, anchorZ);
3036 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3040 _VisualElementImpl::GetChildrenTransformScaleXSubProperty(void) const
3044 float scaleX = 1.0f;
3045 float scaleY = 1.0f;
3046 float scaleZ = 1.0f;
3047 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3049 return Variant(scaleX);
3053 _VisualElementImpl::SetChildrenTransformScaleXSubProperty(const Variant& v)
3055 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3057 float scaleX = 1.0f;
3058 float scaleY = 1.0f;
3059 float scaleZ = 1.0f;
3060 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3061 __decomposedChildrenTransform.SetScaleFactors(v.ToFloat(), scaleY, scaleZ);
3063 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3067 _VisualElementImpl::GetChildrenTransformScaleYSubProperty(void) const
3071 float scaleX = 1.0f;
3072 float scaleY = 1.0f;
3073 float scaleZ = 1.0f;
3074 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3076 return Variant(scaleY);
3080 _VisualElementImpl::SetChildrenTransformScaleYSubProperty(const Variant& v)
3082 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3084 float scaleX = 1.0f;
3085 float scaleY = 1.0f;
3086 float scaleZ = 1.0f;
3087 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3088 __decomposedChildrenTransform.SetScaleFactors(scaleX, v.ToFloat(), scaleZ);
3090 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3094 _VisualElementImpl::GetChildrenTransformScaleZSubProperty(void) const
3098 float scaleX = 1.0f;
3099 float scaleY = 1.0f;
3100 float scaleZ = 1.0f;
3101 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3103 return Variant(scaleZ);
3107 _VisualElementImpl::SetChildrenTransformScaleZSubProperty(const Variant& v)
3109 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3111 float scaleX = 1.0f;
3112 float scaleY = 1.0f;
3113 float scaleZ = 1.0f;
3114 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3115 __decomposedChildrenTransform.SetScaleFactors(scaleX, scaleY, v.ToFloat());
3117 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3121 _VisualElementImpl::GetChildrenTransformScaleXYSubProperty(void) const
3125 float scaleX = 1.0f;
3126 float scaleY = 1.0f;
3127 float scaleZ = 1.0f;
3128 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3130 return Variant(FloatPoint(scaleX, scaleY));
3134 _VisualElementImpl::SetChildrenTransformScaleXYSubProperty(const Variant& v)
3136 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3138 const FloatPoint& point = v.ToFloatPoint();
3140 float scaleX = 1.0f;
3141 float scaleY = 1.0f;
3142 float scaleZ = 1.0f;
3143 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3144 __decomposedChildrenTransform.SetScaleFactors(point.x, point.y, scaleZ);
3146 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3150 _VisualElementImpl::GetChildrenTransformScaleAnchorXSubProperty(void) const
3154 float anchorX = 0.0f;
3155 float anchorY = 0.0f;
3156 float anchorZ = 0.0f;
3157 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3159 return Variant(anchorX);
3163 _VisualElementImpl::SetChildrenTransformScaleAnchorXSubProperty(const Variant& v)
3165 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3167 float anchorX = 0.0f;
3168 float anchorY = 0.0f;
3169 float anchorZ = 0.0f;
3170 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3171 __decomposedChildrenTransform.SetScaleAnchor(v.ToFloat(), anchorY, anchorZ);
3173 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3177 _VisualElementImpl::GetChildrenTransformScaleAnchorYSubProperty(void) const
3181 float anchorX = 0.0f;
3182 float anchorY = 0.0f;
3183 float anchorZ = 0.0f;
3184 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3186 return Variant(anchorY);
3190 _VisualElementImpl::SetChildrenTransformScaleAnchorYSubProperty(const Variant& v)
3192 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3194 float anchorX = 0.0f;
3195 float anchorY = 0.0f;
3196 float anchorZ = 0.0f;
3197 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3198 __decomposedChildrenTransform.SetScaleAnchor(anchorX, v.ToFloat(), anchorZ);
3200 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3204 _VisualElementImpl::GetChildrenTransformScaleAnchorZSubProperty(void) const
3208 float anchorX = 0.0f;
3209 float anchorY = 0.0f;
3210 float anchorZ = 0.0f;
3211 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3213 return Variant(anchorZ);
3217 _VisualElementImpl::SetChildrenTransformScaleAnchorZSubProperty(const Variant& v)
3219 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3221 float anchorX = 0.0f;
3222 float anchorY = 0.0f;
3223 float anchorZ = 0.0f;
3224 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3225 __decomposedChildrenTransform.SetScaleAnchor(anchorX, anchorY, v.ToFloat());
3227 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3231 _VisualElementImpl::GetChildrenTransformScaleAnchorXYSubProperty(void) const
3235 float anchorX = 0.0f;
3236 float anchorY = 0.0f;
3237 float anchorZ = 0.0f;
3238 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3240 return Variant(FloatPoint(anchorX, anchorY));
3244 _VisualElementImpl::SetChildrenTransformScaleAnchorXYSubProperty(const Variant& v)
3246 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3248 const FloatPoint& point = v.ToFloatPoint();
3250 float anchorX = 0.0f;
3251 float anchorY = 0.0f;
3252 float anchorZ = 0.0f;
3253 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3254 __decomposedChildrenTransform.SetScaleAnchor(point.x, point.y, anchorZ);
3256 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3260 _VisualElementImpl::GetChildrenTransformTranslationXSubProperty(void) const
3264 float translateX = 0.0f;
3265 float translateY = 0.0f;
3266 float translateZ = 0.0f;
3267 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3269 return Variant(translateX);
3273 _VisualElementImpl::SetChildrenTransformTranslationXSubProperty(const Variant& v)
3275 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3277 float translateX = 0.0f;
3278 float translateY = 0.0f;
3279 float translateZ = 0.0f;
3280 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3281 __decomposedChildrenTransform.SetTranslationFactors(v.ToFloat(), translateY, translateZ);
3283 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3287 _VisualElementImpl::GetChildrenTransformTranslationYSubProperty(void) const
3291 float translateX = 0.0f;
3292 float translateY = 0.0f;
3293 float translateZ = 0.0f;
3294 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3296 return Variant(translateY);
3300 _VisualElementImpl::SetChildrenTransformTranslationYSubProperty(const Variant& v)
3302 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3304 float translateX = 0.0f;
3305 float translateY = 0.0f;
3306 float translateZ = 0.0f;
3307 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3308 __decomposedChildrenTransform.SetTranslationFactors(translateX, v.ToFloat(), translateZ);
3310 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3314 _VisualElementImpl::GetChildrenTransformTranslationZSubProperty(void) const
3318 float translateX = 0.0f;
3319 float translateY = 0.0f;
3320 float translateZ = 0.0f;
3321 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3323 return Variant(translateZ);
3327 _VisualElementImpl::SetChildrenTransformTranslationZSubProperty(const Variant& v)
3329 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3331 float translateX = 0.0f;
3332 float translateY = 0.0f;
3333 float translateZ = 0.0f;
3334 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3335 __decomposedChildrenTransform.SetTranslationFactors(translateX, translateY, v.ToFloat());
3337 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3341 _VisualElementImpl::GetChildrenTransformTranslationXYSubProperty(void) const
3345 float translateX = 0.0f;
3346 float translateY = 0.0f;
3347 float translateZ = 0.0f;
3348 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3350 return Variant(FloatPoint(translateX, translateY));
3354 _VisualElementImpl::SetChildrenTransformTranslationXYSubProperty(const Variant& v)
3356 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3358 const FloatPoint& point = v.ToFloatPoint();
3360 float translateX = 0.0f;
3361 float translateY = 0.0f;
3362 float translateZ = 0.0f;
3363 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3364 __decomposedChildrenTransform.SetTranslationFactors(point.x, point.y, translateZ);
3366 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3370 _VisualElementImpl::IsClipToParent(void) const
3377 // TBD: clipToParent is not animatable, right??
3379 _VisualElementImpl::SetClipToParent(bool clipToParent)
3381 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
3383 return InvokeOnSetPropertyRequested(*pVePropClipToParent, Variant(clipToParent));
3387 _VisualElementImpl::GetClipToParentProperty(void) const
3390 //SysLog(NID_UI_ANIM, "WARNING: ClipToParent is deprecated.");
3392 return Variant(false);
3396 _VisualElementImpl::SetClipToParentProperty(const Variant& v)
3398 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3400 //SysLog(NID_UI_ANIM, "WARNING: ClipToParent is deprecated.");
3406 _VisualElementImpl::IsClipChildrenEnabled(void) const
3410 return __isClipChildren;
3414 _VisualElementImpl::SetClipChildrenEnabled(bool clipChildren)
3416 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
3417 result r = E_SUCCESS;
3419 if (IS_INTERNAL_CLASS(__pPublicInstance))
3421 r = SetClipChildrenProperty(Variant(clipChildren));
3425 r = InvokeOnSetPropertyRequested(*pVePropClipChildren, Variant(clipChildren));
3427 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
3433 _VisualElementImpl::GetClipChildrenProperty(void) const
3437 return Variant(__isClipChildren);
3441 _VisualElementImpl::SetClipChildrenProperty(const Variant& v)
3443 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3445 bool clipChildren = v.ToBool();
3446 if (likely(clipChildren != __isClipChildren))
3449 //SysLog(NID_UI_ANIM, "%p ClipChildren = %d", this, clipChildren);
3451 __isClipChildren = clipChildren;
3452 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false);
3456 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
3458 __pPresentation->SetClipChildrenProperty(__isClipChildren);
3465 _VisualElementImpl::IsSurfaceOpaque(void) const
3469 return GetSharedData().isSurfaceOpaque;
3473 _VisualElementImpl::SetSurfaceOpaque(bool isSurfaceOpaque)
3475 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
3476 result r = E_SUCCESS;
3478 if (IS_INTERNAL_CLASS(__pPublicInstance))
3480 r = SetSurfaceOpaqueProperty(Variant(isSurfaceOpaque));
3484 r = InvokeOnSetPropertyRequested(*pVePropSurfaceOpaque, Variant(isSurfaceOpaque));
3486 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
3492 _VisualElementImpl::GetSurfaceOpaqueProperty(void) const
3496 return Variant(GetSharedData().isSurfaceOpaque);
3500 _VisualElementImpl::SetSurfaceOpaqueProperty(const Variant& v)
3502 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3504 bool isSurfaceOpaque = v.ToBool();
3505 if (isSurfaceOpaque == GetSharedData().isSurfaceOpaque)
3508 InvalidateHierarchyProps(HIERARCHY_PROPERTY_CONTENTOPACITY, false, false); //don't have to apply the changed opacity to children.
3510 if (IS_PRESENTATION(this))
3512 GetSharedData().isSurfaceOpaque = isSurfaceOpaque;
3514 #ifndef LAZY_EVALUATION
3515 // not needed when no surface
3516 if (HAVE_SURFACE(this))
3517 GetSharedData().NodeReconfigure(*this);
3522 if(IS_NEEDED_UPDATE_PRESENTATION(this))
3524 __pPresentation->SetSurfaceOpaqueProperty(isSurfaceOpaque);
3532 _VisualElementImpl::GetCanvasN(void)
3534 return GetCanvasN(FloatRectangle(0.0f, 0.0f, __bounds.width, __bounds.height));
3538 _VisualElementImpl::GetCanvasN(const Rectangle& bounds)
3540 return GetCanvasN(FloatRectangle(bounds.x, bounds.y, bounds.width, bounds.height));
3544 _VisualElementImpl::GetCanvasN(const FloatRectangle& bounds)
3546 SysTryReturn(NID_UI_ANIM, !GetSharedData().fixedSurfaceSize, null, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Canvas can't be instantiated for fixed-size user surface.");
3547 SysTryReturn(NID_UI_ANIM, bounds.width >= 0.0f && bounds.height >= 0.0f, null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Canvas size is out of range. size = (%f, %f)", bounds.width, bounds.height);
3548 SysTryReturn(NID_UI_ANIM, __imageFilePath.IsEmpty(), null, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Can't get canvas for surface which is from image file.");
3549 SysTryReturn(NID_UI_ANIM, GetRoot(), null, E_INVALID_STATE, "[E_INVALID_STATE] VisualElement is not attached to main tree.");
3550 SysTryReturn(NID_UI_ANIM, IS_MODEL(this), null, E_INVALID_OPERATION, "VisualElement is not Model object.");
3552 // WARNING: WARNING: WARNING:
3553 // If need-redraw and surface is set by user, VE do *NOT* allow GetCanvasN
3554 // because 'bounds' is for the VE does not comply with size of surface.
3555 // (in which case the surface will be displayed scaled)
3557 _VisualElementImpl* pRenderTarget = GetRenderTarget();
3558 SysTryReturn(NID_UI_ANIM, pRenderTarget, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Target VisualElement is not available.");
3559 SysTryReturn(NID_UI_ANIM, pRenderTarget->__pSharedData, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Target VisualElement is not constructed.");
3562 // Forcefully create surface if GetCanvasN is called.
3563 // Without followings, surface may not be created if size of bounds == 0 (the initial size)
3564 if (!HAVE_SURFACE(this))
3566 __needRecreateSurface = true;
3569 pRenderTarget->RebuildHierarchyProps(0, true, true);
3572 SysTryReturn(NID_UI_ANIM, pRenderTarget->GetSharedData().pNativeNode->GetSurface(), null, E_SYSTEM, "[E_INVALID_STATE] Target VisualElement's surface is not constructed.");
3574 SysTryReturn(NID_UI_ANIM, pRenderTarget->GetSharedData().pSurface, null, E_SYSTEM, "[E_INVALID_STATE] Target VisualElement's surface is not constructed.");
3577 FloatRectangle canvasBounds;
3578 FloatRectangle clipBounds;
3581 // Use surface size, not bounds !!!
3583 float canvasX, canvasY, canvasW, canvasH;
3585 if (bounds.width == 0.0f || bounds.height == 0.0f)
3587 float surfaceWidth = __bounds.width;
3588 float surfaceHeight = __bounds.height;
3590 SysTryReturn(NID_UI_ANIM, bounds.x >= 0.0f && bounds.y >= 0.0f && bounds.x <= surfaceWidth && bounds.y <= surfaceHeight, null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Bounds is out of range.");
3599 clipBounds.x = 0.0f;
3600 clipBounds.y = 0.0f;
3601 clipBounds.width = __bounds.width;
3602 clipBounds.height = __bounds.height;
3604 canvasBounds.x = bounds.x;
3605 canvasBounds.y = bounds.y;
3606 canvasBounds.width = bounds.width;
3607 canvasBounds.height = bounds.height;
3609 canvasBounds = canvasBounds.GetIntersection(clipBounds);
3610 pRenderTarget->__pPresentation->ConvertCoordinates(canvasBounds, this->__pPresentation);
3611 canvasBounds = canvasBounds.GetIntersection(pRenderTarget->GetDrawableRect());
3613 SysTryReturn(NID_UI_ANIM, canvasBounds.width > 0.0f && canvasBounds.height > 0.0f, null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Bounds is out of range.");
3615 canvasX = canvasBounds.x;
3616 canvasY = canvasBounds.y;
3617 canvasW = canvasBounds.width;
3618 canvasH = canvasBounds.height;
3622 // From now, canvasBounds contains the clipping area, not subcanvas area.
3623 // (0, 0) of the canvas should be placed on the left-top of the VE !
3625 unique_ptr<_VisualElementCanvas> pCanvas(new (std::nothrow) _VisualElementCanvas);
3627 result r = pCanvas->Construct(*pRenderTarget->GetSharedData().pNativeNode->GetSurface(), FloatRectangle(canvasX, canvasY, canvasW, canvasH));
3628 SysTryReturn(NID_UI_ANIM, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] VisualElement is not constructed.");
3630 pRenderTarget->SetFlushNeeded();
3634 return pCanvas.release();
3638 _VisualElementImpl::GetRoot(void) const
3642 if (IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES))
3644 const_cast< _VisualElementImpl* >(this)->RebuildCoordinates();
3651 _VisualElementImpl::GetParent(void) const
3659 _VisualElementImpl::GetChildrenCount(void) const
3663 return __children.GetCount();
3666 Tizen::Base::Collection::IList*
3667 _VisualElementImpl::GetPublicChildrenN(void) const
3669 unique_ptr<Tizen::Base::Collection::ArrayList> pArrayList(new (std::nothrow) Tizen::Base::Collection::ArrayList());
3670 SysTryReturn(NID_UI_ANIM, pArrayList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
3672 int count = __children.GetCount();
3673 SysTryReturn(NID_UI_ANIM, !IsFailed(pArrayList->Construct(count)), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
3675 for (int i = 0; i < count; i++)
3677 const _VisualElementImpl* pChild = __children.GetChildAt(i);
3679 if (likely(pChild) && likely(pChild->__pPublicInstance))
3681 SysTryReturn(NID_UI_ANIM, !IsFailed(pArrayList->Add(*pChild->__pPublicInstance)), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
3687 return pArrayList.release();
3691 _VisualElementImpl::IsChildOf(const _VisualElementImpl& element) const
3695 if (unlikely(this == &element))
3700 if (unlikely(!__pParent))
3705 if (likely(__pParent == &element))
3710 return __pParent->IsChildOf(element);
3714 _VisualElementImpl::SetZOrder(const _VisualElementImpl* pReference, bool above)
3716 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
3717 SysTryReturnResult(NID_UI_ANIM, !pReference || pReference->__pParent, E_INVALID_ARG, "pReference doesn't have parent.");
3718 SysTryReturnResult(NID_UI_ANIM, __pParent, E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement doesn't have a parent.");
3719 SysTryReturnResult(NID_UI_ANIM, __isAllowedTreeModification == true, E_INVALID_OPERATION, "Z-order cannot be modified inside the OnAttached() or OnDetached() method of VisualElementEventListener.");
3721 return __pParent->InsertChild(*this, pReference, above);
3725 _VisualElementImpl::RemoveFromParent(void)
3727 if (likely(__pParent))
3729 __pParent->RemoveChild(*this);
3734 _VisualElementImpl::AddChild(_VisualElementImpl& child)
3736 //SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
3737 SysTryReturnResult(NID_UI_ANIM, child.__pSharedData, E_INVALID_ARG, "Child VisualElement is not constructed.");
3738 SysTryReturnResult(NID_UI_ANIM, child.__isAllowedTreeModification == true, E_INVALID_OPERATION, "Z-order cannot be modified inside the OnAttached() or OnDetached() method of VisualElementEventListener.");
3740 return ChangeZOrder(child, null, true, child._zOrderGroup);
3744 _VisualElementImpl::GetChildIndex(const _VisualElementImpl& child) const
3747 result r = __children.IndexOf(const_cast< _VisualElementImpl* >(&child), index);
3754 // r == E_OUT_OF_RANGE or E_OBJ_NOT_FOUND
3759 * @param[in] group will be changed group of the visualemenet.
3760 * @param[out] belowIndex the index of last item of below group's item.
3761 * @param[out] aboveIndex the index of first item of above group's item.
3763 * if group is lower than __children's lowest item, belowIndex = -1 , aboveIndex = 0
3764 * if group is higher than __children's highest item, belowIndex is last index of children, aboveIndex is 1 bigger than belowIndex.
3767 * B = Z_ORDER_GROUP_ALWAYS_BELOW_BOTTOM // lowest drawing gadget.(Background)
3768 * N = Z_ORDER_GROUP_NORMAL; // level of the default group.
3769 * T = Z_ORDER_GROUP_ALWAYS_ON_TOP; // highest drawing gadget.
3770 * 0 1 2 3 4 5 6 7 8 9
3771 * [B][B][B][N][N][N][N][T][T][T]
3772 * __GetZOrderGroupIndex(Z_ORDER_GROUP_NORMAL, below, above);
3775 * __GetZOrderGroupIndex(Z_ORDER_GROUP_ALWAYS_ON_TOP, below, above);
3778 * __GetZOrderGroupIndex(Z_ORDER_GROUP_ALWAYS_BELOW_BOTTOM, below, above);
3781 * 0 1 2 3 4 5 6 7 8 9
3782 * [B][B][B][B][B][T][T][T][T][T]
3783 * __GetZOrderGroupIndex(Z_ORDER_GROUP_NORMAL, below, above);
3786 * __GetZOrderGroupIndex(Z_ORDER_GROUP_ALWAYS_ON_TOP, below, above);
3789 * __GetZOrderGroupIndex(Z_ORDER_GROUP_ALWAYS_BELOW_BOTTOM, below, above);
3796 _VisualElementImpl::GetZOrderGroupIndex(int group, int& belowIndex, int& aboveIndex) const
3798 int lastIndex = __children.GetCount() - 1;
3799 if (lastIndex < 0) // _children is empty.
3806 if (group < (__children.GetChildAt(0))->_zOrderGroup) // group is lower than __children's lowest item.
3813 if (group > (__children.GetChildAt(lastIndex))->_zOrderGroup) // group is higher than __children's highest item.
3815 belowIndex = lastIndex;
3816 aboveIndex = lastIndex + 1;
3824 if (group >= __children.GetChildAt(i)->_zOrderGroup)
3834 if (group > __children.GetChildAt(i)->_zOrderGroup)
3846 _VisualElementImpl::InsertChild(_VisualElementImpl& child, const _VisualElementImpl* pReference, bool above)
3848 //SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
3849 SysTryReturnResult(NID_UI_ANIM, child.__pSharedData, E_INVALID_ARG, "Child VisualElement is not constructed.");
3850 SysTryReturnResult(NID_UI_ANIM, child.__isAllowedTreeModification == true, E_INVALID_OPERATION, "Z-order cannot be modified inside the OnAttached() or OnDetached() method of VisualElementEventListener.");
3852 int zOrderGroup = child._zOrderGroup;
3854 if (unlikely(pReference))
3856 zOrderGroup = pReference->_zOrderGroup;
3859 return ChangeZOrder(child, pReference, above, zOrderGroup);
3863 _VisualElementImpl::ChangeZOrder(_VisualElementImpl& child, const _VisualElementImpl* pReference, bool above, int group)
3866 int indexReference = -1;
3867 int indexInsert = -1;
3869 bool sameParent = false;
3871 // If not constructed well, disallow attaching !
3873 if (IsChildOf(child) || this == &child || &child == pReference || (pReference && pReference->__pParent != this))
3875 return E_INVALID_ARG;
3878 // TBD: check ownership!!!
3879 if (IS_PRESENTATION(this))
3881 _RootVisualElement* pChildRoot = child.GetRootPublic();
3883 if (GetRootPublic() != null && pChildRoot != GetRootPublic())
3885 child.RebuildNativeNodeTree(*this);
3891 indexReference = GetChildIndex(*pReference);
3892 SysTryReturnResult(NID_UI_ANIM, indexReference >= 0, E_INVALID_ARG, "Invalid argument(s) is used. pReference is not a child of this instance.");
3903 indexReference = __children.GetCount();
3911 int belowIndex, aboveIndex, indexRange;
3913 indexRange = GetZOrderGroupIndex(group, belowIndex, aboveIndex);
3919 else if (indexRange > 0)
3921 indexInsert = __children.GetCount();
3925 if (indexReference <= belowIndex + 1)
3927 indexInsert = belowIndex + 1;
3929 else if (indexReference >= aboveIndex)
3931 indexInsert = aboveIndex;
3935 indexInsert = indexReference;
3938 if (indexInsert < 0)
3944 if (child.__pParent == this) //case 1: move to the same parent. (just changed order )
3948 indexChild = GetChildIndex(child);
3949 SysTryReturn(NID_UI_ANIM, indexChild >= 0,
3950 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. The child(%p) isn't managed by this instance.", &child);
3952 if (indexChild < indexInsert)
3954 indexInsert--; // one of child item is removed so total item index is decreased.
3957 if (indexChild == indexInsert) //same position. don't have to do any action.
3959 child._zOrderGroup = group;
3961 //update presentation zorder group
3962 if (!IS_PRESENTATION(this))
3964 child.UpdatePresentationWhenZOrderChanged(pReference, above);
3969 SysTryReturn(NID_UI_ANIM, RemoveChildWithoutReconfiguring(indexChild, true) == E_SUCCESS,
3970 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Failed to remove a child(%p) from this instance.", &child);
3973 else //case 2: move to the other parent.
3974 { //case 3: child never been attached to the any parent.
3975 if (child.__pParent)
3977 child.__pParent->RemoveChild(child);
3980 // Setting implicit animation to the child.
3981 if (!IS_PRESENTATION(this) && _AnimationManager::GetInstance()->IsImplicitAnimationEnabled() && child.__isImplicitAnimationEnabled)
3983 child.RemoveAnimation(*pVePropActionAttach);
3985 #if defined(SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION)
3986 VisualElementAnimation* pAnimation = child.InvokeCreateAnimationForProperty(*pVePropActionAttach);
3988 VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
3989 SysTryReturn(NID_UI_ANIM, pAnimation != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
3990 pAnimation->SetPropertyName(*pVePropOpacity);
3991 pAnimation->SetStartValue(Variant(0.0f));
3993 if (pAnimation != null)
3995 pAnimation->SetVisualElementAnimationStatusEventListener(null);
3996 (child.GetPublic())->AddAnimation(*pVePropActionAttach, *pAnimation);
4003 child._zOrderGroup = group;
4005 //SysLog(NID_UI_ANIM, "Insert child %p(%d)", &child, indexInsert);
4007 if (!IS_PRESENTATION(this))
4011 VE_DELEGATE(this, InvokeOnChildAttaching, child);
4012 VE_DELEGATE(&child, InvokeOnAttaching, *this);
4016 __children.InsertAt(&child, indexInsert); // need addref -> jobs -> release ...
4017 child.__pParent = this;
4019 child.InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES | HIERARCHY_PROPERTY_OPACITY | HIERARCHY_PROPERTY_SHOWSTATE, true, false);
4021 // propagate child's prop. status to parents
4022 //__InvalidateHierarchyProps(child.__childrenNeedsUpdateProps, false, true);
4023 InvalidateHierarchyProps(child.__childrenNeedsUpdateProps, true, false);
4026 // When no surface, it is needed to invalidated.
4028 if (unlikely(!NEED_SURFACE(&child)))
4030 child.ExposeRectangle(null, true);
4034 // Because tree hierarchy is not a property, VE hierarchy tree changes are not
4035 // notified by property observer. So, we invoke method in presentation VE directly.
4038 if (!IS_PRESENTATION(this))
4040 child.UpdatePresentationWhenZOrderChanged(pReference, above);
4042 if(!sameParent) // when child was moved to same parent, don't have to detach and attach to parent.
4044 if (child.GetSharedData().pEventListener != null)
4046 child.InvokeOnAttached();
4049 if (GetSharedData().pEventListener != null)
4051 InvokeOnChildAttached(child);
4057 if (likely(GetSharedData().pNativeNode) && likely(child.GetSharedData().pNativeNode))
4059 _VisualElementImpl* pReferenceNode = null;
4061 if (indexInsert > 0)
4063 pReferenceNode = __children.GetChildAt(indexInsert - 1);
4066 // exceptional case: the pRefenreceNode is null and indexInsert are more than __children.count() + 1, then this case is something wrong.
4067 // normal case : when pReferenceNode is null , indexInsert has 0 or more small value.
4069 GetSharedData().pNativeNode->InsertChild(
4070 *child.GetSharedData().pNativeNode,
4071 (pReferenceNode ? pReferenceNode->GetSharedData().pNativeNode : null),
4072 (pReferenceNode ? true : false)
4081 _VisualElementImpl::UpdatePresentationWhenCustomPropertyChanged(const String& property, const Variant& value)
4083 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
4084 result r = E_SUCCESS;
4086 if (IS_NEEDED_UPDATE_PRESENTATION(this))
4089 Variant oldV = __pPresentation->InvokeOnGetPropertyRequested(property);
4091 if(CreateImplicitAnimationIfNeeded(property,value,oldV, NULL) == false)
4093 r = __pPresentation->InvokeOnSetPropertyRequested(property, value);
4100 _VisualElementImpl::UpdatePresentationWhenZOrderChanged(const _VisualElementImpl* pReferenceModel, bool above)
4102 if(!IS_MODEL(this) || !__pParent)
4107 _VisualElementImpl* pReferencePresenter = (pReferenceModel ? (pReferenceModel->__pPresentation ? pReferenceModel->__pPresentation : null) : null);
4109 if (likely(__pParent->__pPresentation) && likely(__pPresentation))
4111 __pParent->__pPresentation->ChangeZOrder(*__pPresentation, pReferencePresenter, above, _zOrderGroup);
4118 _VisualElementImpl::RemoveChildWithoutReconfiguring(int indexChild, bool invalidate)
4120 SysTryReturnResult(NID_UI_ANIM, indexChild >= 0 && indexChild < __children.GetCount(), E_OBJ_NOT_FOUND, "There is no VisualElement at %d th index.", indexChild);
4122 _VisualElementImpl* pChild = __children.GetChildAt(indexChild);
4123 SysTryReturnResult(NID_UI_ANIM, pChild, E_OBJ_NOT_FOUND, "There is no VisualElement at %d th index.", indexChild);
4126 //SysLog(NID_UI_ANIM, "Remove child %p(%d)", pChild, indexChild);
4127 __children.RemoveAt(indexChild);
4128 pChild->__pParent = null;
4129 // pChild->__ClearHierarchyInfo();
4132 if (!IS_PRESENTATION(this))
4134 // removed element need not invalidation !
4137 if (NEED_SURFACE(pChild))
4139 pChild->ExposeRectangle(null, false);
4143 pChild->InvalidateVisibleRectToRenderTarget(null);
4149 if (GetSharedData().pNativeNode && pChild->GetSharedData().pNativeNode)
4151 GetSharedData().pNativeNode->RemoveChild(*pChild->GetSharedData().pNativeNode);
4156 // Because some properties such as root, visible rect and etc. can be accessed detached, invalidating is needed here !
4157 // (Will be invalidated again on attaching)
4159 pChild->InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false);
4165 _VisualElementImpl::CreateElementTreeForDetachImplicitAnimation(_VisualElementImpl& child)
4167 result r = E_SYSTEM;
4169 VisualElement* pRoot = child.CreateElementForImplicitAnimationN();
4175 pRoot->_pVisualElementImpl->SetInternal(true);
4177 #if defined(SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION)
4178 VisualElementAnimation* pAnimation = child.InvokeCreateAnimationForProperty(*pVePropActionDetach);
4180 VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
4181 pAnimation->SetPropertyName(*pVePropOpacity);
4182 pAnimation->SetEndValue(Variant(0.0f));
4186 _VisualElementImplicitAnimationEventListener* pListener = new (std::nothrow) _VisualElementImplicitAnimationEventListener();
4189 pAnimation->SetVisualElementAnimationStatusEventListener(pListener);
4191 r = pRoot->AddAnimation(*pVePropActionDetach, *pAnimation);
4199 r = GetPublic()->AttachChild(*pRoot);
4218 _VisualElementImpl::CreateElementForImplicitAnimationN(void) const
4220 VisualElement* pElement = new (std::nothrow) VisualElement(*GetPublic());
4221 if (pElement == null)
4226 result r = pElement->Construct();
4229 pElement->Destroy();
4233 pElement->SetImplicitAnimationEnabled(false);
4235 if (HAVE_SURFACE(this))
4237 VisualElementSurface* pSurface = GetSurfaceN();
4240 pElement->SetSurface(pSurface);
4245 int count = __children.GetCount();
4246 for (int i = 0; i < count; i++)
4248 _VisualElementImpl* pVisualElementImpl = __children.GetChildAt(i);
4249 if (likely(pVisualElementImpl))
4251 r = pElement->AttachChild(*pVisualElementImpl->CreateElementForImplicitAnimationN());
4252 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4265 _VisualElementImpl::RemoveChild(_VisualElementImpl& child, bool deallocate)
4267 //SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
4268 SysTryReturnResult(NID_UI_ANIM, child.__isAllowedTreeModification == true, E_INVALID_OPERATION, "Z-order cannot be modified inside the OnAttached() or OnDetached() method of VisualElementEventListener.");
4270 int indexChild = GetChildIndex(child);
4271 SysTryReturnResult(NID_UI_ANIM, indexChild >= 0, E_OBJ_NOT_FOUND, "child is not a child of this instance.");
4273 if (!IS_PRESENTATION(this))
4276 VE_DELEGATE(this, InvokeOnChildDetaching, child);
4278 // IMPORTANT! When destroying, don't have to invoke OnDetached and OnDetaching after invoked OnDestructing.
4279 // call OnDestructing -> call OnDetaching it is ambiguous operation
4280 // it is called by RemoveFromParent() method, so pChild is destroying currently.
4281 if (!child.__isDestroying)
4283 VE_DELEGATE(&child, InvokeOnDetaching);
4287 result r = RemoveChildWithoutReconfiguring(indexChild, true);
4288 if (unlikely(r != E_SUCCESS))
4290 return E_OBJ_NOT_FOUND;
4293 if (!IS_PRESENTATION(this) && (_AnimationManager::GetInstance()->IsImplicitAnimationEnabled()
4294 && child.__isImplicitAnimationEnabled) && child.IsAncestorDestroying() == false)
4296 r = CreateElementTreeForDetachImplicitAnimation(child);
4297 if (unlikely(r != E_SUCCESS))
4299 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Dummy VisualElement cannot be attached.");
4304 // Because tree hierarchy is not a property, VE hierarchy tree changes are not
4305 // notified by property observer. So, we invoke method in presentation VE directly.
4307 if (!IS_PRESENTATION(this))
4310 if (likely(__pPresentation) && likely(child.GetPresentation()))
4312 __pPresentation->RemoveChild(*child.GetPresentation(), deallocate);
4315 // IMPORTANT! When destroying, don't have to invoke OnDetached and OnDetaching after invoked OnDestructing.
4316 // call OnDestructing -> call OnDetaching it is ambiguous operation
4317 // it is called by RemoveFromParent() method, so pChild is destroying currently.
4318 if (!child.__isDestroying && child.GetSharedData().pEventListener != null)
4320 child.InvokeOnDetached(*this);
4323 if (GetSharedData().pEventListener != null)
4325 InvokeOnChildDetached(child);
4337 _VisualElementImpl::RemoveAllChild(void)
4339 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
4345 _VisualElementImpl::RebuildNativeNodeTree(_VisualElementImpl& parent)
4347 if (!IS_PRESENTATION(this))
4352 _INativeNode* pNode = GetNativeNode();
4353 _INativeNode* pParentNode = parent.GetNativeNode();
4355 if (!pNode || !pParentNode)
4360 pNode->RebuildIfNeeded(*pParentNode);
4362 //TODO : must check ,don't you need to rebuild???
4363 // RebuildCoordinates();
4365 const int nativeProps = _VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES
4366 | _VisualElementImpl::HIERARCHY_PROPERTY_OPACITY
4367 | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY
4368 | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS;
4371 InvalidateHierarchyProps(nativeProps, false, false);
4373 int count = __children.GetCount();
4374 for ( int i = 0 ; i < count ; i++ )
4376 _VisualElementImpl* pVe = __children.GetChildAt(i);
4379 pVe->RebuildNativeNodeTree(*this);
4380 _INativeNode* pChildNode = pVe->GetNativeNode();
4381 pNode->InsertChild(*pChildNode,null, true);
4389 _VisualElementImpl::GetName(void) const
4393 return GetSharedData().name;
4397 _VisualElementImpl::SetName(const Tizen::Base::String& name)
4399 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
4400 result r = InvokeOnSetPropertyRequested(*pVePropName, Variant(name));
4401 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
4407 _VisualElementImpl::GetNameProperty(void) const
4411 return Variant(GetSharedData().name);
4415 _VisualElementImpl::SetNameProperty(const Variant& v)
4417 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_STRING, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
4419 const Tizen::Base::String& name = v.ToString();
4420 if (name == GetSharedData().name)
4425 GetSharedData().name = name;
4431 _VisualElementImpl::SetUserData(void* pUserData)
4433 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
4435 GetSharedData().pUserData = pUserData;
4441 _VisualElementImpl::GetUserData(void) const
4445 return GetSharedData().pUserData;
4449 _VisualElementImpl::GetChild(const Tizen::Base::String& name, bool searchAllDescendants) const
4453 int count = __children.GetCount();
4455 // for performance, look children directly
4456 for (int i = 0; i < count; i++)
4458 const _VisualElementImpl* pChild = __children.GetChildAt(i);
4459 if (unlikely(pChild->GetSharedData().name == name))
4461 return const_cast< _VisualElementImpl* >(pChild);
4465 if (searchAllDescendants)
4467 for (int i = 0; i < count; i++)
4469 const _VisualElementImpl* pChild = __children.GetChildAt(i)->GetChild(name, true);
4472 return const_cast< _VisualElementImpl* >(pChild);
4477 SetLastResult(E_OBJ_NOT_FOUND);
4483 _VisualElementImpl::GetVisibleRect(void) const
4485 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
4487 if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
4488 pThis->RebuildCoordinates();
4491 return FloatRectangle();
4493 if (likely(__visibleRectValid))
4494 return __visibleRect;
4498 FloatRectangle parentVisibleRect(__pClipSource->GetVisibleRect());
4499 ConvertCoordinates(parentVisibleRect, __pClipSource);
4500 pThis->__visibleRect = parentVisibleRect.GetIntersection(__visibleRect);
4503 pThis->__visibleRectValid = true;
4505 return __visibleRect;
4509 _VisualElementImpl::GetDrawableRect(void) const
4511 // If VE has backing-buffer, visible status is not important for drawing...
4512 bool needSurface = NEED_SURFACE(this);
4514 if (unlikely(!needSurface))
4516 return FloatRectangle();
4519 if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
4521 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
4522 pThis->RebuildCoordinates();
4526 // Even when surface exists, the size might be invalidated by changing bounds.
4528 if (HAVE_SURFACE(this) && GetSharedData().fixedSurfaceSize)
4530 return FloatRectangle(0.0f, 0.0f, GetSharedData().pSurface->GetSizeF().width, GetSharedData().pSurface->GetSizeF().height);
4533 return FloatRectangle(0.0f, 0.0f, __bounds.width, __bounds.height);
4537 _VisualElementImpl::GetOpacityFromRoot(void) const
4539 float opacity = __contentOpacity * __opacity * __showOpacity;
4540 const _VisualElementImpl* pElement = __pParent;
4543 if (!VE_VISIBLE(pElement))
4548 opacity *= pElement->__opacity * pElement->__showOpacity;
4549 pElement = pElement->__pParent;
4555 const FloatRectangle&
4556 _VisualElementImpl::GetBoundingBoxI(void) const
4558 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
4560 if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
4562 pThis->RebuildCoordinates();
4565 if (unlikely(!__boundingBoxValid))
4567 float x[4] = { 0.0f, __bounds.width, 0.0f, __bounds.width };
4568 float y[4] = { 0.0f, 0.0f, __bounds.height, __bounds.height };
4569 CalculateBoundingBox(x, y, pThis->__boundingBox);
4571 pThis->__boundingBoxValid = true;
4574 return __boundingBox;
4578 _VisualElementImpl::GetMatrixToSuper(void) const
4580 if (unlikely(__matrixToSuperValid))
4581 return __matrixToSuper;
4583 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
4585 pThis->__matrixToSuperValid = true;
4587 if (unlikely(__pParent == null))
4589 _MatrixUtilSetIdentity(pThis->__matrixToSuper);
4590 return __matrixToSuper;
4593 const bool needSurface = NEED_SURFACE(this);
4595 // apply subprojection && translation
4596 if (likely(needSurface))
4598 MatrixUtilCopy(pThis->__matrixToSuper, __pParent->__childrenTransform);
4599 _MatrixUtilTranslate(pThis->__matrixToSuper, __bounds.x, __bounds.y, __zPosition);
4603 _MatrixUtilSetTranslation(pThis->__matrixToSuper, __bounds.x, __bounds.y, __zPosition);
4608 if (likely(needSurface))
4610 if (likely(__decomposedTransform.GetMatrixType() != MATRIX4_Identity))
4612 bool needAnchor = (unlikely(__anchorZ != 0.0f) || unlikely(__anchor.x != 0.0f) || unlikely(__anchor.y != 0.0f));
4613 if (unlikely(needAnchor))
4614 _MatrixUtilTranslate(pThis->__matrixToSuper, __anchor.x * __bounds.width, __anchor.y * __bounds.height, __anchorZ);
4616 _MatrixUtilMultiply(pThis->__matrixToSuper, __matrixToSuper, __transform);
4618 if (unlikely(needAnchor))
4619 _MatrixUtilTranslate(pThis->__matrixToSuper, -__anchor.x * __bounds.width, -__anchor.y * __bounds.height, -__anchorZ);
4623 return __matrixToSuper;
4627 _VisualElementImpl::GetMatrixToTop(void) const
4629 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
4631 if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
4633 pThis->RebuildCoordinates();
4637 if (unlikely(!__matrixToTopValid))
4639 _MatrixUtilMultiply(pThis->__matrixToTop, __pParent->GetMatrixToTop(), GetMatrixToSuper());
4640 pThis->__matrixToTopValid = true;
4643 return __matrixToTop;
4647 _VisualElementImpl::GetMatrixFromTop(void) const
4649 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
4651 if (IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES))
4653 pThis->RebuildCoordinates();
4656 if (!__matrixFromTopValid)
4658 MatrixUtilCopy(pThis->__matrixFromTop, GetMatrixToTop());
4659 pThis->__matrixFromTopInvertible = _MatrixUtilInvert(pThis->__matrixFromTop);
4660 pThis->__matrixFromTopValid = true;
4663 return __matrixFromTop;
4667 _VisualElementImpl::CalcMatrixToBase(const _VisualElementImpl& base) const
4670 return FloatMatrix4();
4672 FloatMatrix4 matrixToBase(GetMatrixToSuper());
4674 const _VisualElementImpl* pParent = GetParent();
4677 pParent = pParent->GetParent();
4680 _MatrixUtilMultiply(matrixToBase, pParent->GetMatrixToSuper(), matrixToBase);
4681 pParent = pParent->GetParent();
4685 return matrixToBase;
4689 _VisualElementImpl::GetMatrixToClipSource(void) const
4691 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
4693 if (IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES))
4695 pThis->RebuildCoordinates();
4699 if (unlikely(!__matrixToClipSourceValid))
4701 if (likely(__pParent))
4703 if (__pParent->__isClipChildren)
4705 MatrixUtilCopy(pThis->__matrixToClipSource, GetMatrixToSuper());
4709 _MatrixUtilMultiply(pThis->__matrixToClipSource, __pParent->GetMatrixToClipSource(), GetMatrixToSuper());
4714 _MatrixUtilSetIdentity(pThis->__matrixToClipSource);
4717 pThis->__matrixToClipSourceValid = true;
4720 return __matrixToClipSource;
4724 _VisualElementImpl::InvalidateVisibleRectToRenderTarget(const FloatRectangle* pDirtyRectangle)
4726 if (unlikely(GetSharedData().invalidationLockCount > 0))
4729 if (!IsDrawingObject())
4732 FloatRectangle bounds;
4734 bounds = __pPresentation->GetVisibleRect();
4735 if (pDirtyRectangle)
4737 bounds = bounds.GetIntersection(*pDirtyRectangle);
4740 if (!bounds.IsEmpty())
4742 _VisualElementImpl* pRenderTarget = __pPresentation->GetRenderTarget();
4745 pRenderTarget->ConvertCoordinates(bounds, this);
4746 pRenderTarget->InvalidateRectangleI(&bounds);
4752 _VisualElementImpl::RebuildCoordinates(void)
4754 if (unlikely(!IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
4759 SetPropsValidaty(HIERARCHY_PROPERTY_COORDINATES, 0);
4761 __visibleRect.x = 0.0f;
4762 __visibleRect.y = 0.0f;
4763 __visibleRect.width = __bounds.width;
4764 __visibleRect.height = __bounds.height;
4767 if (unlikely(!__pParent))
4770 // Need to allowing transform to root element !
4772 _MatrixUtilSetIdentity(__matrixToTop);
4773 _MatrixUtilSetIdentity(__matrixFromTop);
4774 _MatrixUtilSetIdentity(__matrixToClipSource);
4775 __pClipSource = null;
4779 RectUtilCopy(__boundingBox, __bounds);
4780 RectUtilCopy(__boundingBoxToClipSource, __bounds);
4782 _RootVisualElement* pRoot = dynamic_cast< _RootVisualElement* >(__pPublicInstance);
4786 __pRoot = pRoot->_pVisualElementImpl;
4793 __needTransform = false;
4794 __needClipForUntransformed = false;
4797 __matrixFromTopValid = true;
4798 __matrixToTopValid = true;
4799 __matrixToClipSourceValid = true;
4800 __matrixToSuperValid = true;
4802 __boundingBoxValid = true;
4803 __visibleRectValid = true;
4807 if (unlikely(__pParent->IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
4809 __pParent->RebuildCoordinates();
4812 __pRoot = __pParent->__pRoot;
4814 Matrix4Type transformType = __decomposedTransform.GetMatrixType();
4815 const Matrix4Type parentChildrenTransformType = __pParent->__decomposedChildrenTransform.GetMatrixType();
4817 if (parentChildrenTransformType > MATRIX4_Translation)
4818 transformType = MATRIX4_Generic;
4821 if (unlikely(__pParent->__isClipChildren))
4823 __pClipSource = __pParent;
4825 __needTransform = (transformType > MATRIX4_Translation);
4826 if (likely(!__needTransform))
4828 __boundingBoxToClipSource.x = __bounds.x + __transform.matrix[3][0];
4829 __boundingBoxToClipSource.y = __bounds.y + __transform.matrix[3][1];
4830 __boundingBoxToClipSource.width = __bounds.width;
4831 __boundingBoxToClipSource.height = __bounds.height;
4836 __pClipSource = __pParent->__pClipSource;
4838 if (unlikely(transformType > MATRIX4_Translation))
4839 __needTransform = true;
4841 __needTransform = __pParent->__needTransform;
4843 if (likely(!__needTransform))
4845 __boundingBoxToClipSource.x = __pParent->__boundingBoxToClipSource.x + __bounds.x + __transform.matrix[3][0];
4846 __boundingBoxToClipSource.y = __pParent->__boundingBoxToClipSource.y + __bounds.y + __transform.matrix[3][1];
4847 __boundingBoxToClipSource.width = __bounds.width;
4848 __boundingBoxToClipSource.height = __bounds.height;
4850 if (unlikely(parentChildrenTransformType == MATRIX4_Translation))
4852 __boundingBoxToClipSource.x += __pParent->__childrenTransform.matrix[3][0];
4853 __boundingBoxToClipSource.y += __pParent->__childrenTransform.matrix[3][1];
4859 if (likely(!__needTransform))
4861 if (unlikely(parentChildrenTransformType == MATRIX4_Translation))
4863 __boundingBoxToClipSource.x += __pParent->__childrenTransform.matrix[3][0];
4864 __boundingBoxToClipSource.y += __pParent->__childrenTransform.matrix[3][1];
4868 __needClipForUntransformed = __pParent->__needClipForUntransformed;
4869 if (likely(!__needClipForUntransformed) && likely(__pClipSource))
4871 if (likely(__boundingBoxToClipSource.x >= 0.0f) &&
4872 likely(__boundingBoxToClipSource.y >= 0.0f) &&
4873 likely(__boundingBoxToClipSource.x + __boundingBoxToClipSource.width <= __pClipSource->__bounds.width) &&
4874 likely(__boundingBoxToClipSource.y + __boundingBoxToClipSource.height <= __pClipSource->__bounds.height))
4875 __needClipForUntransformed = false;
4877 __needClipForUntransformed = true;
4881 __needClipForUntransformed = true;
4885 __matrixFromTopValid = false;
4886 __matrixToTopValid = false;
4887 __matrixToClipSourceValid = false;
4888 __matrixToSuperValid = false;
4890 __boundingBoxValid = false;
4891 __visibleRectValid = false;
4896 _VisualElementImpl::RebuildVisibility(void)
4898 const int mask = HIERARCHY_PROPERTY_COORDINATES | HIERARCHY_PROPERTY_SHOWSTATE | HIERARCHY_PROPERTY_OPACITY | HIERARCHY_PROPERTY_CONTENTOPACITY;
4900 if (unlikely(!IsPropsInvalidated(mask)))
4905 if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
4907 RebuildCoordinates();
4911 SetPropsValidaty(mask, 0);
4913 if (unlikely(!__pParent))
4916 // Need to allowing transform to root element !
4919 __isVisible = false;
4921 __isVisible = VE_VISIBLE(this);
4925 if (unlikely(__pParent->IsPropsInvalidated(mask)))
4927 __pParent->RebuildVisibility();
4930 if (likely(__pParent->__isVisible))
4931 __isVisible = VE_VISIBLE(this);
4933 __isVisible = false;
4938 _VisualElementImpl::LockInvalidate(bool lock)
4940 GetSharedData().LockInvalidate(lock);
4944 _VisualElementImpl::InvalidateHierarchyPropsDownward(int invalidProps, bool broadcastToChildren, bool propagateToParentsOnly)
4946 invalidProps &= HIERARCHY_PROPERTY_MASK;
4948 __childrenNeedsUpdateProps |= invalidProps;
4950 if (likely(!propagateToParentsOnly))
4952 SetPropsValidaty(0, invalidProps);
4954 if (likely(invalidProps & HIERARCHY_PROPERTY_COORDINATES))
4956 __matrixFromTopValid = false;
4957 __matrixToSuperValid = false;
4958 __boundingBoxValid = false;
4962 if (unlikely(!broadcastToChildren))
4967 int count = __children.GetCount();
4968 for (int i = 0; i < count; i++)
4970 __children.GetChildAt(i)->InvalidateHierarchyPropsDownward(invalidProps, broadcastToChildren, propagateToParentsOnly);
4973 // may need update some attribute variables for other hierarchy properties
4978 _VisualElementImpl::InvalidateHierarchyProps(int invalidProps, bool broadcastToChildren, bool propagateToParentsOnly)
4980 invalidProps &= HIERARCHY_PROPERTY_MASK;
4982 // // For model tree, it is not needed to invalidate children-opacity and show-state
4983 // if (!IS_PRESENTATION(this))
4985 // invalidProps &= ~(HIERARCHY_PROPERTY_OPACITY | HIERARCHY_PROPERTY_SHOWSTATE);
4988 if (unlikely(!invalidProps))
4993 InvalidateHierarchyPropsDownward(invalidProps, broadcastToChildren, propagateToParentsOnly);
4995 _VisualElementImpl* pElement = __pParent; // WARNING: 'this' is updated in '__InvalidateHierarchyPropsDownward'
4998 pElement->__childrenNeedsUpdateProps |= invalidProps;
4999 pElement = pElement->__pParent;
5003 // HIERARCHY_PROPERTY_CONTENT is not handled here, but in drawing logic
5005 _VisualElementImpl::RebuildHierarchyProps(int props, bool checkSurface, bool reconfSurfaceOnly)
5007 if (likely(__pParent) && (unlikely(__pParent->IsPropsInvalidated(props)) || unlikely(__pParent->GetSharedData().NeedNativeReconfigure())))
5010 // 'checkSurface' for parent will make surface !
5011 __pParent->RebuildHierarchyProps(props, false, false);
5015 // TBD: Recreating surface may have to be done in presentation layer (thread!)
5016 if (unlikely(checkSurface))
5018 if (likely(IsDrawingObject()))
5020 ResetSurfaceIfNeeded(); // may invalidate GetSharedData().surfaceChanged
5024 const bool needApplyNatives = GetSharedData().NeedNativeReconfigure();
5026 props &= HIERARCHY_PROPERTY_MASK;
5027 if (unlikely(!IsPropsInvalidated(props)) && likely(!checkSurface) && unlikely(needApplyNatives == 0))
5032 if (likely(props & HIERARCHY_PROPERTY_CONTENTBOUNDS) && likely(IsPropsInvalidated(HIERARCHY_PROPERTY_CONTENTBOUNDS)))
5034 SetPropsValidaty(HIERARCHY_PROPERTY_CONTENTBOUNDS, 0);
5037 if (likely(props & HIERARCHY_PROPERTY_COORDINATES) && likely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
5039 RebuildCoordinates();
5040 //__SetPropsValidaty(HIERARCHY_PROPERTY_COORDINATES, 0); --> need not. __RebuildCoordinates will validate.
5044 // 'Visibility' should be checked after validating tree-hierarchy information.
5045 // (For example, attaching/detaching may affect visibility.)
5046 const int mask = HIERARCHY_PROPERTY_OPACITY | HIERARCHY_PROPERTY_SHOWSTATE | HIERARCHY_PROPERTY_CONTENTOPACITY;
5047 if (unlikely((props & mask) != 0) && unlikely(IsPropsInvalidated(props & mask)))
5049 RebuildVisibility();
5052 if (likely(__pPresentation) && likely(needApplyNatives))
5054 if (unlikely(!IS_PRESENTATION(this)))
5057 // In model, native nodes are updated only when the surface was changed.
5058 //if (unlikely(GetSharedData().surfaceChanged))
5060 __pPresentation->FlushNativeChanges();
5065 GetSharedData().NodeReconfigure(*__pPresentation, false);
5071 _VisualElementImpl::FlushNativeChanges(void)
5073 if (unlikely(!IS_PRESENTATION(this)))
5076 if (likely(__pPresentation))
5077 GetSharedData().NodeReconfigure(*__pPresentation, false);
5081 _VisualElementImpl::UpdateHierarchyProps(void)
5084 // HIERARCHY_PROPERTY_CONTENT is not handled here, but in drawing logic.
5085 const int mask = HIERARCHY_PROPERTY_MASK;
5087 if (unlikely((__childrenNeedsUpdateProps & mask) == 0 && GetSharedData().childrenSurfaceChanged == false))
5090 // Node will be reconfigured later(before OnDraw, or DrawRectangle, ...)
5091 if (likely(IsPropsInvalidated(mask)) || likely(GetSharedData().NeedNativeReconfigure()))
5092 RebuildHierarchyProps(mask, false, false);
5095 // __childrenNeedsUpdateProps should be cleared *ONLY AFTER* flushing native nodes !
5096 __childrenNeedsUpdateProps &= ~mask;
5097 GetSharedData().childrenSurfaceChanged = false;
5099 int count = __children.GetCount();
5100 for (int i = 0; i < count; i++)
5102 _VisualElementImpl* pChild = __children.GetChildAt(i);
5103 if (likely((pChild->__childrenNeedsUpdateProps & mask) != 0 || pChild->GetSharedData().childrenSurfaceChanged == true))
5104 pChild->UpdateHierarchyProps();
5109 _VisualElementImpl::ExposeRectangle(const FloatRectangle* pDirtyRectangle, bool invalidate)
5111 if (unlikely(!IsDrawingObject()))
5114 if (unlikely(invalidate))
5116 InvalidateRectangleI(pDirtyRectangle);
5121 _VisualElementImpl::SetFlushNeeded(void)
5123 FloatRectangle rect;
5125 if (!IS_PRESENTATION(this))
5127 return __pPresentation->SetFlushNeeded();
5131 rect.SetPosition(0.0f, 0.0f);
5133 if (likely(HAVE_SURFACE(this)))
5135 GetSharedData().pNativeNode->SetFlushNeeded();
5139 _VisualElementImpl* pRenderTarget = GetRenderTarget();
5141 if (likely(pRenderTarget && pRenderTarget->GetSharedData().pNativeNode))
5143 pRenderTarget->ConvertCoordinates(rect, this);
5144 pRenderTarget->GetSharedData().pNativeNode->SetFlushNeeded();
5152 _VisualElementImpl::Flush(void)
5154 if (likely(GetSharedData().pNativeNode))
5156 GetSharedData().pNativeNode->Flush();
5163 _VisualElementImpl::InvalidateRectangle(const FloatRectangle* pRectangle)
5165 return InvalidateRectangleI(pRectangle);
5169 _VisualElementImpl::InvalidateRectangleI(const FloatRectangle* pRectangle)
5171 SysTryReturnResult(NID_UI_ANIM, !GetSharedData().fixedSurfaceSize, E_INVALID_OPERATION, "VisualElement with User-Surface do not allow invalidating and redrawing.");
5172 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "Invalidating VisualElement should be performed on a model layer.");
5174 if (unlikely(GetSharedData().invalidationLockCount > 0))
5179 FloatRectangle invRect;
5181 if (unlikely(pRectangle))
5183 if (unlikely(pRectangle->IsEmpty()))
5188 invRect = *pRectangle;
5193 invRect.SetPosition(0.0f, 0.0f);
5196 if (unlikely(invRect.IsEmpty()))
5203 // 'GetUnion' method will not behave as our intention.
5204 // If the parameter or self is empty, the union of rectangle should ignore it !
5205 //invRect = GetSharedData().invalidatedRegion.GetUnion(invRect);
5206 RectUtilUnion(invRect, GetSharedData().invalidatedRegion);
5210 // If new requested invalidate region is already included currently,
5211 // we can skip the following calculations (but invalidating flags are STILL needed !)
5213 _VisualElementImpl* pRenderTarget = GetRenderTarget();
5215 if (likely(pRenderTarget == this))
5217 // Make invalidated area a bit larger to be aligned on the render target
5218 RectUtilMakeIntegral(invRect);
5221 GetSharedData().invalidatedRegion = invRect;
5223 _VisualElementImpl* pElement = this;
5226 pElement->GetSharedData().childrenInvalidated = true;
5227 pElement = pElement->GetParent();
5229 SetRootNeedsContentUpdate();
5235 _VisualElementImpl::GetInvalidatedRectangle(void) const
5239 if (IS_PRESENTATION(this))
5243 return __pModel->GetInvalidatedRectangle();
5247 return GetSharedData().invalidatedRegion;
5251 _VisualElementImpl::GetUpdateRectangle(void) const
5255 return GetSharedData().updateRegion;
5259 _VisualElementImpl::IsOpaque(void) const
5263 if (HAVE_SURFACE(this))
5265 return IsSurfaceOpaque();
5272 _VisualElementImpl::Draw(void)
5274 SysTryReturnResult(NID_UI_ANIM, IS_ATTACHED(this), E_INVALID_STATE, "Drawing VisualElement should be attached to the root tree.");
5275 if (!IS_MODEL(this))
5277 //SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
5281 // Not a good position to apply property changes into native(EFL) system.
5282 // Because of no-compositor in VE, we cannot control each element's
5283 // visibilities (show-state, bounds, opacity, etc.) !
5284 // Is there any good idea ?
5286 // if (IS_PRESENTATION(this))
5287 // __UpdateHierarchyProps();
5289 if (unlikely(GetSharedData().childrenInvalidated))
5291 // if (unlikely(!IS_PRESENTATION(this)))
5292 // __UpdateHierarchyProps();
5295 // Drawing must be done from first opaque.
5296 // But, because we assume all VE's are transparent, all drawings are done from root !!!
5298 _VisualElementImpl* pRenderTarget = GetRenderTarget();
5299 bool needFullScreenDraw = __isRoot;
5301 if (unlikely(!pRenderTarget))
5303 // On no render target, flush invalidated area from root
5304 pRenderTarget = GetRoot();
5305 SysTryReturnResult(NID_UI_ANIM, pRenderTarget, E_SYSTEM, "A system error has been occurred. This VisualElement doesn't have rendering target.");
5306 needFullScreenDraw = true;
5311 // To minimize drawing area(with clip), use '__DrawRectangleIfNeeded'
5312 // To reduce drawing calls such as 'OnDraw', use '__DrawRectangle' directly
5314 int maxScreenSize = _Max(_VisualElementCoordinateSystem::logScreenWidth, _VisualElementCoordinateSystem::logScreenHeight);
5315 pRenderTarget->DrawRectangleIfNeeded(
5316 needFullScreenDraw ? FloatRectangle(0.0f, 0.0f, maxScreenSize, maxScreenSize) : GetDrawableRect()
5320 if (IS_PRESENTATION(this))
5321 UpdateHierarchyProps();
5327 _VisualElementImpl::DrawForAnimation(void)
5329 if (!IS_ATTACHED(this))
5334 if (unlikely(GetSharedData().childrenInvalidated))
5336 _VisualElementImpl* pRenderTarget = GetRenderTarget();
5337 pRenderTarget->DrawRectangle(GetSharedData().invalidatedRegion);
5339 if (likely(GetSharedData().childrenInvalidated == false))
5344 _VisualElementImpl* pChild = null;
5345 bool childrenNeedUpdate = false;
5346 int count = __children.GetCount();
5347 for (int i = 0; i < count; i++)
5349 pChild = __children.GetChildAt(i);
5350 if (!pChild || (pChild->GetSharedData().childrenInvalidated == false))
5355 pChild->DrawForAnimation();
5357 if ((pChild->GetSharedData().childrenInvalidated))
5359 childrenNeedUpdate = true;
5363 // update 'needUpdate' flag regarding children only if no invalidated-region
5364 if (GetSharedData().invalidatedRegion.IsEmpty())
5366 if (childrenNeedUpdate)
5368 GetSharedData().childrenInvalidated = true;
5377 _VisualElementImpl::DrawRectangleIfNeeded(const FloatRectangle& drawRect)
5379 if (unlikely(!IsVisibleI()) || GetSharedData().childrenInvalidated == false)
5385 // VE with surface redraws *ALL INVALIDATED* region !! --> TBD: make an option/flags for this???
5387 FloatRectangle drawableRect;
5389 if (NEED_SURFACE(this))
5392 // Redraw only if the request has some valid region to draw.
5393 drawableRect = GetDrawableRect();
5394 if (!drawRect.IsIntersected(drawableRect))
5395 drawableRect.SetSize(0.0f, 0.0f); // Make empty
5399 drawableRect = drawRect;
5402 DrawRectangle(drawableRect.GetIntersection(GetSharedData().invalidatedRegion));
5405 // needUpdate flag may be 'true' after drawring invalidated region.
5406 // This means that some children still need to be updated !
5408 if (likely(GetSharedData().childrenInvalidated == false))
5414 // Some children still need to update in case that invalidated rect of this
5415 // is smaller than 'drawRect' which can overlap the invalid rect of children
5419 // Because user can do anything in drawing logic,
5420 // adding-reference may be safe.......
5422 _VisualElementImpl* pChild = null;
5423 FloatRectangle updateRect, childBounds;
5424 bool childrenNeedUpdate = false;
5425 int count = __children.GetCount();
5426 for (int i = 0; i < count; i++)
5428 pChild = __children.GetChildAt(i);
5429 if (!pChild || pChild->GetSharedData().childrenInvalidated == false)
5436 // Draw all children with surface.
5437 // Children with empty invalidated region will ignore re-drawing.
5439 updateRect = drawRect;
5440 pChild->ConvertCoordinates(updateRect, this);
5442 if (likely(NEED_SURFACE(pChild)))
5444 pChild->DrawRectangleIfNeeded(updateRect);
5448 childBounds = pChild->__pPresentation->__bounds;
5449 childBounds.SetPosition(0.0f, 0.0f);
5450 updateRect = updateRect.GetIntersection(childBounds);
5451 if (unlikely(!updateRect.IsEmpty()))
5452 pChild->DrawRectangleIfNeeded(updateRect);
5455 if (pChild->GetSharedData().childrenInvalidated)
5457 childrenNeedUpdate = true;
5461 // update 'needUpdate' flag regarding children only if no invalidated-region
5462 if (GetSharedData().invalidatedRegion.IsEmpty())
5464 if (childrenNeedUpdate)
5466 GetSharedData().childrenInvalidated = true;
5471 // TODO: change name(remove 'rectangle')
5473 _VisualElementImpl::DrawRectangle(const FloatRectangle& drawRect)
5475 if (unlikely(!GetRootPublic()) || unlikely(drawRect.IsEmpty()))
5480 //SysLog(NID_UI_ANIM, "DrawRectangle");
5482 bool needDraw = false;
5483 bool fullValidated = false;
5484 FloatRectangle drawableRect(GetDrawableRect());
5485 FloatRectangle drawRectVisible(drawRect.GetIntersection(drawableRect));
5486 FloatRectangle invalidatedRectVisible(GetSharedData().invalidatedRegion.GetIntersection(drawableRect));
5488 if (unlikely(!drawRectVisible.IsEmpty()))
5491 // Draw full-invalidated-content (not partial) if VE has surface.
5492 if (likely(NEED_SURFACE(this)))
5493 drawRectVisible = drawableRect;
5500 // Make dirty/draw area a bit larger to be pixel-aligned and prevent drawing-artifacts caused by float-error.
5501 RectUtilMakeIntegral(drawRectVisible);
5502 RectUtilMakeIntegral(invalidatedRectVisible);
5504 // DO NOT USE drawRectVisible.Contains(invalidatedRectVisible))
5505 if (invalidatedRectVisible.IsEmpty() || (drawRectVisible.x <= invalidatedRectVisible.x &&
5506 drawRectVisible.y <= invalidatedRectVisible.y &&
5507 drawRectVisible.x + drawRectVisible.width >= invalidatedRectVisible.x + invalidatedRectVisible.width &&
5508 drawRectVisible.y + drawRectVisible.height >= invalidatedRectVisible.y + invalidatedRectVisible.height))
5510 fullValidated = true;
5516 // VisualElement with User-Set surface does not allow invalidating and redrawing.
5517 // Because there should be no invalidated region in this case, checking User-Surface may redundant.
5519 if (GetSharedData().fixedSurfaceSize)
5522 fullValidated = true;
5523 drawRectVisible = GetSharedData().invalidatedRegion;
5528 // Set update region before 'CanDraw' and 'OnDraw' delegations to check real-update region
5530 GetSharedData().updateRegion = drawRectVisible;
5535 // Clear *BEFORE* drawing because 'OnDraw' may add invalidated regions...
5537 GetSharedData().invalidatedRegion.SetBounds(0.0f, 0.0f, 0.0f, 0.0f); // SetEmpty()
5538 GetSharedData().childrenInvalidated = false;
5544 if (!VE_DELEGATE(this, InvokePrepareDraw))
5552 Canvas* pCanvas = GetCanvasN();
5556 result r = pCanvas->SetClipBounds(FloatRectangle(drawRectVisible.x,
5558 drawRectVisible.width,
5559 drawRectVisible.height));
5562 SysLogException(NID_UI_ANIM, r, "[%s] Failed to set clip-bounds on canvas", GetErrorMessage(r));
5565 VE_DELEGATE(this, InvokeOnDraw, *pCanvas);
5570 // Flushing canvas is done at GetCanvasN.
5576 // Clear update region after drawing
5577 GetSharedData().updateRegion.SetBounds(0.0f, 0.0f, 0.0f, 0.0f);
5581 // Because user can do anything in drawing logic,
5582 // adding-reference/copying-list may be safe.......
5584 _VisualElementImpl* pChild = null;
5585 int count = __children.GetCount();
5586 bool childrenNeedUpdate = false;
5587 FloatRectangle childBounds;
5588 for (int i = 0; i < count; i++)
5590 pChild = __children.GetChildAt(i);
5591 if (likely(!NEED_SURFACE(pChild)))
5593 drawRectVisible = drawRect;
5594 pChild->ConvertCoordinates(drawRectVisible, this);
5595 childBounds = pChild->__pPresentation->__bounds;
5597 childBounds.SetPosition(0.0f, 0.0f);
5599 drawRectVisible = drawRectVisible.GetIntersection(childBounds);
5600 if (likely(!drawRectVisible.IsEmpty()))
5601 pChild->DrawRectangle(drawRectVisible);
5604 if (pChild->GetSharedData().childrenInvalidated)
5606 childrenNeedUpdate = true;
5611 // If not all children have been validated during update,
5612 // we should not clear update flag to flush them later.
5614 if (childrenNeedUpdate)
5616 GetSharedData().childrenInvalidated = true;
5620 // for a cumstom property animation
5622 _VisualElementImpl::SetPropertyI(const String& property, const Variant& value)
5624 result r = E_SUCCESS;
5626 if (likely(__pPublicInstance))
5628 r = __pPublicInstance->OnSetPropertyRequested(property, value);
5629 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
5636 _VisualElementImpl::InvokeOnSetPropertyRequested(const String& property, const Variant& value)
5638 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
5639 result r = E_SUCCESS;
5641 if (likely(__pPublicInstance))
5643 r = __pPublicInstance->OnSetPropertyRequested(property, value);
5644 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
5651 _VisualElementImpl::HitTestI(const FloatPoint& point)
5655 return HITTEST_NOWHERE;
5658 if (//NEED_SURFACE(&target) &&
5659 !GetSharedData().isSurfaceOpaque &&
5660 _FloatHardCompare(GetOpacityFromRoot(), 0.0f))
5662 return HITTEST_NOWHERE;
5665 if (!GetVisibleRect().Contains(point))
5667 return HITTEST_NOWHERE;
5670 _VisualElementImpl* pClipSource = GetClipSource();
5673 FloatPoint pt = point;
5674 pClipSource->ConvertCoordinates(pt, this);
5676 if (!pClipSource->GetVisibleRect().Contains(pt))
5678 return HITTEST_NOWHERE;
5682 pClipSource = pClipSource->GetClipSource();
5686 return HITTEST_MATCH;
5690 _VisualElementImpl::GetChildAtPointI(const FloatPoint& point, int parentHitTest)
5692 _VisualElementImpl* pHitTarget = null;
5693 FloatPoint hitPoint = point;
5696 hitTest = VE_DELEGATE(this, InvokeHitTest, point);
5697 if ((hitTest & HITTEST_MATCH) != 0)
5703 if ((hitTest & HITTEST_NOMORECHILDREN) == 0)
5705 int count = __children.GetCount();
5706 for (int i = count - 1; i >= 0; i--) // from top to bottom
5708 _VisualElementImpl* pChild = __children.GetChildAt(i);
5714 FloatPoint childHitPoint = point;
5715 pChild->ConvertCoordinates(childHitPoint, this);
5717 _VisualElementImpl* pChildHitTarget = pChild->GetChildAtPointI(childHitPoint, hitTest);
5718 if (pChildHitTarget)
5720 pHitTarget = pChildHitTarget;
5721 hitPoint = childHitPoint;
5730 // point = hitPoint;
5738 // Because Hit-Testing from self, clipping flags of self will be ignored.
5741 _VisualElementImpl::GetChildAt(const FloatPoint& point)
5743 _VisualElementImpl* pHitTarget = GetChildAtPointI(point, HITTEST_MATCH);
5744 if (unlikely(!pHitTarget))
5746 SetLastResult(E_OBJ_NOT_FOUND);
5757 _VisualElementImpl::ScrollByPoint(const FloatPoint& pointOffset, bool scrollSelf)
5759 if (_FloatCompare(pointOffset.x, 0.0f) && _FloatCompare(pointOffset.y, 0.0f))
5765 FloatMatrix4 xform = __childrenTransform;
5766 FloatMatrix4 xformOrg = xform;
5767 FloatRectangle rectInvalidated;
5769 _MatrixUtilTranslate(xform, pointOffset.x, pointOffset.y, 0.0f);
5771 if (HAVE_SURFACE(this))
5773 int count = __children.GetCount();
5775 LockInvalidate(true);
5776 for (int i = 0; i < count; i++)
5778 __children.GetChildAt(i)->LockInvalidate(true);
5781 r = SetChildrenTransformMatrix(xform);
5783 LockInvalidate(false);
5784 for (int i = 0; i < count; i++)
5786 __children.GetChildAt(i)->LockInvalidate(false);
5791 r = SetChildrenTransformMatrix(xform);
5794 SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, E_SYSTEM, "Failed to translate matrix for scrolling ");
5796 if (!NEED_SURFACE(this))
5798 InvalidateVisibleRectToRenderTarget(null);
5800 else if (scrollSelf)
5802 Canvas* pCanvas = GetCanvasN(); // TODO: clip rect......
5806 _CanvasImpl* pCanvasImpl = _CanvasImpl::GetInstance(*pCanvas);
5810 Rectangle rectSource;
5812 rectSource.SetBounds(0, 0, __bounds.width, __bounds.height);
5814 rectInvalidated = __bounds;
5815 rectInvalidated.SetPosition(0.0f, 0.0f);
5816 if (pointOffset.x > 0)
5818 rectSource.width -= pointOffset.x;
5819 pointDest.x = pointOffset.x;
5820 rectInvalidated.width = pointOffset.x;
5824 rectSource.x += -pointOffset.x;
5825 rectSource.width -= -pointOffset.x;
5827 rectInvalidated.x = rectSource.width;
5828 rectInvalidated.width = -pointOffset.x;
5831 InvalidateVisibleRectToRenderTarget(&rectInvalidated);
5834 rectInvalidated = __bounds;
5835 rectInvalidated.SetPosition(0.0f, 0.0f);
5836 if (pointOffset.y > 0)
5838 rectSource.height -= pointOffset.y;
5839 pointDest.y = pointOffset.y;
5840 rectInvalidated.height = pointOffset.y;
5844 rectSource.y += -pointOffset.y;
5845 rectSource.height -= -pointOffset.y;
5847 rectInvalidated.y = rectSource.height;
5848 rectInvalidated.height = -pointOffset.y;
5851 InvalidateVisibleRectToRenderTarget(&rectInvalidated);
5854 r = pCanvasImpl->CopyEx(pointDest, *pCanvasImpl, rectSource);
5858 SysLogException(NID_UI_ANIM, r, "[%s] Can't copy area.", GetErrorMessage(r));
5859 SetChildrenTransformMatrix(xformOrg); // ???????????????????
5875 _VisualElementImpl::ConvertCoordinates(FloatPoint& point, const _VisualElementImpl* pFromElement) const
5877 if (unlikely(this == pFromElement))
5882 _VisualElementImpl* pFromRoot = null;
5887 if (likely(pFromElement))
5889 pFromRoot = pFromElement->GetRoot();
5890 SysTryReturnResult(NID_UI_ANIM, GetRoot() == pFromRoot, E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement and pFromElement is not belong to the same tree.");
5891 SysTryReturnResult(NID_UI_ANIM, pFromRoot || pFromElement->IsChildOf(*this) || IsChildOf(*pFromElement),
5892 E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement(%p) and pFromElement(%p) is not related.", this, pFromElement);
5896 pFromRoot = GetRoot();
5897 SysTryReturnResult(NID_UI_ANIM, pFromRoot, E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement is not attached to main tree.");
5900 const FloatMatrix4& toTopMatrix = (pFromElement ? pFromElement->GetMatrixToTop() : pFromRoot->GetMatrixToTop());
5901 _MatrixUtilTransform(toTopMatrix, &x, &y, &z);
5903 if (this != pFromRoot)
5905 const FloatMatrix4& fromTopMatrix = GetMatrixFromTop();
5907 SysTryReturnResult(NID_UI_ANIM, __matrixFromTopInvertible, E_INVALID_OPERATION, "The matrix for this conversion is singular which has zero determinant.");
5908 SysTryReturnResult(NID_UI_ANIM, fromTopMatrix.matrix[2][2] != 0, E_INVALID_OPERATION, "It is failed to calculate z of world-coordinate mapped x-y plane of depth==0");
5911 // We should calculate z of world-coordinate mapped x-y plane of depth==0 in VE coordinate !
5912 z = -(fromTopMatrix.matrix[0][2] * x + fromTopMatrix.matrix[1][2] * y + fromTopMatrix.matrix[3][2]) / fromTopMatrix.matrix[2][2];
5914 _MatrixUtilTransform(fromTopMatrix, &x, &y, &z);
5917 point.SetPosition(x, y); // z is omitted
5923 _VisualElementImpl::ConvertCoordinates(FloatRectangle& rectangle, const _VisualElementImpl* pFromElement) const
5925 if (unlikely(this == pFromElement))
5930 _VisualElementImpl* pFromRoot = null;
5931 float x[4] = { rectangle.x, rectangle.x + rectangle.width, rectangle.x, rectangle.x + rectangle.width };
5932 float y[4] = { rectangle.y, rectangle.y, rectangle.y + rectangle.height, rectangle.y + rectangle.height };
5933 float z[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
5935 if (likely(pFromElement))
5937 pFromRoot = pFromElement->GetRoot();
5938 SysTryReturnResult(NID_UI_ANIM, GetRoot() == pFromRoot, E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement and pFromElement is not belong to the same main tree.");
5939 SysTryReturnResult(NID_UI_ANIM, pFromRoot || pFromElement->IsChildOf(*this) || IsChildOf(*pFromElement),
5940 E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement(%p) and pFromElement(%p) is not related.", this, pFromElement);
5944 pFromRoot = GetRoot();
5945 SysTryReturnResult(NID_UI_ANIM, pFromRoot, E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement is not attached to main tree.");
5948 const FloatMatrix4& toTopMatrix = (pFromElement ? pFromElement->GetMatrixToTop() : pFromRoot->GetMatrixToTop());
5950 for (int i = 0; i < 4; i++)
5952 _MatrixUtilTransform(toTopMatrix, &x[i], &y[i], &z[i]);
5955 if (this != pFromRoot)
5957 const FloatMatrix4& fromTopMatrix = GetMatrixFromTop();
5959 SysTryReturnResult(NID_UI_ANIM, __matrixFromTopInvertible, E_INVALID_OPERATION, "The matrix for this conversion is singular which has zero determinant.");
5960 SysTryReturnResult(NID_UI_ANIM, fromTopMatrix.matrix[2][2] != 0, E_INVALID_OPERATION, "It is failed to calculate z of world-coordinate mapped x-y plane of depth==0");
5962 for (int i = 0; i < 4; i++)
5965 // We should calculate z of world-coordinate mapped x-y plane of depth==0 in VE coordinate !
5966 z[i] = -(fromTopMatrix.matrix[0][2] * x[i] + fromTopMatrix.matrix[1][2] * y[i] + fromTopMatrix.matrix[3][2]) / fromTopMatrix.matrix[2][2];
5967 _MatrixUtilTransform(fromTopMatrix, &x[i], &y[i], &z[i]);
5972 CalculateBoundingBox(x, y, rectangle);
5978 _VisualElementImpl::ConvertCoordinates(float* x, float* y, float* z, int count, const _VisualElementImpl* pFromElement) const
5980 if (unlikely(this == pFromElement) || unlikely(count <= 0))
5985 _VisualElementImpl* pFromRoot = null;
5987 if (likely(pFromElement))
5989 pFromRoot = pFromElement->GetRoot();
5990 SysTryReturnResult(NID_UI_ANIM, GetRoot() == pFromRoot, E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement and pFromElement is not belong to the same main tree.");
5991 SysTryReturnResult(NID_UI_ANIM, pFromRoot || pFromElement->IsChildOf(*this) || IsChildOf(*pFromElement),
5992 E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement(%p) and pFromElement(%p) is not related.", this, pFromElement);
5996 pFromRoot = GetRoot();
5997 SysTryReturnResult(NID_UI_ANIM, pFromRoot, E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement is not attached to main tree.");
6000 bool isUpwardConvertOnly = (pFromElement && pFromElement->IsChildOf(*this));
6001 const FloatMatrix4& toTopMatrix = (isUpwardConvertOnly ? pFromElement->CalcMatrixToBase(*this) :
6002 pFromElement ? pFromElement->GetMatrixToTop() : pFromRoot->GetMatrixToTop());
6004 for (int i = 0; i < count; i++)
6006 _MatrixUtilTransform(toTopMatrix, &x[i], &y[i], &z[i]);
6009 if (!isUpwardConvertOnly)
6011 const FloatMatrix4& fromTopMatrix = GetMatrixFromTop();
6013 SysTryReturnResult(NID_UI_ANIM, __matrixFromTopInvertible, E_INVALID_OPERATION, "The matrix for this conversion is singular which has zero determinant.");
6014 SysTryReturnResult(NID_UI_ANIM, fromTopMatrix.matrix[2][2] != 0, E_INVALID_OPERATION, "It is failed to calculate z of world-coordinate mapped x-y plane of depth==0");
6016 for (int i = 0; i < count; i++)
6019 // We should calculate z of world-coordinate mapped x-y plane of depth==0 in VE coordinate !
6020 z[i] = -(fromTopMatrix.matrix[0][2] * x[i] + fromTopMatrix.matrix[1][2] * y[i] + fromTopMatrix.matrix[3][2]) / fromTopMatrix.matrix[2][2];
6021 _MatrixUtilTransform(fromTopMatrix, &x[i], &y[i], &z[i]);
6029 _VisualElementImpl::TransformVectorFromOrigin(const Tizen::Graphics::FloatPoint3& originPoint, const _VisualElementImpl* pOriginVisualElement) const
6033 if (unlikely(this == pOriginVisualElement))
6035 return FloatPoint3(originPoint);
6038 float x = originPoint.x;
6039 float y = originPoint.y;
6040 float z = originPoint.z;
6042 _VisualElementImpl* pOriginRoot = pOriginVisualElement->GetRoot();
6044 SysTryReturn(NID_UI_ANIM, GetRoot() == pOriginRoot, FloatPoint3(), E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement and originVisualElement is not belong to the same tree.");
6045 SysTryReturn(NID_UI_ANIM, pOriginRoot || pOriginVisualElement->IsChildOf(*this) || IsChildOf(*pOriginVisualElement),
6046 FloatPoint3(), E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement(%p) and originVisualElement(%p) is not related.", this, pOriginVisualElement);
6048 const FloatMatrix4& toTopMatrix = pOriginVisualElement->GetMatrixToTop();
6049 _MatrixUtilTransform(toTopMatrix, &x, &y, &z);
6051 if (this != pOriginRoot)
6053 const FloatMatrix4& fromTopMatrix = GetMatrixFromTop();
6055 SysTryReturn(NID_UI_ANIM, __matrixFromTopInvertible, FloatPoint3(), E_INVALID_OPERATION, "The matrix for this conversion is singular which has zero determinant.");
6057 _MatrixUtilTransform(fromTopMatrix, &x, &y, &z);
6060 return FloatPoint3(x, y, z);
6064 _VisualElementImpl::CaptureI(Canvas& outputCanvas, const FloatRectangle& rectDest, _VisualElementImpl& reference, const FloatRectangle& rectRef, const FloatRectangle& clipRect, bool withChilren, int depth)
6066 _CanvasImpl* pOutput = _CanvasImpl::GetInstance(outputCanvas);
6068 SysTryReturnResult(NID_UI_ANIM, pOutput, E_INVALID_ARG, "Invalid argument(s) is used. Output canvas is invalid.");
6069 SysTryReturnResult(NID_UI_ANIM, GetRoot(), E_INVALID_STATE, "Invalid argument(s) is used. VisualElement is not attached to main tree.");
6071 FloatRectangle bounds = __bounds;//GetDrawableRect();
6076 reference.ConvertCoordinates(bounds, this);
6077 FloatRectangle drawRect = bounds;
6079 _VisualElementImpl* pRenderTarget = this->GetRenderTarget();
6080 drawRect = rectRef.GetIntersection(bounds);
6081 // drawRect = drawRect.GetIntersection(clipRect);
6083 FloatRectangle tempRect = drawRect;
6086 ConvertCoordinates(drawRect, &reference);
6090 if (!drawRect.IsEmpty())
6092 if (pRenderTarget && HAVE_SURFACE(pRenderTarget)) // If element have surface , justly draw to the canvas
6094 //Canvas* pCanvas = GetCanvasN(elementbounds);
6095 #ifdef USE_CANVAS_FOR_CAPTURE
6096 Canvas* pCanvas = GetCanvasN();
6100 bitmap.Construct(*pCanvas, Rectangle(drawRect.x, drawRect.y, drawRect.width, drawRect.height));
6101 bitmap.SetAlphaConstant((int)(pRenderTarget->GetOpacityFromRoot()*255));
6104 point.x = rectDest.x + bounds.x;
6105 point.y = rectDest.y + bounds.y;
6106 outputCanvas.DrawBitmap(point, bitmap);
6111 if (__pSharedData->pSurface)
6113 _EflVisualElementSurfaceImpl* pSurfImpl = dynamic_cast<_EflVisualElementSurfaceImpl*>(_VisualElementSurfaceImpl::GetInstance(*__pSharedData->pSurface));
6115 if(pSurfImpl && pSurfImpl->GetNativeHandle() && pSurfImpl->__isImageObject)
6118 __pSharedData->pSurface->GetBufferInfo(info);
6120 byte* pStart = (byte*)evas_object_image_data_get((Evas_Object*)pSurfImpl->GetNativeHandle(), false);
6125 _VisualElementCoordinateSystem::ConvertRectangleToPhysicalIntegral(drawRect.x, drawRect.y, drawRect.width, drawRect.height);
6128 BufferInfo copyInfo;
6129 copyInfo.bitsPerPixel = info.bitsPerPixel;
6130 copyInfo.width = drawRect.width;
6131 copyInfo.height = drawRect.height;
6132 copyInfo.pitch = (info.pitch/info.width)*copyInfo.width;
6134 byte* pCopy = new (std::nothrow) byte[copyInfo.height*(copyInfo.pitch)];
6138 //memcpy(pCopy, pStart, info.height*(info.pitch));
6140 for (int y = 0; y < copyInfo.height; y++)
6142 unsigned int* pSrc = (unsigned int*)((unsigned char*)pStart + info.pitch * (y + int(drawRect.y)) + int(drawRect.x) * 4);
6143 unsigned int* pAddr = (unsigned int*)((unsigned char*)pCopy + copyInfo.pitch * y);
6144 for (int x = 0; x < copyInfo.width; x++)
6146 int a = ((*pSrc) >> 24) & 0xff;
6147 int r = ((*pSrc) >> 16) & 0xff;
6148 int g = ((*pSrc) >> 8) & 0xff;
6149 int b = ((*pSrc) >> 0) & 0xff;
6152 float fa = (float)a / 255.0f;
6156 *pAddr = (a << 24) | (r << 16) | (g << 8) | b;
6163 _VisualElementCoordinateSystem::ConvertRectangleToLogical(drawRect.x, drawRect.y, drawRect.width, drawRect.height);
6167 result r = buffer.Construct(pCopy, 0, copyInfo.height*(copyInfo.pitch), copyInfo.height*(copyInfo.pitch));
6171 Bitmap* pBitmap = Bitmap::GetNonScaledBitmapN(buffer, Dimension(copyInfo.width, copyInfo.height), BITMAP_PIXEL_FORMAT_ARGB8888);
6174 _BitmapImpl::GetInstance(*pBitmap)->SetAsPremultiplied();
6175 pBitmap->SetAlphaConstant((int)(pRenderTarget->GetOpacityFromRoot() * 255.0f));
6177 FloatRectangle outputRect(rectDest.x + bounds.x - rectRef.x, rectDest.y + bounds.y - rectRef.y, drawRect.width, drawRect.height);
6178 FloatRectangle srcRect = outputRect;
6181 outputCanvas.DrawBitmap(outputRect, *pBitmap, srcRect);
6195 _EflNode* pNativeNode = dynamic_cast< _EflNode* >(GetNativeNode());
6197 SysTryReturnResult(NID_UI_ANIM, pNativeNode, E_INVALID_STATE, "No object for background"); // CHECKME: Default BG?
6198 _Colorf bgcolorf = pNativeNode->GetBackgroundColor();
6199 Color color(bgcolorf.Red()*255, bgcolorf.Green()*255, bgcolorf.Blue()*255, bgcolorf.Alpha()*255);
6202 point.x = rectDest.x + bounds.x - rectRef.x;
6203 point.y = rectDest.y + bounds.y - rectRef.y;
6205 //pOutput->FillRectangle(color, Rectangle(drawRect.x + bounds.x, drawRect.y + bounds.y, drawRect.width, drawRect.height));
6206 pOutput->FillRectangle(color, FloatRectangle(point.x, point.y, drawRect.width, drawRect.height));
6210 if (withChilren) // child draw
6212 _VisualElementImpl* pChild = null;
6214 FloatRectangle clipBounds = clipRect;
6216 int count = __children.GetCount();
6218 if(count > 0 && __isClipChildren)
6220 clipBounds = clipRect.GetIntersection(bounds);
6223 for (int i = 0; i < count; i++)
6225 pChild = __children.GetChildAt(i);
6226 if (unlikely(!pChild) || unlikely(!VE_VISIBLE(pChild)))
6230 pChild->CaptureI(outputCanvas, rectDest, reference, rectRef, clipBounds, true, depth + 1);
6238 _VisualElementImpl::CaptureI(Canvas& outputCanvas, const FloatRectangle& rectDest, _VisualElementImpl& reference, const FloatRectangle& clipRect, bool withChilren, int depth)
6240 _CanvasImpl* pOutput = _CanvasImpl::GetInstance(outputCanvas);
6242 SysTryReturnResult(NID_UI_ANIM, pOutput, E_INVALID_ARG, "Invalid argument(s) is used. Output canvas is invalid.");
6243 SysTryReturnResult(NID_UI_ANIM, GetRoot(), E_INVALID_STATE, "Invalid argument(s) is used. VisualElement is not attached to main tree.");
6245 FloatRectangle bounds = __bounds;//GetDrawableRect();
6250 reference.ConvertCoordinates(bounds, this);
6251 FloatRectangle drawRect = bounds;
6253 _VisualElementImpl* pRenderTarget = this->GetRenderTarget();
6254 drawRect = bounds.GetIntersection(clipRect);
6256 FloatRectangle tempRect = drawRect;
6258 drawRect.x -= bounds.x;
6259 drawRect.y -= bounds.y; //--> 0 - -20 = 20 : 20 - 20 = 0
6263 if (!drawRect.IsEmpty())
6265 if (pRenderTarget && HAVE_SURFACE(pRenderTarget)) // If element have surface , justly draw to the canvas
6267 //Canvas* pCanvas = GetCanvasN(elementbounds);
6268 #ifdef USE_CANVAS_FOR_CAPTURE
6269 Canvas* pCanvas = GetCanvasN();
6273 bitmap.Construct(*pCanvas, Rectangle(drawRect.x, drawRect.y, drawRect.width, drawRect.height));
6274 bitmap.SetAlphaConstant((int)(pRenderTarget->GetOpacityFromRoot()*255));
6277 point.x = rectDest.x + bounds.x;
6278 point.y = rectDest.y + bounds.y;
6279 outputCanvas.DrawBitmap(point, bitmap);
6283 if (__pSharedData->pSurface)
6286 _EflVisualElementSurfaceImpl* pSurfImpl = dynamic_cast<_EflVisualElementSurfaceImpl*>(_VisualElementSurfaceImpl::GetInstance(*__pSharedData->pSurface));
6288 if(pSurfImpl && pSurfImpl->GetNativeHandle() && pSurfImpl->__isImageObject)
6290 byte* pStart = (byte*)evas_object_image_data_get((Evas_Object*)pSurfImpl->GetNativeHandle(), false);
6292 __pSharedData->pSurface->GetBufferInfo(info);
6297 result r = buffer.Construct(pStart, 0, info.height*(info.pitch), info.height*(info.pitch));
6301 Bitmap* pBitmap = Bitmap::GetNonScaledBitmapN(buffer, Dimension(info.width, info.height), BITMAP_PIXEL_FORMAT_ARGB8888);
6304 _BitmapImpl::GetInstance(*pBitmap)->SetAsPremultiplied();
6305 pBitmap->SetAlphaConstant((int)(pRenderTarget->GetOpacityFromRoot() * 255.0f));
6307 FloatRectangle outputRect(rectDest.x + bounds.x, rectDest.y + bounds.y, drawRect.width, drawRect.height);
6309 _VisualElementCoordinateSystem::ConvertRectangleToPhysicalIntegral(drawRect.x, drawRect.y, drawRect.width, drawRect.height);
6310 _VisualElementCoordinateSystem::ConvertRectangleToLogical(drawRect.x, drawRect.y, drawRect.width, drawRect.height);
6312 outputCanvas.DrawBitmap(outputRect, *pBitmap, drawRect);
6324 _EflNode* pNativeNode = dynamic_cast< _EflNode* >(GetNativeNode());
6326 SysTryReturnResult(NID_UI_ANIM, pNativeNode, E_INVALID_STATE, "No object for background"); // CHECKME: Default BG?
6327 _Colorf bgcolorf = pNativeNode->GetBackgroundColor();
6328 Color color(bgcolorf.Red()*255, bgcolorf.Green()*255, bgcolorf.Blue()*255, bgcolorf.Alpha()*255);
6331 point.x = rectDest.x + bounds.x;
6332 point.y = rectDest.y + bounds.y;
6334 //pOutput->FillRectangle(color, Rectangle(drawRect.x + bounds.x, drawRect.y + bounds.y, drawRect.width, drawRect.height));
6335 pOutput->FillRectangle(color, FloatRectangle(point.x, point.y, drawRect.width, drawRect.height));
6339 if (withChilren) // child draw
6341 _VisualElementImpl* pChild = null;
6343 FloatRectangle clipBounds = clipRect;
6345 int count = __children.GetCount();
6347 if(count > 0 && __isClipChildren)
6349 clipBounds = clipRect.GetIntersection(bounds);
6352 for (int i = 0; i < count; i++)
6354 pChild = __children.GetChildAt(i);
6355 if (unlikely(!pChild) || unlikely(!VE_VISIBLE(pChild)))
6359 pChild->CaptureI(outputCanvas, rectDest, reference, clipBounds, true, depth + 1);
6367 _VisualElementImpl::Capture(Canvas& outputCanvas, const FloatRectangle& rectDest,const FloatRectangle& rectSrc, bool withChildren)
6369 FloatRectangle tempSrcRect = rectSrc;
6370 FloatRectangle tempDestRect = rectDest;
6371 // tempSrcRect.x = rectDest.x;
6372 // tempSrcRect.y = rectDest.y;
6378 tempDestRect.width -= diff;
6381 tempSrcRect.x += diff;
6382 tempSrcRect.width -= diff;
6387 tempDestRect.height -= diff;
6390 tempSrcRect.y += diff;
6391 tempSrcRect.height -= diff;
6394 FloatRectangle clipBounds = tempDestRect;
6395 clipBounds.x = tempSrcRect.x;
6396 clipBounds.y = tempSrcRect.y;
6398 clipBounds = clipBounds.GetIntersection(tempSrcRect);
6399 tempSrcRect = clipBounds;
6401 if(!VE_VISIBLE(this))
6404 return CaptureI(outputCanvas, tempDestRect, *this, tempSrcRect, clipBounds, withChildren, 0);
6408 _VisualElementImpl::Capture(Canvas& outputCanvas, const FloatRectangle& rectDest, bool withChildren)
6410 FloatRectangle tempDestRect = rectDest;
6411 tempDestRect.x = __bounds.x;
6412 tempDestRect.y = __bounds.y;
6413 FloatRectangle clipBounds = __bounds;
6415 clipBounds = tempDestRect.GetIntersection(__bounds);
6419 if(!VE_VISIBLE(this))
6422 return CaptureI(outputCanvas, rectDest, *this, clipBounds, withChildren, 0);
6424 // Rectangle cBounds = outputCanvas.GetBounds();
6425 // outputCanvas.SetForegroundColor(Color(10,110,20));
6426 // outputCanvas.DrawRectangle(Rectangle(cBounds.x+1,cBounds.y+1,cBounds.width-2,cBounds.height-2));
6427 // outputCanvas.SetForegroundColor(Color(10,20,20));
6428 // outputCanvas.DrawRectangle(Rectangle(rectDest.x+1,rectDest.y+1,rectDest.width-2,rectDest.height-2));
6429 // return E_SUCCESS;
6433 _VisualElementImpl::Capture(Canvas& outputCanvas, const FloatRectangle& rectDest, bool withChildren)
6435 result r = E_SUCCESS;
6439 rect.x = rectDest.x;
6440 rect.y = rectDest.y;
6441 rect.width = rectDest.width;
6442 rect.height = rectDest.height;
6446 Canvas* pCanvas = GetCanvasN();
6449 r = outputCanvas.Copy(Point(0,0), *pCanvas, rect);
6454 return GetLastResult();
6458 _EflNode* pNode = dynamic_cast<_EflNode*>(GetNativeNode());
6459 SysTryReturnResult(pNode, E_INVALID_STATE, "VisualElement is invalid.");
6462 r = pNode->Capture(outputCanvas, Point(0,0), rect);
6465 SysTryReturn(r == E_SUCCESS, r, r,"[%s] Propagating.", GetErrorMessage(r));
6472 _VisualElementImpl::AddAnimation(const Tizen::Base::String* pKeyName, VisualElementAnimation& animation)
6474 SysTryReturnResult(NID_UI_ANIM, !IS_PRESENTATION(this), E_INVALID_OPERATION, "This is not model.");
6476 result r = E_SUCCESS;
6478 bool isPropertyPropagationEnabled = __isPropertyPropagationEnabled;
6480 __isPropertyPropagationEnabled = false;
6482 if (dynamic_cast< VisualElementAnimationGroup* >(&animation) != null)
6484 VisualElementAnimation* pCloned = animation.CloneN();
6485 SysTryReturnResult(NID_UI_ANIM, pCloned != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
6487 r = AddAnimationGroupI(pKeyName, *pCloned);
6488 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
6497 r = AddAnimationI(pKeyName, animation);
6498 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
6501 __isPropertyPropagationEnabled = isPropertyPropagationEnabled;
6507 _VisualElementImpl::AddAnimationI(const Tizen::Base::String* pKeyName, VisualElementAnimation& animation)
6509 result r = E_SUCCESS;
6511 IVisualElementAnimationTickEventListener* pTickListener = null;
6514 VisualElementValueAnimation* pValueAnimation = dynamic_cast< VisualElementValueAnimation* >(&animation);
6515 if (pValueAnimation != null)
6517 _VisualElementValueAnimationImpl* pValueAnimationImpl = _VisualElementValueAnimationImpl::GetInstance(*pValueAnimation);
6518 SysTryReturnResult(NID_UI_ANIM, (pValueAnimationImpl->IsValid()), E_INVALID_ARG, "Invalid argument(s) is used. Animation value is invalid.");
6520 pTickListener = pValueAnimationImpl->GetTickEventListener();
6524 VisualElementAnimation* pCloned = animation.CloneN();
6525 SysTryReturnResult(NID_UI_ANIM, (pCloned != null), E_OUT_OF_MEMORY, "Memory allocation failed.");
6527 _VisualElementAnimationImpl* pAnimationImpl = _VisualElementAnimationImpl::GetInstance(*pCloned);
6529 if (pAnimationImpl->GetStatusEventListener() != null || pTickListener != null)
6531 pAnimationImpl->SetEventTarget(*GetPublic());
6534 // Use presentation tree for animation
6535 VisualElement* pPresentation = __pPresentation->__pPublicInstance;
6537 r = _AnimationManager::GetInstance()->AddAnimation(*pPresentation, pKeyName, *pCloned);
6540 SysTryLog(NID_UI_ANIM, "[%s] Failed to add animation.", GetErrorMessage(r));
6546 // Change model tree value if endValueApplied is true
6547 VisualElementPropertyAnimation* pPropertyAnimation = dynamic_cast< VisualElementPropertyAnimation* >(pCloned);
6549 if (pPropertyAnimation
6550 && pPropertyAnimation->IsEndValueApplied()
6551 && !pPropertyAnimation->IsAutoReverseEnabled()
6552 && pPropertyAnimation->GetRepeatCount() != 0)
6554 const String& propertyName = pPropertyAnimation->GetPropertyName();
6555 const Variant& endValue = pPropertyAnimation->GetEndValue();
6557 if (endValue.IsEmpty() == false && InvokeOnGetPropertyRequested(propertyName) != endValue)
6559 (void) InvokeOnSetPropertyRequested(propertyName, endValue);
6567 _VisualElementImpl::AddAnimationGroupI(const Tizen::Base::String* pKeyName, VisualElementAnimation& animation)
6569 _AnimationManager* pAnimationManager = _AnimationManager::GetInstance();
6571 // Get presentation tree
6572 VisualElement* pPresentation = __pPresentation->__pPublicInstance;
6574 VisualElementAnimationGroup* pAnimationGroup = dynamic_cast< VisualElementAnimationGroup* >(&animation);
6576 SysTryReturnResult(NID_UI_ANIM, (pAnimationGroup != null), E_INVALID_ARG, "Invalid argument(s) is used. Failed to add animation group.");
6577 SysTryReturnResult(NID_UI_ANIM, (pAnimationGroup->GetAnimationCount() > 0), E_INVALID_ARG, "Invalid argument(s) is used. Animation group has no animation.");
6579 _VisualElementAnimationGroupImpl* pAnimationGroupImpl = _VisualElementAnimationGroupImpl::GetInstance(*pAnimationGroup);
6581 if (pAnimationGroupImpl->GetStatusEventListener() != null)
6583 pAnimationGroupImpl->SetEventTarget(*GetPublic());
6586 result r = E_SUCCESS;
6588 VisualElementAnimation* pAnimation = null;
6589 Tizen::Base::String name;
6590 int animationCount = 0;
6592 int transactionID = pAnimationManager->BeginGroupTransaction(*pPresentation, pKeyName, *pAnimationGroup);
6594 r = GetLastResult();
6595 SysTryCatch(NID_UI_ANIM, (transactionID > 0), , r, "[%s] Transaction is not created.", GetErrorMessage(r));
6597 animationCount = pAnimationGroupImpl->GetAnimationCount();
6599 for (int index = 0; index < animationCount; index++)
6601 pAnimation = pAnimationGroupImpl->GetAnimation(index);
6603 if (pAnimation == null)
6608 if (dynamic_cast< VisualElementAnimationGroup* >(pAnimation) != null)
6610 r = AddAnimationGroupI(&name, *pAnimation);
6614 r = AddAnimationI(&name, *pAnimation);
6617 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] animation manager is null.", GetErrorMessage(r));
6620 pAnimationManager->CommitTransaction();
6626 if (transactionID > 0)
6628 pAnimationManager->DiscardTransaction(transactionID);
6635 _VisualElementImpl::RemoveAnimation(const Tizen::Base::String& keyName)
6637 VisualElement* pPresentation = __pPresentation->__pPublicInstance;
6639 return _AnimationManager::GetInstance()->RemoveAnimation(*pPresentation, keyName);
6643 _VisualElementImpl::RemoveAllAnimations(void)
6645 VisualElement* pPresentation = __pPresentation->__pPublicInstance;
6647 _AnimationManager::GetInstance()->RemoveAllAnimations(*pPresentation);
6652 VisualElementAnimation*
6653 _VisualElementImpl::GetAnimationN(const Tizen::Base::String& keyName) const
6655 VisualElement* pPresentation = __pPresentation->__pPublicInstance;
6659 return _AnimationManager::GetInstance()->GetAnimationN(*pPresentation, keyName);
6663 _VisualElementImpl::CheckIfAnimatable(const String& property) const
6666 // Optimize using map or other algorithms !
6670 static const wchar_t* supportedProperties[] = {
6671 VeSubPropTransformScaleXY,
6674 VePropContentOpacity,
6677 VePropChildrenTransform,
6678 VePropZPosition, // TBD:
6679 VeSubPropBoundsPosition,
6680 VeSubPropBoundsSize,
6682 VeSubPropTransformRotationX,
6683 VeSubPropTransformRotationY,
6684 VeSubPropTransformRotationZ,
6685 VeSubPropTransformRotationXY,
6686 VeSubPropTransformScaleX,
6687 VeSubPropTransformScaleY,
6688 VeSubPropTransformScaleZ,
6690 VeSubPropTransformTranslationX,
6691 VeSubPropTransformTranslationY,
6692 VeSubPropTransformTranslationZ,
6693 VeSubPropTransformTranslationXY,
6694 VeSubPropChildrenTransformRotationX,
6695 VeSubPropChildrenTransformRotationY,
6696 VeSubPropChildrenTransformRotationZ,
6697 VeSubPropChildrenTransformRotationXY,
6698 VeSubPropChildrenTransformScaleX,
6699 VeSubPropChildrenTransformScaleY,
6700 VeSubPropChildrenTransformScaleZ,
6701 VeSubPropChildrenTransformScaleXY,
6702 VeSubPropChildrenTransformTranslationX,
6703 VeSubPropChildrenTransformTranslationY,
6704 VeSubPropChildrenTransformTranslationZ,
6705 VeSubPropChildrenTransformTranslationXY
6708 static String* const* supportedProperties[] = {
6710 &pVePropContentOpacity,
6713 &pVePropChildrenTransform,
6714 &pVePropZPosition, // TBD:
6715 &pVeSubPropBoundsPosition,
6716 &pVeSubPropBoundsSize,
6718 &pVePropContentBounds,
6719 #if defined(SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION)
6720 &pVePropActionDetach,
6721 &pVePropActionAttach,
6723 &pVeSubPropTransformRotationX,
6724 &pVeSubPropTransformRotationY,
6725 &pVeSubPropTransformRotationZ,
6726 &pVeSubPropTransformRotationXY,
6727 &pVeSubPropTransformScaleX,
6728 &pVeSubPropTransformScaleY,
6729 &pVeSubPropTransformScaleZ,
6730 &pVeSubPropTransformScaleXY,
6731 &pVeSubPropTransformTranslationX,
6732 &pVeSubPropTransformTranslationY,
6733 &pVeSubPropTransformTranslationZ,
6734 &pVeSubPropTransformTranslationXY,
6735 &pVeSubPropChildrenTransformRotationX,
6736 &pVeSubPropChildrenTransformRotationY,
6737 &pVeSubPropChildrenTransformRotationZ,
6738 &pVeSubPropChildrenTransformRotationXY,
6739 &pVeSubPropChildrenTransformScaleX,
6740 &pVeSubPropChildrenTransformScaleY,
6741 &pVeSubPropChildrenTransformScaleZ,
6742 &pVeSubPropChildrenTransformScaleXY,
6743 &pVeSubPropChildrenTransformTranslationX,
6744 &pVeSubPropChildrenTransformTranslationY,
6745 &pVeSubPropChildrenTransformTranslationZ,
6746 &pVeSubPropChildrenTransformTranslationXY
6750 for (int i = 0; i < static_cast< int >(sizeof(supportedProperties) / sizeof(supportedProperties[0])); i++)
6752 //if (wcscmp(property.GetPointer(), supportedProperties[i]) == 0)
6753 if (property.GetPointer() == (*supportedProperties[i])->GetPointer() || property == **supportedProperties[i])
6762 VisualElementAnimation*
6763 _VisualElementImpl::CreateAnimationForPropertyI(const Tizen::Base::String& property)
6765 if (IS_PRESENTATION(this) || !CheckIfAnimatable(property))
6771 if (property.CompareTo(String(VePropBounds)) == 0)
6773 //ToDo: default implementation
6775 else if (property.CompareTo(String(VePropOpacity)) == 0)
6777 //ToDo: default implementation
6779 else if (property.CompareTo(String(VePropChildrenOpacity)) == 0)
6781 //ToDo: default implementation
6783 else if (property.CompareTo(String(VePropShowState)) == 0)
6785 //ToDo: default implementation
6787 else if (property.CompareTo(String(VePropTransform)) == 0)
6789 //ToDo: default implementation
6791 else if (property.CompareTo(String(VePropChildrenTransform)) == 0)
6793 //ToDo: default implementation
6795 else if (property.CompareTo(String(VePropZPosition)) == 0)
6797 //ToDo: default implementation
6802 VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
6803 SysTryReturn(NID_UI_ANIM, pAnimation != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
6805 #if defined(SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION)
6806 if (unlikely(property == *pVePropActionAttach))
6808 pAnimation->SetPropertyName(*pVePropOpacity);
6809 pAnimation->SetStartValue(Variant(0.0f));
6811 else if (unlikely(property == *pVePropActionDetach))
6813 pAnimation->SetPropertyName(*pVePropOpacity);
6814 pAnimation->SetEndValue(Variant(0.0f));
6819 _VisualElementImpl* pPresentation = GetPresentation();
6821 const Variant& curValue = pPresentation->InvokeOnGetPropertyRequested(property);
6822 result r = GetLastResult();
6823 SysTryCatch(NID_UI_ANIM, !IsFailed(r), , r, "[%s] No property for animation exists.", GetErrorMessage(r));
6825 pAnimation->SetPropertyName(property);
6826 pAnimation->SetStartValue(curValue);
6839 _VisualElementImpl::SetBoundsChangedCallback(BoundsChangedCallback pCallback, void* pData)
6841 __pBoundsChangedCallback = pCallback;
6842 __pBoundsChangedCallbackData = pData;
6846 _VisualElementImpl::SetDestroyedCallback(DestroyedCallback pCallback, void* pData)
6848 __pDestroyedCallback = pCallback;
6849 __pDestroyedCallbackData = pData;
6853 // delegate---------------------------------------------------------------------------------
6856 _VisualElementImpl::InvokeOnConstructed(void)
6858 if (__pPublicInstance)
6862 __pPublicInstance->OnConstructed();
6870 _VisualElementImpl::InvokeOnDestructing(void)
6872 if (__pPublicInstance)
6876 __pPublicInstance->OnDestructing();
6884 _VisualElementImpl::InvokeHitTest(const Tizen::Graphics::FloatPoint& point)
6886 int hitTest = _VisualElementImpl::HITTEST_NOWHERE;
6888 if (__pPublicInstance && !__isInternal)
6890 HitTestResult hitResult = HIT_TEST_NOWHERE;
6892 if (GetSharedData().pContentProvider)
6894 hitResult = GetSharedData().pContentProvider->HitTest(*__pPublicInstance, point);
6898 hitResult = __pPublicInstance->OnHitTest(point);
6901 if (hitResult == HIT_TEST_NOWHERE)
6903 hitTest = _VisualElementImpl::HITTEST_NOWHERE;
6907 hitTest = _VisualElementImpl::HITTEST_MATCH;
6912 return HitTestI(point);
6921 _VisualElementImpl::InvokePrepareDraw(void)
6925 if (__pPublicInstance)
6927 if (GetSharedData().pContentProvider)
6929 result = GetSharedData().pContentProvider->PrepareDraw(*__pPublicInstance);
6933 result = __pPublicInstance->OnPrepareDraw();
6943 _VisualElementImpl::InvokeOnDraw(Tizen::Graphics::Canvas& canvas)
6945 if (__pPublicInstance)
6947 if (GetSharedData().pContentProvider)
6949 GetSharedData().pContentProvider->DrawContent(*__pPublicInstance, canvas);
6953 __pPublicInstance->OnDraw(canvas);
6960 VisualElementAnimation*
6961 _VisualElementImpl::InvokeCreateAnimationForProperty(const Tizen::Base::String& property)
6963 VisualElementAnimation* pAnimation = null;
6965 if (__pPublicInstance)
6967 if (GetSharedData().pAnimationProvider)
6969 pAnimation = GetSharedData().pAnimationProvider->CreateAnimationForProperty(*__pPublicInstance, property);
6973 pAnimation = __pPublicInstance->OnCreateAnimationForProperty(property);
6983 _VisualElementImpl::InvokeOnChildAttaching(_VisualElementImpl& child)
6990 _VisualElementImpl::InvokeOnChildAttached(_VisualElementImpl& child)
6992 if (__pPublicInstance && !__isInternal)
6994 VisualElement* pChild = child.__pPublicInstance;
6996 if (GetSharedData().pEventListener)
6998 GetSharedData().pEventListener->OnChildAttached(*__pPublicInstance, *pChild);
7006 _VisualElementImpl::InvokeOnChildDetaching(_VisualElementImpl& child)
7013 _VisualElementImpl::InvokeOnChildDetached(_VisualElementImpl& child)
7015 if (__pPublicInstance && !__isInternal)
7017 VisualElement* pChild = child.__pPublicInstance;
7019 if (GetSharedData().pEventListener)
7021 GetSharedData().pEventListener->OnChildDetached(*__pPublicInstance, *pChild);
7029 _VisualElementImpl::InvokeOnAttaching(_VisualElementImpl& parent)
7036 _VisualElementImpl::InvokeOnAttached(void)
7038 if (__pPublicInstance && !__isInternal)
7040 _VisualElementImpl* pParentInternal = GetParent();
7041 if (pParentInternal)
7043 VisualElement* pParent = pParentInternal->__pPublicInstance;
7045 if (GetSharedData().pEventListener)
7047 __isAllowedTreeModification = false;
7048 GetSharedData().pEventListener->OnAttached(*__pPublicInstance, *pParent);
7049 __isAllowedTreeModification = true;
7058 _VisualElementImpl::InvokeOnDetaching(void)
7065 _VisualElementImpl::InvokeOnDetached(_VisualElementImpl& parent)
7067 if (__pPublicInstance && !__isInternal)
7069 VisualElement* pParent = parent.__pPublicInstance;
7071 if (GetSharedData().pEventListener)
7073 __isAllowedTreeModification = false;
7074 GetSharedData().pEventListener->OnDetached(*__pPublicInstance, *pParent);
7075 __isAllowedTreeModification = true;
7081 _VisualElementImpl::InvokeOnAnimationAdded(const VisualElementAnimation* pAnimation)
7083 //TODO: Implementation
7089 _VisualElementImpl::InvokeOnAnimationRemoved(const VisualElementAnimation* pAnimation)
7091 //TODO: Implementation
7097 _VisualElementImpl::InvokeOnShowStateChanged(bool showState)
7099 if (__pPublicInstance && !__isInternal)
7101 if (GetSharedData().pEventListener)
7103 GetSharedData().pEventListener->OnShowStateChanged(*__pPublicInstance, showState);
7111 _VisualElementImpl::InvokeOnTransformMatrixChanging(FloatMatrix4& newTransform)
7113 if (__pPublicInstance && !__isInternal)
7115 if (GetSharedData().pEventListener)
7117 return GetSharedData().pEventListener->OnTransformChanging(*__pPublicInstance, newTransform);
7123 return E_INVALID_STATE;
7127 _VisualElementImpl::InvokeOnTransformMatrixChanged(const FloatMatrix4& oldTransform)
7129 if (__pPublicInstance && !__isInternal)
7131 if (GetSharedData().pEventListener)
7133 GetSharedData().pEventListener->OnTransformChanged(*__pPublicInstance, oldTransform);
7141 _VisualElementImpl::InvokeOnChildrenTransformMatrixChanging(FloatMatrix4& newTransform)
7143 if (__pPublicInstance && !__isInternal)
7145 if (GetSharedData().pEventListener)
7147 return GetSharedData().pEventListener->OnChildrenTransformChanging(*__pPublicInstance, newTransform);
7153 return E_INVALID_STATE;
7157 _VisualElementImpl::InvokeOnChildrenTransformMatrixChanged(const FloatMatrix4& oldTransform)
7159 if (__pPublicInstance && !__isInternal)
7161 if (GetSharedData().pEventListener)
7163 GetSharedData().pEventListener->OnChildrenTransformChanged(*__pPublicInstance, oldTransform);
7171 _VisualElementImpl::InvokeOnBoundsChanging(FloatRectangle& newBounds)
7173 if (__pPublicInstance && !__isInternal)
7175 if (GetSharedData().pEventListener)
7177 return GetSharedData().pEventListener->OnBoundsChanging(*__pPublicInstance, newBounds);
7183 return E_INVALID_STATE;
7187 _VisualElementImpl::InvokeOnBoundsChanged(const FloatRectangle& oldBounds)
7189 if (__pPublicInstance && !__isInternal)
7191 if (GetSharedData().pEventListener)
7193 GetSharedData().pEventListener->OnBoundsChanged(*__pPublicInstance, oldBounds);