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_EflLayer.h"
63 #include "FUiAnim_VisualElementSurfaceImpl.h"
64 #include "FUiAnim_EflVisualElementSurfaceImpl.h"
65 #include "FUiAnim_DisplayManager.h"
69 using namespace Tizen::Base;
70 using namespace Tizen::Base::Collection;
71 using namespace Tizen::Graphics;
72 using namespace Tizen::Ui;
74 #define LAZY_EVALUATION // lazy updating and reconfiguring.
75 #define IMPLICIT_ANIMATION_IMPL //prototyping implicit animation.
76 //#define MANUAL_PROPERTY_CHANGE_NOTIFICATION
78 #define IS_INTERNAL_CLASS(_PUBLIC) (likely(typeid(*(_PUBLIC)) == VeTypeId) || likely(typeid(*(_PUBLIC)) == internalVeTypeId) || likely(typeid(*(_PUBLIC)) == controlVeTypeId) || likely(typeid(*(_PUBLIC)) == rootVeTypeId))
79 #define IS_NEEDED_UPDATE_PRESENTATION(__MODEL) (((__MODEL)->__isPropertyPropagationEnabled) && ((__MODEL)->__pPresentation))
82 static const char* STR_ERROR_INVALID_VARIANT_ARG_TYPE = "[E_INVALID_ARG] Invalid argument(s) is used. Variant type is invalid.";
85 CalculateBoundingBox(const float x[4], const float y[4], Tizen::Graphics::FloatRectangle& rectangle)
91 for (int i = 1; i < 4; i++)
108 rectangle.width = maxX - minX;
109 rectangle.height = maxY - minY;
115 namespace Tizen { namespace Ui { namespace Animations
117 // rules of visual element.
119 // 1. almost controlling pSharedData occurred in the PRESENTATION layer.
120 // 2. almost Delegate's methods occurred in the MODEL layer.
123 #define SHOWOPACITY_VISIBLE(so) \
126 #define VE_VISIBLE(o) \
127 SHOWOPACITY_VISIBLE((o)->__showOpacity)
129 #define HAVE_SURFACE(o) \
130 (likely((o)->GetSharedData().pSurface))
132 //TODO: require further examination : __NeedSurface() instead of NEED_SURFACE() macro
133 #define NEED_SURFACE(o) \
134 (likely((o)->GetSharedData().needSurface))
136 #define IS_ATTACHED(o) \
137 ((o)->GetRoot() != null)
139 #define IS_PRESENTATION(o) \
140 ((o)->__pPresentation == (o))
142 #define IS_MODEL(o) \
143 ((o)->__pModel == (o))
145 #define VE_DELEGATE(target, func, ...) \
146 (target)->func(__VA_ARGS__)
150 static const std::type_info& VeTypeId = typeid(VisualElement);
151 static const std::type_info& rootVeTypeId = typeid(_RootVisualElement);
152 static const std::type_info& internalVeTypeId = typeid(_VisualElement);
153 static const std::type_info& controlVeTypeId = typeid(_ControlVisualElement);
155 // declared AnimationEventListener for implicit animation
156 class _VisualElementImplicitAnimationEventListener
157 : public IVisualElementAnimationStatusEventListener
158 , virtual public Tizen::Base::Runtime::IEventListener
161 _VisualElementImplicitAnimationEventListener(void) {}
162 virtual ~_VisualElementImplicitAnimationEventListener(void) {}
164 virtual void OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target) {}
165 virtual void OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount) {}
166 virtual void OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally)
173 IMPLEMENT_PROPERTY(_VisualElementImpl);
175 _VisualElementImpl::_VisualElementImpl(VisualElement& element)
176 : _zOrderGroup(Z_ORDER_GROUP_NORMAL)
177 , __pSharedData(null)
180 , __pPresentation(null)
184 , __showOpacity(0.0f)
185 , __needRecreateSurface(false)
186 , __bounds(0.0f, 0.0f, 0.0f, 0.0f)
187 , __alignedSize(0.0f, 0.0f)
188 , __contentBounds(0.0f, 0.0f, 1.0f, 1.0f)
189 , __useContentBounds(false)
191 , __contentOpacity(1.0f)
193 , __anchor(0.5f, 0.5f)
196 , __decomposedTransform()
197 , __childrenTransform()
198 , __decomposedChildrenTransform()
199 , __childrenNeedsUpdateProps(HIERARCHY_PROPERTY_MASK)
200 , __invalidatedProps(HIERARCHY_PROPERTY_MASK)
201 , __matrixFromTopValid(false)
202 , __matrixFromTopInvertible(true)
203 , __matrixToSuperValid(false)
204 , __matrixToTopValid(false)
205 , __matrixToClipSourceValid(false)
206 , __boundingBoxValid(false)
207 , __visibleRectValid(false)
208 , __needTransform(false)
209 , __needClipForUntransformed(false)
210 , __isImplicitAnimationEnabled(true)
211 , __isClipChildren(false)
212 , __boundingBox(0.0f, 0.0f, 0.0f, 0.0f)
213 , __pClipSource(null)
214 , __visibleRect(0.0f, 0.0f, 0.0f, 0.0f)
215 , __isPropertyPropagationEnabled(true)
216 , __isDestroying(false)
217 , __isHidingParent(false)
218 , __isInternal(false)
219 , __isAllowedTreeModification(true)
220 , __pPublicInstance(&element)
222 , __renderOperation(VisualElement::RENDER_OPERATION_BLEND)
223 , __pBoundsChangedCallback(null)
224 , __pBoundsChangedCallbackData(null)
225 , __pDestroyedCallback(null)
226 , __pDestroyedCallbackData(null)
230 __children.Construct();
233 _VisualElementImpl::_VisualElementImpl(VisualElement& presentation, _VisualElementImpl& modelImpl)
234 : _zOrderGroup(modelImpl._zOrderGroup)
235 , __pSharedData(null)
238 , __pPresentation(null)
240 , __isRoot(modelImpl.__isRoot)
241 , __isVisible(modelImpl.__isVisible)
242 , __showOpacity(modelImpl.__showOpacity)
243 , __needRecreateSurface(false)
244 , __bounds(modelImpl.__bounds)
245 , __alignedSize(modelImpl.__alignedSize)
246 , __contentBounds(modelImpl.__contentBounds)
247 , __useContentBounds(modelImpl.__useContentBounds)
248 , __zPosition(modelImpl.__zPosition)
249 , __contentOpacity(modelImpl.__contentOpacity)
250 , __opacity(modelImpl.__opacity)
251 , __anchor(modelImpl.__anchor)
252 , __anchorZ(modelImpl.__anchorZ)
253 , __transform(modelImpl.__transform)
254 , __decomposedTransform(modelImpl.__decomposedTransform)
255 , __childrenTransform(modelImpl.__childrenTransform)
256 , __decomposedChildrenTransform(modelImpl.__decomposedChildrenTransform)
257 , __childrenNeedsUpdateProps(HIERARCHY_PROPERTY_MASK)
258 , __invalidatedProps(HIERARCHY_PROPERTY_MASK)
259 , __matrixFromTopValid(false)
260 , __matrixFromTopInvertible(true)
261 , __matrixToSuperValid(false)
262 , __matrixToTopValid(false)
263 , __matrixToClipSourceValid(false)
264 , __boundingBoxValid(false)
265 , __visibleRectValid(false)
266 , __needTransform(modelImpl.__needTransform)
267 , __needClipForUntransformed(modelImpl.__needClipForUntransformed)
268 , __isImplicitAnimationEnabled(modelImpl.__isImplicitAnimationEnabled)
269 , __isClipChildren(modelImpl.__isClipChildren)
270 , __boundingBox(0.0f, 0.0f, 0.0f, 0.0f)
271 , __pClipSource(null)
272 , __visibleRect(0.0f, 0.0f, 0.0f, 0.0f)
273 , __isPropertyPropagationEnabled(false) // it differs from the property of MODEL object
274 , __isDestroying(false)
275 , __isHidingParent(modelImpl.__isHidingParent)
276 , __isInternal(modelImpl.__isInternal)
277 , __isAllowedTreeModification(true)
278 , __pPublicInstance(&presentation)
279 , __imageFilePath(modelImpl.__imageFilePath)
280 , __renderOperation(modelImpl.__renderOperation)
281 , __pBoundsChangedCallback(modelImpl.__pBoundsChangedCallback)
282 , __pBoundsChangedCallbackData(modelImpl.__pBoundsChangedCallbackData)
283 , __pDestroyedCallback(modelImpl.__pDestroyedCallback)
284 , __pDestroyedCallbackData(modelImpl.__pDestroyedCallbackData)
288 __children.Construct();
291 _VisualElementImpl::~_VisualElementImpl(void)
294 // clear data after detaching children
295 if (likely(__pSharedData))
297 __pSharedData->Release();
298 __pSharedData = null;
301 // remove public instance
302 __pPublicInstance = null;
304 if (__pDestroyedCallback != null)
306 __pDestroyedCallback(__pDestroyedCallbackData);
311 _VisualElementImpl::Destroy(void)
313 //SysLog(NID_UI_ANIM, "destruct[%x]-->begin", this);
315 if (unlikely(__isDestroying))
320 __isDestroying = true;
324 // Destroy and its callback will be called from the leaf of hiearchy tree first.
325 // That is, this method first destroys children(Destroy and OnDestructing), and it destroys itself later.
327 while (__children.GetCount() > 0)
329 _VisualElementImpl* pChild = __children.GetChildAt(0);
332 //pChild->RemoveFromParent();
334 if (likely(pChild->__pPublicInstance))
336 pChild->__pPublicInstance->Destroy();
340 SysAssertf(false, "VisualElement does not have public instance.");
346 SysAssertf(false, "VisualElement has no child.");
353 // Is this right place for invoking 'OnDestructing' ?
354 // OnConstructed will be called from public instance.
356 if (!IS_PRESENTATION(this))
358 VE_DELEGATE(this, InvokeOnDestructing);
367 if (likely(__pPresentation))
369 __pPresentation->__pPublicInstance->Destroy();
371 __pPresentation = null;
375 _AnimationManager* pManager = _AnimationManager::GetInstance();
378 pManager->RemoveAllAnimations(*__pPublicInstance);
388 _VisualElementImpl::Construct(void)
390 result r = E_SUCCESS;
391 __pSharedData = new (std::nothrow) _VisualElementSharedData;
392 SysTryCatch(NID_UI_ANIM, __pSharedData, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
393 SysTryCatch(NID_UI_ANIM, GetSharedData().Construct() == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] failed in shared data constructing.");
396 __pPresentation = null;
397 //SysLog(NID_UI_ANIM, "Created(efl=%p)", GetSharedData().pNativeNode);
399 #if 0 // REMOVED : We should invoke property observer method manually.
400 if (__isPropertyPropagationEnabled)
402 AddPropertyChangeEventListener(_VisualElementModelObserver::GetInstance());
406 //VE_DELEGATE(this, InvokeOnConstructed);
412 if (likely(__pSharedData))
414 GetSharedData().Release();
415 __pSharedData = null;
421 IVisualElementAnimationProvider*
422 _VisualElementImpl::GetAnimationProvider(void) const
425 SysTryReturn(NID_UI_ANIM, IS_MODEL(this), null, E_INVALID_OPERATION, "[E_INVALID_OPERATION] VisualElement is not Model object.");
427 return GetSharedData().pAnimationProvider;
431 _VisualElementImpl::SetAnimationProvider(IVisualElementAnimationProvider* pProvider)
433 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
435 GetSharedData().pAnimationProvider = pProvider;
440 IVisualElementContentProvider*
441 _VisualElementImpl::GetContentProvider(void) const
444 SysTryReturn(NID_UI_ANIM, IS_MODEL(this), null, E_INVALID_OPERATION, "[E_INVALID_OPERATION] VisualElement is not Model object.");
446 return GetSharedData().pContentProvider;
450 _VisualElementImpl::SetContentProvider(IVisualElementContentProvider* pProvider)
452 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
454 GetSharedData().pContentProvider = pProvider;
459 IVisualElementEventListener*
460 _VisualElementImpl::GetVisualElementEventListener(void) const
463 SysTryReturn(NID_UI_ANIM, IS_MODEL(this), null, E_INVALID_OPERATION, "[E_INVALID_OPERATION] VisualElement is not Model object.");
465 return GetSharedData().pEventListener;
469 _VisualElementImpl::SetVisualElementEventListener(IVisualElementEventListener* pListener)
471 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
473 GetSharedData().pEventListener = pListener;
479 _VisualElementImpl::FlushI(void)
481 #ifdef VE_VSYNC_UPDATE
482 _DisplayManager::GetInstance()->RenderAll();
485 return _DisplayManager::GetInstance()->Flush();
489 _VisualElementImpl::CreateImplicitAnimationIfNeeded( const String& property,
490 const Variant& newValue, const Variant& currentPresentationValue, const String** pSubProperties)
494 _AnimationManager* pAnimationManager = _AnimationManager::GetInstance();
496 if (likely(GetRoot())
497 && likely(GetSharedData().needSurface)
498 && (unlikely(pAnimationManager->IsImplicitAnimationEnabled() && __isImplicitAnimationEnabled)) )
501 // For performance, following must be done only when oldValue != newValue.
502 VisualElementAnimation* pAnimation = InvokeCreateAnimationForProperty(property);
504 // user can make other type animation like aAnimationGroup or ValueAnimation
505 // in this case pPropertyAnimation will have a null value.
506 VisualElementPropertyAnimation* pPropertyAnimation = dynamic_cast< VisualElementPropertyAnimation* >(pAnimation);
507 if (likely(pPropertyAnimation))
509 if (pPropertyAnimation->GetEndValue().IsEmpty())
511 pPropertyAnimation->SetEndValue(newValue);
514 if (pPropertyAnimation->GetStartValue().IsEmpty())
516 pPropertyAnimation->SetStartValue(currentPresentationValue);
521 { // remove sub property
522 for(int i = 0 ; pSubProperties[i] != NULL ; i++)
524 pAnimationManager->RemoveAnimationByProperty(*__pPublicInstance, *pSubProperties[i]);
527 if (unlikely(pAnimation))
530 // Adding property animation causes previous animation for same property to be removed in Animation Manager.
531 if (unlikely(IsFailed(AddAnimation(null, *pAnimation))))
533 pAnimationManager->RemoveAnimationByProperty(*__pPresentation->__pPublicInstance, property);
542 // Remove previous animation even when trying to change the property without animation.
543 pAnimationManager->RemoveAnimationByProperty(*__pPresentation->__pPublicInstance, property);
549 pAnimationManager->RemoveAnimationByProperty(*__pPresentation->__pPublicInstance, property);
557 _VisualElementImpl::SetRenderOperation(VisualElement::RenderOperation renderOperation)
559 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
561 result r = InvokeOnSetPropertyRequested(*pVePropRenderOperation, Variant(static_cast< int >(renderOperation)));
562 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
567 VisualElement::RenderOperation
568 _VisualElementImpl::GetRenderOperation(void) const
573 int renderOperation = InvokeOnGetPropertyRequested(*pVePropRenderOperation).ToInt();
574 if (GetLastResult() != E_SUCCESS)
576 return VisualElement::RENDER_OPERATION_BLEND;
579 return static_cast< VisualElement::RenderOperation >(renderOperation);
581 return __renderOperation;
586 _VisualElementImpl::GetRenderOperationProperty(void) const
590 return Variant(static_cast< int >(__renderOperation));
594 _VisualElementImpl::SetRenderOperationProperty(const Variant& v)
596 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_INT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
598 VisualElement::RenderOperation renderOperation = static_cast< VisualElement::RenderOperation >(v.ToInt());
599 if (likely(__renderOperation != renderOperation))
603 renderOperation >= VisualElement::RENDER_OPERATION_BLEND && renderOperation <= VisualElement::RENDER_OPERATION_COPY,
605 "Invalid argument(s) is used. The given render operation is out of range."
608 __renderOperation = renderOperation;
609 InvalidateHierarchyProps(HIERARCHY_PROPERTY_OPACITY, false, false);
611 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
613 __pPresentation->SetRenderOperationProperty(__renderOperation);
620 _VisualElementImpl::GetBackBufferEnabled(void) const
624 return GetSharedData().needSurface;
628 _VisualElementImpl::SetBackBufferEnabled(bool enabled)
630 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
632 if (likely(GetSharedData().needSurface != enabled))
635 // Need to check transform matrix if the transform matrix is complex(generic). In this case, disabling Backing-Buffer
636 // should not be allowed !
638 if (likely(NEED_SURFACE(this))) // may be redundant checking.... (or using !enabled). Check if this needs surface currently.
641 // __transform.Optimize();
642 // SysTryReturnResult(NID_UI_ANIM, !__transform.IsGeneric(), E_INVALID_STATE, "VisualElement cannot release back-buffer if transform isn't identity or translation.");
644 Matrix4Type matrixType = _GetMatrix4Type(__transform);
647 matrixType == MATRIX4_Identity || matrixType == MATRIX4_Translation,
649 "VisualElement cannot release back-buffer if transform isn't identity nor translation."
653 GetSharedData().needSurface = enabled;
655 if (NEED_SURFACE(this))
657 ExposeRectangle(null, true);
661 InvalidateVisibleRectToRenderTarget(null);
671 _VisualElementImpl::GetRedrawOnResizeEnabled(void) const
675 return GetSharedData().redrawOnResize;
679 _VisualElementImpl::SetRedrawOnResizeEnabled(bool enabled)
681 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
683 GetSharedData().redrawOnResize = enabled;
689 _VisualElementImpl::GetPropertyPropagationEnabled(void) const
693 // TBD: forward using property or direct return ?
695 bool isPropertyPropagationEnabled = InvokeOnGetPropertyRequested(*pVePropPropertyPropagationEnabled).ToBool();
696 if (GetLastResult() != E_SUCCESS)
701 return isPropertyPropagationEnabled;
703 return __isPropertyPropagationEnabled;
708 _VisualElementImpl::SetPropertyPropagationEnabledI(bool enable)
710 if (unlikely(enable == __isPropertyPropagationEnabled))
715 __isPropertyPropagationEnabled = enable;
717 // if (IS_MODEL(this))
719 // if (__isPropertyPropagationEnabled)
721 // AddPropertyChangeEventListener(_VisualElementModelObserver::GetInstance());
725 // RemovePropertyChangeEventListener(_VisualElementModelObserver::GetInstance());
733 _VisualElementImpl::SetPropertyPropagationEnabled(bool enable)
735 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
736 if (enable == __isPropertyPropagationEnabled)
739 result r = InvokeOnSetPropertyRequested(*pVePropPropertyPropagationEnabled, Variant(enable));
740 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
746 _VisualElementImpl::GetPropertyPropagationProperty(void) const
750 return Variant(__isPropertyPropagationEnabled);
754 _VisualElementImpl::SetPropertyPropagationProperty(const Variant& v)
757 // Remove this from property. It is used as a property because of _ControlVisualElement when a control was made up of three VEs.
758 if (IS_PRESENTATION(this))
761 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
763 return SetPropertyPropagationEnabledI(v.ToBool());
767 _VisualElementImpl::IsSurfaceNeeded(void) const
769 // TBD: root VE must have surface always...
770 if (unlikely(!__pParent))
776 const _VisualElementImpl* pCurrent;
781 if (!pCurrent->__pSharedData)
786 if (!pCurrent->GetSharedData().needSurface)
791 pCurrent = pCurrent->__pParent;
796 return GetSharedData().needSurface;
801 _VisualElementImpl::RebuildSurfaces(void)
803 if (unlikely(!IS_PRESENTATION(this)) || unlikely(!IS_ATTACHED(this)))
808 ResetSurfaceIfNeeded();
810 int count = __children.GetCount();
811 for (int i = 0; i < count; i++)
813 __children.GetChildAt(i)->RebuildSurfaces();
818 _VisualElementImpl::ResetSurfaceIfNeeded(void)
820 if (unlikely(!__needRecreateSurface))
825 __needRecreateSurface = false;
827 if (unlikely(HAVE_SURFACE(this)) && unlikely(GetSharedData().fixedSurfaceSize))
833 _VisualElementImpl* pPresentation = null;
835 if (likely(__pPresentation))
837 pPresentation = __pPresentation;
841 pPresentation = this;
844 if (likely(IsSurfaceNeeded()))
848 _RootVisualElement* pRoot = dynamic_cast<_RootVisualElement*>(GetRoot()->GetPublic());
850 if (pRoot && pRoot->GetNativeLayer())
852 GetSharedData().fixedSurfaceSize = false;
854 float surfaceWidth = __bounds.width;
855 float surfaceHeight = __bounds.height;
857 if (likely(GetSharedData().CreateSurface(FloatDimension(surfaceWidth, surfaceHeight), *pRoot->GetNativeLayer()) == E_SUCCESS))
859 if (unlikely(!HAVE_SURFACE(this)))
861 pPresentation->InvalidateVisibleRectToRenderTarget(null);
869 else // surface not needed, so remove Surface
871 if (unlikely(HAVE_SURFACE(this)))
873 GetSharedData().RemoveSurface(*pPresentation);
880 _VisualElementImpl::GetRenderTarget(void) const
882 _VisualElementImpl* pRenderTarget = const_cast< _VisualElementImpl* >(this);
884 while (likely(pRenderTarget))
886 if (likely(NEED_SURFACE(pRenderTarget)))
888 return pRenderTarget;
891 pRenderTarget = pRenderTarget->__pParent;
897 VisualElementSurface*
898 _VisualElementImpl::GetSurfaceN(void) const
900 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
901 pThis->RebuildHierarchyProps(0, true, true);
903 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.");
905 VisualElementSurface* pSurface = new (std::nothrow) VisualElementSurface(*pThis->GetSharedData().pSurface);
906 SysTryReturn(NID_UI_ANIM, pSurface, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
914 _VisualElementImpl::SetSurface(const VisualElementSurface* pSurface)
916 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
917 SysTryReturnResult(NID_UI_ANIM, NEED_SURFACE(this), E_INVALID_OPERATION, "A surface cannot be set if VisualElement need no back-buffer.");
919 if (unlikely(pSurface == GetSharedData().pSurface))
924 if (likely(pSurface) && likely(GetSharedData().pSurface))
926 if (unlikely(pSurface->Equals(*GetSharedData().pSurface)))
930 if (likely(pSurface))
932 unique_ptr<VisualElementSurface> pTempSurface(new (std::nothrow) VisualElementSurface(*pSurface));
933 SysTryReturnResult(NID_UI_ANIM, pTempSurface, E_OUT_OF_MEMORY, "Memory allocation failed.");
935 // Delete the old surface
936 if (GetSharedData().pSurface)
938 delete GetSharedData().pSurface;
941 GetSharedData().pSurface = pTempSurface.release();
942 GetSharedData().fixedSurfaceSize = true;
944 // Clear invalidated region if newly fixed-size surface is attached which do not need(inhibit) redrawing
945 GetSharedData().invalidatedRegion.SetBounds(0.0f, 0.0f, __bounds.width, __bounds.height);
949 // Delete the old surface
950 if (GetSharedData().pSurface)
952 delete GetSharedData().pSurface;
955 __needRecreateSurface = true;
957 GetSharedData().pSurface = null;
958 GetSharedData().fixedSurfaceSize = false;
960 // Fully invalidate because new surface should be allocated and redrawn
961 GetSharedData().invalidatedRegion.SetBounds(0.0f, 0.0f, __bounds.width, __bounds.height);
971 _VisualElementImpl::SetImageSource(const String& filePath)
973 result r = E_SUCCESS;
975 // Delete the old surface
976 if (GetSharedData().pSurface)
978 delete GetSharedData().pSurface;
981 __needRecreateSurface = true;
983 GetSharedData().pSurface = null;
984 GetSharedData().fixedSurfaceSize = false;
986 // Fully invalidate because new surface should be allocated and redrawn
987 GetSharedData().invalidatedRegion.SetBounds(0.0f, 0.0f, __bounds.width, __bounds.height);
990 RebuildHierarchyProps(0, true, true);
992 SysTryReturnResult(NID_UI_ANIM, HAVE_SURFACE(this), E_SYSTEM, "Realizing back-buffer surface failed.");
994 if (!filePath.IsEmpty())
996 r = GetSharedData().SetImage(filePath);
997 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1000 __imageFilePath = filePath;
1006 _VisualElementImpl::SetSurfaceChanged(void)
1008 GetSharedData().surfaceChanged = true;
1010 if (likely(!IS_PRESENTATION(this)))
1014 _VisualElementImpl* pElement = __pPresentation;
1017 pElement->GetSharedData().childrenSurfaceChanged = true;
1018 pElement = pElement->__pParent;
1024 _VisualElementImpl* pElement = this;
1027 pElement->GetSharedData().childrenSurfaceChanged = true;
1028 pElement = pElement->__pParent;
1034 _VisualElementImpl::SetContentBoundsI(const FloatRectangle& contentBounds)
1036 // const Dimension& surfaceSize = GetSharedData().pSurface->GetSize();
1037 // SysTryReturn(NID_UI_ANIM,
1038 // contentBounds.x >= 0 && contentBounds.y >= 0 && contentBounds.width >= 0 && contentBounds.height >= 0 &&
1039 // contentBounds.x + contentBounds.width <= surfaceSize.width && contentBounds.y + contentBounds.height <= surfaceSize.height,
1042 // "[E_INVALID_ARG] Invalid content bounds.(%f,%f,%f,%f)", contentBounds.x, contentBounds.y, contentBounds.width, contentBounds.height
1045 if (unlikely(RectUtilIsEqual(__contentBounds, contentBounds)))
1048 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.");
1050 __contentBounds = contentBounds;
1051 __useContentBounds = (__contentBounds.x != 0.0f || __contentBounds.y != 0.0f || __contentBounds.width != 1.0f || __contentBounds.height != 1.0f);
1053 InvalidateHierarchyProps(HIERARCHY_PROPERTY_CONTENTBOUNDS, false, false);
1055 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1057 FloatRectangle currentValue = __pPresentation->__contentBounds;
1059 if(CreateImplicitAnimationIfNeeded(*pVePropContentBounds, __contentBounds, currentValue, NULL) == false)
1061 __pPresentation->SetContentBoundsProperty(__contentBounds);
1069 _VisualElementImpl::SetContentBounds(const FloatRectangle& contentBounds)
1071 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1072 result r = InvokeOnSetPropertyRequested(*pVePropContentBounds, Variant(contentBounds));
1073 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1079 _VisualElementImpl::GetContentBounds(void) const
1083 return __contentBounds;
1087 _VisualElementImpl::GetContentBoundsProperty(void) const
1091 return Variant(__contentBounds);
1095 _VisualElementImpl::SetContentBoundsProperty(const Variant& v)
1097 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_RECTANGLE, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1099 return SetContentBoundsI(v.ToFloatRectangle());
1104 _VisualElementImpl::GetImplicitAnimationEnabled(void) const
1108 return __isImplicitAnimationEnabled;
1112 _VisualElementImpl::SetImplicitAnimationEnabled(bool enable)
1114 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1115 result r = InvokeOnSetPropertyRequested(*pVePropImplicitAnimationEnabled, Variant(enable));
1116 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1122 _VisualElementImpl::GetImplicitAnimationProperty(void) const
1126 return Variant(__isImplicitAnimationEnabled);
1130 _VisualElementImpl::SetImplicitAnimationProperty(const Variant& v)
1132 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1134 bool isImplicitAnimationEnabled = v.ToBool();
1135 if (isImplicitAnimationEnabled != __isImplicitAnimationEnabled)
1137 __isImplicitAnimationEnabled = isImplicitAnimationEnabled;
1139 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1141 __pPresentation->SetImplicitAnimationProperty(__isImplicitAnimationEnabled);
1148 _VisualElementImpl::GetBoundingBox(void) const
1152 return GetBoundingBoxI();
1156 _VisualElementImpl::GetBounds(void) const
1164 _VisualElementImpl::SetBoundsI(const FloatRectangle& bounds)
1166 _Rectanglef boundsAdjusted(bounds);
1167 FloatRectangle oldValue(__bounds);
1169 result r = E_SUCCESS;
1170 bool sizeChanged = false;
1172 if (unlikely(GetSharedData().pEventListener != null))
1174 if (IS_MODEL(this)) // CHECKME: checking need??
1176 FloatRectangle tmpBounds(bounds);
1177 r = VE_DELEGATE(this, InvokeOnBoundsChanging, tmpBounds);
1179 boundsAdjusted = tmpBounds;
1183 if (likely(boundsAdjusted != __bounds))
1185 float newWidth = boundsAdjusted.Width();
1186 if (unlikely(newWidth < 0.0f))
1191 float newHeight = boundsAdjusted.Height();
1192 if (unlikely(newHeight < 0.0f))
1197 if (unlikely(newWidth != __bounds.width) || unlikely(newHeight != __bounds.height))
1202 // Adjust logical bounds(size) to sync. with that of surface(physical)
1204 float alignedWidth = newWidth;
1205 float alignedHeight = newHeight;
1207 __needRecreateSurface = true;
1209 _VisualElementCoordinateSystem::ConvertDimensionToPhysicalIntegral(alignedWidth, alignedHeight);
1211 if (likely(GetSharedData().pSurface))
1213 FloatDimension surfaceSize(GetSharedData().pSurface->GetSizeF());
1215 _VisualElementCoordinateSystem::ConvertDimensionToPhysicalIntegral(surfaceSize.width, surfaceSize.height);
1216 if (likely(alignedWidth == surfaceSize.width) && likely(alignedHeight == surfaceSize.height))
1218 __needRecreateSurface = false;
1222 _VisualElementCoordinateSystem::ConvertDimensionToLogical(alignedWidth, alignedHeight);
1224 if (newWidth > 0.0f && alignedWidth == 0.0f)
1226 _VisualElementCoordinateSystem::MakeLogicalWidthForPhysicalOne(alignedWidth);
1229 if (newHeight > 0.0f && alignedHeight == 0.0f)
1231 _VisualElementCoordinateSystem::MakeLogicalHeightForPhysicalOne(alignedHeight);
1234 __alignedSize.width = alignedWidth;
1235 __alignedSize.height = alignedHeight;
1238 // TODO: Need to optimize dirty rectangle.
1240 // invalidate with previous bounds
1241 if (unlikely(!NEED_SURFACE(this)))
1242 InvalidateVisibleRectToRenderTarget(null);
1244 __bounds.x = boundsAdjusted.Left();
1245 __bounds.y = boundsAdjusted.Top();
1246 __bounds.width = newWidth;
1247 __bounds.height = newHeight;
1249 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false);
1251 // TBD: Recreating surface may have to be done in presentation layer (thread!)
1254 // Even when 'no redrawOnResize', it is needed to invalidate for redrawing if surface is not created yet.
1256 if (unlikely(sizeChanged))
1258 if (unlikely(!NEED_SURFACE(this)) || unlikely(GetSharedData().redrawOnResize))
1259 ExposeRectangle(null, true);
1262 // Shrink invalidated region to bounds
1263 RectUtilIntersect(GetSharedData().invalidatedRegion, FloatRectangle(0.0f, 0.0f, __bounds.width, __bounds.height));
1267 if (unlikely(!NEED_SURFACE(this)))
1268 ExposeRectangle(null, true);
1273 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1275 FloatRectangle currentValue = __pPresentation->__bounds;
1277 static const String* subProperties[] = { pVeSubPropBoundsSize, pVeSubPropBoundsPosition, NULL };
1278 if(CreateImplicitAnimationIfNeeded(*pVePropBounds, __bounds, currentValue, subProperties ) == false)
1280 __pPresentation->SetBoundsProperty(__bounds);
1283 VE_DELEGATE(this, InvokeOnBoundsChanged, oldValue);
1285 if(__pBoundsChangedCallback && sizeChanged == true)
1287 (*__pBoundsChangedCallback)(__pBoundsChangedCallbackData);
1297 _VisualElementImpl::SetBounds(const FloatRectangle& bounds)
1299 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1300 result r = E_SUCCESS;
1302 if (IS_INTERNAL_CLASS(__pPublicInstance))
1304 r = SetBoundsI(bounds);
1308 r = InvokeOnSetPropertyRequested(*pVePropBounds, Variant(bounds));
1310 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1316 _VisualElementImpl::GetBoundsProperty(void) const
1320 return Variant(__bounds);
1324 _VisualElementImpl::SetBoundsProperty(const Variant& v)
1326 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_RECTANGLE, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1328 return SetBoundsI(v.ToFloatRectangle());
1332 _VisualElementImpl::GetBoundsPositionSubProperty(void) const
1336 return Variant(__bounds.GetTopLeft());
1340 _VisualElementImpl::SetBoundsPositionSubProperty(const Variant& v)
1342 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1344 const FloatPoint& position = v.ToFloatPoint();
1345 return SetBoundsProperty(Variant(FloatRectangle(position.x, position.y, __bounds.width, __bounds.height)));
1349 _VisualElementImpl::GetBoundsSizeSubProperty(void) const
1353 return Variant(FloatDimension(__bounds.width, __bounds.height));
1357 _VisualElementImpl::SetBoundsSizeSubProperty(const Variant& v)
1359 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_DIMENSION, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1361 const FloatDimension& size = v.ToFloatDimension();
1362 return SetBoundsProperty(Variant(FloatRectangle(__bounds.x, __bounds.y, size.width, size.height)));
1366 _VisualElementImpl::GetZPosition(void) const
1374 _VisualElementImpl::SetZPositionI(float zPosition)
1376 if (likely(zPosition != __zPosition))
1378 __zPosition = zPosition;
1379 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false); // lazy evaluation: property changed flag
1382 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1384 float currentValue = __pPresentation->__zPosition;
1386 if(CreateImplicitAnimationIfNeeded(*pVePropZPosition, __zPosition, currentValue, NULL) == false)
1388 __pPresentation->SetZPositionProperty(__zPosition);
1397 _VisualElementImpl::SetZPosition(float zPosition)
1399 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1400 result r = E_SUCCESS;
1402 if (IS_INTERNAL_CLASS(__pPublicInstance))
1404 r = SetZPositionI(zPosition);
1408 r = InvokeOnSetPropertyRequested(*pVePropZPosition, Variant(zPosition));
1411 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1419 _VisualElementImpl::GetZPositionProperty(void) const
1423 return Variant(__zPosition);
1427 _VisualElementImpl::SetZPositionProperty(const Variant& v)
1429 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1431 return SetZPositionI(v.ToFloat());
1435 _VisualElementImpl::SetZOrderGroupI(int zOrderGroup)
1437 result r = E_SUCCESS;
1439 if (likely(__pParent))
1441 r= __pParent->ChangeZOrder(*this, null, true, zOrderGroup);
1445 _zOrderGroup = zOrderGroup;
1448 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1450 __pPresentation->SetZOrderGroupProperty(_zOrderGroup);
1456 _VisualElementImpl::SetZOrderGroup(int zOrderGroup)
1458 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1459 result r = E_SUCCESS;
1461 if (IS_INTERNAL_CLASS(__pPublicInstance))
1463 r = SetZOrderGroupI(zOrderGroup);
1467 r = InvokeOnSetPropertyRequested(*pVePropZOrderGroup, Variant(zOrderGroup));
1470 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1476 _VisualElementImpl::GetZOrderGroup(void) const
1480 return _zOrderGroup;
1484 _VisualElementImpl::GetZOrderGroupProperty(void) const
1488 return Variant(_zOrderGroup);
1492 _VisualElementImpl::SetZOrderGroupProperty(const Variant& v)
1494 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_INT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1496 return SetZOrderGroupI(v.ToInt());
1500 _VisualElementImpl::IsVisible(void) const
1504 return IsVisibleI();
1508 _VisualElementImpl::GetShowState(void) const
1512 return VE_VISIBLE(this);
1516 _VisualElementImpl::SetShowOpacityI(float showOpacity)
1518 bool oldShowState = SHOWOPACITY_VISIBLE(__showOpacity);
1520 if (unlikely(showOpacity < 0.0f))
1524 else if (unlikely(showOpacity > 1.0f))
1529 if (likely(__showOpacity != showOpacity))
1532 bool showStateChanged = (oldShowState != SHOWOPACITY_VISIBLE(showOpacity));
1534 __showOpacity = showOpacity;
1536 if (likely(showStateChanged))
1541 // Coordinates are calculated using visibleRect which is empty when invisible state.
1542 // Show-Recalculation is needed when being visible !
1543 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES | HIERARCHY_PROPERTY_SHOWSTATE | HIERARCHY_PROPERTY_OPACITY, true, false);
1545 if (unlikely(!NEED_SURFACE(this)))
1547 ExposeRectangle(null, true);
1552 InvalidateHierarchyProps(HIERARCHY_PROPERTY_SHOWSTATE | HIERARCHY_PROPERTY_OPACITY, true, false);
1554 if (unlikely(!NEED_SURFACE(this)))
1556 InvalidateVisibleRectToRenderTarget(null);
1563 // showOpacity is applicable only for surfaces
1564 if (likely(NEED_SURFACE(this)))
1566 InvalidateHierarchyProps(HIERARCHY_PROPERTY_OPACITY, true, false);
1571 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1573 bool needPresentationUpdate = true;
1574 const String& property = *pVePropShowState;
1575 _AnimationManager* pAnimationManager = _AnimationManager::GetInstance();
1577 if (likely(GetRoot()) && (unlikely(pAnimationManager->IsImplicitAnimationEnabled() && __isImplicitAnimationEnabled)))
1580 // For performance, following must be done only when oldValue != newValue.
1581 VisualElementAnimation* pAnimation = InvokeCreateAnimationForProperty(property);
1582 VisualElementPropertyAnimation* pPropertyAnimation = NULL;
1585 pPropertyAnimation = new (std::nothrow) VisualElementPropertyAnimation();
1586 if(pPropertyAnimation)
1588 pPropertyAnimation->SetPropertyName(*pVePrivPropShowOpacity);
1589 needPresentationUpdate = true;
1594 pPropertyAnimation = dynamic_cast< VisualElementPropertyAnimation* >(pAnimation);
1597 if (likely(pPropertyAnimation))
1599 if (pPropertyAnimation->GetEndValue().IsEmpty())
1601 pPropertyAnimation->SetEndValue(__showOpacity);
1604 if (pPropertyAnimation->GetStartValue().IsEmpty())
1606 pPropertyAnimation->SetStartValue(__pPresentation->__showOpacity);
1610 if (unlikely(pPropertyAnimation))
1613 // Adding property animation causes previous animation for same property to be removed in Animation Manager.
1614 if (unlikely(IsFailed(AddAnimation(null, *pPropertyAnimation))))
1616 needPresentationUpdate = true;
1617 //pAnimationManager->RemoveAnimationByProperty(*presentation.GetPublic(), property);
1620 delete pPropertyAnimation;
1625 // Remove previous animation even when trying to change the property without animation.
1626 pAnimationManager->RemoveAnimationByProperty(*__pPresentation->__pPublicInstance, property);
1627 pAnimationManager->RemoveAnimationByProperty(*__pPresentation->__pPublicInstance, *pVePrivPropShowOpacity);
1628 needPresentationUpdate = true;
1633 pAnimationManager->RemoveAnimationByProperty(*__pPresentation->__pPublicInstance, property);
1634 pAnimationManager->RemoveAnimationByProperty(*__pPresentation->__pPublicInstance, *pVePrivPropShowOpacity);
1635 needPresentationUpdate = true;
1638 if(needPresentationUpdate)
1640 __pPresentation->SetShowStateProperty(SHOWOPACITY_VISIBLE(__showOpacity));
1642 InvokeOnShowStateChanged(oldShowState);
1650 _VisualElementImpl::SetShowStateI(bool show)
1652 return SetShowOpacityI(show ? 1.0f : 0.0f);
1656 _VisualElementImpl::SetShowState(bool show)
1658 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1659 result r = E_SUCCESS;
1661 if (IS_INTERNAL_CLASS(__pPublicInstance))
1663 r = SetShowOpacityI(show ? 1.0f : 0.0f);
1667 r = InvokeOnSetPropertyRequested(*pVePropShowState, Variant(show));
1670 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1676 _VisualElementImpl::GetShowStateProperty(void) const
1680 return Variant(VE_VISIBLE(this));
1684 _VisualElementImpl::SetShowStateProperty(const Variant& v)
1686 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1688 bool showState = v.ToBool();
1690 return SetShowOpacityI(showState ? 1.0f : 0.0f);
1694 _VisualElementImpl::GetShowOpacityPrivateProperty(void) const
1698 return Variant(__showOpacity);
1702 _VisualElementImpl::SetShowOpacityPrivateProperty(const Variant& v)
1704 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1706 return SetShowOpacityI(v.ToFloat());
1710 _VisualElementImpl::GetContentOpacity(void) const
1714 return __contentOpacity;
1718 _VisualElementImpl::SetContentOpacityI(float contentOpacity)
1720 if (unlikely(contentOpacity == __contentOpacity)) // do not take care of float-error !!
1725 SysTryReturnResult(NID_UI_ANIM, contentOpacity >= 0.0f && contentOpacity <= 1.0f, E_INVALID_ARG, "Invalid argument(s) is used. Invalid opacity range.");
1727 __contentOpacity = contentOpacity;
1729 InvalidateHierarchyProps(HIERARCHY_PROPERTY_CONTENTOPACITY, false, false); //don't have to apply the changed opacity to children.
1731 #ifndef LAZY_EVALUATION
1732 if (IS_PRESENTATION(this) && likely(__pSharedData) && likely(GetSharedData().pNativeNode))
1734 GetSharedData().NodeReconfigure(*this);
1738 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1740 float currentValue = __pPresentation->__contentOpacity;
1742 if(CreateImplicitAnimationIfNeeded(*pVePropContentOpacity, __contentOpacity, currentValue, NULL) == false)
1744 __pPresentation->SetContentOpacityProperty(__contentOpacity);
1752 _VisualElementImpl::SetContentOpacity(float contentOpacity)
1754 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1755 result r = E_SUCCESS;
1757 // PROPERTY_PROCESS(SetContentOpacityI, GetContentOpacityProperty, SetContentOpacityProperty, pVePropContentOpacity, __contentOpacity, contentOpacity);
1758 if (IS_INTERNAL_CLASS(__pPublicInstance))
1760 r = SetContentOpacityI(contentOpacity);
1764 r = InvokeOnSetPropertyRequested(*pVePropContentOpacity, Variant(contentOpacity));
1767 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1774 _VisualElementImpl::GetContentOpacityProperty(void) const
1778 return Variant(__contentOpacity);
1782 _VisualElementImpl::SetContentOpacityProperty(const Variant& v)
1784 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1786 return SetContentOpacityI(v.ToFloat());
1790 _VisualElementImpl::GetOpacity(void) const
1798 _VisualElementImpl::SetOpacityI(float opacity)
1800 if (likely(opacity != __opacity)) // do not take care of float-error !!
1802 if (unlikely(opacity > 1.0f))
1806 else if (unlikely(opacity < 0.0f))
1811 __opacity = opacity;
1813 InvalidateHierarchyProps(HIERARCHY_PROPERTY_OPACITY, true, false);
1816 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1818 float currentValue = __pPresentation->__opacity;
1820 if(CreateImplicitAnimationIfNeeded(*pVePropOpacity, __opacity, currentValue, NULL) == false)
1822 __pPresentation->SetOpacityProperty(__opacity);
1829 _VisualElementImpl::SetOpacity(float opacity)
1831 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1832 result r = E_SUCCESS;
1834 // PROPERTY_PROCESS(SetOpacityI, GetOpacityProperty, SetOpacityProperty, pVePropOpacity, __opacity, opacity);
1835 if (IS_INTERNAL_CLASS(__pPublicInstance))
1837 r = SetOpacityI(opacity);
1841 r = InvokeOnSetPropertyRequested(*pVePropOpacity, Variant(opacity));
1844 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1850 _VisualElementImpl::GetOpacityProperty(void) const
1854 return Variant(__opacity);
1858 _VisualElementImpl::SetOpacityProperty(const Variant& v)
1860 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1862 return SetOpacityI(v.ToFloat());
1866 _VisualElementImpl::GetAnchor(void) const
1874 _VisualElementImpl::SetAnchorI(const FloatPoint& anchor)
1876 if (likely(anchor != __anchor))
1881 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false);
1883 // VE with surface will be exposed automatically on rebuilding coordinates...
1884 if (unlikely(!HAVE_SURFACE(this)))
1886 ExposeRectangle(null, true); // CHECKME: needed ???
1890 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1892 FloatPoint currentValue = __pPresentation->__anchor;
1894 if(CreateImplicitAnimationIfNeeded(*pVePropAnchor, __anchor, currentValue, NULL) == false)
1896 __pPresentation->SetAnchorProperty(__anchor);
1904 _VisualElementImpl::SetAnchor(const FloatPoint& anchor)
1906 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1907 result r = E_SUCCESS;
1909 // PROPERTY_PROCESS(SetAnchorI, GetAnchorProperty, SetAnchorProperty, pVePropAnchor, __anchor, anchor);
1910 if (IS_INTERNAL_CLASS(__pPublicInstance))
1912 r = SetAnchorI(anchor);
1916 r = InvokeOnSetPropertyRequested(*pVePropAnchor, Variant(anchor));
1919 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1926 _VisualElementImpl::GetAnchorProperty(void) const
1930 return Variant(__anchor);
1934 _VisualElementImpl::SetAnchorProperty(const Variant& v)
1936 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1938 return SetAnchorI(v.ToFloatPoint());
1942 _VisualElementImpl::GetAnchorZ(void) const
1950 _VisualElementImpl::SetAnchorZI(float anchorZ)
1952 if (likely(anchorZ != __anchorZ))
1954 __anchorZ = anchorZ;
1956 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false);
1958 // VE with surface will be exposed automatically on rebuilding coordinates...
1959 if (unlikely(!HAVE_SURFACE(this)))
1961 ExposeRectangle(null, true); // CHECKME: needed ???
1965 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1967 float currentValue = __pPresentation->__anchorZ;
1969 if(CreateImplicitAnimationIfNeeded(*pVePropAnchorZ, __anchorZ, currentValue, NULL) == false)
1971 __pPresentation->SetAnchorZProperty(__anchorZ);
1979 _VisualElementImpl::SetAnchorZ(float anchorZ)
1981 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1982 result r = E_SUCCESS;
1984 // PROPERTY_PROCESS(SetAnchorZI, GetAnchorZProperty, SetAnchorZProperty, pVePropAnchorZ, __anchorZ, anchorZ);
1985 if (IS_INTERNAL_CLASS(__pPublicInstance))
1987 r = SetAnchorZI(anchorZ);
1991 r = InvokeOnSetPropertyRequested(*pVePropAnchorZ, Variant(anchorZ));
1994 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
2002 _VisualElementImpl::GetAnchorZProperty(void) const
2006 return Variant(__anchorZ);
2010 _VisualElementImpl::SetAnchorZProperty(const Variant& v)
2012 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2014 return SetAnchorZI(v.ToFloat());
2018 _VisualElementImpl::GetTransformMatrix(void) const
2026 _VisualElementImpl::SetTransformMatrixI(const FloatMatrix4& xform, bool updateDecomposed)
2029 result r = E_SUCCESS;
2031 FloatMatrix4 oldValue(__transform);
2033 FloatMatrix4 matrixAdjusted(xform);
2035 if (unlikely(GetSharedData().pEventListener != null))
2037 if (IS_MODEL(this)) // CHECKME: checking need??
2039 r = VE_DELEGATE(this, InvokeOnTransformMatrixChanging, matrixAdjusted);
2043 if (r == E_SUCCESS && likely(matrixAdjusted != __transform)) // check again because delegate may change the transform matrix
2045 // render target updates for previous bounds
2046 if (unlikely(!NEED_SURFACE(this)))
2048 InvalidateVisibleRectToRenderTarget(null);
2052 MatrixUtilCopy(__transform, matrixAdjusted);
2054 if (unlikely(updateDecomposed))
2056 __decomposedTransform.SetTransformMatrix(__transform);
2059 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false);
2061 // VE with surface will be exposed automatically on rebuilding coordinates...
2062 if (unlikely(!NEED_SURFACE(this)))
2064 ExposeRectangle(null, true); // CHECKME: needed ???
2068 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
2070 FloatMatrix4 currentValue = __pPresentation->__transform;
2072 static const String* subProperties[] = { pVeSubPropTransformRotationX,
2073 pVeSubPropTransformRotationY,
2074 pVeSubPropTransformRotationZ,
2075 pVeSubPropTransformScaleX,
2076 pVeSubPropTransformScaleY,
2077 pVeSubPropTransformScaleZ,
2078 pVeSubPropTransformTranslationX,
2079 pVeSubPropTransformTranslationY,
2080 pVeSubPropTransformTranslationZ,
2081 pVeSubPropTransformRotationAnchorX,
2082 pVeSubPropTransformRotationAnchorY,
2083 pVeSubPropTransformRotationAnchorZ,
2084 pVeSubPropTransformScaleAnchorX,
2085 pVeSubPropTransformScaleAnchorY,
2086 pVeSubPropTransformScaleAnchorZ,
2089 if(CreateImplicitAnimationIfNeeded(*pVePropTransform, __transform, currentValue, subProperties ) == false)
2091 __pPresentation->SetTransformMatrixProperty(__transform);
2094 VE_DELEGATE(this, InvokeOnTransformMatrixChanged, oldValue);
2100 _VisualElementImpl::SetTransformMatrix(const FloatMatrix4& xform)
2102 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
2103 result r = E_SUCCESS;
2105 // PROPERTY_PROCESS(SetTransformMatrixI, GetTransformMatrixProperty, SetTransformMatrixProperty, pVePropTransform, __transform, xform);
2106 if (IS_INTERNAL_CLASS(__pPublicInstance))
2108 r = SetTransformMatrixI(xform);
2112 r = InvokeOnSetPropertyRequested(*pVePropTransform, Variant(xform));
2115 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
2123 _VisualElementImpl::GetTransformMatrixProperty(void) const
2127 return Variant(__transform);
2132 _VisualElementImpl::SetTransformMatrixProperty(const Variant& v)
2134 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_MATRIX4, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2136 return SetTransformMatrixI(v.ToFloatMatrix4(), true);
2140 _VisualElementImpl::GetTransformRotationXSubProperty(void) const
2144 float angleX = 0.0f;
2145 float angleY = 0.0f;
2146 float angleZ = 0.0f;
2147 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2149 return Variant(angleX);
2153 _VisualElementImpl::SetTransformRotationXSubProperty(const Variant& v)
2155 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2157 float angleX = 0.0f;
2158 float angleY = 0.0f;
2159 float angleZ = 0.0f;
2160 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2161 __decomposedTransform.UpdateRotationFromEulerAngles(v.ToFloat(), angleY, angleZ);
2163 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2167 _VisualElementImpl::GetTransformRotationYSubProperty(void) const
2171 float angleX = 0.0f;
2172 float angleY = 0.0f;
2173 float angleZ = 0.0f;
2174 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2176 return Variant(angleY);
2180 _VisualElementImpl::SetTransformRotationYSubProperty(const Variant& v)
2182 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2184 float angleX = 0.0f;
2185 float angleY = 0.0f;
2186 float angleZ = 0.0f;
2187 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2188 __decomposedTransform.UpdateRotationFromEulerAngles(angleX, v.ToFloat(), angleZ);
2190 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2194 _VisualElementImpl::GetTransformRotationZSubProperty(void) const
2198 float angleX = 0.0f;
2199 float angleY = 0.0f;
2200 float angleZ = 0.0f;
2201 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2203 return Variant(angleZ);
2207 _VisualElementImpl::SetTransformRotationZSubProperty(const Variant& v)
2209 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2211 float angleX = 0.0f;
2212 float angleY = 0.0f;
2213 float angleZ = 0.0f;
2214 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2215 __decomposedTransform.UpdateRotationFromEulerAngles(angleX, angleY, v.ToFloat());
2217 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2221 _VisualElementImpl::GetTransformRotationXYSubProperty(void) const
2225 float angleX = 0.0f;
2226 float angleY = 0.0f;
2227 float angleZ = 0.0f;
2228 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2230 return Variant(FloatPoint(angleX, angleY));
2234 _VisualElementImpl::SetTransformRotationXYSubProperty(const Variant& v)
2236 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2238 const FloatPoint& point = v.ToFloatPoint();
2240 float angleX = 0.0f;
2241 float angleY = 0.0f;
2242 float angleZ = 0.0f;
2243 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2244 __decomposedTransform.UpdateRotationFromEulerAngles(point.x, point.y, angleZ);
2246 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2250 _VisualElementImpl::GetTransformRotationAnchorXSubProperty(void) const
2254 float anchorX = 0.0f;
2255 float anchorY = 0.0f;
2256 float anchorZ = 0.0f;
2257 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2259 return Variant(anchorX);
2263 _VisualElementImpl::SetTransformRotationAnchorXSubProperty(const Variant& v)
2265 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2267 float anchorX = 0.0f;
2268 float anchorY = 0.0f;
2269 float anchorZ = 0.0f;
2270 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2271 __decomposedTransform.SetRotationAnchor(v.ToFloat(), anchorY, anchorZ);
2273 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2277 _VisualElementImpl::GetTransformRotationAnchorYSubProperty(void) const
2281 float anchorX = 0.0f;
2282 float anchorY = 0.0f;
2283 float anchorZ = 0.0f;
2284 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2286 return Variant(anchorY);
2290 _VisualElementImpl::SetTransformRotationAnchorYSubProperty(const Variant& v)
2292 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2294 float anchorX = 0.0f;
2295 float anchorY = 0.0f;
2296 float anchorZ = 0.0f;
2297 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2298 __decomposedTransform.SetRotationAnchor(anchorX, v.ToFloat(), anchorZ);
2300 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2304 _VisualElementImpl::GetTransformRotationAnchorZSubProperty(void) const
2308 float anchorX = 0.0f;
2309 float anchorY = 0.0f;
2310 float anchorZ = 0.0f;
2311 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2313 return Variant(anchorZ);
2317 _VisualElementImpl::SetTransformRotationAnchorZSubProperty(const Variant& v)
2319 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2321 float anchorX = 0.0f;
2322 float anchorY = 0.0f;
2323 float anchorZ = 0.0f;
2324 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2325 __decomposedTransform.SetRotationAnchor(anchorX, anchorY, v.ToFloat());
2327 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2331 _VisualElementImpl::GetTransformRotationAnchorXYSubProperty(void) const
2335 float anchorX = 0.0f;
2336 float anchorY = 0.0f;
2337 float anchorZ = 0.0f;
2338 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2340 return Variant(FloatPoint(anchorX, anchorY));
2344 _VisualElementImpl::SetTransformRotationAnchorXYSubProperty(const Variant& v)
2346 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2348 const FloatPoint& point = v.ToFloatPoint();
2350 float anchorX = 0.0f;
2351 float anchorY = 0.0f;
2352 float anchorZ = 0.0f;
2353 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2354 __decomposedTransform.SetRotationAnchor(point.x, point.y, anchorZ);
2356 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2360 _VisualElementImpl::GetTransformScaleXSubProperty(void) const
2364 float scaleX = 1.0f;
2365 float scaleY = 1.0f;
2366 float scaleZ = 1.0f;
2367 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2369 return Variant(scaleX);
2373 _VisualElementImpl::SetTransformScaleXSubProperty(const Variant& v)
2375 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2377 float scaleX = 1.0f;
2378 float scaleY = 1.0f;
2379 float scaleZ = 1.0f;
2380 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2381 __decomposedTransform.SetScaleFactors(v.ToFloat(), scaleY, scaleZ);
2383 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2387 _VisualElementImpl::GetTransformScaleYSubProperty(void) const
2391 float scaleX = 1.0f;
2392 float scaleY = 1.0f;
2393 float scaleZ = 1.0f;
2394 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2396 return Variant(scaleY);
2400 _VisualElementImpl::SetTransformScaleYSubProperty(const Variant& v)
2402 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2404 float scaleX = 1.0f;
2405 float scaleY = 1.0f;
2406 float scaleZ = 1.0f;
2407 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2408 __decomposedTransform.SetScaleFactors(scaleX, v.ToFloat(), scaleZ);
2410 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2414 _VisualElementImpl::GetTransformScaleZSubProperty(void) const
2418 float scaleX = 1.0f;
2419 float scaleY = 1.0f;
2420 float scaleZ = 1.0f;
2421 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2423 return Variant(scaleZ);
2427 _VisualElementImpl::SetTransformScaleZSubProperty(const Variant& v)
2429 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2431 float scaleX = 1.0f;
2432 float scaleY = 1.0f;
2433 float scaleZ = 1.0f;
2434 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2435 __decomposedTransform.SetScaleFactors(scaleX, scaleY, v.ToFloat());
2437 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2441 _VisualElementImpl::GetTransformScaleXYSubProperty(void) const
2445 float scaleX = 1.0f;
2446 float scaleY = 1.0f;
2447 float scaleZ = 1.0f;
2448 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2450 return Variant(FloatPoint(scaleX, scaleY));
2454 _VisualElementImpl::SetTransformScaleXYSubProperty(const Variant& v)
2456 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2458 const FloatPoint& point = v.ToFloatPoint();
2460 float scaleX = 1.0f;
2461 float scaleY = 1.0f;
2462 float scaleZ = 1.0f;
2463 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2464 if (unlikely(scaleX == point.x) && unlikely(scaleY == point.y))
2469 __decomposedTransform.SetScaleFactors(point.x, point.y, scaleZ);
2471 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2475 _VisualElementImpl::GetTransformScaleAnchorXSubProperty(void) const
2479 float anchorX = 0.0f;
2480 float anchorY = 0.0f;
2481 float anchorZ = 0.0f;
2482 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2484 return Variant(anchorX);
2488 _VisualElementImpl::SetTransformScaleAnchorXSubProperty(const Variant& v)
2490 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2492 float anchorX = 0.0f;
2493 float anchorY = 0.0f;
2494 float anchorZ = 0.0f;
2495 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2496 __decomposedTransform.SetScaleAnchor(v.ToFloat(), anchorY, anchorZ);
2498 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2502 _VisualElementImpl::GetTransformScaleAnchorYSubProperty(void) const
2506 float anchorX = 0.0f;
2507 float anchorY = 0.0f;
2508 float anchorZ = 0.0f;
2509 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2511 return Variant(anchorY);
2515 _VisualElementImpl::SetTransformScaleAnchorYSubProperty(const Variant& v)
2517 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2519 float anchorX = 0.0f;
2520 float anchorY = 0.0f;
2521 float anchorZ = 0.0f;
2522 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2523 __decomposedTransform.SetScaleAnchor(anchorX, v.ToFloat(), anchorZ);
2525 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2529 _VisualElementImpl::GetTransformScaleAnchorZSubProperty(void) const
2533 float anchorX = 0.0f;
2534 float anchorY = 0.0f;
2535 float anchorZ = 0.0f;
2536 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2538 return Variant(anchorZ);
2542 _VisualElementImpl::SetTransformScaleAnchorZSubProperty(const Variant& v)
2544 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2546 float anchorX = 0.0f;
2547 float anchorY = 0.0f;
2548 float anchorZ = 0.0f;
2549 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2550 __decomposedTransform.SetScaleAnchor(anchorX, anchorY, v.ToFloat());
2552 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2556 _VisualElementImpl::GetTransformScaleAnchorXYSubProperty(void) const
2560 float anchorX = 0.0f;
2561 float anchorY = 0.0f;
2562 float anchorZ = 0.0f;
2563 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2565 return Variant(FloatPoint(anchorX, anchorY));
2569 _VisualElementImpl::SetTransformScaleAnchorXYSubProperty(const Variant& v)
2571 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2573 const FloatPoint& point = v.ToFloatPoint();
2575 float anchorX = 0.0f;
2576 float anchorY = 0.0f;
2577 float anchorZ = 0.0f;
2578 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2579 __decomposedTransform.SetScaleAnchor(point.x, point.y, anchorZ);
2581 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2585 _VisualElementImpl::GetTransformTranslationXSubProperty(void) const
2589 float translateX = 0.0f;
2590 float translateY = 0.0f;
2591 float translateZ = 0.0f;
2592 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2594 return Variant(translateX);
2598 _VisualElementImpl::SetTransformTranslationXSubProperty(const Variant& v)
2600 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2602 float translateX = 0.0f;
2603 float translateY = 0.0f;
2604 float translateZ = 0.0f;
2605 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2606 __decomposedTransform.SetTranslationFactors(v.ToFloat(), translateY, translateZ);
2608 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2612 _VisualElementImpl::GetTransformTranslationYSubProperty(void) const
2616 float translateX = 0.0f;
2617 float translateY = 0.0f;
2618 float translateZ = 0.0f;
2619 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2621 return Variant(translateY);
2625 _VisualElementImpl::SetTransformTranslationYSubProperty(const Variant& v)
2627 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2629 float translateX = 0.0f;
2630 float translateY = 0.0f;
2631 float translateZ = 0.0f;
2632 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2633 __decomposedTransform.SetTranslationFactors(translateX, v.ToFloat(), translateZ);
2635 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2639 _VisualElementImpl::GetTransformTranslationZSubProperty(void) const
2643 float translateX = 0.0f;
2644 float translateY = 0.0f;
2645 float translateZ = 0.0f;
2646 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2648 return Variant(translateZ);
2652 _VisualElementImpl::SetTransformTranslationZSubProperty(const Variant& v)
2654 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2656 float translateX = 0.0f;
2657 float translateY = 0.0f;
2658 float translateZ = 0.0f;
2659 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2660 __decomposedTransform.SetTranslationFactors(translateX, translateY, v.ToFloat());
2662 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2666 _VisualElementImpl::GetTransformTranslationXYSubProperty(void) const
2670 float translateX = 0.0f;
2671 float translateY = 0.0f;
2672 float translateZ = 0.0f;
2673 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2675 return Variant(FloatPoint(translateX, translateY));
2679 _VisualElementImpl::SetTransformTranslationXYSubProperty(const Variant& v)
2681 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2683 const FloatPoint& point = v.ToFloatPoint();
2685 float translateX = 0.0f;
2686 float translateY = 0.0f;
2687 float translateZ = 0.0f;
2688 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2689 __decomposedTransform.SetTranslationFactors(point.x, point.y, translateZ);
2691 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2695 _VisualElementImpl::GetChildrenTransformMatrix(void) const
2699 return __childrenTransform;
2704 _VisualElementImpl::SetChildrenTransformMatrixI(const FloatMatrix4& xform, bool updateDecomposed)
2706 FloatMatrix4 matrixAdjusted(xform);
2707 FloatMatrix4 oldValue(__childrenTransform);
2708 result r = E_SUCCESS;
2710 if (unlikely(GetSharedData().pEventListener != null))
2712 if (IS_MODEL(this)) // CHECKME: checking need??
2714 r = VE_DELEGATE(this, InvokeOnChildrenTransformMatrixChanging, matrixAdjusted);
2719 if (r == E_SUCCESS && likely(matrixAdjusted != __childrenTransform)) // check again because delegate may change the transform matrix
2722 // May be un-needed from now...... (no support for VE without surface or shared-canvas)
2723 if (!IS_PRESENTATION(this))
2725 int count = __children.GetCount();
2726 for (int i = 0; i < count; i++)
2728 // VE with surface will be exposed automatically on rebuilding coordinates...
2729 _VisualElementImpl* pVe = __children.GetChildAt(i);
2730 if (pVe && !NEED_SURFACE(pVe))
2732 pVe->ExposeRectangle(null, true);
2734 // render target update for previous bounds
2735 pVe->InvalidateVisibleRectToRenderTarget(null);
2740 MatrixUtilCopy(__childrenTransform, matrixAdjusted);
2742 if (unlikely(updateDecomposed))
2744 __decomposedChildrenTransform.SetTransformMatrix(__childrenTransform);
2747 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false);
2750 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
2752 FloatMatrix4 currentValue = __pPresentation->__childrenTransform;
2753 static const String* subProperties[] = {
2754 pVeSubPropChildrenTransformRotationX,
2755 pVeSubPropChildrenTransformRotationY,
2756 pVeSubPropChildrenTransformRotationZ,
2757 pVeSubPropChildrenTransformScaleX,
2758 pVeSubPropChildrenTransformScaleY,
2759 pVeSubPropChildrenTransformScaleZ,
2760 pVeSubPropChildrenTransformTranslationX,
2761 pVeSubPropChildrenTransformTranslationY,
2762 pVeSubPropChildrenTransformTranslationZ,
2763 pVeSubPropChildrenTransformRotationAnchorX,
2764 pVeSubPropChildrenTransformRotationAnchorY,
2765 pVeSubPropChildrenTransformRotationAnchorZ,
2766 pVeSubPropChildrenTransformScaleAnchorX,
2767 pVeSubPropChildrenTransformScaleAnchorY,
2768 pVeSubPropChildrenTransformScaleAnchorZ,
2771 if(CreateImplicitAnimationIfNeeded(*pVePropChildrenTransform, __childrenTransform, currentValue, subProperties ) == false)
2773 __pPresentation->SetChildrenTransformMatrixProperty(__childrenTransform);
2776 VE_DELEGATE(this, InvokeOnChildrenTransformMatrixChanged, oldValue);
2783 _VisualElementImpl::SetChildrenTransformMatrix(const FloatMatrix4& xform)
2785 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
2786 result r = E_SUCCESS;
2788 //PROPERTY_PROCESS(SetChildrenTransformMatrixI, GetChildrenTransformMatrixProperty, SetChildrenTransformMatrixProperty, pVePropChildrenTransform, __childrenTransform, xform);
2789 if (IS_INTERNAL_CLASS(__pPublicInstance))
2791 r = SetChildrenTransformMatrixI(xform);
2795 r = InvokeOnSetPropertyRequested(*pVePropChildrenTransform, Variant(xform));
2798 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
2804 _VisualElementImpl::GetChildrenTransformMatrixProperty(void) const
2808 return Variant(__childrenTransform);
2813 _VisualElementImpl::SetChildrenTransformMatrixProperty(const Variant& v)
2815 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_MATRIX4, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2817 return SetChildrenTransformMatrixI(v.ToFloatMatrix4(), true);
2821 _VisualElementImpl::GetChildrenTransformRotationXSubProperty(void) const
2825 float angleX = 0.0f;
2826 float angleY = 0.0f;
2827 float angleZ = 0.0f;
2828 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
2830 return Variant(angleX);
2834 _VisualElementImpl::SetChildrenTransformRotationXSubProperty(const Variant& v)
2836 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2838 float angleX = 0.0f;
2839 float angleY = 0.0f;
2840 float angleZ = 0.0f;
2841 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
2842 __decomposedChildrenTransform.UpdateRotationFromEulerAngles(v.ToFloat(), angleY, angleZ);
2844 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
2848 _VisualElementImpl::GetChildrenTransformRotationYSubProperty(void) const
2852 float angleX = 0.0f;
2853 float angleY = 0.0f;
2854 float angleZ = 0.0f;
2855 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
2857 return Variant(angleY);
2861 _VisualElementImpl::SetChildrenTransformRotationYSubProperty(const Variant& v)
2863 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2865 float angleX = 0.0f;
2866 float angleY = 0.0f;
2867 float angleZ = 0.0f;
2868 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
2869 __decomposedChildrenTransform.UpdateRotationFromEulerAngles(angleX, v.ToFloat(), angleZ);
2871 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
2875 _VisualElementImpl::GetChildrenTransformRotationZSubProperty(void) const
2879 float angleX = 0.0f;
2880 float angleY = 0.0f;
2881 float angleZ = 0.0f;
2882 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
2884 return Variant(angleZ);
2888 _VisualElementImpl::SetChildrenTransformRotationZSubProperty(const Variant& v)
2890 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2892 float angleX = 0.0f;
2893 float angleY = 0.0f;
2894 float angleZ = 0.0f;
2895 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
2896 __decomposedChildrenTransform.UpdateRotationFromEulerAngles(angleX, angleY, v.ToFloat());
2898 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
2902 _VisualElementImpl::GetChildrenTransformRotationXYSubProperty(void) const
2906 float angleX = 0.0f;
2907 float angleY = 0.0f;
2908 float angleZ = 0.0f;
2909 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
2911 return Variant(FloatPoint(angleX, angleY));
2915 _VisualElementImpl::SetChildrenTransformRotationXYSubProperty(const Variant& v)
2917 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2919 const FloatPoint& point = v.ToFloatPoint();
2921 float angleX = 0.0f;
2922 float angleY = 0.0f;
2923 float angleZ = 0.0f;
2924 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
2925 __decomposedChildrenTransform.UpdateRotationFromEulerAngles(point.x, point.y, angleZ);
2927 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
2931 _VisualElementImpl::GetChildrenTransformRotationAnchorXSubProperty(void) const
2935 float anchorX = 0.0f;
2936 float anchorY = 0.0f;
2937 float anchorZ = 0.0f;
2938 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2940 return Variant(anchorX);
2944 _VisualElementImpl::SetChildrenTransformRotationAnchorXSubProperty(const Variant& v)
2946 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2948 float anchorX = 0.0f;
2949 float anchorY = 0.0f;
2950 float anchorZ = 0.0f;
2951 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2952 __decomposedChildrenTransform.SetRotationAnchor(v.ToFloat(), anchorY, anchorZ);
2954 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
2958 _VisualElementImpl::GetChildrenTransformRotationAnchorYSubProperty(void) const
2962 float anchorX = 0.0f;
2963 float anchorY = 0.0f;
2964 float anchorZ = 0.0f;
2965 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2967 return Variant(anchorY);
2971 _VisualElementImpl::SetChildrenTransformRotationAnchorYSubProperty(const Variant& v)
2973 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2975 float anchorX = 0.0f;
2976 float anchorY = 0.0f;
2977 float anchorZ = 0.0f;
2978 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2979 __decomposedChildrenTransform.SetRotationAnchor(anchorX, v.ToFloat(), anchorZ);
2981 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
2985 _VisualElementImpl::GetChildrenTransformRotationAnchorZSubProperty(void) const
2989 float anchorX = 0.0f;
2990 float anchorY = 0.0f;
2991 float anchorZ = 0.0f;
2992 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2994 return Variant(anchorZ);
2998 _VisualElementImpl::SetChildrenTransformRotationAnchorZSubProperty(const Variant& v)
3000 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3002 float anchorX = 0.0f;
3003 float anchorY = 0.0f;
3004 float anchorZ = 0.0f;
3005 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
3006 __decomposedChildrenTransform.SetRotationAnchor(anchorX, anchorY, v.ToFloat());
3008 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3012 _VisualElementImpl::GetChildrenTransformRotationAnchorXYSubProperty(void) const
3016 float anchorX = 0.0f;
3017 float anchorY = 0.0f;
3018 float anchorZ = 0.0f;
3019 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
3021 return Variant(FloatPoint(anchorX, anchorY));
3025 _VisualElementImpl::SetChildrenTransformRotationAnchorXYSubProperty(const Variant& v)
3027 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3029 const FloatPoint& point = v.ToFloatPoint();
3031 float anchorX = 0.0f;
3032 float anchorY = 0.0f;
3033 float anchorZ = 0.0f;
3034 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
3035 __decomposedChildrenTransform.SetRotationAnchor(point.x, point.y, anchorZ);
3037 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3041 _VisualElementImpl::GetChildrenTransformScaleXSubProperty(void) const
3045 float scaleX = 1.0f;
3046 float scaleY = 1.0f;
3047 float scaleZ = 1.0f;
3048 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3050 return Variant(scaleX);
3054 _VisualElementImpl::SetChildrenTransformScaleXSubProperty(const Variant& v)
3056 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3058 float scaleX = 1.0f;
3059 float scaleY = 1.0f;
3060 float scaleZ = 1.0f;
3061 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3062 __decomposedChildrenTransform.SetScaleFactors(v.ToFloat(), scaleY, scaleZ);
3064 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3068 _VisualElementImpl::GetChildrenTransformScaleYSubProperty(void) const
3072 float scaleX = 1.0f;
3073 float scaleY = 1.0f;
3074 float scaleZ = 1.0f;
3075 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3077 return Variant(scaleY);
3081 _VisualElementImpl::SetChildrenTransformScaleYSubProperty(const Variant& v)
3083 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3085 float scaleX = 1.0f;
3086 float scaleY = 1.0f;
3087 float scaleZ = 1.0f;
3088 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3089 __decomposedChildrenTransform.SetScaleFactors(scaleX, v.ToFloat(), scaleZ);
3091 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3095 _VisualElementImpl::GetChildrenTransformScaleZSubProperty(void) const
3099 float scaleX = 1.0f;
3100 float scaleY = 1.0f;
3101 float scaleZ = 1.0f;
3102 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3104 return Variant(scaleZ);
3108 _VisualElementImpl::SetChildrenTransformScaleZSubProperty(const Variant& v)
3110 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3112 float scaleX = 1.0f;
3113 float scaleY = 1.0f;
3114 float scaleZ = 1.0f;
3115 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3116 __decomposedChildrenTransform.SetScaleFactors(scaleX, scaleY, v.ToFloat());
3118 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3122 _VisualElementImpl::GetChildrenTransformScaleXYSubProperty(void) const
3126 float scaleX = 1.0f;
3127 float scaleY = 1.0f;
3128 float scaleZ = 1.0f;
3129 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3131 return Variant(FloatPoint(scaleX, scaleY));
3135 _VisualElementImpl::SetChildrenTransformScaleXYSubProperty(const Variant& v)
3137 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3139 const FloatPoint& point = v.ToFloatPoint();
3141 float scaleX = 1.0f;
3142 float scaleY = 1.0f;
3143 float scaleZ = 1.0f;
3144 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3145 __decomposedChildrenTransform.SetScaleFactors(point.x, point.y, scaleZ);
3147 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3151 _VisualElementImpl::GetChildrenTransformScaleAnchorXSubProperty(void) const
3155 float anchorX = 0.0f;
3156 float anchorY = 0.0f;
3157 float anchorZ = 0.0f;
3158 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3160 return Variant(anchorX);
3164 _VisualElementImpl::SetChildrenTransformScaleAnchorXSubProperty(const Variant& v)
3166 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3168 float anchorX = 0.0f;
3169 float anchorY = 0.0f;
3170 float anchorZ = 0.0f;
3171 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3172 __decomposedChildrenTransform.SetScaleAnchor(v.ToFloat(), anchorY, anchorZ);
3174 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3178 _VisualElementImpl::GetChildrenTransformScaleAnchorYSubProperty(void) const
3182 float anchorX = 0.0f;
3183 float anchorY = 0.0f;
3184 float anchorZ = 0.0f;
3185 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3187 return Variant(anchorY);
3191 _VisualElementImpl::SetChildrenTransformScaleAnchorYSubProperty(const Variant& v)
3193 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3195 float anchorX = 0.0f;
3196 float anchorY = 0.0f;
3197 float anchorZ = 0.0f;
3198 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3199 __decomposedChildrenTransform.SetScaleAnchor(anchorX, v.ToFloat(), anchorZ);
3201 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3205 _VisualElementImpl::GetChildrenTransformScaleAnchorZSubProperty(void) const
3209 float anchorX = 0.0f;
3210 float anchorY = 0.0f;
3211 float anchorZ = 0.0f;
3212 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3214 return Variant(anchorZ);
3218 _VisualElementImpl::SetChildrenTransformScaleAnchorZSubProperty(const Variant& v)
3220 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3222 float anchorX = 0.0f;
3223 float anchorY = 0.0f;
3224 float anchorZ = 0.0f;
3225 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3226 __decomposedChildrenTransform.SetScaleAnchor(anchorX, anchorY, v.ToFloat());
3228 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3232 _VisualElementImpl::GetChildrenTransformScaleAnchorXYSubProperty(void) const
3236 float anchorX = 0.0f;
3237 float anchorY = 0.0f;
3238 float anchorZ = 0.0f;
3239 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3241 return Variant(FloatPoint(anchorX, anchorY));
3245 _VisualElementImpl::SetChildrenTransformScaleAnchorXYSubProperty(const Variant& v)
3247 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3249 const FloatPoint& point = v.ToFloatPoint();
3251 float anchorX = 0.0f;
3252 float anchorY = 0.0f;
3253 float anchorZ = 0.0f;
3254 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3255 __decomposedChildrenTransform.SetScaleAnchor(point.x, point.y, anchorZ);
3257 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3261 _VisualElementImpl::GetChildrenTransformTranslationXSubProperty(void) const
3265 float translateX = 0.0f;
3266 float translateY = 0.0f;
3267 float translateZ = 0.0f;
3268 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3270 return Variant(translateX);
3274 _VisualElementImpl::SetChildrenTransformTranslationXSubProperty(const Variant& v)
3276 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3278 float translateX = 0.0f;
3279 float translateY = 0.0f;
3280 float translateZ = 0.0f;
3281 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3282 __decomposedChildrenTransform.SetTranslationFactors(v.ToFloat(), translateY, translateZ);
3284 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3288 _VisualElementImpl::GetChildrenTransformTranslationYSubProperty(void) const
3292 float translateX = 0.0f;
3293 float translateY = 0.0f;
3294 float translateZ = 0.0f;
3295 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3297 return Variant(translateY);
3301 _VisualElementImpl::SetChildrenTransformTranslationYSubProperty(const Variant& v)
3303 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3305 float translateX = 0.0f;
3306 float translateY = 0.0f;
3307 float translateZ = 0.0f;
3308 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3309 __decomposedChildrenTransform.SetTranslationFactors(translateX, v.ToFloat(), translateZ);
3311 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3315 _VisualElementImpl::GetChildrenTransformTranslationZSubProperty(void) const
3319 float translateX = 0.0f;
3320 float translateY = 0.0f;
3321 float translateZ = 0.0f;
3322 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3324 return Variant(translateZ);
3328 _VisualElementImpl::SetChildrenTransformTranslationZSubProperty(const Variant& v)
3330 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3332 float translateX = 0.0f;
3333 float translateY = 0.0f;
3334 float translateZ = 0.0f;
3335 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3336 __decomposedChildrenTransform.SetTranslationFactors(translateX, translateY, v.ToFloat());
3338 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3342 _VisualElementImpl::GetChildrenTransformTranslationXYSubProperty(void) const
3346 float translateX = 0.0f;
3347 float translateY = 0.0f;
3348 float translateZ = 0.0f;
3349 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3351 return Variant(FloatPoint(translateX, translateY));
3355 _VisualElementImpl::SetChildrenTransformTranslationXYSubProperty(const Variant& v)
3357 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3359 const FloatPoint& point = v.ToFloatPoint();
3361 float translateX = 0.0f;
3362 float translateY = 0.0f;
3363 float translateZ = 0.0f;
3364 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3365 __decomposedChildrenTransform.SetTranslationFactors(point.x, point.y, translateZ);
3367 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3371 _VisualElementImpl::IsClipToParent(void) const
3378 // TBD: clipToParent is not animatable, right??
3380 _VisualElementImpl::SetClipToParent(bool clipToParent)
3382 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
3384 return InvokeOnSetPropertyRequested(*pVePropClipToParent, Variant(clipToParent));
3388 _VisualElementImpl::GetClipToParentProperty(void) const
3391 //SysLog(NID_UI_ANIM, "WARNING: ClipToParent is deprecated.");
3393 return Variant(false);
3397 _VisualElementImpl::SetClipToParentProperty(const Variant& v)
3399 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3401 //SysLog(NID_UI_ANIM, "WARNING: ClipToParent is deprecated.");
3407 _VisualElementImpl::IsClipChildrenEnabled(void) const
3411 return __isClipChildren;
3415 _VisualElementImpl::SetClipChildrenEnabled(bool clipChildren)
3417 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
3418 result r = E_SUCCESS;
3420 if (IS_INTERNAL_CLASS(__pPublicInstance))
3422 r = SetClipChildrenProperty(Variant(clipChildren));
3426 r = InvokeOnSetPropertyRequested(*pVePropClipChildren, Variant(clipChildren));
3428 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
3434 _VisualElementImpl::GetClipChildrenProperty(void) const
3438 return Variant(__isClipChildren);
3442 _VisualElementImpl::SetClipChildrenProperty(const Variant& v)
3444 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3446 bool clipChildren = v.ToBool();
3447 if (likely(clipChildren != __isClipChildren))
3450 //SysLog(NID_UI_ANIM, "%p ClipChildren = %d", this, clipChildren);
3452 __isClipChildren = clipChildren;
3453 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false);
3457 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
3459 __pPresentation->SetClipChildrenProperty(__isClipChildren);
3466 _VisualElementImpl::IsSurfaceOpaque(void) const
3470 return GetSharedData().isSurfaceOpaque;
3474 _VisualElementImpl::SetSurfaceOpaque(bool isSurfaceOpaque)
3476 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
3477 result r = E_SUCCESS;
3479 if (IS_INTERNAL_CLASS(__pPublicInstance))
3481 r = SetSurfaceOpaqueProperty(Variant(isSurfaceOpaque));
3485 r = InvokeOnSetPropertyRequested(*pVePropSurfaceOpaque, Variant(isSurfaceOpaque));
3487 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
3493 _VisualElementImpl::GetSurfaceOpaqueProperty(void) const
3497 return Variant(GetSharedData().isSurfaceOpaque);
3501 _VisualElementImpl::SetSurfaceOpaqueProperty(const Variant& v)
3503 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3505 bool isSurfaceOpaque = v.ToBool();
3506 if (isSurfaceOpaque == GetSharedData().isSurfaceOpaque)
3509 InvalidateHierarchyProps(HIERARCHY_PROPERTY_CONTENTOPACITY, false, false); //don't have to apply the changed opacity to children.
3511 if (IS_PRESENTATION(this))
3513 GetSharedData().isSurfaceOpaque = isSurfaceOpaque;
3515 #ifndef LAZY_EVALUATION
3516 // not needed when no surface
3517 if (HAVE_SURFACE(this))
3518 GetSharedData().NodeReconfigure(*this);
3523 if(IS_NEEDED_UPDATE_PRESENTATION(this))
3525 __pPresentation->SetSurfaceOpaqueProperty(isSurfaceOpaque);
3533 _VisualElementImpl::GetCanvasN(void)
3535 return GetCanvasN(FloatRectangle(0.0f, 0.0f, __bounds.width, __bounds.height));
3539 _VisualElementImpl::GetCanvasN(const Rectangle& bounds)
3541 return GetCanvasN(FloatRectangle(bounds.x, bounds.y, bounds.width, bounds.height));
3545 _VisualElementImpl::GetCanvasN(const FloatRectangle& bounds)
3547 SysTryReturn(NID_UI_ANIM, !GetSharedData().fixedSurfaceSize, null, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Canvas can't be instantiated for fixed-size user surface.");
3548 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);
3549 SysTryReturn(NID_UI_ANIM, __imageFilePath.IsEmpty(), null, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Can't get canvas for surface which is from image file.");
3550 SysTryReturn(NID_UI_ANIM, GetRoot(), null, E_INVALID_STATE, "[E_INVALID_STATE] VisualElement is not attached to main tree.");
3551 SysTryReturn(NID_UI_ANIM, IS_MODEL(this), null, E_INVALID_OPERATION, "VisualElement is not Model object.");
3553 // WARNING: WARNING: WARNING:
3554 // If need-redraw and surface is set by user, VE do *NOT* allow GetCanvasN
3555 // because 'bounds' is for the VE does not comply with size of surface.
3556 // (in which case the surface will be displayed scaled)
3558 _VisualElementImpl* pRenderTarget = GetRenderTarget();
3559 SysTryReturn(NID_UI_ANIM, pRenderTarget, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Target VisualElement is not available.");
3560 SysTryReturn(NID_UI_ANIM, pRenderTarget->__pSharedData, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Target VisualElement is not constructed.");
3563 // Forcefully create surface if GetCanvasN is called.
3564 // Without followings, surface may not be created if size of bounds == 0 (the initial size)
3565 if (!HAVE_SURFACE(this))
3567 __needRecreateSurface = true;
3570 pRenderTarget->RebuildHierarchyProps(0, true, true);
3573 SysTryReturn(NID_UI_ANIM, pRenderTarget->GetSharedData().pNativeNode->GetSurface(), null, E_SYSTEM, "[E_INVALID_STATE] Target VisualElement's surface is not constructed.");
3575 SysTryReturn(NID_UI_ANIM, pRenderTarget->GetSharedData().pSurface, null, E_SYSTEM, "[E_INVALID_STATE] Target VisualElement's surface is not constructed.");
3578 FloatRectangle canvasBounds;
3579 FloatRectangle clipBounds;
3582 // Use surface size, not bounds !!!
3584 float canvasX, canvasY, canvasW, canvasH;
3586 if (bounds.width == 0.0f || bounds.height == 0.0f)
3588 float surfaceWidth = __bounds.width;
3589 float surfaceHeight = __bounds.height;
3591 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.");
3600 clipBounds.x = 0.0f;
3601 clipBounds.y = 0.0f;
3602 clipBounds.width = __bounds.width;
3603 clipBounds.height = __bounds.height;
3605 canvasBounds.x = bounds.x;
3606 canvasBounds.y = bounds.y;
3607 canvasBounds.width = bounds.width;
3608 canvasBounds.height = bounds.height;
3610 canvasBounds = canvasBounds.GetIntersection(clipBounds);
3611 pRenderTarget->__pPresentation->ConvertCoordinates(canvasBounds, this->__pPresentation);
3612 canvasBounds = canvasBounds.GetIntersection(pRenderTarget->GetDrawableRect());
3614 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.");
3616 canvasX = canvasBounds.x;
3617 canvasY = canvasBounds.y;
3618 canvasW = canvasBounds.width;
3619 canvasH = canvasBounds.height;
3623 // From now, canvasBounds contains the clipping area, not subcanvas area.
3624 // (0, 0) of the canvas should be placed on the left-top of the VE !
3626 unique_ptr<_VisualElementCanvas> pCanvas(new (std::nothrow) _VisualElementCanvas);
3628 result r = pCanvas->Construct(*pRenderTarget->GetSharedData().pNativeNode->GetSurface(), FloatRectangle(canvasX, canvasY, canvasW, canvasH));
3629 SysTryReturn(NID_UI_ANIM, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] VisualElement is not constructed.");
3631 pRenderTarget->SetFlushNeeded();
3635 return pCanvas.release();
3639 _VisualElementImpl::GetRoot(void) const
3643 if (IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES))
3645 const_cast< _VisualElementImpl* >(this)->RebuildCoordinates();
3652 _VisualElementImpl::GetParent(void) const
3660 _VisualElementImpl::GetChildrenCount(void) const
3664 return __children.GetCount();
3667 Tizen::Base::Collection::IList*
3668 _VisualElementImpl::GetPublicChildrenN(void) const
3670 unique_ptr<Tizen::Base::Collection::ArrayList> pArrayList(new (std::nothrow) Tizen::Base::Collection::ArrayList());
3671 SysTryReturn(NID_UI_ANIM, pArrayList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
3673 int count = __children.GetCount();
3674 SysTryReturn(NID_UI_ANIM, !IsFailed(pArrayList->Construct(count)), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
3676 for (int i = 0; i < count; i++)
3678 const _VisualElementImpl* pChild = __children.GetChildAt(i);
3680 if (likely(pChild) && likely(pChild->__pPublicInstance))
3682 SysTryReturn(NID_UI_ANIM, !IsFailed(pArrayList->Add(*pChild->__pPublicInstance)), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
3688 return pArrayList.release();
3692 _VisualElementImpl::IsChildOf(const _VisualElementImpl& element) const
3696 if (unlikely(this == &element))
3701 if (unlikely(!__pParent))
3706 if (likely(__pParent == &element))
3711 return __pParent->IsChildOf(element);
3715 _VisualElementImpl::SetZOrder(const _VisualElementImpl* pReference, bool above)
3717 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
3718 SysTryReturnResult(NID_UI_ANIM, !pReference || pReference->__pParent, E_INVALID_ARG, "pReference doesn't have parent.");
3719 SysTryReturnResult(NID_UI_ANIM, __pParent, E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement doesn't have a parent.");
3720 SysTryReturnResult(NID_UI_ANIM, __isAllowedTreeModification == true, E_INVALID_OPERATION, "Z-order cannot be modified inside the OnAttached() or OnDetached() method of VisualElementEventListener.");
3722 return __pParent->InsertChild(*this, pReference, above);
3726 _VisualElementImpl::RemoveFromParent(void)
3728 if (likely(__pParent))
3730 __pParent->RemoveChild(*this);
3735 _VisualElementImpl::AddChild(_VisualElementImpl& child)
3737 //SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
3738 SysTryReturnResult(NID_UI_ANIM, child.__pSharedData, E_INVALID_ARG, "Child VisualElement is not constructed.");
3739 SysTryReturnResult(NID_UI_ANIM, child.__isAllowedTreeModification == true, E_INVALID_OPERATION, "Z-order cannot be modified inside the OnAttached() or OnDetached() method of VisualElementEventListener.");
3741 return ChangeZOrder(child, null, true, child._zOrderGroup);
3745 _VisualElementImpl::GetChildIndex(const _VisualElementImpl& child) const
3748 result r = __children.IndexOf(const_cast< _VisualElementImpl* >(&child), index);
3755 // r == E_OUT_OF_RANGE or E_OBJ_NOT_FOUND
3760 * @param[in] group will be changed group of the visualemenet.
3761 * @param[out] belowIndex the index of last item of below group's item.
3762 * @param[out] aboveIndex the index of first item of above group's item.
3764 * if group is lower than __children's lowest item, belowIndex = -1 , aboveIndex = 0
3765 * if group is higher than __children's highest item, belowIndex is last index of children, aboveIndex is 1 bigger than belowIndex.
3768 * B = Z_ORDER_GROUP_ALWAYS_BELOW_BOTTOM // lowest drawing gadget.(Background)
3769 * N = Z_ORDER_GROUP_NORMAL; // level of the default group.
3770 * T = Z_ORDER_GROUP_ALWAYS_ON_TOP; // highest drawing gadget.
3771 * 0 1 2 3 4 5 6 7 8 9
3772 * [B][B][B][N][N][N][N][T][T][T]
3773 * __GetZOrderGroupIndex(Z_ORDER_GROUP_NORMAL, below, above);
3776 * __GetZOrderGroupIndex(Z_ORDER_GROUP_ALWAYS_ON_TOP, below, above);
3779 * __GetZOrderGroupIndex(Z_ORDER_GROUP_ALWAYS_BELOW_BOTTOM, below, above);
3782 * 0 1 2 3 4 5 6 7 8 9
3783 * [B][B][B][B][B][T][T][T][T][T]
3784 * __GetZOrderGroupIndex(Z_ORDER_GROUP_NORMAL, below, above);
3787 * __GetZOrderGroupIndex(Z_ORDER_GROUP_ALWAYS_ON_TOP, below, above);
3790 * __GetZOrderGroupIndex(Z_ORDER_GROUP_ALWAYS_BELOW_BOTTOM, below, above);
3797 _VisualElementImpl::GetZOrderGroupIndex(int group, int& belowIndex, int& aboveIndex) const
3799 int lastIndex = __children.GetCount() - 1;
3800 if (lastIndex < 0) // _children is empty.
3807 if (group < (__children.GetChildAt(0))->_zOrderGroup) // group is lower than __children's lowest item.
3814 if (group > (__children.GetChildAt(lastIndex))->_zOrderGroup) // group is higher than __children's highest item.
3816 belowIndex = lastIndex;
3817 aboveIndex = lastIndex + 1;
3825 if (group >= __children.GetChildAt(i)->_zOrderGroup)
3835 if (group > __children.GetChildAt(i)->_zOrderGroup)
3847 _VisualElementImpl::InsertChild(_VisualElementImpl& child, const _VisualElementImpl* pReference, bool above)
3849 //SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
3850 SysTryReturnResult(NID_UI_ANIM, child.__pSharedData, E_INVALID_ARG, "Child VisualElement is not constructed.");
3851 SysTryReturnResult(NID_UI_ANIM, child.__isAllowedTreeModification == true, E_INVALID_OPERATION, "Z-order cannot be modified inside the OnAttached() or OnDetached() method of VisualElementEventListener.");
3853 int zOrderGroup = child._zOrderGroup;
3855 if (unlikely(pReference))
3857 zOrderGroup = pReference->_zOrderGroup;
3860 return ChangeZOrder(child, pReference, above, zOrderGroup);
3864 _VisualElementImpl::ChangeZOrder(_VisualElementImpl& child, const _VisualElementImpl* pReference, bool above, int group)
3867 int indexReference = -1;
3868 int indexInsert = -1;
3870 bool sameParent = false;
3872 // If not constructed well, disallow attaching !
3874 if (IsChildOf(child) || this == &child || &child == pReference || (pReference && pReference->__pParent != this))
3876 return E_INVALID_ARG;
3879 // TBD: check ownership!!!
3880 if (IS_PRESENTATION(this))
3882 _RootVisualElement* pChildRoot = child.GetRootPublic();
3884 if (GetRootPublic() != null && pChildRoot != GetRootPublic())
3886 child.RebuildNativeNodeTree(*this);
3892 indexReference = GetChildIndex(*pReference);
3893 SysTryReturnResult(NID_UI_ANIM, indexReference >= 0, E_INVALID_ARG, "Invalid argument(s) is used. pReference is not a child of this instance.");
3904 indexReference = __children.GetCount();
3912 int belowIndex, aboveIndex, indexRange;
3914 indexRange = GetZOrderGroupIndex(group, belowIndex, aboveIndex);
3920 else if (indexRange > 0)
3922 indexInsert = __children.GetCount();
3926 if (indexReference <= belowIndex + 1)
3928 indexInsert = belowIndex + 1;
3930 else if (indexReference >= aboveIndex)
3932 indexInsert = aboveIndex;
3936 indexInsert = indexReference;
3939 if (indexInsert < 0)
3945 if (child.__pParent == this) //case 1: move to the same parent. (just changed order )
3949 indexChild = GetChildIndex(child);
3950 SysTryReturn(NID_UI_ANIM, indexChild >= 0,
3951 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. The child(%p) isn't managed by this instance.", &child);
3953 if (indexChild < indexInsert)
3955 indexInsert--; // one of child item is removed so total item index is decreased.
3958 if (indexChild == indexInsert) //same position. don't have to do any action.
3960 child._zOrderGroup = group;
3962 //update presentation zorder group
3963 if (!IS_PRESENTATION(this))
3965 child.UpdatePresentationWhenZOrderChanged(pReference, above);
3970 SysTryReturn(NID_UI_ANIM, RemoveChildWithoutReconfiguring(indexChild, true) == E_SUCCESS,
3971 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Failed to remove a child(%p) from this instance.", &child);
3974 else //case 2: move to the other parent.
3975 { //case 3: child never been attached to the any parent.
3976 if (child.__pParent)
3978 child.__pParent->RemoveChild(child);
3981 // Setting implicit animation to the child.
3982 if (!IS_PRESENTATION(this) && _AnimationManager::GetInstance()->IsImplicitAnimationEnabled() && child.__isImplicitAnimationEnabled)
3984 child.RemoveAnimation(*pVePropActionAttach);
3986 #if defined(SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION)
3987 VisualElementAnimation* pAnimation = child.InvokeCreateAnimationForProperty(*pVePropActionAttach);
3989 VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
3990 SysTryReturn(NID_UI_ANIM, pAnimation != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
3991 pAnimation->SetPropertyName(*pVePropOpacity);
3992 pAnimation->SetStartValue(Variant(0.0f));
3994 if (pAnimation != null)
3996 pAnimation->SetVisualElementAnimationStatusEventListener(null);
3997 (child.GetPublic())->AddAnimation(*pVePropActionAttach, *pAnimation);
4004 child._zOrderGroup = group;
4006 //SysLog(NID_UI_ANIM, "Insert child %p(%d)", &child, indexInsert);
4008 if (!IS_PRESENTATION(this))
4012 VE_DELEGATE(this, InvokeOnChildAttaching, child);
4013 VE_DELEGATE(&child, InvokeOnAttaching, *this);
4017 __children.InsertAt(&child, indexInsert); // need addref -> jobs -> release ...
4018 child.__pParent = this;
4020 child.InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES | HIERARCHY_PROPERTY_OPACITY | HIERARCHY_PROPERTY_SHOWSTATE, true, false);
4022 // propagate child's prop. status to parents
4023 //__InvalidateHierarchyProps(child.__childrenNeedsUpdateProps, false, true);
4024 InvalidateHierarchyProps(child.__childrenNeedsUpdateProps, true, false);
4027 // When no surface, it is needed to invalidated.
4029 if (unlikely(!NEED_SURFACE(&child)))
4031 child.ExposeRectangle(null, true);
4035 // Because tree hierarchy is not a property, VE hierarchy tree changes are not
4036 // notified by property observer. So, we invoke method in presentation VE directly.
4039 if (!IS_PRESENTATION(this))
4041 child.UpdatePresentationWhenZOrderChanged(pReference, above);
4043 if(!sameParent) // when child was moved to same parent, don't have to detach and attach to parent.
4045 if (child.GetSharedData().pEventListener != null)
4047 child.InvokeOnAttached();
4050 if (GetSharedData().pEventListener != null)
4052 InvokeOnChildAttached(child);
4058 if (likely(GetSharedData().pNativeNode) && likely(child.GetSharedData().pNativeNode))
4060 _VisualElementImpl* pReferenceNode = null;
4062 if (indexInsert > 0)
4064 pReferenceNode = __children.GetChildAt(indexInsert - 1);
4067 // exceptional case: the pRefenreceNode is null and indexInsert are more than __children.count() + 1, then this case is something wrong.
4068 // normal case : when pReferenceNode is null , indexInsert has 0 or more small value.
4070 GetSharedData().pNativeNode->InsertChild(
4071 *child.GetSharedData().pNativeNode,
4072 (pReferenceNode ? pReferenceNode->GetSharedData().pNativeNode : null),
4073 (pReferenceNode ? true : false)
4082 _VisualElementImpl::UpdatePresentationWhenCustomPropertyChanged(const String& property, const Variant& value)
4084 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
4085 result r = E_SUCCESS;
4087 if (IS_NEEDED_UPDATE_PRESENTATION(this))
4090 Variant oldV = __pPresentation->InvokeOnGetPropertyRequested(property);
4092 if(CreateImplicitAnimationIfNeeded(property,value,oldV, NULL) == false)
4094 r = __pPresentation->InvokeOnSetPropertyRequested(property, value);
4101 _VisualElementImpl::UpdatePresentationWhenZOrderChanged(const _VisualElementImpl* pReferenceModel, bool above)
4103 if(!IS_MODEL(this) || !__pParent)
4108 _VisualElementImpl* pReferencePresenter = (pReferenceModel ? (pReferenceModel->__pPresentation ? pReferenceModel->__pPresentation : null) : null);
4110 if (likely(__pParent->__pPresentation) && likely(__pPresentation))
4112 __pParent->__pPresentation->ChangeZOrder(*__pPresentation, pReferencePresenter, above, _zOrderGroup);
4119 _VisualElementImpl::RemoveChildWithoutReconfiguring(int indexChild, bool invalidate)
4121 SysTryReturnResult(NID_UI_ANIM, indexChild >= 0 && indexChild < __children.GetCount(), E_OBJ_NOT_FOUND, "There is no VisualElement at %d th index.", indexChild);
4123 _VisualElementImpl* pChild = __children.GetChildAt(indexChild);
4124 SysTryReturnResult(NID_UI_ANIM, pChild, E_OBJ_NOT_FOUND, "There is no VisualElement at %d th index.", indexChild);
4127 //SysLog(NID_UI_ANIM, "Remove child %p(%d)", pChild, indexChild);
4128 __children.RemoveAt(indexChild);
4129 pChild->__pParent = null;
4130 // pChild->__ClearHierarchyInfo();
4133 if (!IS_PRESENTATION(this))
4135 // removed element need not invalidation !
4138 if (NEED_SURFACE(pChild))
4140 pChild->ExposeRectangle(null, false);
4144 pChild->InvalidateVisibleRectToRenderTarget(null);
4150 if (GetSharedData().pNativeNode && pChild->GetSharedData().pNativeNode)
4152 GetSharedData().pNativeNode->RemoveChild(*pChild->GetSharedData().pNativeNode);
4157 // Because some properties such as root, visible rect and etc. can be accessed detached, invalidating is needed here !
4158 // (Will be invalidated again on attaching)
4160 pChild->InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false);
4166 _VisualElementImpl::CreateElementTreeForDetachImplicitAnimation(_VisualElementImpl& child)
4168 result r = E_SYSTEM;
4170 VisualElement* pRoot = child.CreateElementForImplicitAnimationN();
4176 pRoot->_pVisualElementImpl->SetInternal(true);
4178 #if defined(SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION)
4179 VisualElementAnimation* pAnimation = child.InvokeCreateAnimationForProperty(*pVePropActionDetach);
4181 VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
4182 pAnimation->SetPropertyName(*pVePropOpacity);
4183 pAnimation->SetEndValue(Variant(0.0f));
4187 _VisualElementImplicitAnimationEventListener* pListener = new (std::nothrow) _VisualElementImplicitAnimationEventListener();
4190 pAnimation->SetVisualElementAnimationStatusEventListener(pListener);
4192 r = pRoot->AddAnimation(*pVePropActionDetach, *pAnimation);
4200 r = GetPublic()->AttachChild(*pRoot);
4219 _VisualElementImpl::CreateElementForImplicitAnimationN(void) const
4221 VisualElement* pElement = new (std::nothrow) VisualElement(*GetPublic());
4222 if (pElement == null)
4227 result r = pElement->Construct();
4230 pElement->Destroy();
4234 pElement->SetImplicitAnimationEnabled(false);
4236 if (HAVE_SURFACE(this))
4238 VisualElementSurface* pSurface = GetSurfaceN();
4241 pElement->SetSurface(pSurface);
4246 int count = __children.GetCount();
4247 for (int i = 0; i < count; i++)
4249 _VisualElementImpl* pVisualElementImpl = __children.GetChildAt(i);
4250 if (likely(pVisualElementImpl))
4252 r = pElement->AttachChild(*pVisualElementImpl->CreateElementForImplicitAnimationN());
4253 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4266 _VisualElementImpl::RemoveChild(_VisualElementImpl& child, bool deallocate)
4268 //SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
4269 SysTryReturnResult(NID_UI_ANIM, child.__isAllowedTreeModification == true, E_INVALID_OPERATION, "Z-order cannot be modified inside the OnAttached() or OnDetached() method of VisualElementEventListener.");
4271 int indexChild = GetChildIndex(child);
4272 SysTryReturnResult(NID_UI_ANIM, indexChild >= 0, E_OBJ_NOT_FOUND, "child is not a child of this instance.");
4274 if (!IS_PRESENTATION(this))
4277 VE_DELEGATE(this, InvokeOnChildDetaching, child);
4279 // IMPORTANT! When destroying, don't have to invoke OnDetached and OnDetaching after invoked OnDestructing.
4280 // call OnDestructing -> call OnDetaching it is ambiguous operation
4281 // it is called by RemoveFromParent() method, so pChild is destroying currently.
4282 if (!child.__isDestroying)
4284 VE_DELEGATE(&child, InvokeOnDetaching);
4288 result r = RemoveChildWithoutReconfiguring(indexChild, true);
4289 if (unlikely(r != E_SUCCESS))
4291 return E_OBJ_NOT_FOUND;
4294 if (!IS_PRESENTATION(this) && (_AnimationManager::GetInstance()->IsImplicitAnimationEnabled()
4295 && child.__isImplicitAnimationEnabled) && child.IsAncestorDestroying() == false)
4297 r = CreateElementTreeForDetachImplicitAnimation(child);
4298 if (unlikely(r != E_SUCCESS))
4300 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Dummy VisualElement cannot be attached.");
4305 // Because tree hierarchy is not a property, VE hierarchy tree changes are not
4306 // notified by property observer. So, we invoke method in presentation VE directly.
4308 if (!IS_PRESENTATION(this))
4311 if (likely(__pPresentation) && likely(child.GetPresentation()))
4313 __pPresentation->RemoveChild(*child.GetPresentation(), deallocate);
4316 // IMPORTANT! When destroying, don't have to invoke OnDetached and OnDetaching after invoked OnDestructing.
4317 // call OnDestructing -> call OnDetaching it is ambiguous operation
4318 // it is called by RemoveFromParent() method, so pChild is destroying currently.
4319 if (!child.__isDestroying && child.GetSharedData().pEventListener != null)
4321 child.InvokeOnDetached(*this);
4324 if (GetSharedData().pEventListener != null)
4326 InvokeOnChildDetached(child);
4338 _VisualElementImpl::RemoveAllChild(void)
4340 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
4346 _VisualElementImpl::RebuildNativeNodeTree(_VisualElementImpl& parent)
4348 if (!IS_PRESENTATION(this))
4353 _INativeNode* pNode = GetNativeNode();
4354 _INativeNode* pParentNode = parent.GetNativeNode();
4356 if (!pNode || !pParentNode)
4361 pNode->RebuildIfNeeded(*pParentNode);
4363 //TODO : must check ,don't you need to rebuild???
4364 // RebuildCoordinates();
4366 const int nativeProps = _VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES
4367 | _VisualElementImpl::HIERARCHY_PROPERTY_OPACITY
4368 | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY
4369 | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS;
4372 InvalidateHierarchyProps(nativeProps, false, false);
4374 int count = __children.GetCount();
4375 for ( int i = 0 ; i < count ; i++ )
4377 _VisualElementImpl* pVe = __children.GetChildAt(i);
4380 pVe->RebuildNativeNodeTree(*this);
4381 _INativeNode* pChildNode = pVe->GetNativeNode();
4382 pNode->InsertChild(*pChildNode,null, true);
4390 _VisualElementImpl::GetName(void) const
4394 return GetSharedData().name;
4398 _VisualElementImpl::SetName(const Tizen::Base::String& name)
4400 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
4401 result r = InvokeOnSetPropertyRequested(*pVePropName, Variant(name));
4402 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
4408 _VisualElementImpl::GetNameProperty(void) const
4412 return Variant(GetSharedData().name);
4416 _VisualElementImpl::SetNameProperty(const Variant& v)
4418 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_STRING, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
4420 const Tizen::Base::String& name = v.ToString();
4421 if (name == GetSharedData().name)
4426 GetSharedData().name = name;
4432 _VisualElementImpl::SetUserData(void* pUserData)
4434 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
4436 GetSharedData().pUserData = pUserData;
4442 _VisualElementImpl::GetUserData(void) const
4446 return GetSharedData().pUserData;
4450 _VisualElementImpl::GetChild(const Tizen::Base::String& name, bool searchAllDescendants) const
4454 int count = __children.GetCount();
4456 // for performance, look children directly
4457 for (int i = 0; i < count; i++)
4459 const _VisualElementImpl* pChild = __children.GetChildAt(i);
4460 if (unlikely(pChild->GetSharedData().name == name))
4462 return const_cast< _VisualElementImpl* >(pChild);
4466 if (searchAllDescendants)
4468 for (int i = 0; i < count; i++)
4470 const _VisualElementImpl* pChild = __children.GetChildAt(i)->GetChild(name, true);
4473 return const_cast< _VisualElementImpl* >(pChild);
4478 SetLastResult(E_OBJ_NOT_FOUND);
4484 _VisualElementImpl::GetVisibleRect(void) const
4486 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
4488 if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
4489 pThis->RebuildCoordinates();
4492 return FloatRectangle();
4494 if (likely(__visibleRectValid))
4495 return __visibleRect;
4499 FloatRectangle parentVisibleRect(__pClipSource->GetVisibleRect());
4500 ConvertCoordinates(parentVisibleRect, __pClipSource);
4501 pThis->__visibleRect = parentVisibleRect.GetIntersection(__visibleRect);
4504 pThis->__visibleRectValid = true;
4506 return __visibleRect;
4510 _VisualElementImpl::GetDrawableRect(void) const
4512 // If VE has backing-buffer, visible status is not important for drawing...
4513 bool needSurface = NEED_SURFACE(this);
4515 if (unlikely(!needSurface))
4517 return FloatRectangle();
4520 if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
4522 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
4523 pThis->RebuildCoordinates();
4527 // Even when surface exists, the size might be invalidated by changing bounds.
4529 if (HAVE_SURFACE(this) && GetSharedData().fixedSurfaceSize)
4531 return FloatRectangle(0.0f, 0.0f, GetSharedData().pSurface->GetSizeF().width, GetSharedData().pSurface->GetSizeF().height);
4534 return FloatRectangle(0.0f, 0.0f, __bounds.width, __bounds.height);
4538 _VisualElementImpl::GetOpacityFromRoot(void) const
4540 float opacity = __contentOpacity * __opacity * __showOpacity;
4541 const _VisualElementImpl* pElement = __pParent;
4544 if (!VE_VISIBLE(pElement))
4549 opacity *= pElement->__opacity * pElement->__showOpacity;
4550 pElement = pElement->__pParent;
4556 const FloatRectangle&
4557 _VisualElementImpl::GetBoundingBoxI(void) const
4559 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
4561 if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
4563 pThis->RebuildCoordinates();
4566 if (unlikely(!__boundingBoxValid))
4568 float x[4] = { 0.0f, __bounds.width, 0.0f, __bounds.width };
4569 float y[4] = { 0.0f, 0.0f, __bounds.height, __bounds.height };
4570 CalculateBoundingBox(x, y, pThis->__boundingBox);
4572 pThis->__boundingBoxValid = true;
4575 return __boundingBox;
4579 _VisualElementImpl::GetMatrixToSuper(void) const
4581 if (unlikely(__matrixToSuperValid))
4582 return __matrixToSuper;
4584 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
4586 pThis->__matrixToSuperValid = true;
4588 if (unlikely(__pParent == null))
4590 _MatrixUtilSetIdentity(pThis->__matrixToSuper);
4591 return __matrixToSuper;
4594 const bool needSurface = NEED_SURFACE(this);
4596 // apply subprojection && translation
4597 if (likely(needSurface))
4599 MatrixUtilCopy(pThis->__matrixToSuper, __pParent->__childrenTransform);
4600 _MatrixUtilTranslate(pThis->__matrixToSuper, __bounds.x, __bounds.y, __zPosition);
4604 _MatrixUtilSetTranslation(pThis->__matrixToSuper, __bounds.x, __bounds.y, __zPosition);
4609 if (likely(needSurface))
4611 if (likely(__decomposedTransform.GetMatrixType() != MATRIX4_Identity))
4613 bool needAnchor = (unlikely(__anchorZ != 0.0f) || unlikely(__anchor.x != 0.0f) || unlikely(__anchor.y != 0.0f));
4614 if (unlikely(needAnchor))
4615 _MatrixUtilTranslate(pThis->__matrixToSuper, __anchor.x * __bounds.width, __anchor.y * __bounds.height, __anchorZ);
4617 _MatrixUtilMultiply(pThis->__matrixToSuper, __matrixToSuper, __transform);
4619 if (unlikely(needAnchor))
4620 _MatrixUtilTranslate(pThis->__matrixToSuper, -__anchor.x * __bounds.width, -__anchor.y * __bounds.height, -__anchorZ);
4624 return __matrixToSuper;
4628 _VisualElementImpl::GetMatrixToTop(void) const
4630 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
4632 if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
4634 pThis->RebuildCoordinates();
4638 if (unlikely(!__matrixToTopValid))
4640 _MatrixUtilMultiply(pThis->__matrixToTop, __pParent->GetMatrixToTop(), GetMatrixToSuper());
4641 pThis->__matrixToTopValid = true;
4644 return __matrixToTop;
4648 _VisualElementImpl::GetMatrixFromTop(void) const
4650 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
4652 if (IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES))
4654 pThis->RebuildCoordinates();
4657 if (!__matrixFromTopValid)
4659 MatrixUtilCopy(pThis->__matrixFromTop, GetMatrixToTop());
4660 pThis->__matrixFromTopInvertible = _MatrixUtilInvert(pThis->__matrixFromTop);
4661 pThis->__matrixFromTopValid = true;
4664 return __matrixFromTop;
4668 _VisualElementImpl::CalcMatrixToBase(const _VisualElementImpl& base) const
4671 return FloatMatrix4();
4673 FloatMatrix4 matrixToBase(GetMatrixToSuper());
4675 const _VisualElementImpl* pParent = GetParent();
4678 pParent = pParent->GetParent();
4681 _MatrixUtilMultiply(matrixToBase, pParent->GetMatrixToSuper(), matrixToBase);
4682 pParent = pParent->GetParent();
4686 return matrixToBase;
4690 _VisualElementImpl::GetMatrixToClipSource(void) const
4692 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
4694 if (IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES))
4696 pThis->RebuildCoordinates();
4700 if (unlikely(!__matrixToClipSourceValid))
4702 if (likely(__pParent))
4704 if (__pParent->__isClipChildren)
4706 MatrixUtilCopy(pThis->__matrixToClipSource, GetMatrixToSuper());
4710 _MatrixUtilMultiply(pThis->__matrixToClipSource, __pParent->GetMatrixToClipSource(), GetMatrixToSuper());
4715 _MatrixUtilSetIdentity(pThis->__matrixToClipSource);
4718 pThis->__matrixToClipSourceValid = true;
4721 return __matrixToClipSource;
4725 _VisualElementImpl::InvalidateVisibleRectToRenderTarget(const FloatRectangle* pDirtyRectangle)
4727 if (unlikely(GetSharedData().invalidationLockCount > 0))
4730 if (!IsDrawingObject())
4733 FloatRectangle bounds;
4735 bounds = __pPresentation->GetVisibleRect();
4736 if (pDirtyRectangle)
4738 bounds = bounds.GetIntersection(*pDirtyRectangle);
4741 if (!bounds.IsEmpty())
4743 _VisualElementImpl* pRenderTarget = __pPresentation->GetRenderTarget();
4746 pRenderTarget->ConvertCoordinates(bounds, this);
4747 pRenderTarget->InvalidateRectangleI(&bounds);
4753 _VisualElementImpl::RebuildCoordinates(void)
4755 if (unlikely(!IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
4760 SetPropsValidaty(HIERARCHY_PROPERTY_COORDINATES, 0);
4762 __visibleRect.x = 0.0f;
4763 __visibleRect.y = 0.0f;
4764 __visibleRect.width = __bounds.width;
4765 __visibleRect.height = __bounds.height;
4768 if (unlikely(!__pParent))
4771 // Need to allowing transform to root element !
4773 _MatrixUtilSetIdentity(__matrixToTop);
4774 _MatrixUtilSetIdentity(__matrixFromTop);
4775 _MatrixUtilSetIdentity(__matrixToClipSource);
4776 __pClipSource = null;
4780 RectUtilCopy(__boundingBox, __bounds);
4781 RectUtilCopy(__boundingBoxToClipSource, __bounds);
4783 _RootVisualElement* pRoot = dynamic_cast< _RootVisualElement* >(__pPublicInstance);
4787 __pRoot = pRoot->_pVisualElementImpl;
4794 __needTransform = false;
4795 __needClipForUntransformed = false;
4798 __matrixFromTopValid = true;
4799 __matrixToTopValid = true;
4800 __matrixToClipSourceValid = true;
4801 __matrixToSuperValid = true;
4803 __boundingBoxValid = true;
4804 __visibleRectValid = true;
4808 if (unlikely(__pParent->IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
4810 __pParent->RebuildCoordinates();
4813 __pRoot = __pParent->__pRoot;
4815 Matrix4Type transformType = __decomposedTransform.GetMatrixType();
4816 const Matrix4Type parentChildrenTransformType = __pParent->__decomposedChildrenTransform.GetMatrixType();
4818 if (parentChildrenTransformType > MATRIX4_Translation)
4819 transformType = MATRIX4_Generic;
4822 if (unlikely(__pParent->__isClipChildren))
4824 __pClipSource = __pParent;
4826 __needTransform = (transformType > MATRIX4_Translation);
4827 if (likely(!__needTransform))
4829 __boundingBoxToClipSource.x = __bounds.x + __transform.matrix[3][0];
4830 __boundingBoxToClipSource.y = __bounds.y + __transform.matrix[3][1];
4831 __boundingBoxToClipSource.width = __bounds.width;
4832 __boundingBoxToClipSource.height = __bounds.height;
4837 __pClipSource = __pParent->__pClipSource;
4839 if (unlikely(transformType > MATRIX4_Translation))
4840 __needTransform = true;
4842 __needTransform = __pParent->__needTransform;
4844 if (likely(!__needTransform))
4846 __boundingBoxToClipSource.x = __pParent->__boundingBoxToClipSource.x + __bounds.x + __transform.matrix[3][0];
4847 __boundingBoxToClipSource.y = __pParent->__boundingBoxToClipSource.y + __bounds.y + __transform.matrix[3][1];
4848 __boundingBoxToClipSource.width = __bounds.width;
4849 __boundingBoxToClipSource.height = __bounds.height;
4851 if (unlikely(parentChildrenTransformType == MATRIX4_Translation))
4853 __boundingBoxToClipSource.x += __pParent->__childrenTransform.matrix[3][0];
4854 __boundingBoxToClipSource.y += __pParent->__childrenTransform.matrix[3][1];
4860 if (likely(!__needTransform))
4862 if (unlikely(parentChildrenTransformType == MATRIX4_Translation))
4864 __boundingBoxToClipSource.x += __pParent->__childrenTransform.matrix[3][0];
4865 __boundingBoxToClipSource.y += __pParent->__childrenTransform.matrix[3][1];
4869 __needClipForUntransformed = __pParent->__needClipForUntransformed;
4870 if (likely(!__needClipForUntransformed) && likely(__pClipSource))
4872 if (likely(__boundingBoxToClipSource.x >= 0.0f) &&
4873 likely(__boundingBoxToClipSource.y >= 0.0f) &&
4874 likely(__boundingBoxToClipSource.x + __boundingBoxToClipSource.width <= __pClipSource->__bounds.width) &&
4875 likely(__boundingBoxToClipSource.y + __boundingBoxToClipSource.height <= __pClipSource->__bounds.height))
4876 __needClipForUntransformed = false;
4878 __needClipForUntransformed = true;
4882 __needClipForUntransformed = true;
4886 __matrixFromTopValid = false;
4887 __matrixToTopValid = false;
4888 __matrixToClipSourceValid = false;
4889 __matrixToSuperValid = false;
4891 __boundingBoxValid = false;
4892 __visibleRectValid = false;
4897 _VisualElementImpl::RebuildVisibility(void)
4899 const int mask = HIERARCHY_PROPERTY_COORDINATES | HIERARCHY_PROPERTY_SHOWSTATE | HIERARCHY_PROPERTY_OPACITY | HIERARCHY_PROPERTY_CONTENTOPACITY;
4901 if (unlikely(!IsPropsInvalidated(mask)))
4906 if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
4908 RebuildCoordinates();
4912 SetPropsValidaty(mask, 0);
4914 if (unlikely(!__pParent))
4917 // Need to allowing transform to root element !
4920 __isVisible = false;
4922 __isVisible = VE_VISIBLE(this);
4926 if (unlikely(__pParent->IsPropsInvalidated(mask)))
4928 __pParent->RebuildVisibility();
4931 if (likely(__pParent->__isVisible))
4932 __isVisible = VE_VISIBLE(this);
4934 __isVisible = false;
4939 _VisualElementImpl::LockInvalidate(bool lock)
4941 GetSharedData().LockInvalidate(lock);
4945 _VisualElementImpl::InvalidateHierarchyPropsDownward(int invalidProps, bool broadcastToChildren, bool propagateToParentsOnly)
4947 invalidProps &= HIERARCHY_PROPERTY_MASK;
4949 __childrenNeedsUpdateProps |= invalidProps;
4951 if (likely(!propagateToParentsOnly))
4953 SetPropsValidaty(0, invalidProps);
4955 if (likely(invalidProps & HIERARCHY_PROPERTY_COORDINATES))
4957 __matrixFromTopValid = false;
4958 __matrixToSuperValid = false;
4959 __boundingBoxValid = false;
4963 if (unlikely(!broadcastToChildren))
4968 int count = __children.GetCount();
4969 for (int i = 0; i < count; i++)
4971 __children.GetChildAt(i)->InvalidateHierarchyPropsDownward(invalidProps, broadcastToChildren, propagateToParentsOnly);
4974 // may need update some attribute variables for other hierarchy properties
4979 _VisualElementImpl::InvalidateHierarchyProps(int invalidProps, bool broadcastToChildren, bool propagateToParentsOnly)
4981 invalidProps &= HIERARCHY_PROPERTY_MASK;
4983 // // For model tree, it is not needed to invalidate children-opacity and show-state
4984 // if (!IS_PRESENTATION(this))
4986 // invalidProps &= ~(HIERARCHY_PROPERTY_OPACITY | HIERARCHY_PROPERTY_SHOWSTATE);
4989 if (unlikely(!invalidProps))
4994 InvalidateHierarchyPropsDownward(invalidProps, broadcastToChildren, propagateToParentsOnly);
4996 _VisualElementImpl* pElement = __pParent; // WARNING: 'this' is updated in '__InvalidateHierarchyPropsDownward'
4999 pElement->__childrenNeedsUpdateProps |= invalidProps;
5000 pElement = pElement->__pParent;
5004 // HIERARCHY_PROPERTY_CONTENT is not handled here, but in drawing logic
5006 _VisualElementImpl::RebuildHierarchyProps(int props, bool checkSurface, bool reconfSurfaceOnly)
5008 if (likely(__pParent) && (unlikely(__pParent->IsPropsInvalidated(props)) || unlikely(__pParent->GetSharedData().NeedNativeReconfigure())))
5011 // 'checkSurface' for parent will make surface !
5012 __pParent->RebuildHierarchyProps(props, false, false);
5016 // TBD: Recreating surface may have to be done in presentation layer (thread!)
5017 if (unlikely(checkSurface))
5019 if (likely(IsDrawingObject()))
5021 ResetSurfaceIfNeeded(); // may invalidate GetSharedData().surfaceChanged
5025 const bool needApplyNatives = GetSharedData().NeedNativeReconfigure();
5027 props &= HIERARCHY_PROPERTY_MASK;
5028 if (unlikely(!IsPropsInvalidated(props)) && likely(!checkSurface) && unlikely(needApplyNatives == 0))
5033 if (likely(props & HIERARCHY_PROPERTY_CONTENTBOUNDS) && likely(IsPropsInvalidated(HIERARCHY_PROPERTY_CONTENTBOUNDS)))
5035 SetPropsValidaty(HIERARCHY_PROPERTY_CONTENTBOUNDS, 0);
5038 if (likely(props & HIERARCHY_PROPERTY_COORDINATES) && likely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
5040 RebuildCoordinates();
5041 //__SetPropsValidaty(HIERARCHY_PROPERTY_COORDINATES, 0); --> need not. __RebuildCoordinates will validate.
5045 // 'Visibility' should be checked after validating tree-hierarchy information.
5046 // (For example, attaching/detaching may affect visibility.)
5047 const int mask = HIERARCHY_PROPERTY_OPACITY | HIERARCHY_PROPERTY_SHOWSTATE | HIERARCHY_PROPERTY_CONTENTOPACITY;
5048 if (unlikely((props & mask) != 0) && unlikely(IsPropsInvalidated(props & mask)))
5050 RebuildVisibility();
5053 if (likely(__pPresentation) && likely(needApplyNatives))
5055 if (unlikely(!IS_PRESENTATION(this)))
5058 // In model, native nodes are updated only when the surface was changed.
5059 //if (unlikely(GetSharedData().surfaceChanged))
5061 __pPresentation->FlushNativeChanges();
5066 GetSharedData().NodeReconfigure(*__pPresentation, false);
5072 _VisualElementImpl::FlushNativeChanges(void)
5074 if (unlikely(!IS_PRESENTATION(this)))
5077 if (likely(__pPresentation))
5078 GetSharedData().NodeReconfigure(*__pPresentation, false);
5082 _VisualElementImpl::UpdateHierarchyProps(void)
5085 // HIERARCHY_PROPERTY_CONTENT is not handled here, but in drawing logic.
5086 const int mask = HIERARCHY_PROPERTY_MASK;
5088 if (unlikely((__childrenNeedsUpdateProps & mask) == 0 && GetSharedData().childrenSurfaceChanged == false))
5091 // Node will be reconfigured later(before OnDraw, or DrawRectangle, ...)
5092 if (likely(IsPropsInvalidated(mask)) || likely(GetSharedData().NeedNativeReconfigure()))
5093 RebuildHierarchyProps(mask, false, false);
5096 // __childrenNeedsUpdateProps should be cleared *ONLY AFTER* flushing native nodes !
5097 __childrenNeedsUpdateProps &= ~mask;
5098 GetSharedData().childrenSurfaceChanged = false;
5100 int count = __children.GetCount();
5101 for (int i = 0; i < count; i++)
5103 _VisualElementImpl* pChild = __children.GetChildAt(i);
5104 if (likely((pChild->__childrenNeedsUpdateProps & mask) != 0 || pChild->GetSharedData().childrenSurfaceChanged == true))
5105 pChild->UpdateHierarchyProps();
5110 _VisualElementImpl::ExposeRectangle(const FloatRectangle* pDirtyRectangle, bool invalidate)
5112 if (unlikely(!IsDrawingObject()))
5115 if (unlikely(invalidate))
5117 InvalidateRectangleI(pDirtyRectangle);
5122 _VisualElementImpl::SetFlushNeeded(void)
5124 FloatRectangle rect;
5126 if (!IS_PRESENTATION(this))
5128 return __pPresentation->SetFlushNeeded();
5132 rect.SetPosition(0.0f, 0.0f);
5134 if (likely(HAVE_SURFACE(this)))
5136 GetSharedData().pNativeNode->SetFlushNeeded();
5140 _VisualElementImpl* pRenderTarget = GetRenderTarget();
5142 if (likely(pRenderTarget && pRenderTarget->GetSharedData().pNativeNode))
5144 pRenderTarget->ConvertCoordinates(rect, this);
5145 pRenderTarget->GetSharedData().pNativeNode->SetFlushNeeded();
5153 _VisualElementImpl::Flush(void)
5155 if (likely(GetSharedData().pNativeNode))
5157 GetSharedData().pNativeNode->Flush();
5164 _VisualElementImpl::InvalidateRectangle(const FloatRectangle* pRectangle)
5166 return InvalidateRectangleI(pRectangle);
5170 _VisualElementImpl::InvalidateRectangleI(const FloatRectangle* pRectangle)
5172 SysTryReturnResult(NID_UI_ANIM, !GetSharedData().fixedSurfaceSize, E_INVALID_OPERATION, "VisualElement with User-Surface do not allow invalidating and redrawing.");
5173 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "Invalidating VisualElement should be performed on a model layer.");
5175 if (unlikely(GetSharedData().invalidationLockCount > 0))
5180 FloatRectangle invRect;
5182 if (unlikely(pRectangle))
5184 if (unlikely(pRectangle->IsEmpty()))
5189 invRect = *pRectangle;
5194 invRect.SetPosition(0.0f, 0.0f);
5197 if (unlikely(invRect.IsEmpty()))
5204 // 'GetUnion' method will not behave as our intention.
5205 // If the parameter or self is empty, the union of rectangle should ignore it !
5206 //invRect = GetSharedData().invalidatedRegion.GetUnion(invRect);
5207 RectUtilUnion(invRect, GetSharedData().invalidatedRegion);
5211 // If new requested invalidate region is already included currently,
5212 // we can skip the following calculations (but invalidating flags are STILL needed !)
5214 _VisualElementImpl* pRenderTarget = GetRenderTarget();
5216 if (likely(pRenderTarget == this))
5218 // Make invalidated area a bit larger to be aligned on the render target
5219 RectUtilMakeIntegral(invRect);
5222 GetSharedData().invalidatedRegion = invRect;
5224 _VisualElementImpl* pElement = this;
5227 pElement->GetSharedData().childrenInvalidated = true;
5228 pElement = pElement->GetParent();
5230 SetRootNeedsContentUpdate();
5236 _VisualElementImpl::GetInvalidatedRectangle(void) const
5240 if (IS_PRESENTATION(this))
5244 return __pModel->GetInvalidatedRectangle();
5248 return GetSharedData().invalidatedRegion;
5252 _VisualElementImpl::GetUpdateRectangle(void) const
5256 return GetSharedData().updateRegion;
5260 _VisualElementImpl::IsOpaque(void) const
5264 if (HAVE_SURFACE(this))
5266 return IsSurfaceOpaque();
5273 _VisualElementImpl::Draw(void)
5275 SysTryReturnResult(NID_UI_ANIM, IS_ATTACHED(this), E_INVALID_STATE, "Drawing VisualElement should be attached to the root tree.");
5276 if (!IS_MODEL(this))
5278 //SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
5282 // Not a good position to apply property changes into native(EFL) system.
5283 // Because of no-compositor in VE, we cannot control each element's
5284 // visibilities (show-state, bounds, opacity, etc.) !
5285 // Is there any good idea ?
5287 // if (IS_PRESENTATION(this))
5288 // __UpdateHierarchyProps();
5290 if (unlikely(GetSharedData().childrenInvalidated))
5292 // if (unlikely(!IS_PRESENTATION(this)))
5293 // __UpdateHierarchyProps();
5296 // Drawing must be done from first opaque.
5297 // But, because we assume all VE's are transparent, all drawings are done from root !!!
5299 _VisualElementImpl* pRenderTarget = GetRenderTarget();
5300 bool needFullScreenDraw = __isRoot;
5302 if (unlikely(!pRenderTarget))
5304 // On no render target, flush invalidated area from root
5305 pRenderTarget = GetRoot();
5306 SysTryReturnResult(NID_UI_ANIM, pRenderTarget, E_SYSTEM, "A system error has been occurred. This VisualElement doesn't have rendering target.");
5307 needFullScreenDraw = true;
5312 // To minimize drawing area(with clip), use '__DrawRectangleIfNeeded'
5313 // To reduce drawing calls such as 'OnDraw', use '__DrawRectangle' directly
5315 int maxScreenSize = _Max(_VisualElementCoordinateSystem::logScreenWidth, _VisualElementCoordinateSystem::logScreenHeight);
5316 pRenderTarget->DrawRectangleIfNeeded(
5317 needFullScreenDraw ? FloatRectangle(0.0f, 0.0f, maxScreenSize, maxScreenSize) : GetDrawableRect()
5321 if (IS_PRESENTATION(this))
5322 UpdateHierarchyProps();
5328 _VisualElementImpl::DrawForAnimation(void)
5330 if (!IS_ATTACHED(this))
5335 if (unlikely(GetSharedData().childrenInvalidated))
5337 _VisualElementImpl* pRenderTarget = GetRenderTarget();
5338 pRenderTarget->DrawRectangle(GetSharedData().invalidatedRegion);
5340 if (likely(GetSharedData().childrenInvalidated == false))
5345 _VisualElementImpl* pChild = null;
5346 bool childrenNeedUpdate = false;
5347 int count = __children.GetCount();
5348 for (int i = 0; i < count; i++)
5350 pChild = __children.GetChildAt(i);
5351 if (!pChild || (pChild->GetSharedData().childrenInvalidated == false))
5356 pChild->DrawForAnimation();
5358 if ((pChild->GetSharedData().childrenInvalidated))
5360 childrenNeedUpdate = true;
5364 // update 'needUpdate' flag regarding children only if no invalidated-region
5365 if (GetSharedData().invalidatedRegion.IsEmpty())
5367 if (childrenNeedUpdate)
5369 GetSharedData().childrenInvalidated = true;
5378 _VisualElementImpl::DrawRectangleIfNeeded(const FloatRectangle& drawRect)
5380 if (unlikely(!IsVisibleI()) || GetSharedData().childrenInvalidated == false)
5386 // VE with surface redraws *ALL INVALIDATED* region !! --> TBD: make an option/flags for this???
5388 FloatRectangle drawableRect;
5390 if (NEED_SURFACE(this))
5393 // Redraw only if the request has some valid region to draw.
5394 drawableRect = GetDrawableRect();
5395 if (!drawRect.IsIntersected(drawableRect))
5396 drawableRect.SetSize(0.0f, 0.0f); // Make empty
5400 drawableRect = drawRect;
5403 DrawRectangle(drawableRect.GetIntersection(GetSharedData().invalidatedRegion));
5406 // needUpdate flag may be 'true' after drawring invalidated region.
5407 // This means that some children still need to be updated !
5409 if (likely(GetSharedData().childrenInvalidated == false))
5415 // Some children still need to update in case that invalidated rect of this
5416 // is smaller than 'drawRect' which can overlap the invalid rect of children
5420 // Because user can do anything in drawing logic,
5421 // adding-reference may be safe.......
5423 _VisualElementImpl* pChild = null;
5424 FloatRectangle updateRect, childBounds;
5425 bool childrenNeedUpdate = false;
5426 int count = __children.GetCount();
5427 for (int i = 0; i < count; i++)
5429 pChild = __children.GetChildAt(i);
5430 if (!pChild || pChild->GetSharedData().childrenInvalidated == false)
5437 // Draw all children with surface.
5438 // Children with empty invalidated region will ignore re-drawing.
5440 updateRect = drawRect;
5441 pChild->ConvertCoordinates(updateRect, this);
5443 if (likely(NEED_SURFACE(pChild)))
5445 pChild->DrawRectangleIfNeeded(updateRect);
5449 childBounds = pChild->__pPresentation->__bounds;
5450 childBounds.SetPosition(0.0f, 0.0f);
5451 updateRect = updateRect.GetIntersection(childBounds);
5452 if (unlikely(!updateRect.IsEmpty()))
5453 pChild->DrawRectangleIfNeeded(updateRect);
5456 if (pChild->GetSharedData().childrenInvalidated)
5458 childrenNeedUpdate = true;
5462 // update 'needUpdate' flag regarding children only if no invalidated-region
5463 if (GetSharedData().invalidatedRegion.IsEmpty())
5465 if (childrenNeedUpdate)
5467 GetSharedData().childrenInvalidated = true;
5472 // TODO: change name(remove 'rectangle')
5474 _VisualElementImpl::DrawRectangle(const FloatRectangle& drawRect)
5476 if (unlikely(!GetRootPublic()) || unlikely(drawRect.IsEmpty()))
5481 //SysLog(NID_UI_ANIM, "DrawRectangle");
5483 bool needDraw = false;
5484 bool fullValidated = false;
5485 FloatRectangle drawableRect(GetDrawableRect());
5486 FloatRectangle drawRectVisible(drawRect.GetIntersection(drawableRect));
5487 FloatRectangle invalidatedRectVisible(GetSharedData().invalidatedRegion.GetIntersection(drawableRect));
5489 if (unlikely(!drawRectVisible.IsEmpty()))
5492 // Draw full-invalidated-content (not partial) if VE has surface.
5493 if (likely(NEED_SURFACE(this)))
5494 drawRectVisible = drawableRect;
5501 // Make dirty/draw area a bit larger to be pixel-aligned and prevent drawing-artifacts caused by float-error.
5502 RectUtilMakeIntegral(drawRectVisible);
5503 RectUtilMakeIntegral(invalidatedRectVisible);
5505 // DO NOT USE drawRectVisible.Contains(invalidatedRectVisible))
5506 if (invalidatedRectVisible.IsEmpty() || (drawRectVisible.x <= invalidatedRectVisible.x &&
5507 drawRectVisible.y <= invalidatedRectVisible.y &&
5508 drawRectVisible.x + drawRectVisible.width >= invalidatedRectVisible.x + invalidatedRectVisible.width &&
5509 drawRectVisible.y + drawRectVisible.height >= invalidatedRectVisible.y + invalidatedRectVisible.height))
5511 fullValidated = true;
5517 // VisualElement with User-Set surface does not allow invalidating and redrawing.
5518 // Because there should be no invalidated region in this case, checking User-Surface may redundant.
5520 if (GetSharedData().fixedSurfaceSize)
5523 fullValidated = true;
5524 drawRectVisible = GetSharedData().invalidatedRegion;
5529 // Set update region before 'CanDraw' and 'OnDraw' delegations to check real-update region
5531 GetSharedData().updateRegion = drawRectVisible;
5536 // Clear *BEFORE* drawing because 'OnDraw' may add invalidated regions...
5538 GetSharedData().invalidatedRegion.SetBounds(0.0f, 0.0f, 0.0f, 0.0f); // SetEmpty()
5539 GetSharedData().childrenInvalidated = false;
5545 if (!VE_DELEGATE(this, InvokePrepareDraw))
5553 Canvas* pCanvas = GetCanvasN();
5557 result r = pCanvas->SetClipBounds(FloatRectangle(drawRectVisible.x,
5559 drawRectVisible.width,
5560 drawRectVisible.height));
5563 SysLogException(NID_UI_ANIM, r, "[%s] Failed to set clip-bounds on canvas", GetErrorMessage(r));
5566 VE_DELEGATE(this, InvokeOnDraw, *pCanvas);
5571 // Flushing canvas is done at GetCanvasN.
5577 // Clear update region after drawing
5578 GetSharedData().updateRegion.SetBounds(0.0f, 0.0f, 0.0f, 0.0f);
5582 // Because user can do anything in drawing logic,
5583 // adding-reference/copying-list may be safe.......
5585 _VisualElementImpl* pChild = null;
5586 int count = __children.GetCount();
5587 bool childrenNeedUpdate = false;
5588 FloatRectangle childBounds;
5589 for (int i = 0; i < count; i++)
5591 pChild = __children.GetChildAt(i);
5592 if (likely(!NEED_SURFACE(pChild)))
5594 drawRectVisible = drawRect;
5595 pChild->ConvertCoordinates(drawRectVisible, this);
5596 childBounds = pChild->__pPresentation->__bounds;
5598 childBounds.SetPosition(0.0f, 0.0f);
5600 drawRectVisible = drawRectVisible.GetIntersection(childBounds);
5601 if (likely(!drawRectVisible.IsEmpty()))
5602 pChild->DrawRectangle(drawRectVisible);
5605 if (pChild->GetSharedData().childrenInvalidated)
5607 childrenNeedUpdate = true;
5612 // If not all children have been validated during update,
5613 // we should not clear update flag to flush them later.
5615 if (childrenNeedUpdate)
5617 GetSharedData().childrenInvalidated = true;
5621 // for a cumstom property animation
5623 _VisualElementImpl::SetPropertyI(const String& property, const Variant& value)
5625 result r = E_SUCCESS;
5627 if (likely(__pPublicInstance))
5629 r = __pPublicInstance->OnSetPropertyRequested(property, value);
5630 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
5637 _VisualElementImpl::InvokeOnSetPropertyRequested(const String& property, const Variant& value)
5639 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
5640 result r = E_SUCCESS;
5642 if (likely(__pPublicInstance))
5644 r = __pPublicInstance->OnSetPropertyRequested(property, value);
5645 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
5652 _VisualElementImpl::HitTestI(const FloatPoint& point)
5656 return HITTEST_NOWHERE;
5659 if (//NEED_SURFACE(&target) &&
5660 !GetSharedData().isSurfaceOpaque &&
5661 _FloatHardCompare(GetOpacityFromRoot(), 0.0f))
5663 return HITTEST_NOWHERE;
5666 if (!GetVisibleRect().Contains(point))
5668 return HITTEST_NOWHERE;
5671 _VisualElementImpl* pClipSource = GetClipSource();
5674 FloatPoint pt = point;
5675 pClipSource->ConvertCoordinates(pt, this);
5677 if (!pClipSource->GetVisibleRect().Contains(pt))
5679 return HITTEST_NOWHERE;
5683 pClipSource = pClipSource->GetClipSource();
5687 return HITTEST_MATCH;
5691 _VisualElementImpl::GetChildAtPointI(const FloatPoint& point, int parentHitTest)
5693 _VisualElementImpl* pHitTarget = null;
5694 FloatPoint hitPoint = point;
5697 hitTest = VE_DELEGATE(this, InvokeHitTest, point);
5698 if ((hitTest & HITTEST_MATCH) != 0)
5704 if ((hitTest & HITTEST_NOMORECHILDREN) == 0)
5706 int count = __children.GetCount();
5707 for (int i = count - 1; i >= 0; i--) // from top to bottom
5709 _VisualElementImpl* pChild = __children.GetChildAt(i);
5715 FloatPoint childHitPoint = point;
5716 pChild->ConvertCoordinates(childHitPoint, this);
5718 _VisualElementImpl* pChildHitTarget = pChild->GetChildAtPointI(childHitPoint, hitTest);
5719 if (pChildHitTarget)
5721 pHitTarget = pChildHitTarget;
5722 hitPoint = childHitPoint;
5731 // point = hitPoint;
5739 // Because Hit-Testing from self, clipping flags of self will be ignored.
5742 _VisualElementImpl::GetChildAt(const FloatPoint& point)
5744 _VisualElementImpl* pHitTarget = GetChildAtPointI(point, HITTEST_MATCH);
5745 if (unlikely(!pHitTarget))
5747 SetLastResult(E_OBJ_NOT_FOUND);
5758 _VisualElementImpl::ScrollByPoint(const FloatPoint& pointOffset, bool scrollSelf)
5760 if (_FloatCompare(pointOffset.x, 0.0f) && _FloatCompare(pointOffset.y, 0.0f))
5766 FloatMatrix4 xform = __childrenTransform;
5767 FloatMatrix4 xformOrg = xform;
5768 FloatRectangle rectInvalidated;
5770 _MatrixUtilTranslate(xform, pointOffset.x, pointOffset.y, 0.0f);
5772 if (HAVE_SURFACE(this))
5774 int count = __children.GetCount();
5776 LockInvalidate(true);
5777 for (int i = 0; i < count; i++)
5779 __children.GetChildAt(i)->LockInvalidate(true);
5782 r = SetChildrenTransformMatrix(xform);
5784 LockInvalidate(false);
5785 for (int i = 0; i < count; i++)
5787 __children.GetChildAt(i)->LockInvalidate(false);
5792 r = SetChildrenTransformMatrix(xform);
5795 SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, E_SYSTEM, "Failed to translate matrix for scrolling ");
5797 if (!NEED_SURFACE(this))
5799 InvalidateVisibleRectToRenderTarget(null);
5801 else if (scrollSelf)
5803 Canvas* pCanvas = GetCanvasN(); // TODO: clip rect......
5807 _CanvasImpl* pCanvasImpl = _CanvasImpl::GetInstance(*pCanvas);
5811 Rectangle rectSource;
5813 rectSource.SetBounds(0, 0, __bounds.width, __bounds.height);
5815 rectInvalidated = __bounds;
5816 rectInvalidated.SetPosition(0.0f, 0.0f);
5817 if (pointOffset.x > 0)
5819 rectSource.width -= pointOffset.x;
5820 pointDest.x = pointOffset.x;
5821 rectInvalidated.width = pointOffset.x;
5825 rectSource.x += -pointOffset.x;
5826 rectSource.width -= -pointOffset.x;
5828 rectInvalidated.x = rectSource.width;
5829 rectInvalidated.width = -pointOffset.x;
5832 InvalidateVisibleRectToRenderTarget(&rectInvalidated);
5835 rectInvalidated = __bounds;
5836 rectInvalidated.SetPosition(0.0f, 0.0f);
5837 if (pointOffset.y > 0)
5839 rectSource.height -= pointOffset.y;
5840 pointDest.y = pointOffset.y;
5841 rectInvalidated.height = pointOffset.y;
5845 rectSource.y += -pointOffset.y;
5846 rectSource.height -= -pointOffset.y;
5848 rectInvalidated.y = rectSource.height;
5849 rectInvalidated.height = -pointOffset.y;
5852 InvalidateVisibleRectToRenderTarget(&rectInvalidated);
5855 r = pCanvasImpl->CopyEx(pointDest, *pCanvasImpl, rectSource);
5859 SysLogException(NID_UI_ANIM, r, "[%s] Can't copy area.", GetErrorMessage(r));
5860 SetChildrenTransformMatrix(xformOrg); // ???????????????????
5876 _VisualElementImpl::ConvertCoordinates(FloatPoint& point, const _VisualElementImpl* pFromElement) const
5878 if (unlikely(this == pFromElement))
5883 _VisualElementImpl* pFromRoot = null;
5888 if (likely(pFromElement))
5890 pFromRoot = pFromElement->GetRoot();
5891 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.");
5892 SysTryReturnResult(NID_UI_ANIM, pFromRoot || pFromElement->IsChildOf(*this) || IsChildOf(*pFromElement),
5893 E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement(%p) and pFromElement(%p) is not related.", this, pFromElement);
5897 pFromRoot = GetRoot();
5898 SysTryReturnResult(NID_UI_ANIM, pFromRoot, E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement is not attached to main tree.");
5901 const FloatMatrix4& toTopMatrix = (pFromElement ? pFromElement->GetMatrixToTop() : pFromRoot->GetMatrixToTop());
5902 _MatrixUtilTransform(toTopMatrix, &x, &y, &z);
5904 if (this != pFromRoot)
5906 const FloatMatrix4& fromTopMatrix = GetMatrixFromTop();
5908 SysTryReturnResult(NID_UI_ANIM, __matrixFromTopInvertible, E_INVALID_OPERATION, "The matrix for this conversion is singular which has zero determinant.");
5909 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");
5912 // We should calculate z of world-coordinate mapped x-y plane of depth==0 in VE coordinate !
5913 z = -(fromTopMatrix.matrix[0][2] * x + fromTopMatrix.matrix[1][2] * y + fromTopMatrix.matrix[3][2]) / fromTopMatrix.matrix[2][2];
5915 _MatrixUtilTransform(fromTopMatrix, &x, &y, &z);
5918 point.SetPosition(x, y); // z is omitted
5924 _VisualElementImpl::ConvertCoordinates(FloatRectangle& rectangle, const _VisualElementImpl* pFromElement) const
5926 if (unlikely(this == pFromElement))
5931 _VisualElementImpl* pFromRoot = null;
5932 float x[4] = { rectangle.x, rectangle.x + rectangle.width, rectangle.x, rectangle.x + rectangle.width };
5933 float y[4] = { rectangle.y, rectangle.y, rectangle.y + rectangle.height, rectangle.y + rectangle.height };
5934 float z[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
5936 if (likely(pFromElement))
5938 pFromRoot = pFromElement->GetRoot();
5939 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.");
5940 SysTryReturnResult(NID_UI_ANIM, pFromRoot || pFromElement->IsChildOf(*this) || IsChildOf(*pFromElement),
5941 E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement(%p) and pFromElement(%p) is not related.", this, pFromElement);
5945 pFromRoot = GetRoot();
5946 SysTryReturnResult(NID_UI_ANIM, pFromRoot, E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement is not attached to main tree.");
5949 const FloatMatrix4& toTopMatrix = (pFromElement ? pFromElement->GetMatrixToTop() : pFromRoot->GetMatrixToTop());
5951 for (int i = 0; i < 4; i++)
5953 _MatrixUtilTransform(toTopMatrix, &x[i], &y[i], &z[i]);
5956 if (this != pFromRoot)
5958 const FloatMatrix4& fromTopMatrix = GetMatrixFromTop();
5960 SysTryReturnResult(NID_UI_ANIM, __matrixFromTopInvertible, E_INVALID_OPERATION, "The matrix for this conversion is singular which has zero determinant.");
5961 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");
5963 for (int i = 0; i < 4; i++)
5966 // We should calculate z of world-coordinate mapped x-y plane of depth==0 in VE coordinate !
5967 z[i] = -(fromTopMatrix.matrix[0][2] * x[i] + fromTopMatrix.matrix[1][2] * y[i] + fromTopMatrix.matrix[3][2]) / fromTopMatrix.matrix[2][2];
5968 _MatrixUtilTransform(fromTopMatrix, &x[i], &y[i], &z[i]);
5973 CalculateBoundingBox(x, y, rectangle);
5979 _VisualElementImpl::ConvertCoordinates(float* x, float* y, float* z, int count, const _VisualElementImpl* pFromElement) const
5981 if (unlikely(this == pFromElement) || unlikely(count <= 0))
5986 _VisualElementImpl* pFromRoot = null;
5988 if (likely(pFromElement))
5990 pFromRoot = pFromElement->GetRoot();
5991 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.");
5992 SysTryReturnResult(NID_UI_ANIM, pFromRoot || pFromElement->IsChildOf(*this) || IsChildOf(*pFromElement),
5993 E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement(%p) and pFromElement(%p) is not related.", this, pFromElement);
5997 pFromRoot = GetRoot();
5998 SysTryReturnResult(NID_UI_ANIM, pFromRoot, E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement is not attached to main tree.");
6001 bool isUpwardConvertOnly = (pFromElement && pFromElement->IsChildOf(*this));
6002 const FloatMatrix4& toTopMatrix = (isUpwardConvertOnly ? pFromElement->CalcMatrixToBase(*this) :
6003 pFromElement ? pFromElement->GetMatrixToTop() : pFromRoot->GetMatrixToTop());
6005 for (int i = 0; i < count; i++)
6007 _MatrixUtilTransform(toTopMatrix, &x[i], &y[i], &z[i]);
6010 if (!isUpwardConvertOnly)
6012 const FloatMatrix4& fromTopMatrix = GetMatrixFromTop();
6014 SysTryReturnResult(NID_UI_ANIM, __matrixFromTopInvertible, E_INVALID_OPERATION, "The matrix for this conversion is singular which has zero determinant.");
6015 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");
6017 for (int i = 0; i < count; i++)
6020 // We should calculate z of world-coordinate mapped x-y plane of depth==0 in VE coordinate !
6021 z[i] = -(fromTopMatrix.matrix[0][2] * x[i] + fromTopMatrix.matrix[1][2] * y[i] + fromTopMatrix.matrix[3][2]) / fromTopMatrix.matrix[2][2];
6022 _MatrixUtilTransform(fromTopMatrix, &x[i], &y[i], &z[i]);
6030 _VisualElementImpl::TransformVectorFromOrigin(const Tizen::Graphics::FloatPoint3& originPoint, const _VisualElementImpl* pOriginVisualElement) const
6034 if (unlikely(this == pOriginVisualElement))
6036 return FloatPoint3(originPoint);
6039 float x = originPoint.x;
6040 float y = originPoint.y;
6041 float z = originPoint.z;
6043 _VisualElementImpl* pOriginRoot = pOriginVisualElement->GetRoot();
6045 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.");
6046 SysTryReturn(NID_UI_ANIM, pOriginRoot || pOriginVisualElement->IsChildOf(*this) || IsChildOf(*pOriginVisualElement),
6047 FloatPoint3(), E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement(%p) and originVisualElement(%p) is not related.", this, pOriginVisualElement);
6049 const FloatMatrix4& toTopMatrix = pOriginVisualElement->GetMatrixToTop();
6050 _MatrixUtilTransform(toTopMatrix, &x, &y, &z);
6052 if (this != pOriginRoot)
6054 const FloatMatrix4& fromTopMatrix = GetMatrixFromTop();
6056 SysTryReturn(NID_UI_ANIM, __matrixFromTopInvertible, FloatPoint3(), E_INVALID_OPERATION, "The matrix for this conversion is singular which has zero determinant.");
6058 _MatrixUtilTransform(fromTopMatrix, &x, &y, &z);
6061 return FloatPoint3(x, y, z);
6065 _VisualElementImpl::CaptureI(Canvas& outputCanvas, const FloatRectangle& rectDest, _VisualElementImpl& reference, const FloatRectangle& rectRef, const FloatRectangle& clipRect, bool withChilren, int depth)
6067 _CanvasImpl* pOutput = _CanvasImpl::GetInstance(outputCanvas);
6069 SysTryReturnResult(NID_UI_ANIM, pOutput, E_INVALID_ARG, "Invalid argument(s) is used. Output canvas is invalid.");
6070 SysTryReturnResult(NID_UI_ANIM, GetRoot(), E_INVALID_STATE, "Invalid argument(s) is used. VisualElement is not attached to main tree.");
6072 FloatRectangle bounds = __bounds;//GetDrawableRect();
6077 reference.ConvertCoordinates(bounds, this);
6078 FloatRectangle drawRect = bounds;
6080 _VisualElementImpl* pRenderTarget = this->GetRenderTarget();
6081 drawRect = rectRef.GetIntersection(bounds);
6082 // drawRect = drawRect.GetIntersection(clipRect);
6084 FloatRectangle tempRect = drawRect;
6087 ConvertCoordinates(drawRect, &reference);
6091 if (!drawRect.IsEmpty())
6093 if (pRenderTarget && HAVE_SURFACE(pRenderTarget)) // If element have surface , justly draw to the canvas
6095 //Canvas* pCanvas = GetCanvasN(elementbounds);
6096 #ifdef USE_CANVAS_FOR_CAPTURE
6097 Canvas* pCanvas = GetCanvasN();
6101 bitmap.Construct(*pCanvas, Rectangle(drawRect.x, drawRect.y, drawRect.width, drawRect.height));
6102 bitmap.SetAlphaConstant((int)(pRenderTarget->GetOpacityFromRoot()*255));
6105 point.x = rectDest.x + bounds.x;
6106 point.y = rectDest.y + bounds.y;
6107 outputCanvas.DrawBitmap(point, bitmap);
6112 if (__pSharedData->pSurface)
6114 _EflVisualElementSurfaceImpl* pSurfImpl = dynamic_cast<_EflVisualElementSurfaceImpl*>(_VisualElementSurfaceImpl::GetInstance(*__pSharedData->pSurface));
6116 if(pSurfImpl && pSurfImpl->GetNativeHandle() && pSurfImpl->__isImageObject)
6119 __pSharedData->pSurface->GetBufferInfo(info);
6121 byte* pStart = (byte*)evas_object_image_data_get((Evas_Object*)pSurfImpl->GetNativeHandle(), false);
6122 _DisplayManager::RestoreContext();
6127 _VisualElementCoordinateSystem::ConvertRectangleToPhysicalIntegral(drawRect.x, drawRect.y, drawRect.width, drawRect.height);
6130 BufferInfo copyInfo;
6131 copyInfo.bitsPerPixel = info.bitsPerPixel;
6132 copyInfo.width = drawRect.width;
6133 copyInfo.height = drawRect.height;
6134 copyInfo.pitch = (info.pitch/info.width)*copyInfo.width;
6136 byte* pCopy = new (std::nothrow) byte[copyInfo.height*(copyInfo.pitch)];
6140 //memcpy(pCopy, pStart, info.height*(info.pitch));
6142 for (int y = 0; y < copyInfo.height; y++)
6144 unsigned int* pSrc = (unsigned int*)((unsigned char*)pStart + info.pitch * (y + int(drawRect.y)) + int(drawRect.x) * 4);
6145 unsigned int* pAddr = (unsigned int*)((unsigned char*)pCopy + copyInfo.pitch * y);
6146 for (int x = 0; x < copyInfo.width; x++)
6148 int a = ((*pSrc) >> 24) & 0xff;
6149 int r = ((*pSrc) >> 16) & 0xff;
6150 int g = ((*pSrc) >> 8) & 0xff;
6151 int b = ((*pSrc) >> 0) & 0xff;
6154 float fa = (float)a / 255.0f;
6158 *pAddr = (a << 24) | (r << 16) | (g << 8) | b;
6165 _VisualElementCoordinateSystem::ConvertRectangleToLogical(drawRect.x, drawRect.y, drawRect.width, drawRect.height);
6169 result r = buffer.Construct(pCopy, 0, copyInfo.height*(copyInfo.pitch), copyInfo.height*(copyInfo.pitch));
6173 Bitmap* pBitmap = Bitmap::GetNonScaledBitmapN(buffer, Dimension(copyInfo.width, copyInfo.height), BITMAP_PIXEL_FORMAT_ARGB8888);
6176 _BitmapImpl::GetInstance(*pBitmap)->SetAsPremultiplied();
6177 pBitmap->SetAlphaConstant((int)(pRenderTarget->GetOpacityFromRoot() * 255.0f));
6179 FloatRectangle outputRect(rectDest.x + bounds.x - rectRef.x, rectDest.y + bounds.y - rectRef.y, drawRect.width, drawRect.height);
6180 FloatRectangle srcRect = outputRect;
6183 outputCanvas.DrawBitmap(outputRect, *pBitmap, srcRect);
6197 _EflNode* pNativeNode = dynamic_cast< _EflNode* >(GetNativeNode());
6199 SysTryReturnResult(NID_UI_ANIM, pNativeNode, E_INVALID_STATE, "No object for background"); // CHECKME: Default BG?
6200 _Colorf bgcolorf = pNativeNode->GetBackgroundColor();
6201 Color color(bgcolorf.Red()*255, bgcolorf.Green()*255, bgcolorf.Blue()*255, bgcolorf.Alpha()*255);
6204 point.x = rectDest.x + bounds.x - rectRef.x;
6205 point.y = rectDest.y + bounds.y - rectRef.y;
6207 //pOutput->FillRectangle(color, Rectangle(drawRect.x + bounds.x, drawRect.y + bounds.y, drawRect.width, drawRect.height));
6208 pOutput->FillRectangle(color, FloatRectangle(point.x, point.y, drawRect.width, drawRect.height));
6212 if (withChilren) // child draw
6214 _VisualElementImpl* pChild = null;
6216 FloatRectangle clipBounds = clipRect;
6218 int count = __children.GetCount();
6220 if(count > 0 && __isClipChildren)
6222 clipBounds = clipRect.GetIntersection(bounds);
6225 for (int i = 0; i < count; i++)
6227 pChild = __children.GetChildAt(i);
6228 if (unlikely(!pChild) || unlikely(!VE_VISIBLE(pChild)))
6232 pChild->CaptureI(outputCanvas, rectDest, reference, rectRef, clipBounds, true, depth + 1);
6240 _VisualElementImpl::CaptureI(Canvas& outputCanvas, const FloatRectangle& rectDest, _VisualElementImpl& reference, const FloatRectangle& clipRect, bool withChilren, int depth)
6242 _CanvasImpl* pOutput = _CanvasImpl::GetInstance(outputCanvas);
6244 SysTryReturnResult(NID_UI_ANIM, pOutput, E_INVALID_ARG, "Invalid argument(s) is used. Output canvas is invalid.");
6245 SysTryReturnResult(NID_UI_ANIM, GetRoot(), E_INVALID_STATE, "Invalid argument(s) is used. VisualElement is not attached to main tree.");
6247 FloatRectangle bounds = __bounds;//GetDrawableRect();
6252 reference.ConvertCoordinates(bounds, this);
6253 FloatRectangle drawRect = bounds;
6255 _VisualElementImpl* pRenderTarget = this->GetRenderTarget();
6256 drawRect = bounds.GetIntersection(clipRect);
6258 FloatRectangle tempRect = drawRect;
6260 drawRect.x -= bounds.x;
6261 drawRect.y -= bounds.y; //--> 0 - -20 = 20 : 20 - 20 = 0
6265 if (!drawRect.IsEmpty())
6267 if (pRenderTarget && HAVE_SURFACE(pRenderTarget)) // If element have surface , justly draw to the canvas
6269 //Canvas* pCanvas = GetCanvasN(elementbounds);
6270 #ifdef USE_CANVAS_FOR_CAPTURE
6271 Canvas* pCanvas = GetCanvasN();
6275 bitmap.Construct(*pCanvas, Rectangle(drawRect.x, drawRect.y, drawRect.width, drawRect.height));
6276 bitmap.SetAlphaConstant((int)(pRenderTarget->GetOpacityFromRoot()*255));
6279 point.x = rectDest.x + bounds.x;
6280 point.y = rectDest.y + bounds.y;
6281 outputCanvas.DrawBitmap(point, bitmap);
6285 if (__pSharedData->pSurface)
6288 _EflVisualElementSurfaceImpl* pSurfImpl = dynamic_cast<_EflVisualElementSurfaceImpl*>(_VisualElementSurfaceImpl::GetInstance(*__pSharedData->pSurface));
6290 if(pSurfImpl && pSurfImpl->GetNativeHandle() && pSurfImpl->__isImageObject)
6292 byte* pStart = (byte*)evas_object_image_data_get((Evas_Object*)pSurfImpl->GetNativeHandle(), false);
6293 _DisplayManager::RestoreContext();
6296 __pSharedData->pSurface->GetBufferInfo(info);
6301 result r = buffer.Construct(pStart, 0, info.height*(info.pitch), info.height*(info.pitch));
6305 Bitmap* pBitmap = Bitmap::GetNonScaledBitmapN(buffer, Dimension(info.width, info.height), BITMAP_PIXEL_FORMAT_ARGB8888);
6308 _BitmapImpl::GetInstance(*pBitmap)->SetAsPremultiplied();
6309 pBitmap->SetAlphaConstant((int)(pRenderTarget->GetOpacityFromRoot() * 255.0f));
6311 FloatRectangle outputRect(rectDest.x + bounds.x, rectDest.y + bounds.y, drawRect.width, drawRect.height);
6313 _VisualElementCoordinateSystem::ConvertRectangleToPhysicalIntegral(drawRect.x, drawRect.y, drawRect.width, drawRect.height);
6314 _VisualElementCoordinateSystem::ConvertRectangleToLogical(drawRect.x, drawRect.y, drawRect.width, drawRect.height);
6316 outputCanvas.DrawBitmap(outputRect, *pBitmap, drawRect);
6328 _EflNode* pNativeNode = dynamic_cast< _EflNode* >(GetNativeNode());
6330 SysTryReturnResult(NID_UI_ANIM, pNativeNode, E_INVALID_STATE, "No object for background"); // CHECKME: Default BG?
6331 _Colorf bgcolorf = pNativeNode->GetBackgroundColor();
6332 Color color(bgcolorf.Red()*255, bgcolorf.Green()*255, bgcolorf.Blue()*255, bgcolorf.Alpha()*255);
6335 point.x = rectDest.x + bounds.x;
6336 point.y = rectDest.y + bounds.y;
6338 //pOutput->FillRectangle(color, Rectangle(drawRect.x + bounds.x, drawRect.y + bounds.y, drawRect.width, drawRect.height));
6339 pOutput->FillRectangle(color, FloatRectangle(point.x, point.y, drawRect.width, drawRect.height));
6343 if (withChilren) // child draw
6345 _VisualElementImpl* pChild = null;
6347 FloatRectangle clipBounds = clipRect;
6349 int count = __children.GetCount();
6351 if(count > 0 && __isClipChildren)
6353 clipBounds = clipRect.GetIntersection(bounds);
6356 for (int i = 0; i < count; i++)
6358 pChild = __children.GetChildAt(i);
6359 if (unlikely(!pChild) || unlikely(!VE_VISIBLE(pChild)))
6363 pChild->CaptureI(outputCanvas, rectDest, reference, clipBounds, true, depth + 1);
6371 _VisualElementImpl::Capture(Canvas& outputCanvas, const FloatRectangle& rectDest,const FloatRectangle& rectSrc, bool withChildren)
6373 FloatRectangle tempSrcRect = rectSrc;
6374 FloatRectangle tempDestRect = rectDest;
6375 // tempSrcRect.x = rectDest.x;
6376 // tempSrcRect.y = rectDest.y;
6382 tempDestRect.width -= diff;
6385 tempSrcRect.x += diff;
6386 tempSrcRect.width -= diff;
6391 tempDestRect.height -= diff;
6394 tempSrcRect.y += diff;
6395 tempSrcRect.height -= diff;
6398 FloatRectangle clipBounds = tempDestRect;
6399 clipBounds.x = tempSrcRect.x;
6400 clipBounds.y = tempSrcRect.y;
6402 clipBounds = clipBounds.GetIntersection(tempSrcRect);
6403 tempSrcRect = clipBounds;
6405 if(!VE_VISIBLE(this))
6408 return CaptureI(outputCanvas, tempDestRect, *this, tempSrcRect, clipBounds, withChildren, 0);
6412 _VisualElementImpl::Capture(Canvas& outputCanvas, const FloatRectangle& rectDest, bool withChildren)
6414 FloatRectangle tempDestRect = rectDest;
6415 tempDestRect.x = __bounds.x;
6416 tempDestRect.y = __bounds.y;
6417 FloatRectangle clipBounds = __bounds;
6419 clipBounds = tempDestRect.GetIntersection(__bounds);
6423 if(!VE_VISIBLE(this))
6426 return CaptureI(outputCanvas, rectDest, *this, clipBounds, withChildren, 0);
6428 // Rectangle cBounds = outputCanvas.GetBounds();
6429 // outputCanvas.SetForegroundColor(Color(10,110,20));
6430 // outputCanvas.DrawRectangle(Rectangle(cBounds.x+1,cBounds.y+1,cBounds.width-2,cBounds.height-2));
6431 // outputCanvas.SetForegroundColor(Color(10,20,20));
6432 // outputCanvas.DrawRectangle(Rectangle(rectDest.x+1,rectDest.y+1,rectDest.width-2,rectDest.height-2));
6433 // return E_SUCCESS;
6437 _VisualElementImpl::Capture(Canvas& outputCanvas, const FloatRectangle& rectDest, bool withChildren)
6439 result r = E_SUCCESS;
6443 rect.x = rectDest.x;
6444 rect.y = rectDest.y;
6445 rect.width = rectDest.width;
6446 rect.height = rectDest.height;
6450 Canvas* pCanvas = GetCanvasN();
6453 r = outputCanvas.Copy(Point(0,0), *pCanvas, rect);
6458 return GetLastResult();
6462 _EflNode* pNode = dynamic_cast<_EflNode*>(GetNativeNode());
6463 SysTryReturnResult(pNode, E_INVALID_STATE, "VisualElement is invalid.");
6466 r = pNode->Capture(outputCanvas, Point(0,0), rect);
6469 SysTryReturn(r == E_SUCCESS, r, r,"[%s] Propagating.", GetErrorMessage(r));
6476 _VisualElementImpl::AddAnimation(const Tizen::Base::String* pKeyName, VisualElementAnimation& animation)
6478 SysTryReturnResult(NID_UI_ANIM, !IS_PRESENTATION(this), E_INVALID_OPERATION, "This is not model.");
6480 result r = E_SUCCESS;
6482 bool isPropertyPropagationEnabled = __isPropertyPropagationEnabled;
6484 __isPropertyPropagationEnabled = false;
6486 if (dynamic_cast< VisualElementAnimationGroup* >(&animation) != null)
6488 VisualElementAnimation* pCloned = animation.CloneN();
6489 SysTryReturnResult(NID_UI_ANIM, pCloned != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
6491 r = AddAnimationGroupI(pKeyName, *pCloned);
6492 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
6501 r = AddAnimationI(pKeyName, animation);
6502 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
6505 __isPropertyPropagationEnabled = isPropertyPropagationEnabled;
6511 _VisualElementImpl::AddAnimationI(const Tizen::Base::String* pKeyName, VisualElementAnimation& animation)
6513 result r = E_SUCCESS;
6515 IVisualElementAnimationTickEventListener* pTickListener = null;
6518 VisualElementValueAnimation* pValueAnimation = dynamic_cast< VisualElementValueAnimation* >(&animation);
6519 if (pValueAnimation != null)
6521 _VisualElementValueAnimationImpl* pValueAnimationImpl = _VisualElementValueAnimationImpl::GetInstance(*pValueAnimation);
6522 SysTryReturnResult(NID_UI_ANIM, (pValueAnimationImpl->IsValid()), E_INVALID_ARG, "Invalid argument(s) is used. Animation value is invalid.");
6524 pTickListener = pValueAnimationImpl->GetTickEventListener();
6528 VisualElementAnimation* pCloned = animation.CloneN();
6529 SysTryReturnResult(NID_UI_ANIM, (pCloned != null), E_OUT_OF_MEMORY, "Memory allocation failed.");
6531 _VisualElementAnimationImpl* pAnimationImpl = _VisualElementAnimationImpl::GetInstance(*pCloned);
6533 if (pAnimationImpl->GetStatusEventListener() != null || pTickListener != null)
6535 pAnimationImpl->SetEventTarget(*GetPublic());
6538 // Use presentation tree for animation
6539 VisualElement* pPresentation = __pPresentation->__pPublicInstance;
6541 r = _AnimationManager::GetInstance()->AddAnimation(*pPresentation, pKeyName, *pCloned);
6544 SysTryLog(NID_UI_ANIM, "[%s] Failed to add animation.", GetErrorMessage(r));
6550 // Change model tree value if endValueApplied is true
6551 VisualElementPropertyAnimation* pPropertyAnimation = dynamic_cast< VisualElementPropertyAnimation* >(pCloned);
6553 if (pPropertyAnimation
6554 && pPropertyAnimation->IsEndValueApplied()
6555 && !pPropertyAnimation->IsAutoReverseEnabled()
6556 && pPropertyAnimation->GetRepeatCount() != 0)
6558 const String& propertyName = pPropertyAnimation->GetPropertyName();
6559 const Variant& endValue = pPropertyAnimation->GetEndValue();
6561 if (endValue.IsEmpty() == false && InvokeOnGetPropertyRequested(propertyName) != endValue)
6563 (void) InvokeOnSetPropertyRequested(propertyName, endValue);
6571 _VisualElementImpl::AddAnimationGroupI(const Tizen::Base::String* pKeyName, VisualElementAnimation& animation)
6573 _AnimationManager* pAnimationManager = _AnimationManager::GetInstance();
6575 // Get presentation tree
6576 VisualElement* pPresentation = __pPresentation->__pPublicInstance;
6578 VisualElementAnimationGroup* pAnimationGroup = dynamic_cast< VisualElementAnimationGroup* >(&animation);
6580 SysTryReturnResult(NID_UI_ANIM, (pAnimationGroup != null), E_INVALID_ARG, "Invalid argument(s) is used. Failed to add animation group.");
6581 SysTryReturnResult(NID_UI_ANIM, (pAnimationGroup->GetAnimationCount() > 0), E_INVALID_ARG, "Invalid argument(s) is used. Animation group has no animation.");
6583 _VisualElementAnimationGroupImpl* pAnimationGroupImpl = _VisualElementAnimationGroupImpl::GetInstance(*pAnimationGroup);
6585 if (pAnimationGroupImpl->GetStatusEventListener() != null)
6587 pAnimationGroupImpl->SetEventTarget(*GetPublic());
6590 result r = E_SUCCESS;
6592 VisualElementAnimation* pAnimation = null;
6593 Tizen::Base::String name;
6594 int animationCount = 0;
6596 int transactionID = pAnimationManager->BeginGroupTransaction(*pPresentation, pKeyName, *pAnimationGroup);
6598 r = GetLastResult();
6599 SysTryCatch(NID_UI_ANIM, (transactionID > 0), , r, "[%s] Transaction is not created.", GetErrorMessage(r));
6601 animationCount = pAnimationGroupImpl->GetAnimationCount();
6603 for (int index = 0; index < animationCount; index++)
6605 pAnimation = pAnimationGroupImpl->GetAnimation(index);
6607 if (pAnimation == null)
6612 if (dynamic_cast< VisualElementAnimationGroup* >(pAnimation) != null)
6614 r = AddAnimationGroupI(&name, *pAnimation);
6618 r = AddAnimationI(&name, *pAnimation);
6621 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] animation manager is null.", GetErrorMessage(r));
6624 pAnimationManager->CommitTransaction();
6630 if (transactionID > 0)
6632 pAnimationManager->DiscardTransaction(transactionID);
6639 _VisualElementImpl::RemoveAnimation(const Tizen::Base::String& keyName)
6641 VisualElement* pPresentation = __pPresentation->__pPublicInstance;
6643 return _AnimationManager::GetInstance()->RemoveAnimation(*pPresentation, keyName);
6647 _VisualElementImpl::RemoveAllAnimations(void)
6649 VisualElement* pPresentation = __pPresentation->__pPublicInstance;
6651 _AnimationManager::GetInstance()->RemoveAllAnimations(*pPresentation);
6656 VisualElementAnimation*
6657 _VisualElementImpl::GetAnimationN(const Tizen::Base::String& keyName) const
6659 VisualElement* pPresentation = __pPresentation->__pPublicInstance;
6663 return _AnimationManager::GetInstance()->GetAnimationN(*pPresentation, keyName);
6667 _VisualElementImpl::CheckIfAnimatable(const String& property) const
6670 // Optimize using map or other algorithms !
6674 static const wchar_t* supportedProperties[] = {
6675 VeSubPropTransformScaleXY,
6678 VePropContentOpacity,
6681 VePropChildrenTransform,
6682 VePropZPosition, // TBD:
6683 VeSubPropBoundsPosition,
6684 VeSubPropBoundsSize,
6686 VeSubPropTransformRotationX,
6687 VeSubPropTransformRotationY,
6688 VeSubPropTransformRotationZ,
6689 VeSubPropTransformRotationXY,
6690 VeSubPropTransformScaleX,
6691 VeSubPropTransformScaleY,
6692 VeSubPropTransformScaleZ,
6694 VeSubPropTransformTranslationX,
6695 VeSubPropTransformTranslationY,
6696 VeSubPropTransformTranslationZ,
6697 VeSubPropTransformTranslationXY,
6698 VeSubPropChildrenTransformRotationX,
6699 VeSubPropChildrenTransformRotationY,
6700 VeSubPropChildrenTransformRotationZ,
6701 VeSubPropChildrenTransformRotationXY,
6702 VeSubPropChildrenTransformScaleX,
6703 VeSubPropChildrenTransformScaleY,
6704 VeSubPropChildrenTransformScaleZ,
6705 VeSubPropChildrenTransformScaleXY,
6706 VeSubPropChildrenTransformTranslationX,
6707 VeSubPropChildrenTransformTranslationY,
6708 VeSubPropChildrenTransformTranslationZ,
6709 VeSubPropChildrenTransformTranslationXY
6712 static String* const* supportedProperties[] = {
6714 &pVePropContentOpacity,
6717 &pVePropChildrenTransform,
6718 &pVePropZPosition, // TBD:
6719 &pVeSubPropBoundsPosition,
6720 &pVeSubPropBoundsSize,
6722 &pVePropContentBounds,
6723 #if defined(SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION)
6724 &pVePropActionDetach,
6725 &pVePropActionAttach,
6727 &pVeSubPropTransformRotationX,
6728 &pVeSubPropTransformRotationY,
6729 &pVeSubPropTransformRotationZ,
6730 &pVeSubPropTransformRotationXY,
6731 &pVeSubPropTransformScaleX,
6732 &pVeSubPropTransformScaleY,
6733 &pVeSubPropTransformScaleZ,
6734 &pVeSubPropTransformScaleXY,
6735 &pVeSubPropTransformTranslationX,
6736 &pVeSubPropTransformTranslationY,
6737 &pVeSubPropTransformTranslationZ,
6738 &pVeSubPropTransformTranslationXY,
6739 &pVeSubPropChildrenTransformRotationX,
6740 &pVeSubPropChildrenTransformRotationY,
6741 &pVeSubPropChildrenTransformRotationZ,
6742 &pVeSubPropChildrenTransformRotationXY,
6743 &pVeSubPropChildrenTransformScaleX,
6744 &pVeSubPropChildrenTransformScaleY,
6745 &pVeSubPropChildrenTransformScaleZ,
6746 &pVeSubPropChildrenTransformScaleXY,
6747 &pVeSubPropChildrenTransformTranslationX,
6748 &pVeSubPropChildrenTransformTranslationY,
6749 &pVeSubPropChildrenTransformTranslationZ,
6750 &pVeSubPropChildrenTransformTranslationXY
6754 for (int i = 0; i < static_cast< int >(sizeof(supportedProperties) / sizeof(supportedProperties[0])); i++)
6756 //if (wcscmp(property.GetPointer(), supportedProperties[i]) == 0)
6757 if (property.GetPointer() == (*supportedProperties[i])->GetPointer() || property == **supportedProperties[i])
6766 VisualElementAnimation*
6767 _VisualElementImpl::CreateAnimationForPropertyI(const Tizen::Base::String& property)
6769 if (IS_PRESENTATION(this) || !CheckIfAnimatable(property))
6775 if (property.CompareTo(String(VePropBounds)) == 0)
6777 //ToDo: default implementation
6779 else if (property.CompareTo(String(VePropOpacity)) == 0)
6781 //ToDo: default implementation
6783 else if (property.CompareTo(String(VePropChildrenOpacity)) == 0)
6785 //ToDo: default implementation
6787 else if (property.CompareTo(String(VePropShowState)) == 0)
6789 //ToDo: default implementation
6791 else if (property.CompareTo(String(VePropTransform)) == 0)
6793 //ToDo: default implementation
6795 else if (property.CompareTo(String(VePropChildrenTransform)) == 0)
6797 //ToDo: default implementation
6799 else if (property.CompareTo(String(VePropZPosition)) == 0)
6801 //ToDo: default implementation
6806 VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
6807 SysTryReturn(NID_UI_ANIM, pAnimation != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
6809 #if defined(SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION)
6810 if (unlikely(property == *pVePropActionAttach))
6812 pAnimation->SetPropertyName(*pVePropOpacity);
6813 pAnimation->SetStartValue(Variant(0.0f));
6815 else if (unlikely(property == *pVePropActionDetach))
6817 pAnimation->SetPropertyName(*pVePropOpacity);
6818 pAnimation->SetEndValue(Variant(0.0f));
6823 _VisualElementImpl* pPresentation = GetPresentation();
6825 const Variant& curValue = pPresentation->InvokeOnGetPropertyRequested(property);
6826 result r = GetLastResult();
6827 SysTryCatch(NID_UI_ANIM, !IsFailed(r), , r, "[%s] No property for animation exists.", GetErrorMessage(r));
6829 pAnimation->SetPropertyName(property);
6830 pAnimation->SetStartValue(curValue);
6843 _VisualElementImpl::SetBoundsChangedCallback(BoundsChangedCallback pCallback, void* pData)
6845 __pBoundsChangedCallback = pCallback;
6846 __pBoundsChangedCallbackData = pData;
6850 _VisualElementImpl::SetDestroyedCallback(DestroyedCallback pCallback, void* pData)
6852 __pDestroyedCallback = pCallback;
6853 __pDestroyedCallbackData = pData;
6857 // delegate---------------------------------------------------------------------------------
6860 _VisualElementImpl::InvokeOnConstructed(void)
6862 if (__pPublicInstance)
6866 __pPublicInstance->OnConstructed();
6874 _VisualElementImpl::InvokeOnDestructing(void)
6876 if (__pPublicInstance)
6880 __pPublicInstance->OnDestructing();
6888 _VisualElementImpl::InvokeHitTest(const Tizen::Graphics::FloatPoint& point)
6890 int hitTest = _VisualElementImpl::HITTEST_NOWHERE;
6892 if (__pPublicInstance && !__isInternal)
6894 HitTestResult hitResult = HIT_TEST_NOWHERE;
6896 if (GetSharedData().pContentProvider)
6898 hitResult = GetSharedData().pContentProvider->HitTest(*__pPublicInstance, point);
6902 hitResult = __pPublicInstance->OnHitTest(point);
6905 if (hitResult == HIT_TEST_NOWHERE)
6907 hitTest = _VisualElementImpl::HITTEST_NOWHERE;
6911 hitTest = _VisualElementImpl::HITTEST_MATCH;
6916 return HitTestI(point);
6925 _VisualElementImpl::InvokePrepareDraw(void)
6929 if (__pPublicInstance)
6931 if (GetSharedData().pContentProvider)
6933 result = GetSharedData().pContentProvider->PrepareDraw(*__pPublicInstance);
6937 result = __pPublicInstance->OnPrepareDraw();
6947 _VisualElementImpl::InvokeOnDraw(Tizen::Graphics::Canvas& canvas)
6949 if (__pPublicInstance)
6951 if (GetSharedData().pContentProvider)
6953 GetSharedData().pContentProvider->DrawContent(*__pPublicInstance, canvas);
6957 __pPublicInstance->OnDraw(canvas);
6964 VisualElementAnimation*
6965 _VisualElementImpl::InvokeCreateAnimationForProperty(const Tizen::Base::String& property)
6967 VisualElementAnimation* pAnimation = null;
6969 if (__pPublicInstance)
6971 if (GetSharedData().pAnimationProvider)
6973 pAnimation = GetSharedData().pAnimationProvider->CreateAnimationForProperty(*__pPublicInstance, property);
6977 pAnimation = __pPublicInstance->OnCreateAnimationForProperty(property);
6987 _VisualElementImpl::InvokeOnChildAttaching(_VisualElementImpl& child)
6994 _VisualElementImpl::InvokeOnChildAttached(_VisualElementImpl& child)
6996 if (__pPublicInstance && !__isInternal)
6998 VisualElement* pChild = child.__pPublicInstance;
7000 if (GetSharedData().pEventListener)
7002 GetSharedData().pEventListener->OnChildAttached(*__pPublicInstance, *pChild);
7010 _VisualElementImpl::InvokeOnChildDetaching(_VisualElementImpl& child)
7017 _VisualElementImpl::InvokeOnChildDetached(_VisualElementImpl& child)
7019 if (__pPublicInstance && !__isInternal)
7021 VisualElement* pChild = child.__pPublicInstance;
7023 if (GetSharedData().pEventListener)
7025 GetSharedData().pEventListener->OnChildDetached(*__pPublicInstance, *pChild);
7033 _VisualElementImpl::InvokeOnAttaching(_VisualElementImpl& parent)
7040 _VisualElementImpl::InvokeOnAttached(void)
7042 if (__pPublicInstance && !__isInternal)
7044 _VisualElementImpl* pParentInternal = GetParent();
7045 if (pParentInternal)
7047 VisualElement* pParent = pParentInternal->__pPublicInstance;
7049 if (GetSharedData().pEventListener)
7051 __isAllowedTreeModification = false;
7052 GetSharedData().pEventListener->OnAttached(*__pPublicInstance, *pParent);
7053 __isAllowedTreeModification = true;
7062 _VisualElementImpl::InvokeOnDetaching(void)
7069 _VisualElementImpl::InvokeOnDetached(_VisualElementImpl& parent)
7071 if (__pPublicInstance && !__isInternal)
7073 VisualElement* pParent = parent.__pPublicInstance;
7075 if (GetSharedData().pEventListener)
7077 __isAllowedTreeModification = false;
7078 GetSharedData().pEventListener->OnDetached(*__pPublicInstance, *pParent);
7079 __isAllowedTreeModification = true;
7085 _VisualElementImpl::InvokeOnAnimationAdded(const VisualElementAnimation* pAnimation)
7087 //TODO: Implementation
7093 _VisualElementImpl::InvokeOnAnimationRemoved(const VisualElementAnimation* pAnimation)
7095 //TODO: Implementation
7101 _VisualElementImpl::InvokeOnShowStateChanged(bool showState)
7103 if (__pPublicInstance && !__isInternal)
7105 if (GetSharedData().pEventListener)
7107 GetSharedData().pEventListener->OnShowStateChanged(*__pPublicInstance, showState);
7115 _VisualElementImpl::InvokeOnTransformMatrixChanging(FloatMatrix4& newTransform)
7117 if (__pPublicInstance && !__isInternal)
7119 if (GetSharedData().pEventListener)
7121 return GetSharedData().pEventListener->OnTransformChanging(*__pPublicInstance, newTransform);
7127 return E_INVALID_STATE;
7131 _VisualElementImpl::InvokeOnTransformMatrixChanged(const FloatMatrix4& oldTransform)
7133 if (__pPublicInstance && !__isInternal)
7135 if (GetSharedData().pEventListener)
7137 GetSharedData().pEventListener->OnTransformChanged(*__pPublicInstance, oldTransform);
7145 _VisualElementImpl::InvokeOnChildrenTransformMatrixChanging(FloatMatrix4& newTransform)
7147 if (__pPublicInstance && !__isInternal)
7149 if (GetSharedData().pEventListener)
7151 return GetSharedData().pEventListener->OnChildrenTransformChanging(*__pPublicInstance, newTransform);
7157 return E_INVALID_STATE;
7161 _VisualElementImpl::InvokeOnChildrenTransformMatrixChanged(const FloatMatrix4& oldTransform)
7163 if (__pPublicInstance && !__isInternal)
7165 if (GetSharedData().pEventListener)
7167 GetSharedData().pEventListener->OnChildrenTransformChanged(*__pPublicInstance, oldTransform);
7175 _VisualElementImpl::InvokeOnBoundsChanging(FloatRectangle& newBounds)
7177 if (__pPublicInstance && !__isInternal)
7179 if (GetSharedData().pEventListener)
7181 return GetSharedData().pEventListener->OnBoundsChanging(*__pPublicInstance, newBounds);
7187 return E_INVALID_STATE;
7191 _VisualElementImpl::InvokeOnBoundsChanged(const FloatRectangle& oldBounds)
7193 if (__pPublicInstance && !__isInternal)
7195 if (GetSharedData().pEventListener)
7197 GetSharedData().pEventListener->OnBoundsChanged(*__pPublicInstance, oldBounds);