2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
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 <FGrpBufferInfo.h>
34 #include <FBaseByteBuffer.h>
35 #include <FGrp_CanvasImpl.h>
36 #include <FUiAnimIVisualElementAnimationStatusEventListener.h>
37 #include <FUiAnimVisualElementPropertyAnimation.h>
38 #include <FUiAnimVisualElementAnimationGroup.h>
39 #include <FUiAnimVisualElementSurface.h>
41 #include <FUiAnimVisualElement.h>
43 #include "FUi_Rectanglef.h"
44 #include "FUi_CoordinateSystemUtils.h"
46 #include "FUiAnim_VisualElementImpl.h"
47 #include "FUiAnim_VisualElementCanvas.h"
49 #include "FUiAnim_VisualElementAnimationImpl.h"
50 #include "FUiAnim_VisualElementAnimationGroupImpl.h"
51 #include "FUiAnim_VisualElementValueAnimationImpl.h"
52 #include "FUiAnim_VisualElementPropertyAnimationImpl.h"
53 #include "FUiAnim_AnimationManager.h"
54 #include "FUiAnim_VisualElementSharedData.h"
55 #include "FUiAnim_RootVisualElement.h"
56 #include "FUiAnim_ControlVisualElement.h"
57 #include "FUiAnim_MatrixUtil.h"
58 #include "FUiAnim_Debug.h"
59 #include "FUiAnim_EflNode.h"
60 #include "FUiAnim_VisualElementSurfaceImpl.h"
61 #include "FUiAnim_EflVisualElementSurfaceImpl.h"
62 #include "FUiAnim_DisplayManager.h"
66 using namespace Tizen::Base;
67 using namespace Tizen::Base::Collection;
68 using namespace Tizen::Graphics;
69 using namespace Tizen::Ui;
71 #define LAZY_EVALUATION // lazy updating and reconfiguring.
72 #define IMPLICIT_ANIMATION_IMPL //prototyping implicit animation.
73 //#define MANUAL_PROPERTY_CHANGE_NOTIFICATION
75 #define IS_INTERNAL_CLASS(_PUBLIC) (likely(typeid(*(_PUBLIC)) == VeTypeId) || likely(typeid(*(_PUBLIC)) == internalVeTypeId) || likely(typeid(*(_PUBLIC)) == controlVeTypeId) || likely(typeid(*(_PUBLIC)) == rootVeTypeId))
76 #define IS_NEEDED_UPDATE_PRESENTATION(__MODEL) (((__MODEL)->__isPropertyPropagationEnabled) && ((__MODEL)->__pPresentation))
79 static const char* STR_ERROR_INVALID_VARIANT_ARG_TYPE = "[E_INVALID_ARG] Invalid argument(s) is used. Variant type is invalid.";
82 CalculateBoundingBox(const float x[4], const float y[4], Tizen::Graphics::FloatRectangle& rectangle)
88 for (int i = 1; i < 4; i++)
105 rectangle.width = maxX - minX;
106 rectangle.height = maxY - minY;
112 namespace Tizen { namespace Ui { namespace Animations
114 // rules of visual element.
116 // 1. almost controlling pSharedData occurred in the PRESENTATION layer.
117 // 2. almost Delegate's methods occurred in the MODEL layer.
120 #define SHOWOPACITY_VISIBLE(so) \
123 #define VE_VISIBLE(o) \
124 SHOWOPACITY_VISIBLE((o)->__showOpacity)
126 #define HAVE_SURFACE(o) \
127 (likely((o)->GetSharedData().pSurface))
129 //TODO: require further examination : __NeedSurface() instead of NEED_SURFACE() macro
130 #define NEED_SURFACE(o) \
131 (likely((o)->GetSharedData().needSurface))
133 #define IS_ATTACHED(o) \
134 ((o)->GetRoot() != null)
136 #define IS_PRESENTATION(o) \
137 ((o)->__pPresentation == (o))
139 #define IS_MODEL(o) \
140 ((o)->__pModel == (o))
142 #define VE_DELEGATE(target, func, ...) \
143 (target)->func(__VA_ARGS__)
147 static const std::type_info& VeTypeId = typeid(VisualElement);
148 static const std::type_info& rootVeTypeId = typeid(_RootVisualElement);
149 static const std::type_info& internalVeTypeId = typeid(_VisualElement);
150 static const std::type_info& controlVeTypeId = typeid(_ControlVisualElement);
152 // declared AnimationEventListener for implicit animation
153 class _VisualElementImplicitAnimationEventListener
154 : public IVisualElementAnimationStatusEventListener
155 , virtual public Tizen::Base::Runtime::IEventListener
158 _VisualElementImplicitAnimationEventListener(void) {}
159 virtual ~_VisualElementImplicitAnimationEventListener(void) {}
161 virtual void OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target) {}
162 virtual void OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount) {}
163 virtual void OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally)
170 IMPLEMENT_PROPERTY(_VisualElementImpl);
172 _VisualElementImpl::_VisualElementImpl(VisualElement& element)
173 : _zOrderGroup(Z_ORDER_GROUP_NORMAL)
174 , __pSharedData(null)
177 , __pPresentation(null)
181 , __showOpacity(0.0f)
182 , __needRecreateSurface(false)
183 , __bounds(0.0f, 0.0f, 0.0f, 0.0f)
184 , __alignedSize(0.0f, 0.0f)
185 , __contentBounds(0.0f, 0.0f, 1.0f, 1.0f)
186 , __useContentBounds(false)
188 , __contentOpacity(1.0f)
190 , __anchor(0.5f, 0.5f)
193 , __decomposedTransform()
194 , __childrenTransform()
195 , __decomposedChildrenTransform()
196 , __childrenNeedsUpdateProps(HIERARCHY_PROPERTY_MASK & ~HIERARCHY_PROPERTY_CONTENT)
197 , __invalidatedProps(HIERARCHY_PROPERTY_MASK& ~HIERARCHY_PROPERTY_CONTENT)
198 , __matrixFromTopValid(false)
199 , __matrixFromTopInvertible(true)
200 , __matrixToSuperValid(false)
201 , __matrixToTopValid(false)
202 , __matrixToClipSourceValid(false)
203 , __boundingBoxValid(false)
204 , __visibleRectValid(false)
205 , __needTransform(false)
206 , __needClipForUntransformed(false)
207 , __isImplicitAnimationEnabled(true)
208 , __isClipChildren(false)
209 , __boundingBox(0.0f, 0.0f, 0.0f, 0.0f)
210 , __pClipSource(null)
211 , __visibleRect(0.0f, 0.0f, 0.0f, 0.0f)
212 , __isPropertyPropagationEnabled(true)
213 , __isDestroying(false)
214 , __isHidingParent(false)
215 , __isInternal(false)
216 , __isAllowedTreeModification(true)
217 , __pPublicInstance(&element)
219 , __renderOperation(VisualElement::RENDER_OPERATION_BLEND)
220 , __pBoundsChangedCallback(null)
221 , __pBoundsChangedCallbackData(null)
225 __children.Construct();
228 _VisualElementImpl::_VisualElementImpl(VisualElement& presentation, _VisualElementImpl& modelImpl)
229 : _zOrderGroup(modelImpl._zOrderGroup)
230 , __pSharedData(null)
233 , __pPresentation(null)
235 , __isRoot(modelImpl.__isRoot)
236 , __isVisible(modelImpl.__isVisible)
237 , __showOpacity(modelImpl.__showOpacity)
238 , __needRecreateSurface(false)
239 , __bounds(modelImpl.__bounds)
240 , __alignedSize(modelImpl.__alignedSize)
241 , __contentBounds(modelImpl.__contentBounds)
242 , __useContentBounds(modelImpl.__useContentBounds)
243 , __zPosition(modelImpl.__zPosition)
244 , __contentOpacity(modelImpl.__contentOpacity)
245 , __opacity(modelImpl.__opacity)
246 , __anchor(modelImpl.__anchor)
247 , __anchorZ(modelImpl.__anchorZ)
248 , __transform(modelImpl.__transform)
249 , __decomposedTransform(modelImpl.__decomposedTransform)
250 , __childrenTransform(modelImpl.__childrenTransform)
251 , __decomposedChildrenTransform(modelImpl.__decomposedChildrenTransform)
252 , __childrenNeedsUpdateProps(HIERARCHY_PROPERTY_MASK & ~HIERARCHY_PROPERTY_CONTENT)
253 , __invalidatedProps(HIERARCHY_PROPERTY_MASK & ~HIERARCHY_PROPERTY_CONTENT)
254 , __matrixFromTopValid(false)
255 , __matrixFromTopInvertible(true)
256 , __matrixToSuperValid(false)
257 , __matrixToTopValid(false)
258 , __matrixToClipSourceValid(false)
259 , __boundingBoxValid(false)
260 , __visibleRectValid(false)
261 , __needTransform(modelImpl.__needTransform)
262 , __needClipForUntransformed(modelImpl.__needClipForUntransformed)
263 , __isImplicitAnimationEnabled(modelImpl.__isImplicitAnimationEnabled)
264 , __isClipChildren(modelImpl.__isClipChildren)
265 , __boundingBox(0.0f, 0.0f, 0.0f, 0.0f)
266 , __pClipSource(null)
267 , __visibleRect(0.0f, 0.0f, 0.0f, 0.0f)
268 , __isPropertyPropagationEnabled(false) // it differs from the property of MODEL object
269 , __isDestroying(false)
270 , __isHidingParent(modelImpl.__isHidingParent)
271 , __isInternal(modelImpl.__isInternal)
272 , __isAllowedTreeModification(true)
273 , __pPublicInstance(&presentation)
274 , __imageFilePath(modelImpl.__imageFilePath)
275 , __renderOperation(modelImpl.__renderOperation)
276 , __pBoundsChangedCallback(modelImpl.__pBoundsChangedCallback)
277 , __pBoundsChangedCallbackData(modelImpl.__pBoundsChangedCallbackData)
281 //GetSharedData().AddRef();
283 __children.Construct();
285 //GetSharedData().invalidatedNativeProps = HIERARCHY_PROPERTY_MASK;
288 //modelImpl.__pPresentation = this;
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;
305 // Remove property observer finally
306 // if (IsPropertyChangeEventListenerAdded())
308 // RemovePropertyChangeEventListener(_VisualElementModelObserver::GetInstance());
313 _VisualElementImpl::Destroy(void)
315 //SysLog(NID_UI_ANIM, "destruct[%x]-->begin", this);
317 if (unlikely(__isDestroying))
322 __isDestroying = true;
326 // Destroy and its callback will be called from the leaf of hiearchy tree first.
327 // That is, this method first destroys children(Destroy and OnDestructing), and it destroys itself later.
329 while (__children.GetCount() > 0)
331 _VisualElementImpl* pChild = __children.GetChildAt(0);
334 //pChild->RemoveFromParent();
336 if (likely(pChild->__pPublicInstance))
338 pChild->__pPublicInstance->Destroy();
342 SysAssertf(false, "VisualElement does not have public instance.");
348 SysAssertf(false, "VisualElement has no child.");
355 // Is this right place for invoking 'OnDestructing' ?
356 // OnConstructed will be called from public instance.
358 if (!IS_PRESENTATION(this))
360 VE_DELEGATE(this, InvokeOnDestructing);
369 if (likely(__pPresentation))
371 __pPresentation->__pPublicInstance->Destroy();
373 __pPresentation = null;
377 _AnimationManager::GetInstance()->RemoveAllAnimations(*__pPublicInstance);
386 _VisualElementImpl::Construct(void)
388 result r = E_SUCCESS;
389 __pSharedData = new (std::nothrow) _VisualElementSharedData;
390 SysTryCatch(NID_UI_ANIM, __pSharedData, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
391 SysTryCatch(NID_UI_ANIM, GetSharedData().Construct() == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] failed in shared data constructing.");
394 __pPresentation = null;
395 //SysLog(NID_UI_ANIM, "Created(efl=%p)", GetSharedData().pNativeNode);
397 #if 0 // REMOVED : We should invoke property observer method manually.
398 if (__isPropertyPropagationEnabled)
400 AddPropertyChangeEventListener(_VisualElementModelObserver::GetInstance());
404 //VE_DELEGATE(this, InvokeOnConstructed);
410 if (likely(__pSharedData))
412 GetSharedData().Release();
413 __pSharedData = null;
419 IVisualElementAnimationProvider*
420 _VisualElementImpl::GetAnimationProvider(void) const
423 SysTryReturn(NID_UI_ANIM, IS_MODEL(this), null, E_INVALID_OPERATION, "[E_INVALID_OPERATION] VisualElement is not Model object.");
425 return GetSharedData().pAnimationProvider;
429 _VisualElementImpl::SetAnimationProvider(IVisualElementAnimationProvider* pProvider)
431 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
433 GetSharedData().pAnimationProvider = pProvider;
438 IVisualElementContentProvider*
439 _VisualElementImpl::GetContentProvider(void) const
442 SysTryReturn(NID_UI_ANIM, IS_MODEL(this), null, E_INVALID_OPERATION, "[E_INVALID_OPERATION] VisualElement is not Model object.");
444 return GetSharedData().pContentProvider;
448 _VisualElementImpl::SetContentProvider(IVisualElementContentProvider* pProvider)
450 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
452 GetSharedData().pContentProvider = pProvider;
457 IVisualElementEventListener*
458 _VisualElementImpl::GetVisualElementEventListener(void) const
461 SysTryReturn(NID_UI_ANIM, IS_MODEL(this), null, E_INVALID_OPERATION, "[E_INVALID_OPERATION] VisualElement is not Model object.");
463 return GetSharedData().pEventListener;
467 _VisualElementImpl::SetVisualElementEventListener(IVisualElementEventListener* pListener)
469 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
471 GetSharedData().pEventListener = pListener;
477 _VisualElementImpl::FlushI(void)
479 #ifdef VE_VSYNC_UPDATE
480 _DisplayManager::GetInstance()->RenderAll();
483 return _DisplayManager::GetInstance()->Flush();
487 _VisualElementImpl::SetImageSource(const String& filePath)
489 RebuildHierarchyProps(0, true, true);
491 SysTryReturnResult(NID_UI_ANIM, HAVE_SURFACE(this), E_SYSTEM, "Realizing back-buffer surface failed.");
493 result r = GetSharedData().SetImage(filePath);
494 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
496 __imageFilePath = filePath;
503 _VisualElementImpl::CreateImplicitAnimationIfNeeded( const String& property,
504 const Variant& newValue, const Variant& currentPresentationValue, const String** pSubProperties)
508 _AnimationManager* pAnimationManager = _AnimationManager::GetInstance();
510 if (likely(GetRoot())
511 && likely(GetSharedData().needSurface)
512 && (unlikely(pAnimationManager->IsImplicitAnimationEnabled() && __isImplicitAnimationEnabled)) )
515 // For performance, following must be done only when oldValue != newValue.
516 VisualElementAnimation* pAnimation = InvokeCreateAnimationForProperty(property);
518 // user can make other type animation like aAnimationGroup or ValueAnimation
519 // in this case pPropertyAnimation will have a null value.
520 VisualElementPropertyAnimation* pPropertyAnimation = dynamic_cast< VisualElementPropertyAnimation* >(pAnimation);
521 if (likely(pPropertyAnimation))
523 if (pPropertyAnimation->GetEndValue().IsEmpty())
525 pPropertyAnimation->SetEndValue(newValue);
528 if (pPropertyAnimation->GetStartValue().IsEmpty())
530 pPropertyAnimation->SetStartValue(currentPresentationValue);
535 { // remove sub property
536 for(int i = 0 ; pSubProperties[i] != NULL ; i++)
538 pAnimationManager->RemoveAnimationForProperty(*__pPublicInstance, *pSubProperties[i]);
541 if (unlikely(pAnimation))
544 // Adding property animation causes previous animation for same property to be removed in Animation Manager.
545 if (unlikely(IsFailed(AddAnimation(null, *pAnimation))))
547 pAnimationManager->RemoveAnimationForProperty(*__pPresentation->__pPublicInstance, property);
556 // Remove previous animation even when trying to change the property without animation.
557 pAnimationManager->RemoveAnimationForProperty(*__pPresentation->__pPublicInstance, property);
563 pAnimationManager->RemoveAnimationForProperty(*__pPresentation->__pPublicInstance, property);
571 _VisualElementImpl::SetRenderOperation(VisualElement::RenderOperation renderOperation)
573 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
575 result r = InvokeOnSetPropertyRequested(*pVePropRenderOperation, Variant(static_cast< int >(renderOperation)));
576 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
581 VisualElement::RenderOperation
582 _VisualElementImpl::GetRenderOperation(void) const
587 int renderOperation = InvokeOnGetPropertyRequested(*pVePropRenderOperation).ToInt();
588 if (GetLastResult() != E_SUCCESS)
590 return VisualElement::RENDER_OPERATION_BLEND;
593 return static_cast< VisualElement::RenderOperation >(renderOperation);
595 return __renderOperation;
600 _VisualElementImpl::GetRenderOperationProperty(void) const
604 return Variant(static_cast< int >(__renderOperation));
608 _VisualElementImpl::SetRenderOperationProperty(const Variant& v)
610 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_INT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
612 VisualElement::RenderOperation renderOperation = static_cast< VisualElement::RenderOperation >(v.ToInt());
613 if (likely(__renderOperation != renderOperation))
617 renderOperation >= VisualElement::RENDER_OPERATION_BLEND && renderOperation <= VisualElement::RENDER_OPERATION_COPY,
619 "Invalid argument(s) is used. The given render operation is out of range."
622 __renderOperation = renderOperation;
623 InvalidateHierarchyProps(HIERARCHY_PROPERTY_OPACITY, false, false);
625 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
627 __pPresentation->SetRenderOperationProperty(__renderOperation);
634 _VisualElementImpl::GetBackBufferEnabled(void) const
638 return GetSharedData().needSurface;
642 _VisualElementImpl::SetBackBufferEnabled(bool enabled)
644 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
646 if (likely(GetSharedData().needSurface != enabled))
649 // Need to check transform matrix if the transform matrix is complex(generic). In this case, disabling Backing-Buffer
650 // should not be allowed !
652 if (likely(NEED_SURFACE(this))) // may be redundant checking.... (or using !enabled). Check if this needs surface currently.
655 // __transform.Optimize();
656 // SysTryReturnResult(NID_UI_ANIM, !__transform.IsGeneric(), E_INVALID_STATE, "VisualElement cannot release back-buffer if transform isn't identity or translation.");
658 Matrix4Type matrixType = _GetMatrix4Type(__transform);
661 matrixType == MATRIX4_Identity || matrixType == MATRIX4_Translation,
663 "VisualElement cannot release back-buffer if transform isn't identity nor translation."
667 GetSharedData().needSurface = enabled;
669 if (NEED_SURFACE(this))
671 ExposeRectangle(null, true);
675 InvalidateVisibleRectToRenderTarget(null);
685 _VisualElementImpl::GetRedrawOnResizeEnabled(void) const
689 return GetSharedData().redrawOnResize;
693 _VisualElementImpl::SetRedrawOnResizeEnabled(bool enabled)
695 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
697 GetSharedData().redrawOnResize = enabled;
703 _VisualElementImpl::GetPropertyPropagationEnabled(void) const
707 // TBD: forward using property or direct return ?
709 bool isPropertyPropagationEnabled = InvokeOnGetPropertyRequested(*pVePropPropertyPropagationEnabled).ToBool();
710 if (GetLastResult() != E_SUCCESS)
715 return isPropertyPropagationEnabled;
717 return __isPropertyPropagationEnabled;
722 _VisualElementImpl::SetPropertyPropagationEnabledI(bool enable)
724 if (unlikely(enable == __isPropertyPropagationEnabled))
729 __isPropertyPropagationEnabled = enable;
731 // if (IS_MODEL(this))
733 // if (__isPropertyPropagationEnabled)
735 // AddPropertyChangeEventListener(_VisualElementModelObserver::GetInstance());
739 // RemovePropertyChangeEventListener(_VisualElementModelObserver::GetInstance());
747 _VisualElementImpl::SetPropertyPropagationEnabled(bool enable)
749 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
750 if (enable == __isPropertyPropagationEnabled)
753 result r = InvokeOnSetPropertyRequested(*pVePropPropertyPropagationEnabled, Variant(enable));
754 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
760 _VisualElementImpl::GetPropertyPropagationProperty(void) const
764 return Variant(__isPropertyPropagationEnabled);
768 _VisualElementImpl::SetPropertyPropagationProperty(const Variant& v)
771 // Remove this from property. It is used as a property because of _ControlVisualElement when a control was made up of three VEs.
772 if (IS_PRESENTATION(this))
775 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
777 return SetPropertyPropagationEnabledI(v.ToBool());
781 _VisualElementImpl::IsSurfaceNeeded(void) const
783 // TBD: root VE must have surface always...
784 if (unlikely(!__pParent))
790 const _VisualElementImpl* pCurrent;
795 if (!pCurrent->__pSharedData)
800 if (!pCurrent->GetSharedData().needSurface)
805 pCurrent = pCurrent->__pParent;
810 return GetSharedData().needSurface;
815 _VisualElementImpl::RebuildSurfaces(void)
817 if (unlikely(!IS_PRESENTATION(this)) || unlikely(!IS_ATTACHED(this)))
822 ResetSurfaceIfNeeded();
824 int count = __children.GetCount();
825 for (int i = 0; i < count; i++)
827 __children.GetChildAt(i)->RebuildSurfaces();
832 _VisualElementImpl::ResetSurfaceIfNeeded(void)
834 if (unlikely(!__needRecreateSurface))
839 __needRecreateSurface = false;
842 if (unlikely(HAVE_SURFACE(this)) && unlikely(GetSharedData().fixedSurfaceSize))
848 _VisualElementImpl* pPresentation = null;
850 if (likely(__pPresentation))
852 pPresentation = __pPresentation;
856 pPresentation = this;
860 if (likely(IsSurfaceNeeded()))
864 _RootVisualElement* pRoot = dynamic_cast<_RootVisualElement*>(GetRoot()->GetPublic());
866 if (pRoot && pRoot->GetNativeLayer())
868 GetSharedData().fixedSurfaceSize = false;
870 float surfaceWidth = __bounds.width;
871 float surfaceHeight = __bounds.height;
873 AdjustSizeForSurface(surfaceWidth, surfaceHeight);
875 if (likely(GetSharedData().CreateSurface(Dimension(static_cast< int >(surfaceWidth), static_cast< int >(surfaceHeight)), *pRoot->GetNativeLayer()) == E_SUCCESS))
877 if (unlikely(!HAVE_SURFACE(this)))
879 pPresentation->InvalidateVisibleRectToRenderTarget(null);
887 else // surface not needed, so remove Surface
889 if (unlikely(HAVE_SURFACE(this)))
891 GetSharedData().RemoveSurface(*pPresentation);
898 _VisualElementImpl::GetRenderTarget(void) const
900 _VisualElementImpl* pRenderTarget = const_cast< _VisualElementImpl* >(this);
902 while (likely(pRenderTarget))
904 if (likely(NEED_SURFACE(pRenderTarget)))
906 return pRenderTarget;
909 pRenderTarget = pRenderTarget->__pParent;
915 VisualElementSurface*
916 _VisualElementImpl::GetSurfaceN(void) const
918 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
919 pThis->RebuildHierarchyProps(0, true, true);
921 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.");
923 VisualElementSurface* pSurface = new (std::nothrow) VisualElementSurface(*pThis->GetSharedData().pSurface);
924 SysTryReturn(NID_UI_ANIM, pSurface, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
932 _VisualElementImpl::SetSurface(const VisualElementSurface* pSurface)
934 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
935 SysTryReturnResult(NID_UI_ANIM, NEED_SURFACE(this), E_INVALID_OPERATION, "A surface cannot be set if VisualElement need no back-buffer.");
937 if (unlikely(pSurface == GetSharedData().pSurface))
942 if (likely(pSurface) && likely(GetSharedData().pSurface))
944 if (unlikely(pSurface->Equals(*GetSharedData().pSurface)))
948 if (likely(pSurface))
950 unique_ptr<VisualElementSurface> pTempSurface(new (std::nothrow) VisualElementSurface(*pSurface));
951 SysTryReturnResult(NID_UI_ANIM, pTempSurface, E_OUT_OF_MEMORY, "Memory allocation failed.");
953 // Delete the old surface
954 if (GetSharedData().pSurface)
956 delete GetSharedData().pSurface;
959 GetSharedData().pSurface = pTempSurface.release();
960 GetSharedData().fixedSurfaceSize = true;
962 // Clear invalidated region if newly fixed-size surface is attached which do not need(inhibit) redrawing
963 GetSharedData().invalidatedRegion.SetBounds(0.0f, 0.0f, __bounds.width, __bounds.height);
967 // Delete the old surface
968 if (GetSharedData().pSurface)
970 delete GetSharedData().pSurface;
973 __needRecreateSurface = true;
975 GetSharedData().pSurface = null;
976 GetSharedData().fixedSurfaceSize = false;
978 // Fully invalidate because new surface should be allocated and redrawn
979 GetSharedData().invalidatedRegion.SetBounds(0.0f, 0.0f, __bounds.width, __bounds.height);
989 _VisualElementImpl::SetSurfaceChanged(void)
991 GetSharedData().surfaceChanged = true;
993 if (likely(!IS_PRESENTATION(this)))
997 __pPresentation->InvalidateHierarchyProps(HIERARCHY_PROPERTY_SURFACE, false, false);
1002 InvalidateHierarchyProps(HIERARCHY_PROPERTY_SURFACE, false, false);
1007 _VisualElementImpl::SetContentBoundsI(const FloatRectangle& contentBounds)
1009 // const Dimension& surfaceSize = GetSharedData().pSurface->GetSize();
1010 // SysTryReturn(NID_UI_ANIM,
1011 // contentBounds.x >= 0 && contentBounds.y >= 0 && contentBounds.width >= 0 && contentBounds.height >= 0 &&
1012 // contentBounds.x + contentBounds.width <= surfaceSize.width && contentBounds.y + contentBounds.height <= surfaceSize.height,
1015 // "[E_INVALID_ARG] Invalid content bounds.(%f,%f,%f,%f)", contentBounds.x, contentBounds.y, contentBounds.width, contentBounds.height
1018 if (unlikely(RectUtilIsEqual(__contentBounds, contentBounds)))
1021 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.");
1023 __contentBounds = contentBounds;
1024 __useContentBounds = (__contentBounds.x != 0.0f || __contentBounds.y != 0.0f || __contentBounds.width != 1.0f || __contentBounds.height != 1.0f);
1026 InvalidateHierarchyProps(HIERARCHY_PROPERTY_CONTENTBOUNDS, false, false);
1028 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1030 FloatRectangle currentValue = __pPresentation->__contentBounds;
1032 if(CreateImplicitAnimationIfNeeded(*pVePropContentBounds, __contentBounds, currentValue, NULL) == false)
1034 __pPresentation->SetContentBoundsProperty(__contentBounds);
1042 _VisualElementImpl::SetContentBounds(const FloatRectangle& contentBounds)
1044 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1046 return SetContentBoundsI(contentBounds);
1048 result r = InvokeOnSetPropertyRequested(*pVePropContentBounds, Variant(contentBounds));
1049 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1056 _VisualElementImpl::GetContentBounds(void) const
1060 return __contentBounds;
1064 _VisualElementImpl::GetContentBoundsProperty(void) const
1068 return Variant(__contentBounds);
1072 _VisualElementImpl::SetContentBoundsProperty(const Variant& v)
1074 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_RECTANGLE, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1076 return SetContentBoundsI(v.ToFloatRectangle());
1081 _VisualElementImpl::GetImplicitAnimationEnabled(void) const
1085 // TBD: forward using property or direct return ?
1087 bool isImplicitAnimationEnabled = InvokeOnGetPropertyRequested(*pVePropImplicitAnimationEnabled).ToBool();
1088 if (GetLastResult() != E_SUCCESS)
1091 return isImplicitAnimationEnabled;
1093 return __isImplicitAnimationEnabled;
1098 _VisualElementImpl::SetImplicitAnimationEnabled(bool enable)
1100 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1101 result r = InvokeOnSetPropertyRequested(*pVePropImplicitAnimationEnabled, Variant(enable));
1102 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1108 _VisualElementImpl::GetImplicitAnimationProperty(void) const
1112 return Variant(__isImplicitAnimationEnabled);
1116 _VisualElementImpl::SetImplicitAnimationProperty(const Variant& v)
1118 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1120 bool isImplicitAnimationEnabled = v.ToBool();
1121 if (isImplicitAnimationEnabled != __isImplicitAnimationEnabled)
1123 __isImplicitAnimationEnabled = isImplicitAnimationEnabled;
1125 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1127 __pPresentation->SetImplicitAnimationProperty(__isImplicitAnimationEnabled);
1134 _VisualElementImpl::GetBoundingBox(void) const
1138 return GetBoundingBoxI();
1142 _VisualElementImpl::GetBounds(void) const
1146 // TBD: forward using property or direct return ?
1148 FloatRectangle bounds = InvokeOnGetPropertyRequested(*pVePropBounds).ToFloatRectangle();
1149 if (GetLastResult() != E_SUCCESS)
1151 return FloatRectangle();
1161 _VisualElementImpl::SetBoundsI(const FloatRectangle& bounds)
1163 _Rectanglef boundsAdjusted(bounds);
1164 FloatRectangle oldValue(__bounds);
1166 result r = E_SUCCESS;
1167 bool sizeChanged = false;
1169 if (unlikely(GetSharedData().pEventListener != null))
1171 if (IS_MODEL(this)) // CHECKME: checking need??
1173 FloatRectangle tmpBounds(bounds);
1174 r = VE_DELEGATE(this, InvokeOnBoundsChanging, tmpBounds);
1176 boundsAdjusted = tmpBounds;
1180 if (likely(boundsAdjusted != __bounds))
1183 float newWidth = boundsAdjusted.Width();
1184 if (unlikely(newWidth < 0.0f))
1189 float newHeight = boundsAdjusted.Height();
1190 if (unlikely(newHeight < 0.0f))
1196 if (unlikely(newWidth != __bounds.width) || unlikely(newHeight != __bounds.height))
1201 // Adjust logical bounds(size) to sync. with that of surface(physical)
1203 float alignedWidth = newWidth;
1204 float alignedHeight = newHeight;
1206 AdjustSizeForSurface(alignedWidth, alignedHeight);
1208 __needRecreateSurface = true;
1209 if (likely(GetSharedData().pSurface))
1211 Dimension surfaceSize(GetSharedData().pSurface->GetSize());
1212 if (likely(static_cast< int >(alignedWidth) == surfaceSize.width) && likely(static_cast< int >(alignedHeight) == surfaceSize.height))
1213 __needRecreateSurface = false;
1216 _VisualElementCoordinateSystem::ConvertDimensionToPhysicalIntegral(alignedWidth, alignedHeight);
1217 _VisualElementCoordinateSystem::ConvertDimensionToLogical(alignedWidth, alignedHeight);
1219 if (newWidth > 0.0f && alignedWidth == 0.0f)
1221 alignedWidth = 1.0f / _VisualElementCoordinateSystem::scaleFactorX;
1224 if (newHeight > 0.0f && alignedHeight == 0.0f)
1226 alignedHeight = 1.0f / _VisualElementCoordinateSystem::scaleFactorY;
1229 __alignedSize.width = alignedWidth;
1230 __alignedSize.height = alignedHeight;
1234 // TODO: Need to optimize dirty rectangle.
1236 // invalidate with previous bounds
1237 if (unlikely(!NEED_SURFACE(this)))
1238 InvalidateVisibleRectToRenderTarget(null);
1241 // SysLog(NID_UI_ANIM, "size changing to " VELOGRECTTAG, VELOGRECT(boundsAdjusted));
1243 __bounds.x = boundsAdjusted.Left();
1244 __bounds.y = boundsAdjusted.Top();
1245 __bounds.width = newWidth;
1246 __bounds.height = newHeight;
1248 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false);
1250 // TBD: Recreating surface may have to be done in presentation layer (thread!)
1253 // Even when 'no redrawOnResize', it is needed to invalidate for redrawing if surface is not created yet.
1255 if (unlikely(sizeChanged))
1257 if (unlikely(!NEED_SURFACE(this)) || unlikely(GetSharedData().redrawOnResize))
1258 ExposeRectangle(null, true);
1261 // Shrink invalidated region to bounds
1262 RectUtilIntersect(GetSharedData().invalidatedRegion, FloatRectangle(0.0f, 0.0f, __bounds.width, __bounds.height));
1266 if (unlikely(!NEED_SURFACE(this)))
1267 ExposeRectangle(null, true);
1272 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1274 FloatRectangle currentValue = __pPresentation->__bounds;
1276 const String* subProperties[] = { pVeSubPropBoundsSize, pVeSubPropBoundsPosition, NULL };
1277 if(CreateImplicitAnimationIfNeeded(*pVePropBounds, __bounds, currentValue, subProperties ) == false)
1279 __pPresentation->SetBoundsProperty(__bounds);
1282 VE_DELEGATE(this, InvokeOnBoundsChanged, oldValue);
1284 if(__pBoundsChangedCallback && sizeChanged == true)
1286 (*__pBoundsChangedCallback)(__pBoundsChangedCallbackData);
1296 _VisualElementImpl::SetBounds(const FloatRectangle& bounds)
1298 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1299 result r = E_SUCCESS;
1301 if (IS_INTERNAL_CLASS(__pPublicInstance))
1303 r = SetBoundsI(bounds);
1307 r = InvokeOnSetPropertyRequested(*pVePropBounds, Variant(bounds));
1309 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1315 _VisualElementImpl::GetBoundsProperty(void) const
1319 return Variant(__bounds);
1323 _VisualElementImpl::SetBoundsProperty(const Variant& v)
1325 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_RECTANGLE, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1327 return SetBoundsI(v.ToFloatRectangle());
1331 _VisualElementImpl::GetBoundsPositionSubProperty(void) const
1335 return Variant(__bounds.GetTopLeft());
1339 _VisualElementImpl::SetBoundsPositionSubProperty(const Variant& v)
1341 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1343 const FloatPoint& position = v.ToFloatPoint();
1344 return SetBoundsProperty(Variant(FloatRectangle(position.x, position.y, __bounds.width, __bounds.height)));
1348 _VisualElementImpl::GetBoundsSizeSubProperty(void) const
1352 return Variant(FloatDimension(__bounds.width, __bounds.height));
1356 _VisualElementImpl::SetBoundsSizeSubProperty(const Variant& v)
1358 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_DIMENSION, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1360 const FloatDimension& size = v.ToFloatDimension();
1361 return SetBoundsProperty(Variant(FloatRectangle(__bounds.x, __bounds.y, size.width, size.height)));
1365 _VisualElementImpl::GetZPosition(void) const
1369 // TBD: forward using property or direct return ?
1371 float zPosition = (const_cast< _VisualElementImpl* >(this))->InvokeOnGetPropertyRequested(*pVePropZPosition).ToFloat();
1372 if (GetLastResult() != E_SUCCESS)
1384 _VisualElementImpl::SetZPositionI(float zPosition)
1386 if (likely(zPosition != __zPosition))
1388 __zPosition = zPosition;
1389 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false); // lazy evaluation: property changed flag
1392 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1394 float currentValue = __pPresentation->__zPosition;
1396 if(CreateImplicitAnimationIfNeeded(*pVePropZPosition, __zPosition, currentValue, NULL) == false)
1398 __pPresentation->SetZPositionProperty(__zPosition);
1407 _VisualElementImpl::SetZPosition(float zPosition)
1409 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1410 result r = E_SUCCESS;
1412 if (IS_INTERNAL_CLASS(__pPublicInstance))
1414 r = SetZPositionI(zPosition);
1418 r = InvokeOnSetPropertyRequested(*pVePropZPosition, Variant(zPosition));
1421 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1429 _VisualElementImpl::GetZPositionProperty(void) const
1433 return Variant(__zPosition);
1437 _VisualElementImpl::SetZPositionProperty(const Variant& v)
1439 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1441 return SetZPositionI(v.ToFloat());
1445 _VisualElementImpl::SetZOrderGroupI(int zOrderGroup)
1447 result r = E_SUCCESS;
1449 if (likely(__pParent))
1451 r= __pParent->ChangeZOrder(*this, null, true, zOrderGroup);
1455 _zOrderGroup = zOrderGroup;
1458 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1460 __pPresentation->SetZOrderGroupProperty(_zOrderGroup);
1466 _VisualElementImpl::SetZOrderGroup(int zOrderGroup)
1468 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1469 result r = E_SUCCESS;
1471 if (IS_INTERNAL_CLASS(__pPublicInstance))
1473 r = SetZOrderGroupI(zOrderGroup);
1477 r = InvokeOnSetPropertyRequested(*pVePropZOrderGroup, Variant(zOrderGroup));
1480 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1486 _VisualElementImpl::GetZOrderGroup(void) const
1490 return _zOrderGroup;
1494 _VisualElementImpl::GetZOrderGroupProperty(void) const
1498 return Variant(_zOrderGroup);
1502 _VisualElementImpl::SetZOrderGroupProperty(const Variant& v)
1504 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_INT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1507 return SetZOrderGroupI(v.ToInt());
1513 _VisualElementImpl::IsVisible(void) const
1517 return IsVisibleI();
1522 _VisualElementImpl::IsVisibleI(void) const
1525 const _VisualElementImpl* pElement = this;
1526 const _VisualElementImpl* pRoot = GetRoot();
1528 if (unlikely(!pRoot))
1533 if (!VE_VISIBLE(pElement))
1539 if (!pElement->__pParent)
1541 if (dynamic_cast< const _RootVisualElement* >(pElement) == null)
1547 if (!pElement->__pParent && pElement != pRoot)
1551 pElement = pElement->__pParent;
1556 if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
1558 const_cast< _VisualElementImpl* >(this)->RebuildCoordinates();
1567 _VisualElementImpl::GetShowState(void) const
1571 // TBD: forward using property or direct return ?
1573 return InvokeOnGetPropertyRequested(*pVePropShowState).ToBool();
1575 return VE_VISIBLE(this);
1580 _VisualElementImpl::SetShowOpacityI(float showOpacity)
1582 bool oldShowState = SHOWOPACITY_VISIBLE(__showOpacity);
1584 if (unlikely(showOpacity < 0.0f))
1588 else if (unlikely(showOpacity > 1.0f))
1593 if (likely(__showOpacity != showOpacity))
1596 bool showStateChanged = (oldShowState != SHOWOPACITY_VISIBLE(showOpacity));
1598 __showOpacity = showOpacity;
1600 if (likely(showStateChanged))
1605 // Coordinates are calculated using visibleRect which is empty when invisible state.
1606 // Show-Recalculation is needed when being visible !
1607 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES | HIERARCHY_PROPERTY_SHOWSTATE | HIERARCHY_PROPERTY_OPACITY, true, false);
1609 if (unlikely(!NEED_SURFACE(this)))
1611 ExposeRectangle(null, true);
1616 InvalidateHierarchyProps(HIERARCHY_PROPERTY_SHOWSTATE | HIERARCHY_PROPERTY_OPACITY, true, false);
1618 if (unlikely(!NEED_SURFACE(this)))
1620 InvalidateVisibleRectToRenderTarget(null);
1627 // showOpacity is applicable only for surfaces
1628 if (likely(NEED_SURFACE(this)))
1630 InvalidateHierarchyProps(HIERARCHY_PROPERTY_OPACITY, true, false);
1635 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1637 bool needPresentationUpdate = true;
1638 const String& property = *pVePropShowState;
1639 _AnimationManager* pAnimationManager = _AnimationManager::GetInstance();
1641 if (likely(GetRoot()) && likely(GetSharedData().needSurface)
1642 && (unlikely(pAnimationManager->IsImplicitAnimationEnabled() && __isImplicitAnimationEnabled)))
1645 // For performance, following must be done only when oldValue != newValue.
1646 VisualElementAnimation* pAnimation = InvokeCreateAnimationForProperty(property);
1647 VisualElementPropertyAnimation* pPropertyAnimation = NULL;
1650 pPropertyAnimation = new (std::nothrow) VisualElementPropertyAnimation();
1651 if(pPropertyAnimation)
1653 pPropertyAnimation->SetPropertyName(*pVePrivPropShowOpacity);
1654 needPresentationUpdate = true;
1659 pPropertyAnimation = dynamic_cast< VisualElementPropertyAnimation* >(pAnimation);
1662 if (likely(pPropertyAnimation))
1664 if (pPropertyAnimation->GetEndValue().IsEmpty())
1666 pPropertyAnimation->SetEndValue(__showOpacity);
1669 if (pPropertyAnimation->GetStartValue().IsEmpty())
1671 pPropertyAnimation->SetStartValue(__pPresentation->__showOpacity);
1675 if (unlikely(pPropertyAnimation))
1678 // Adding property animation causes previous animation for same property to be removed in Animation Manager.
1679 if (unlikely(IsFailed(AddAnimation(null, *pPropertyAnimation))))
1681 needPresentationUpdate = true;
1682 //pAnimationManager->RemoveAnimationForProperty(*presentation.GetPublic(), property);
1685 delete pPropertyAnimation;
1690 // Remove previous animation even when trying to change the property without animation.
1691 pAnimationManager->RemoveAnimationForProperty(*__pPresentation->__pPublicInstance, property);
1692 needPresentationUpdate = true;
1697 pAnimationManager->RemoveAnimationForProperty(*__pPresentation->__pPublicInstance, property);
1698 needPresentationUpdate = true;
1701 if(needPresentationUpdate)
1703 __pPresentation->SetShowStateProperty(SHOWOPACITY_VISIBLE(__showOpacity));
1705 InvokeOnShowStateChanged(oldShowState);
1713 _VisualElementImpl::SetShowStateI(bool show)
1715 return SetShowOpacityI(show ? 1.0f : 0.0f);
1719 _VisualElementImpl::SetShowState(bool show)
1721 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1722 result r = E_SUCCESS;
1724 if (IS_INTERNAL_CLASS(__pPublicInstance))
1726 r = SetShowOpacityI(show ? 1.0f : 0.0f);
1730 r = InvokeOnSetPropertyRequested(*pVePropShowState, Variant(show));
1733 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1739 _VisualElementImpl::GetShowStateProperty(void) const
1743 return Variant(VE_VISIBLE(this));
1747 _VisualElementImpl::SetShowStateProperty(const Variant& v)
1749 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1751 bool showState = v.ToBool();
1753 return SetShowOpacityI(showState ? 1.0f : 0.0f);
1757 _VisualElementImpl::GetShowOpacityPrivateProperty(void) const
1761 return Variant(__showOpacity);
1765 _VisualElementImpl::SetShowOpacityPrivateProperty(const Variant& v)
1767 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1769 return SetShowOpacityI(v.ToFloat());
1773 _VisualElementImpl::GetContentOpacity(void) const
1777 // TBD: forward using property or direct return ?
1779 return InvokeOnGetPropertyRequested(*pVePropContentOpacity).ToFloat();
1781 return __contentOpacity;
1786 _VisualElementImpl::SetContentOpacityI(float contentOpacity)
1788 if (unlikely(contentOpacity == __contentOpacity)) // do not take care of float-error !!
1793 SysTryReturnResult(NID_UI_ANIM, contentOpacity >= 0.0f && contentOpacity <= 1.0f, E_INVALID_ARG, "Invalid argument(s) is used. Invalid opacity range.");
1795 __contentOpacity = contentOpacity;
1797 InvalidateHierarchyProps(HIERARCHY_PROPERTY_CONTENTOPACITY, false, false); //don't have to apply the changed opacity to children.
1799 #ifndef LAZY_EVALUATION
1800 if (IS_PRESENTATION(this) && likely(__pSharedData) && likely(GetSharedData().pNativeNode))
1802 GetSharedData().NodeReconfigure(*this);
1806 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1808 float currentValue = __pPresentation->__contentOpacity;
1810 if(CreateImplicitAnimationIfNeeded(*pVePropContentOpacity, __contentOpacity, currentValue, NULL) == false)
1812 __pPresentation->SetContentOpacityProperty(__contentOpacity);
1820 _VisualElementImpl::SetContentOpacity(float contentOpacity)
1822 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1823 result r = E_SUCCESS;
1825 // PROPERTY_PROCESS(SetContentOpacityI, GetContentOpacityProperty, SetContentOpacityProperty, pVePropContentOpacity, __contentOpacity, contentOpacity);
1826 if (IS_INTERNAL_CLASS(__pPublicInstance))
1828 r = SetContentOpacityI(contentOpacity);
1832 r = InvokeOnSetPropertyRequested(*pVePropContentOpacity, Variant(contentOpacity));
1835 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1842 _VisualElementImpl::GetContentOpacityProperty(void) const
1846 return Variant(__contentOpacity);
1850 _VisualElementImpl::SetContentOpacityProperty(const Variant& v)
1852 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1854 return SetContentOpacityI(v.ToFloat());
1858 _VisualElementImpl::GetOpacity(void) const
1862 // TBD: forward using property or direct return ?
1864 return InvokeOnGetPropertyRequested(*pVePropOpacity).ToFloat();
1871 _VisualElementImpl::SetOpacityI(float opacity)
1873 if (likely(opacity != __opacity)) // do not take care of float-error !!
1875 if (unlikely(opacity > 1.0f))
1879 else if (unlikely(opacity < 0.0f))
1884 __opacity = opacity;
1886 InvalidateHierarchyProps(HIERARCHY_PROPERTY_OPACITY, true, false);
1889 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1891 float currentValue = __pPresentation->__opacity;
1893 if(CreateImplicitAnimationIfNeeded(*pVePropOpacity, __opacity, currentValue, NULL) == false)
1895 __pPresentation->SetOpacityProperty(__opacity);
1902 _VisualElementImpl::SetOpacity(float opacity)
1904 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1905 result r = E_SUCCESS;
1907 // PROPERTY_PROCESS(SetOpacityI, GetOpacityProperty, SetOpacityProperty, pVePropOpacity, __opacity, opacity);
1908 if (IS_INTERNAL_CLASS(__pPublicInstance))
1910 r = SetOpacityI(opacity);
1914 r = InvokeOnSetPropertyRequested(*pVePropOpacity, Variant(opacity));
1917 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1923 _VisualElementImpl::GetOpacityProperty(void) const
1927 return Variant(__opacity);
1931 _VisualElementImpl::SetOpacityProperty(const Variant& v)
1933 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
1935 return SetOpacityI(v.ToFloat());
1939 _VisualElementImpl::GetAnchor(void) const
1943 // TBD: forward using property or direct return ?
1945 return InvokeOnGetPropertyRequested(*pVePropAnchor).ToFloatPoint();
1952 _VisualElementImpl::SetAnchorI(const FloatPoint& anchor)
1954 if (likely(anchor != __anchor))
1959 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false);
1961 // VE with surface will be exposed automatically on rebuilding coordinates...
1962 if (unlikely(!HAVE_SURFACE(this)))
1964 ExposeRectangle(null, true); // CHECKME: needed ???
1968 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
1970 FloatPoint currentValue = __pPresentation->__anchor;
1972 if(CreateImplicitAnimationIfNeeded(*pVePropAnchor, __anchor, currentValue, NULL) == false)
1974 __pPresentation->SetAnchorProperty(__anchor);
1982 _VisualElementImpl::SetAnchor(const FloatPoint& anchor)
1984 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
1985 result r = E_SUCCESS;
1987 // PROPERTY_PROCESS(SetAnchorI, GetAnchorProperty, SetAnchorProperty, pVePropAnchor, __anchor, anchor);
1988 if (IS_INTERNAL_CLASS(__pPublicInstance))
1990 r = SetAnchorI(anchor);
1994 r = InvokeOnSetPropertyRequested(*pVePropAnchor, Variant(anchor));
1997 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
2004 _VisualElementImpl::GetAnchorProperty(void) const
2008 return Variant(__anchor);
2012 _VisualElementImpl::SetAnchorProperty(const Variant& v)
2014 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2016 return SetAnchorI(v.ToFloatPoint());
2020 _VisualElementImpl::GetAnchorZ(void) const
2024 // TBD: forward using property or direct return ?
2026 return InvokeOnGetPropertyRequested(*pVePropAnchorZ).ToFloat();
2033 _VisualElementImpl::SetAnchorZI(float anchorZ)
2035 if (likely(anchorZ != __anchorZ))
2037 __anchorZ = anchorZ;
2039 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false);
2041 // VE with surface will be exposed automatically on rebuilding coordinates...
2042 if (unlikely(!HAVE_SURFACE(this)))
2044 ExposeRectangle(null, true); // CHECKME: needed ???
2048 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
2050 float currentValue = __pPresentation->__anchorZ;
2052 if(CreateImplicitAnimationIfNeeded(*pVePropAnchorZ, __anchorZ, currentValue, NULL) == false)
2054 __pPresentation->SetAnchorZProperty(__anchorZ);
2062 _VisualElementImpl::SetAnchorZ(float anchorZ)
2064 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
2065 result r = E_SUCCESS;
2067 // PROPERTY_PROCESS(SetAnchorZI, GetAnchorZProperty, SetAnchorZProperty, pVePropAnchorZ, __anchorZ, anchorZ);
2068 if (IS_INTERNAL_CLASS(__pPublicInstance))
2070 r = SetAnchorZI(anchorZ);
2074 r = InvokeOnSetPropertyRequested(*pVePropAnchorZ, Variant(anchorZ));
2077 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
2085 _VisualElementImpl::GetAnchorZProperty(void) const
2089 return Variant(__anchorZ);
2093 _VisualElementImpl::SetAnchorZProperty(const Variant& v)
2095 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2097 return SetAnchorZI(v.ToFloat());
2101 _VisualElementImpl::GetTransformMatrix(void) const
2105 // TBD: forward using property or direct return ?
2107 return InvokeOnGetPropertyRequested(*pVePropTransform).ToFloatMatrix4();
2114 _VisualElementImpl::SetTransformMatrixI(const FloatMatrix4& xform, bool updateDecomposed)
2117 result r = E_SUCCESS;
2119 FloatMatrix4 oldValue(__transform);
2121 FloatMatrix4 matrixAdjusted(xform);
2123 if (unlikely(GetSharedData().pEventListener != null))
2125 if (IS_MODEL(this)) // CHECKME: checking need??
2127 r = VE_DELEGATE(this, InvokeOnTransformMatrixChanging, matrixAdjusted);
2131 if (r == E_SUCCESS && likely(matrixAdjusted != __transform)) // check again because delegate may change the transform matrix
2133 // render target updates for previous bounds
2134 if (unlikely(!NEED_SURFACE(this)))
2136 InvalidateVisibleRectToRenderTarget(null);
2140 MatrixUtilCopy(__transform, matrixAdjusted);
2142 if (unlikely(updateDecomposed))
2144 __decomposedTransform.SetTransformMatrix(__transform);
2147 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false);
2149 // VE with surface will be exposed automatically on rebuilding coordinates...
2150 if (unlikely(!NEED_SURFACE(this)))
2152 ExposeRectangle(null, true); // CHECKME: needed ???
2156 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
2158 FloatMatrix4 currentValue = __pPresentation->__transform;
2160 const String* subProperties[] = { pVeSubPropTransformRotationX,
2161 pVeSubPropTransformRotationY,
2162 pVeSubPropTransformRotationZ,
2163 pVeSubPropTransformScaleX,
2164 pVeSubPropTransformScaleY,
2165 pVeSubPropTransformScaleZ,
2166 pVeSubPropTransformTranslationX,
2167 pVeSubPropTransformTranslationY,
2168 pVeSubPropTransformTranslationZ,
2169 pVeSubPropTransformRotationAnchorX,
2170 pVeSubPropTransformRotationAnchorY,
2171 pVeSubPropTransformRotationAnchorZ,
2172 pVeSubPropTransformScaleAnchorX,
2173 pVeSubPropTransformScaleAnchorY,
2174 pVeSubPropTransformScaleAnchorZ,
2177 if(CreateImplicitAnimationIfNeeded(*pVePropTransform, __transform, currentValue, subProperties ) == false)
2179 __pPresentation->SetTransformMatrixProperty(__transform);
2182 VE_DELEGATE(this, InvokeOnTransformMatrixChanged, oldValue);
2188 _VisualElementImpl::SetTransformMatrix(const FloatMatrix4& xform)
2190 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
2191 result r = E_SUCCESS;
2193 // PROPERTY_PROCESS(SetTransformMatrixI, GetTransformMatrixProperty, SetTransformMatrixProperty, pVePropTransform, __transform, xform);
2194 if (IS_INTERNAL_CLASS(__pPublicInstance))
2196 r = SetTransformMatrixI(xform);
2200 r = InvokeOnSetPropertyRequested(*pVePropTransform, Variant(xform));
2203 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
2211 _VisualElementImpl::GetTransformMatrixProperty(void) const
2215 return Variant(__transform);
2220 _VisualElementImpl::SetTransformMatrixProperty(const Variant& v)
2222 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_MATRIX4, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2224 return SetTransformMatrixI(v.ToFloatMatrix4(), true);
2228 _VisualElementImpl::GetTransformRotationXSubProperty(void) const
2232 float angleX = 0.0f;
2233 float angleY = 0.0f;
2234 float angleZ = 0.0f;
2235 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2237 return Variant(angleX);
2241 _VisualElementImpl::SetTransformRotationXSubProperty(const Variant& v)
2243 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2245 float angleX = 0.0f;
2246 float angleY = 0.0f;
2247 float angleZ = 0.0f;
2248 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2249 __decomposedTransform.UpdateRotationFromEulerAngles(v.ToFloat(), angleY, angleZ);
2251 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2255 _VisualElementImpl::GetTransformRotationYSubProperty(void) const
2259 float angleX = 0.0f;
2260 float angleY = 0.0f;
2261 float angleZ = 0.0f;
2262 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2264 return Variant(angleY);
2268 _VisualElementImpl::SetTransformRotationYSubProperty(const Variant& v)
2270 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2272 float angleX = 0.0f;
2273 float angleY = 0.0f;
2274 float angleZ = 0.0f;
2275 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2276 __decomposedTransform.UpdateRotationFromEulerAngles(angleX, v.ToFloat(), angleZ);
2278 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2282 _VisualElementImpl::GetTransformRotationZSubProperty(void) const
2286 float angleX = 0.0f;
2287 float angleY = 0.0f;
2288 float angleZ = 0.0f;
2289 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2291 return Variant(angleZ);
2295 _VisualElementImpl::SetTransformRotationZSubProperty(const Variant& v)
2297 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2299 float angleX = 0.0f;
2300 float angleY = 0.0f;
2301 float angleZ = 0.0f;
2302 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2303 __decomposedTransform.UpdateRotationFromEulerAngles(angleX, angleY, v.ToFloat());
2305 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2309 _VisualElementImpl::GetTransformRotationXYSubProperty(void) const
2313 float angleX = 0.0f;
2314 float angleY = 0.0f;
2315 float angleZ = 0.0f;
2316 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2318 return Variant(FloatPoint(angleX, angleY));
2322 _VisualElementImpl::SetTransformRotationXYSubProperty(const Variant& v)
2324 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2326 const FloatPoint& point = v.ToFloatPoint();
2328 float angleX = 0.0f;
2329 float angleY = 0.0f;
2330 float angleZ = 0.0f;
2331 __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ);
2332 __decomposedTransform.UpdateRotationFromEulerAngles(point.x, point.y, angleZ);
2334 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2338 _VisualElementImpl::GetTransformRotationAnchorXSubProperty(void) const
2342 float anchorX = 0.0f;
2343 float anchorY = 0.0f;
2344 float anchorZ = 0.0f;
2345 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2347 return Variant(anchorX);
2351 _VisualElementImpl::SetTransformRotationAnchorXSubProperty(const Variant& v)
2353 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2355 float anchorX = 0.0f;
2356 float anchorY = 0.0f;
2357 float anchorZ = 0.0f;
2358 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2359 __decomposedTransform.SetRotationAnchor(v.ToFloat(), anchorY, anchorZ);
2361 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2365 _VisualElementImpl::GetTransformRotationAnchorYSubProperty(void) const
2369 float anchorX = 0.0f;
2370 float anchorY = 0.0f;
2371 float anchorZ = 0.0f;
2372 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2374 return Variant(anchorY);
2378 _VisualElementImpl::SetTransformRotationAnchorYSubProperty(const Variant& v)
2380 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2382 float anchorX = 0.0f;
2383 float anchorY = 0.0f;
2384 float anchorZ = 0.0f;
2385 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2386 __decomposedTransform.SetRotationAnchor(anchorX, v.ToFloat(), anchorZ);
2388 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2392 _VisualElementImpl::GetTransformRotationAnchorZSubProperty(void) const
2396 float anchorX = 0.0f;
2397 float anchorY = 0.0f;
2398 float anchorZ = 0.0f;
2399 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2401 return Variant(anchorZ);
2405 _VisualElementImpl::SetTransformRotationAnchorZSubProperty(const Variant& v)
2407 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2409 float anchorX = 0.0f;
2410 float anchorY = 0.0f;
2411 float anchorZ = 0.0f;
2412 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2413 __decomposedTransform.SetRotationAnchor(anchorX, anchorY, v.ToFloat());
2415 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2419 _VisualElementImpl::GetTransformRotationAnchorXYSubProperty(void) const
2423 float anchorX = 0.0f;
2424 float anchorY = 0.0f;
2425 float anchorZ = 0.0f;
2426 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2428 return Variant(FloatPoint(anchorX, anchorY));
2432 _VisualElementImpl::SetTransformRotationAnchorXYSubProperty(const Variant& v)
2434 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2436 const FloatPoint& point = v.ToFloatPoint();
2438 float anchorX = 0.0f;
2439 float anchorY = 0.0f;
2440 float anchorZ = 0.0f;
2441 __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
2442 __decomposedTransform.SetRotationAnchor(point.x, point.y, anchorZ);
2444 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2448 _VisualElementImpl::GetTransformScaleXSubProperty(void) const
2452 float scaleX = 1.0f;
2453 float scaleY = 1.0f;
2454 float scaleZ = 1.0f;
2455 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2457 return Variant(scaleX);
2461 _VisualElementImpl::SetTransformScaleXSubProperty(const Variant& v)
2463 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2465 float scaleX = 1.0f;
2466 float scaleY = 1.0f;
2467 float scaleZ = 1.0f;
2468 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2469 __decomposedTransform.SetScaleFactors(v.ToFloat(), scaleY, scaleZ);
2471 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2475 _VisualElementImpl::GetTransformScaleYSubProperty(void) const
2479 float scaleX = 1.0f;
2480 float scaleY = 1.0f;
2481 float scaleZ = 1.0f;
2482 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2484 return Variant(scaleY);
2488 _VisualElementImpl::SetTransformScaleYSubProperty(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 scaleX = 1.0f;
2493 float scaleY = 1.0f;
2494 float scaleZ = 1.0f;
2495 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2496 __decomposedTransform.SetScaleFactors(scaleX, v.ToFloat(), scaleZ);
2498 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2502 _VisualElementImpl::GetTransformScaleZSubProperty(void) const
2506 float scaleX = 1.0f;
2507 float scaleY = 1.0f;
2508 float scaleZ = 1.0f;
2509 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2511 return Variant(scaleZ);
2515 _VisualElementImpl::SetTransformScaleZSubProperty(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 scaleX = 1.0f;
2520 float scaleY = 1.0f;
2521 float scaleZ = 1.0f;
2522 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2523 __decomposedTransform.SetScaleFactors(scaleX, scaleY, v.ToFloat());
2525 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2529 _VisualElementImpl::GetTransformScaleXYSubProperty(void) const
2533 float scaleX = 1.0f;
2534 float scaleY = 1.0f;
2535 float scaleZ = 1.0f;
2536 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2538 return Variant(FloatPoint(scaleX, scaleY));
2542 _VisualElementImpl::SetTransformScaleXYSubProperty(const Variant& v)
2544 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2546 const FloatPoint& point = v.ToFloatPoint();
2548 float scaleX = 1.0f;
2549 float scaleY = 1.0f;
2550 float scaleZ = 1.0f;
2551 __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
2552 if (unlikely(scaleX == point.x) && unlikely(scaleY == point.y))
2557 __decomposedTransform.SetScaleFactors(point.x, point.y, scaleZ);
2559 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2563 _VisualElementImpl::GetTransformScaleAnchorXSubProperty(void) const
2567 float anchorX = 0.0f;
2568 float anchorY = 0.0f;
2569 float anchorZ = 0.0f;
2570 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2572 return Variant(anchorX);
2576 _VisualElementImpl::SetTransformScaleAnchorXSubProperty(const Variant& v)
2578 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2580 float anchorX = 0.0f;
2581 float anchorY = 0.0f;
2582 float anchorZ = 0.0f;
2583 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2584 __decomposedTransform.SetScaleAnchor(v.ToFloat(), anchorY, anchorZ);
2586 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2590 _VisualElementImpl::GetTransformScaleAnchorYSubProperty(void) const
2594 float anchorX = 0.0f;
2595 float anchorY = 0.0f;
2596 float anchorZ = 0.0f;
2597 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2599 return Variant(anchorY);
2603 _VisualElementImpl::SetTransformScaleAnchorYSubProperty(const Variant& v)
2605 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2607 float anchorX = 0.0f;
2608 float anchorY = 0.0f;
2609 float anchorZ = 0.0f;
2610 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2611 __decomposedTransform.SetScaleAnchor(anchorX, v.ToFloat(), anchorZ);
2613 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2617 _VisualElementImpl::GetTransformScaleAnchorZSubProperty(void) const
2621 float anchorX = 0.0f;
2622 float anchorY = 0.0f;
2623 float anchorZ = 0.0f;
2624 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2626 return Variant(anchorZ);
2630 _VisualElementImpl::SetTransformScaleAnchorZSubProperty(const Variant& v)
2632 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2634 float anchorX = 0.0f;
2635 float anchorY = 0.0f;
2636 float anchorZ = 0.0f;
2637 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2638 __decomposedTransform.SetScaleAnchor(anchorX, anchorY, v.ToFloat());
2640 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2644 _VisualElementImpl::GetTransformScaleAnchorXYSubProperty(void) const
2648 float anchorX = 0.0f;
2649 float anchorY = 0.0f;
2650 float anchorZ = 0.0f;
2651 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2653 return Variant(FloatPoint(anchorX, anchorY));
2657 _VisualElementImpl::SetTransformScaleAnchorXYSubProperty(const Variant& v)
2659 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2661 const FloatPoint& point = v.ToFloatPoint();
2663 float anchorX = 0.0f;
2664 float anchorY = 0.0f;
2665 float anchorZ = 0.0f;
2666 __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
2667 __decomposedTransform.SetScaleAnchor(point.x, point.y, anchorZ);
2669 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2673 _VisualElementImpl::GetTransformTranslationXSubProperty(void) const
2677 float translateX = 0.0f;
2678 float translateY = 0.0f;
2679 float translateZ = 0.0f;
2680 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2682 return Variant(translateX);
2686 _VisualElementImpl::SetTransformTranslationXSubProperty(const Variant& v)
2688 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2690 float translateX = 0.0f;
2691 float translateY = 0.0f;
2692 float translateZ = 0.0f;
2693 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2694 __decomposedTransform.SetTranslationFactors(v.ToFloat(), translateY, translateZ);
2696 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2700 _VisualElementImpl::GetTransformTranslationYSubProperty(void) const
2704 float translateX = 0.0f;
2705 float translateY = 0.0f;
2706 float translateZ = 0.0f;
2707 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2709 return Variant(translateY);
2713 _VisualElementImpl::SetTransformTranslationYSubProperty(const Variant& v)
2715 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2717 float translateX = 0.0f;
2718 float translateY = 0.0f;
2719 float translateZ = 0.0f;
2720 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2721 __decomposedTransform.SetTranslationFactors(translateX, v.ToFloat(), translateZ);
2723 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2727 _VisualElementImpl::GetTransformTranslationZSubProperty(void) const
2731 float translateX = 0.0f;
2732 float translateY = 0.0f;
2733 float translateZ = 0.0f;
2734 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2736 return Variant(translateZ);
2740 _VisualElementImpl::SetTransformTranslationZSubProperty(const Variant& v)
2742 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2744 float translateX = 0.0f;
2745 float translateY = 0.0f;
2746 float translateZ = 0.0f;
2747 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2748 __decomposedTransform.SetTranslationFactors(translateX, translateY, v.ToFloat());
2750 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2754 _VisualElementImpl::GetTransformTranslationXYSubProperty(void) const
2758 float translateX = 0.0f;
2759 float translateY = 0.0f;
2760 float translateZ = 0.0f;
2761 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2763 return Variant(FloatPoint(translateX, translateY));
2767 _VisualElementImpl::SetTransformTranslationXYSubProperty(const Variant& v)
2769 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2771 const FloatPoint& point = v.ToFloatPoint();
2773 float translateX = 0.0f;
2774 float translateY = 0.0f;
2775 float translateZ = 0.0f;
2776 __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ);
2777 __decomposedTransform.SetTranslationFactors(point.x, point.y, translateZ);
2779 return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false);
2783 _VisualElementImpl::GetChildrenTransformMatrix(void) const
2787 // TBD: forward using property or direct return ?
2789 return InvokeOnGetPropertyRequested(*pVePropChildrenTransform).ToFloatMatrix4();
2791 return __childrenTransform;
2797 _VisualElementImpl::SetChildrenTransformMatrixI(const FloatMatrix4& xform, bool updateDecomposed)
2799 FloatMatrix4 matrixAdjusted(xform);
2800 FloatMatrix4 oldValue(__childrenTransform);
2801 result r = E_SUCCESS;
2803 if (unlikely(GetSharedData().pEventListener != null))
2805 if (IS_MODEL(this)) // CHECKME: checking need??
2807 r = VE_DELEGATE(this, InvokeOnChildrenTransformMatrixChanging, matrixAdjusted);
2812 if (r == E_SUCCESS && likely(matrixAdjusted != __childrenTransform)) // check again because delegate may change the transform matrix
2815 // May be un-needed from now...... (no support for VE without surface or shared-canvas)
2816 if (!IS_PRESENTATION(this))
2818 int count = __children.GetCount();
2819 for (int i = 0; i < count; i++)
2821 // VE with surface will be exposed automatically on rebuilding coordinates...
2822 _VisualElementImpl* pVe = __children.GetChildAt(i);
2823 if (pVe && !NEED_SURFACE(pVe))
2825 pVe->ExposeRectangle(null, true);
2827 // render target update for previous bounds
2828 pVe->InvalidateVisibleRectToRenderTarget(null);
2833 MatrixUtilCopy(__childrenTransform, matrixAdjusted);
2835 if (unlikely(updateDecomposed))
2837 __decomposedChildrenTransform.SetTransformMatrix(__childrenTransform);
2840 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false);
2843 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
2845 FloatMatrix4 currentValue = __pPresentation->__childrenTransform;
2846 const String* subProperties[] = {
2847 pVeSubPropChildrenTransformRotationX,
2848 pVeSubPropChildrenTransformRotationY,
2849 pVeSubPropChildrenTransformRotationZ,
2850 pVeSubPropChildrenTransformScaleX,
2851 pVeSubPropChildrenTransformScaleY,
2852 pVeSubPropChildrenTransformScaleZ,
2853 pVeSubPropChildrenTransformTranslationX,
2854 pVeSubPropChildrenTransformTranslationY,
2855 pVeSubPropChildrenTransformTranslationZ,
2856 pVeSubPropChildrenTransformRotationAnchorX,
2857 pVeSubPropChildrenTransformRotationAnchorY,
2858 pVeSubPropChildrenTransformRotationAnchorZ,
2859 pVeSubPropChildrenTransformScaleAnchorX,
2860 pVeSubPropChildrenTransformScaleAnchorY,
2861 pVeSubPropChildrenTransformScaleAnchorZ,
2864 if(CreateImplicitAnimationIfNeeded(*pVePropChildrenTransform, __childrenTransform, currentValue, subProperties ) == false)
2866 __pPresentation->SetChildrenTransformMatrixProperty(__childrenTransform);
2869 VE_DELEGATE(this, InvokeOnChildrenTransformMatrixChanged, oldValue);
2876 _VisualElementImpl::SetChildrenTransformMatrix(const FloatMatrix4& xform)
2878 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
2879 result r = E_SUCCESS;
2881 //PROPERTY_PROCESS(SetChildrenTransformMatrixI, GetChildrenTransformMatrixProperty, SetChildrenTransformMatrixProperty, pVePropChildrenTransform, __childrenTransform, xform);
2882 if (IS_INTERNAL_CLASS(__pPublicInstance))
2884 r = SetChildrenTransformMatrixI(xform);
2888 r = InvokeOnSetPropertyRequested(*pVePropChildrenTransform, Variant(xform));
2891 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
2897 _VisualElementImpl::GetChildrenTransformMatrixProperty(void) const
2901 return Variant(__childrenTransform);
2906 _VisualElementImpl::SetChildrenTransformMatrixProperty(const Variant& v)
2908 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_MATRIX4, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2910 return SetChildrenTransformMatrixI(v.ToFloatMatrix4(), true);
2914 _VisualElementImpl::GetChildrenTransformRotationXSubProperty(void) const
2918 float angleX = 0.0f;
2919 float angleY = 0.0f;
2920 float angleZ = 0.0f;
2921 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
2923 return Variant(angleX);
2927 _VisualElementImpl::SetChildrenTransformRotationXSubProperty(const Variant& v)
2929 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2931 float angleX = 0.0f;
2932 float angleY = 0.0f;
2933 float angleZ = 0.0f;
2934 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
2935 __decomposedChildrenTransform.UpdateRotationFromEulerAngles(v.ToFloat(), angleY, angleZ);
2937 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
2941 _VisualElementImpl::GetChildrenTransformRotationYSubProperty(void) const
2945 float angleX = 0.0f;
2946 float angleY = 0.0f;
2947 float angleZ = 0.0f;
2948 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
2950 return Variant(angleY);
2954 _VisualElementImpl::SetChildrenTransformRotationYSubProperty(const Variant& v)
2956 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2958 float angleX = 0.0f;
2959 float angleY = 0.0f;
2960 float angleZ = 0.0f;
2961 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
2962 __decomposedChildrenTransform.UpdateRotationFromEulerAngles(angleX, v.ToFloat(), angleZ);
2964 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
2968 _VisualElementImpl::GetChildrenTransformRotationZSubProperty(void) const
2972 float angleX = 0.0f;
2973 float angleY = 0.0f;
2974 float angleZ = 0.0f;
2975 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
2977 return Variant(angleZ);
2981 _VisualElementImpl::SetChildrenTransformRotationZSubProperty(const Variant& v)
2983 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
2985 float angleX = 0.0f;
2986 float angleY = 0.0f;
2987 float angleZ = 0.0f;
2988 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
2989 __decomposedChildrenTransform.UpdateRotationFromEulerAngles(angleX, angleY, v.ToFloat());
2991 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
2995 _VisualElementImpl::GetChildrenTransformRotationXYSubProperty(void) const
2999 float angleX = 0.0f;
3000 float angleY = 0.0f;
3001 float angleZ = 0.0f;
3002 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
3004 return Variant(FloatPoint(angleX, angleY));
3008 _VisualElementImpl::SetChildrenTransformRotationXYSubProperty(const Variant& v)
3010 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3012 const FloatPoint& point = v.ToFloatPoint();
3014 float angleX = 0.0f;
3015 float angleY = 0.0f;
3016 float angleZ = 0.0f;
3017 __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ);
3018 __decomposedChildrenTransform.UpdateRotationFromEulerAngles(point.x, point.y, angleZ);
3020 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3024 _VisualElementImpl::GetChildrenTransformRotationAnchorXSubProperty(void) const
3028 float anchorX = 0.0f;
3029 float anchorY = 0.0f;
3030 float anchorZ = 0.0f;
3031 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
3033 return Variant(anchorX);
3037 _VisualElementImpl::SetChildrenTransformRotationAnchorXSubProperty(const Variant& v)
3039 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3041 float anchorX = 0.0f;
3042 float anchorY = 0.0f;
3043 float anchorZ = 0.0f;
3044 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
3045 __decomposedChildrenTransform.SetRotationAnchor(v.ToFloat(), anchorY, anchorZ);
3047 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3051 _VisualElementImpl::GetChildrenTransformRotationAnchorYSubProperty(void) const
3055 float anchorX = 0.0f;
3056 float anchorY = 0.0f;
3057 float anchorZ = 0.0f;
3058 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
3060 return Variant(anchorY);
3064 _VisualElementImpl::SetChildrenTransformRotationAnchorYSubProperty(const Variant& v)
3066 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3068 float anchorX = 0.0f;
3069 float anchorY = 0.0f;
3070 float anchorZ = 0.0f;
3071 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
3072 __decomposedChildrenTransform.SetRotationAnchor(anchorX, v.ToFloat(), anchorZ);
3074 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3078 _VisualElementImpl::GetChildrenTransformRotationAnchorZSubProperty(void) const
3082 float anchorX = 0.0f;
3083 float anchorY = 0.0f;
3084 float anchorZ = 0.0f;
3085 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
3087 return Variant(anchorZ);
3091 _VisualElementImpl::SetChildrenTransformRotationAnchorZSubProperty(const Variant& v)
3093 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3095 float anchorX = 0.0f;
3096 float anchorY = 0.0f;
3097 float anchorZ = 0.0f;
3098 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
3099 __decomposedChildrenTransform.SetRotationAnchor(anchorX, anchorY, v.ToFloat());
3101 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3105 _VisualElementImpl::GetChildrenTransformRotationAnchorXYSubProperty(void) const
3109 float anchorX = 0.0f;
3110 float anchorY = 0.0f;
3111 float anchorZ = 0.0f;
3112 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
3114 return Variant(FloatPoint(anchorX, anchorY));
3118 _VisualElementImpl::SetChildrenTransformRotationAnchorXYSubProperty(const Variant& v)
3120 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3122 const FloatPoint& point = v.ToFloatPoint();
3124 float anchorX = 0.0f;
3125 float anchorY = 0.0f;
3126 float anchorZ = 0.0f;
3127 __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ);
3128 __decomposedChildrenTransform.SetRotationAnchor(point.x, point.y, anchorZ);
3130 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3134 _VisualElementImpl::GetChildrenTransformScaleXSubProperty(void) const
3138 float scaleX = 1.0f;
3139 float scaleY = 1.0f;
3140 float scaleZ = 1.0f;
3141 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3143 return Variant(scaleX);
3147 _VisualElementImpl::SetChildrenTransformScaleXSubProperty(const Variant& v)
3149 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3151 float scaleX = 1.0f;
3152 float scaleY = 1.0f;
3153 float scaleZ = 1.0f;
3154 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3155 __decomposedChildrenTransform.SetScaleFactors(v.ToFloat(), scaleY, scaleZ);
3157 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3161 _VisualElementImpl::GetChildrenTransformScaleYSubProperty(void) const
3165 float scaleX = 1.0f;
3166 float scaleY = 1.0f;
3167 float scaleZ = 1.0f;
3168 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3170 return Variant(scaleY);
3174 _VisualElementImpl::SetChildrenTransformScaleYSubProperty(const Variant& v)
3176 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3178 float scaleX = 1.0f;
3179 float scaleY = 1.0f;
3180 float scaleZ = 1.0f;
3181 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3182 __decomposedChildrenTransform.SetScaleFactors(scaleX, v.ToFloat(), scaleZ);
3184 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3188 _VisualElementImpl::GetChildrenTransformScaleZSubProperty(void) const
3192 float scaleX = 1.0f;
3193 float scaleY = 1.0f;
3194 float scaleZ = 1.0f;
3195 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3197 return Variant(scaleZ);
3201 _VisualElementImpl::SetChildrenTransformScaleZSubProperty(const Variant& v)
3203 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3205 float scaleX = 1.0f;
3206 float scaleY = 1.0f;
3207 float scaleZ = 1.0f;
3208 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3209 __decomposedChildrenTransform.SetScaleFactors(scaleX, scaleY, v.ToFloat());
3211 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3215 _VisualElementImpl::GetChildrenTransformScaleXYSubProperty(void) const
3219 float scaleX = 1.0f;
3220 float scaleY = 1.0f;
3221 float scaleZ = 1.0f;
3222 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3224 return Variant(FloatPoint(scaleX, scaleY));
3228 _VisualElementImpl::SetChildrenTransformScaleXYSubProperty(const Variant& v)
3230 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3232 const FloatPoint& point = v.ToFloatPoint();
3234 float scaleX = 1.0f;
3235 float scaleY = 1.0f;
3236 float scaleZ = 1.0f;
3237 __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ);
3238 __decomposedChildrenTransform.SetScaleFactors(point.x, point.y, scaleZ);
3240 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3244 _VisualElementImpl::GetChildrenTransformScaleAnchorXSubProperty(void) const
3248 float anchorX = 0.0f;
3249 float anchorY = 0.0f;
3250 float anchorZ = 0.0f;
3251 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3253 return Variant(anchorX);
3257 _VisualElementImpl::SetChildrenTransformScaleAnchorXSubProperty(const Variant& v)
3259 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3261 float anchorX = 0.0f;
3262 float anchorY = 0.0f;
3263 float anchorZ = 0.0f;
3264 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3265 __decomposedChildrenTransform.SetScaleAnchor(v.ToFloat(), anchorY, anchorZ);
3267 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3271 _VisualElementImpl::GetChildrenTransformScaleAnchorYSubProperty(void) const
3275 float anchorX = 0.0f;
3276 float anchorY = 0.0f;
3277 float anchorZ = 0.0f;
3278 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3280 return Variant(anchorY);
3284 _VisualElementImpl::SetChildrenTransformScaleAnchorYSubProperty(const Variant& v)
3286 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3288 float anchorX = 0.0f;
3289 float anchorY = 0.0f;
3290 float anchorZ = 0.0f;
3291 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3292 __decomposedChildrenTransform.SetScaleAnchor(anchorX, v.ToFloat(), anchorZ);
3294 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3298 _VisualElementImpl::GetChildrenTransformScaleAnchorZSubProperty(void) const
3302 float anchorX = 0.0f;
3303 float anchorY = 0.0f;
3304 float anchorZ = 0.0f;
3305 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3307 return Variant(anchorZ);
3311 _VisualElementImpl::SetChildrenTransformScaleAnchorZSubProperty(const Variant& v)
3313 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3315 float anchorX = 0.0f;
3316 float anchorY = 0.0f;
3317 float anchorZ = 0.0f;
3318 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3319 __decomposedChildrenTransform.SetScaleAnchor(anchorX, anchorY, v.ToFloat());
3321 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3325 _VisualElementImpl::GetChildrenTransformScaleAnchorXYSubProperty(void) const
3329 float anchorX = 0.0f;
3330 float anchorY = 0.0f;
3331 float anchorZ = 0.0f;
3332 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3334 return Variant(FloatPoint(anchorX, anchorY));
3338 _VisualElementImpl::SetChildrenTransformScaleAnchorXYSubProperty(const Variant& v)
3340 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3342 const FloatPoint& point = v.ToFloatPoint();
3344 float anchorX = 0.0f;
3345 float anchorY = 0.0f;
3346 float anchorZ = 0.0f;
3347 __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ);
3348 __decomposedChildrenTransform.SetScaleAnchor(point.x, point.y, anchorZ);
3350 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3354 _VisualElementImpl::GetChildrenTransformTranslationXSubProperty(void) const
3358 float translateX = 0.0f;
3359 float translateY = 0.0f;
3360 float translateZ = 0.0f;
3361 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3363 return Variant(translateX);
3367 _VisualElementImpl::SetChildrenTransformTranslationXSubProperty(const Variant& v)
3369 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3371 float translateX = 0.0f;
3372 float translateY = 0.0f;
3373 float translateZ = 0.0f;
3374 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3375 __decomposedChildrenTransform.SetTranslationFactors(v.ToFloat(), translateY, translateZ);
3377 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3381 _VisualElementImpl::GetChildrenTransformTranslationYSubProperty(void) const
3385 float translateX = 0.0f;
3386 float translateY = 0.0f;
3387 float translateZ = 0.0f;
3388 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3390 return Variant(translateY);
3394 _VisualElementImpl::SetChildrenTransformTranslationYSubProperty(const Variant& v)
3396 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3398 float translateX = 0.0f;
3399 float translateY = 0.0f;
3400 float translateZ = 0.0f;
3401 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3402 __decomposedChildrenTransform.SetTranslationFactors(translateX, v.ToFloat(), translateZ);
3404 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3408 _VisualElementImpl::GetChildrenTransformTranslationZSubProperty(void) const
3412 float translateX = 0.0f;
3413 float translateY = 0.0f;
3414 float translateZ = 0.0f;
3415 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3417 return Variant(translateZ);
3421 _VisualElementImpl::SetChildrenTransformTranslationZSubProperty(const Variant& v)
3423 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3425 float translateX = 0.0f;
3426 float translateY = 0.0f;
3427 float translateZ = 0.0f;
3428 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3429 __decomposedChildrenTransform.SetTranslationFactors(translateX, translateY, v.ToFloat());
3431 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3435 _VisualElementImpl::GetChildrenTransformTranslationXYSubProperty(void) const
3439 float translateX = 0.0f;
3440 float translateY = 0.0f;
3441 float translateZ = 0.0f;
3442 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3444 return Variant(FloatPoint(translateX, translateY));
3448 _VisualElementImpl::SetChildrenTransformTranslationXYSubProperty(const Variant& v)
3450 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3452 const FloatPoint& point = v.ToFloatPoint();
3454 float translateX = 0.0f;
3455 float translateY = 0.0f;
3456 float translateZ = 0.0f;
3457 __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ);
3458 __decomposedChildrenTransform.SetTranslationFactors(point.x, point.y, translateZ);
3460 return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false);
3464 _VisualElementImpl::IsClipToParent(void) const
3468 // TBD: forward using property or direct return ?
3470 return InvokeOnGetPropertyRequested(*pVePropClipToParent).ToBool();
3476 // TBD: clipToParent is not animatable, right??
3478 _VisualElementImpl::SetClipToParent(bool clipToParent)
3480 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
3482 return InvokeOnSetPropertyRequested(*pVePropClipToParent, Variant(clipToParent));
3486 _VisualElementImpl::GetClipToParentProperty(void) const
3489 //SysLog(NID_UI_ANIM, "WARNING: ClipToParent is deprecated.");
3491 return Variant(false);
3495 _VisualElementImpl::SetClipToParentProperty(const Variant& v)
3497 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3499 //SysLog(NID_UI_ANIM, "WARNING: ClipToParent is deprecated.");
3505 _VisualElementImpl::IsClipChildrenEnabled(void) const
3509 return __isClipChildren;
3513 _VisualElementImpl::SetClipChildrenEnabled(bool clipChildren)
3515 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
3516 result r = E_SUCCESS;
3518 if (IS_INTERNAL_CLASS(__pPublicInstance))
3520 r = SetClipChildrenProperty(Variant(clipChildren));
3524 r = InvokeOnSetPropertyRequested(*pVePropClipChildren, Variant(clipChildren));
3526 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
3532 _VisualElementImpl::GetClipChildrenProperty(void) const
3536 return Variant(__isClipChildren);
3540 _VisualElementImpl::SetClipChildrenProperty(const Variant& v)
3542 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3544 bool clipChildren = v.ToBool();
3545 if (likely(clipChildren != __isClipChildren))
3548 //SysLog(NID_UI_ANIM, "%p ClipChildren = %d", this, clipChildren);
3550 __isClipChildren = clipChildren;
3551 InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false);
3555 if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this))
3557 __pPresentation->SetClipChildrenProperty(__isClipChildren);
3564 _VisualElementImpl::IsSurfaceOpaque(void) const
3568 // TBD: forward using property or direct return ?
3570 return InvokeOnGetPropertyRequested(*pVePropSurfaceOpaque).ToBool();
3572 return GetSharedData().isSurfaceOpaque;
3577 _VisualElementImpl::SetSurfaceOpaque(bool isSurfaceOpaque)
3579 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
3580 result r = E_SUCCESS;
3582 if (IS_INTERNAL_CLASS(__pPublicInstance))
3584 r = SetSurfaceOpaqueProperty(Variant(isSurfaceOpaque));
3588 r = InvokeOnSetPropertyRequested(*pVePropSurfaceOpaque, Variant(isSurfaceOpaque));
3590 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
3596 _VisualElementImpl::GetSurfaceOpaqueProperty(void) const
3600 return Variant(GetSharedData().isSurfaceOpaque);
3604 _VisualElementImpl::SetSurfaceOpaqueProperty(const Variant& v)
3606 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
3608 bool isSurfaceOpaque = v.ToBool();
3609 if (isSurfaceOpaque == GetSharedData().isSurfaceOpaque)
3612 InvalidateHierarchyProps(HIERARCHY_PROPERTY_CONTENTOPACITY, false, false); //don't have to apply the changed opacity to children.
3614 if (IS_PRESENTATION(this))
3616 GetSharedData().isSurfaceOpaque = isSurfaceOpaque;
3618 #ifndef LAZY_EVALUATION
3619 // not needed when no surface
3620 if (HAVE_SURFACE(this))
3621 GetSharedData().NodeReconfigure(*this);
3626 if(IS_NEEDED_UPDATE_PRESENTATION(this))
3628 __pPresentation->SetSurfaceOpaqueProperty(isSurfaceOpaque);
3636 _VisualElementImpl::GetCanvasN(void)
3638 return GetCanvasN(Rectangle(0, 0, __bounds.width, __bounds.height));
3642 _VisualElementImpl::GetCanvasN(const Rectangle& bounds)
3644 SysTryReturn(NID_UI_ANIM, !GetSharedData().fixedSurfaceSize, null, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Canvas can't be instantiated for fixed-size user surface.");
3645 SysTryReturn(NID_UI_ANIM, bounds.width >= 0 && bounds.height >= 0, null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Canvas size is out of range. size = (%f, %f)", bounds.width, bounds.height);
3646 SysTryReturn(NID_UI_ANIM, __imageFilePath.IsEmpty(), null, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Can't get canvas for surface which is from image file.");
3647 SysTryReturn(NID_UI_ANIM, GetRoot(), null, E_INVALID_STATE, "[E_INVALID_STATE] VisualElement is not attached to main tree.");
3650 // WARNING: WARNING: WARNING:
3651 // If need-redraw and surface is set by user, VE do *NOT* allow GetCanvasN
3652 // because 'bounds' is for the VE does not comply with size of surface.
3653 // (in which case the surface will be displayed scaled)
3655 _VisualElementImpl* pRenderTarget = null;
3657 pRenderTarget = GetRenderTarget();
3658 SysTryReturn(NID_UI_ANIM, pRenderTarget, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Target VisualElement is not available.");
3659 SysTryReturn(NID_UI_ANIM, pRenderTarget->__pSharedData, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Target VisualElement is not constructed.");
3662 // Forcefully create surface if GetCanvasN is called.
3663 // Without followings, surface may not be created if size of bounds == 0 (the initial size)
3664 if (!HAVE_SURFACE(this))
3665 __needRecreateSurface = true;
3667 pRenderTarget->RebuildHierarchyProps(0, true, true);
3669 SysTryReturn(NID_UI_ANIM, pRenderTarget->GetSharedData().pNativeNode->GetSurface(), null, E_SYSTEM, "[E_INVALID_STATE] Target VisualElement's surface is not constructed.");
3671 SysTryReturn(NID_UI_ANIM, pRenderTarget->GetSharedData().pSurface, null, E_SYSTEM, "[E_INVALID_STATE] Target VisualElement's surface is not constructed.");
3675 FloatRectangle canvasBounds;
3676 FloatRectangle clipBounds;
3679 // Use surface size, not bounds !!!
3681 int canvasX, canvasY, canvasW, canvasH;
3683 if (bounds.width == 0 || bounds.height == 0)
3685 float surfaceWidth = __bounds.width;
3686 float surfaceHeight = __bounds.height;
3687 AdjustSizeForSurface(surfaceWidth, surfaceHeight);
3689 SysTryReturn(NID_UI_ANIM, bounds.x >= 0.0f && bounds.y >= 0.0f && bounds.x <= int(surfaceWidth) && bounds.y <= int(surfaceHeight), null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Bounds is out of range.");
3698 clipBounds.x = 0.0f;
3699 clipBounds.y = 0.0f;
3700 clipBounds.width = __bounds.width;
3701 clipBounds.height = __bounds.height;
3703 canvasBounds.x = bounds.x;
3704 canvasBounds.y = bounds.y;
3705 canvasBounds.width = bounds.width;
3706 canvasBounds.height = bounds.height;
3708 canvasBounds = canvasBounds.GetIntersection(clipBounds);
3709 pRenderTarget->__pPresentation->ConvertCoordinates(canvasBounds, this->__pPresentation);
3710 canvasBounds = canvasBounds.GetIntersection(pRenderTarget->GetDrawableRect());
3712 SysTryReturn(NID_UI_ANIM, canvasBounds.width > 0 && canvasBounds.height > 0, null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Bounds is out of range.");
3713 _VisualElementCoordinateSystem::MakeIntegralPoint(canvasBounds.x, canvasBounds.y, canvasX, canvasY);
3714 _VisualElementCoordinateSystem::MakeIntegralDimension(canvasBounds.width, canvasBounds.height, canvasW, canvasH);
3718 // From now, canvasBounds contains the clipping area, not subcanvas area.
3719 // (0, 0) of the canvas should be placed on the left-top of the VE !
3721 unique_ptr<_VisualElementCanvas> pCanvas(new (std::nothrow) _VisualElementCanvas);
3723 result r = pCanvas->Construct(*pRenderTarget->GetSharedData().pNativeNode->GetSurface(), Rectangle(canvasX, canvasY, canvasW, canvasH));
3724 SysTryReturn(NID_UI_ANIM, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] VisualElement is not constructed.");
3726 pRenderTarget->SetFlushNeeded();
3730 return pCanvas.release();
3734 _VisualElementImpl::GetRoot(void) const
3738 if (IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES))
3740 const_cast< _VisualElementImpl* >(this)->RebuildCoordinates();
3747 _VisualElementImpl::GetParent(void) const
3755 _VisualElementImpl::GetChildrenCount(void) const
3759 return __children.GetCount();
3762 Tizen::Base::Collection::IList*
3763 _VisualElementImpl::GetPublicChildrenN(void) const
3765 unique_ptr<Tizen::Base::Collection::ArrayList> pArrayList(new (std::nothrow) Tizen::Base::Collection::ArrayList());
3766 SysTryReturn(NID_UI_ANIM, pArrayList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
3768 int count = __children.GetCount();
3769 SysTryReturn(NID_UI_ANIM, !IsFailed(pArrayList->Construct(count)), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
3771 for (int i = 0; i < count; i++)
3773 const _VisualElementImpl* pChild = __children.GetChildAt(i);
3775 if (likely(pChild) && likely(pChild->__pPublicInstance))
3777 SysTryReturn(NID_UI_ANIM, !IsFailed(pArrayList->Add(*pChild->__pPublicInstance)), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
3783 return pArrayList.release();
3787 _VisualElementImpl::IsChildOf(const _VisualElementImpl& element) const
3791 if (unlikely(this == &element))
3796 if (unlikely(!__pParent))
3801 if (likely(__pParent == &element))
3806 return __pParent->IsChildOf(element);
3810 _VisualElementImpl::SetZOrder(const _VisualElementImpl* pReference, bool above)
3812 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
3813 SysTryReturnResult(NID_UI_ANIM, !pReference || pReference->__pParent, E_INVALID_ARG, "pReference doesn't have parent.");
3814 SysTryReturnResult(NID_UI_ANIM, __pParent, E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement doesn't have a parent.");
3815 SysTryReturnResult(NID_UI_ANIM, __isAllowedTreeModification == true, E_INVALID_OPERATION, "Z-order cannot be modified inside the OnAttached() or OnDetached() method of VisualElementEventListener.");
3817 return __pParent->InsertChild(*this, pReference, above);
3821 _VisualElementImpl::RemoveFromParent(void)
3823 if (likely(__pParent))
3825 __pParent->RemoveChild(*this);
3830 _VisualElementImpl::AddChild(_VisualElementImpl& child)
3832 //SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
3833 SysTryReturnResult(NID_UI_ANIM, child.__pSharedData, E_INVALID_ARG, "Child VisualElement is not constructed.");
3834 SysTryReturnResult(NID_UI_ANIM, child.__isAllowedTreeModification == true, E_INVALID_OPERATION, "Z-order cannot be modified inside the OnAttached() or OnDetached() method of VisualElementEventListener.");
3836 return ChangeZOrder(child, null, true, child._zOrderGroup);
3840 _VisualElementImpl::GetChildIndex(const _VisualElementImpl& child) const
3843 result r = __children.IndexOf(const_cast< _VisualElementImpl* >(&child), index);
3850 // r == E_OUT_OF_RANGE or E_OBJ_NOT_FOUND
3855 * @param[in] group will be changed group of the visualemenet.
3856 * @param[out] belowIndex the index of last item of below group's item.
3857 * @param[out] aboveIndex the index of first item of above group's item.
3859 * if group is lower than __children's lowest item, belowIndex = -1 , aboveIndex = 0
3860 * if group is higher than __children's highest item, belowIndex is last index of children, aboveIndex is 1 bigger than belowIndex.
3863 * B = Z_ORDER_GROUP_ALWAYS_BELOW_BOTTOM // lowest drawing gadget.(Background)
3864 * N = Z_ORDER_GROUP_NORMAL; // level of the default group.
3865 * T = Z_ORDER_GROUP_ALWAYS_ON_TOP; // highest drawing gadget.
3866 * 0 1 2 3 4 5 6 7 8 9
3867 * [B][B][B][N][N][N][N][T][T][T]
3868 * __GetZOrderGroupIndex(Z_ORDER_GROUP_NORMAL, below, above);
3871 * __GetZOrderGroupIndex(Z_ORDER_GROUP_ALWAYS_ON_TOP, below, above);
3874 * __GetZOrderGroupIndex(Z_ORDER_GROUP_ALWAYS_BELOW_BOTTOM, below, above);
3877 * 0 1 2 3 4 5 6 7 8 9
3878 * [B][B][B][B][B][T][T][T][T][T]
3879 * __GetZOrderGroupIndex(Z_ORDER_GROUP_NORMAL, below, above);
3882 * __GetZOrderGroupIndex(Z_ORDER_GROUP_ALWAYS_ON_TOP, below, above);
3885 * __GetZOrderGroupIndex(Z_ORDER_GROUP_ALWAYS_BELOW_BOTTOM, below, above);
3892 _VisualElementImpl::GetZOrderGroupIndex(int group, int& belowIndex, int& aboveIndex) const
3894 int lastIndex = __children.GetCount() - 1;
3895 if (lastIndex < 0) // _children is empty.
3902 if (group < (__children.GetChildAt(0))->_zOrderGroup) // group is lower than __children's lowest item.
3909 if (group > (__children.GetChildAt(lastIndex))->_zOrderGroup) // group is higher than __children's highest item.
3911 belowIndex = lastIndex;
3912 aboveIndex = lastIndex + 1;
3920 if (group >= __children.GetChildAt(i)->_zOrderGroup)
3930 if (group > __children.GetChildAt(i)->_zOrderGroup)
3942 _VisualElementImpl::InsertChild(_VisualElementImpl& child, const _VisualElementImpl* pReference, bool above)
3944 //SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
3945 SysTryReturnResult(NID_UI_ANIM, child.__pSharedData, E_INVALID_ARG, "Child VisualElement is not constructed.");
3946 SysTryReturnResult(NID_UI_ANIM, child.__isAllowedTreeModification == true, E_INVALID_OPERATION, "Z-order cannot be modified inside the OnAttached() or OnDetached() method of VisualElementEventListener.");
3948 int zOrderGroup = child._zOrderGroup;
3950 if (unlikely(pReference))
3952 zOrderGroup = pReference->_zOrderGroup;
3955 return ChangeZOrder(child, pReference, above, zOrderGroup);
3959 _VisualElementImpl::ChangeZOrder(_VisualElementImpl& child, const _VisualElementImpl* pReference, bool above, int group)
3962 int indexReference = -1;
3963 int indexInsert = -1;
3965 // If not constructed well, disallow attaching !
3967 if (IsChildOf(child) || this == &child || &child == pReference || (pReference && pReference->__pParent != this))
3969 return E_INVALID_ARG;
3972 // TBD: check ownership!!!
3973 if (IS_PRESENTATION(this))
3975 _RootVisualElement* pChildRoot = child.GetRootPublic();
3977 if (GetRootPublic() != null && pChildRoot != GetRootPublic())
3979 child.RebuildNativeNodeTree(*this);
3985 indexReference = GetChildIndex(*pReference);
3986 SysTryReturnResult(NID_UI_ANIM, indexReference >= 0, E_INVALID_ARG, "Invalid argument(s) is used. pReference is not a child of this instance.");
3997 indexReference = __children.GetCount();
4005 int belowIndex, aboveIndex, indexRange;
4007 indexRange = GetZOrderGroupIndex(group, belowIndex, aboveIndex);
4013 else if (indexRange > 0)
4015 indexInsert = __children.GetCount();
4019 if (indexReference <= belowIndex + 1)
4021 indexInsert = belowIndex + 1;
4023 else if (indexReference >= aboveIndex)
4025 indexInsert = aboveIndex;
4029 indexInsert = indexReference;
4032 if (indexInsert < 0)
4038 if (child.__pParent == this) //case 1: move to the same parent. (just changed order )
4040 indexChild = GetChildIndex(child);
4041 SysTryReturn(NID_UI_ANIM, indexChild >= 0,
4042 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. The child(%p) isn't managed by this instance.", &child);
4044 if (indexChild < indexInsert)
4046 indexInsert--; // one of child item is removed so total item index is decreased.
4049 if (indexChild == indexInsert) //same position. don't have to do any action.
4051 child._zOrderGroup = group;
4053 //update presentation zorder group
4054 if (!IS_PRESENTATION(this))
4056 child.UpdatePresentationWhenZOrderChanged(pReference, above);
4061 SysTryReturn(NID_UI_ANIM, RemoveChildWithoutReconfiguring(indexChild, true) == E_SUCCESS,
4062 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Failed to remove a child(%p) from this instance.", &child);
4065 else //case 2: move to the other parent.
4066 { //case 3: child never been attached to the any parent.
4067 if (child.__pParent)
4069 child.__pParent->RemoveChild(child);
4072 // Setting implicit animation to the child.
4073 if (!IS_PRESENTATION(this) && _AnimationManager::GetInstance()->IsImplicitAnimationEnabled() && child.__isImplicitAnimationEnabled)
4075 RemoveAnimation(*pVePropActionAttach);
4077 #if defined(SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION)
4078 VisualElementAnimation* pAnimation = child.InvokeCreateAnimationForProperty(*pVePropActionAttach);
4080 VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
4081 SysTryReturn(NID_UI_ANIM, pAnimation != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
4082 pAnimation->SetPropertyName(*pVePropOpacity);
4083 pAnimation->SetStartValue(Variant(0.0f));
4085 if (pAnimation != null)
4087 pAnimation->SetVisualElementAnimationStatusEventListener(null);
4088 (child.GetPublic())->AddAnimation(*pVePropActionAttach, *pAnimation);
4095 child._zOrderGroup = group;
4097 //SysLog(NID_UI_ANIM, "Insert child %p(%d)", &child, indexInsert);
4099 if (!IS_PRESENTATION(this))
4101 VE_DELEGATE(this, InvokeOnChildAttaching, child);
4102 VE_DELEGATE(&child, InvokeOnAttaching, *this);
4105 __children.InsertAt(&child, indexInsert); // need addref -> jobs -> release ...
4106 child.__pParent = this;
4108 child.InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES | HIERARCHY_PROPERTY_OPACITY | HIERARCHY_PROPERTY_SHOWSTATE, true, false);
4110 // propagate child's prop. status to parents
4111 //__InvalidateHierarchyProps(child.__childrenNeedsUpdateProps, false, true);
4112 InvalidateHierarchyProps(child.__childrenNeedsUpdateProps, true, false);
4114 //SetRootNeedsContentUpdate();
4117 // When no surface, it is needed to invalidated.
4119 if (unlikely(!NEED_SURFACE(&child)))
4121 child.ExposeRectangle(null, true);
4125 // Because tree hierarchy is not a property, VE hierarchy tree changes are not
4126 // notified by property observer. So, we invoke method in presentation VE directly.
4129 if (!IS_PRESENTATION(this))
4131 child.UpdatePresentationWhenZOrderChanged(pReference, above);
4135 if (likely(GetSharedData().pNativeNode) && likely(child.GetSharedData().pNativeNode))
4137 _VisualElementImpl* pReferenceNode = null;
4139 if (indexInsert > 0)
4141 pReferenceNode = __children.GetChildAt(indexInsert - 1);
4144 // exceptional case: the pRefenreceNode is null and indexInsert are more than __children.count() + 1, then this case is something wrong.
4145 // normal case : when pReferenceNode is null , indexInsert has 0 or more small value.
4147 GetSharedData().pNativeNode->InsertChild(
4148 *child.GetSharedData().pNativeNode,
4149 (pReferenceNode ? pReferenceNode->GetSharedData().pNativeNode : null),
4150 (pReferenceNode ? true : false)
4159 _VisualElementImpl::UpdatePresentationWhenCustomPropertyChanged(const String& property, const Variant& value)
4161 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
4162 result r = E_SUCCESS;
4164 if (IS_NEEDED_UPDATE_PRESENTATION(this))
4167 Variant oldV = __pPresentation->InvokeOnGetPropertyRequested(property);
4169 if(CreateImplicitAnimationIfNeeded(property,value,oldV, NULL) == false)
4171 r = __pPresentation->InvokeOnSetPropertyRequested(property, value);
4178 _VisualElementImpl::UpdatePresentationWhenZOrderChanged(const _VisualElementImpl* pReferenceModel, bool above)
4180 if(!IS_MODEL(this) || !__pParent)
4185 _VisualElementImpl* pReferencePresenter = (pReferenceModel ? (pReferenceModel->__pPresentation ? pReferenceModel->__pPresentation : null) : null);
4187 if (likely(__pParent->__pPresentation) && likely(__pPresentation))
4189 __pParent->__pPresentation->ChangeZOrder(*__pPresentation, pReferencePresenter, above, _zOrderGroup);
4191 if (GetSharedData().pEventListener != null)
4196 if (__pParent->GetSharedData().pEventListener != null)
4198 __pParent->InvokeOnChildAttached(*this);
4204 _VisualElementImpl::UpdatePresentationWhenChildRemoved(_VisualElementImpl& child, bool deallocate)
4211 if (likely(__pPresentation) && likely(child.GetPresentation()))
4213 __pPresentation->RemoveChild(*child.GetPresentation(), deallocate);
4216 // IMPORTANT! When destroying, don't have to invoke OnDetached and OnDetaching after invoked OnDestructing.
4217 // call OnDestructing -> call OnDetaching it is ambiguous operation
4218 // it is called by RemoveFromParent() method, so pChild is destroying currently.
4219 if (!child.__isDestroying && child.GetSharedData().pEventListener != null)
4221 child.InvokeOnDetached(*this);
4224 if (GetSharedData().pEventListener != null)
4226 InvokeOnChildDetached(child);
4231 _VisualElementImpl::RemoveChildWithoutReconfiguring(int indexChild, bool invalidate)
4233 SysTryReturnResult(NID_UI_ANIM, indexChild >= 0 && indexChild < __children.GetCount(), E_OBJ_NOT_FOUND, "There is no VisualElement at %d th index.", indexChild);
4235 _VisualElementImpl* pChild = __children.GetChildAt(indexChild);
4236 SysTryReturnResult(NID_UI_ANIM, pChild, E_OBJ_NOT_FOUND, "There is no VisualElement at %d th index.", indexChild);
4238 if (!IS_PRESENTATION(this))
4241 VE_DELEGATE(this, InvokeOnChildDetaching, *pChild);
4243 // IMPORTANT! When destroying, don't have to invoke OnDetached and OnDetaching after invoked OnDestructing.
4244 // call OnDestructing -> call OnDetaching it is ambiguous operation
4245 // it is called by RemoveFromParent() method, so pChild is destroying currently.
4246 if (!pChild->__isDestroying)
4248 VE_DELEGATE(pChild, InvokeOnDetaching);
4252 //SysLog(NID_UI_ANIM, "Remove child %p(%d)", pChild, indexChild);
4253 __children.RemoveAt(indexChild);
4254 pChild->__pParent = null;
4255 // pChild->__ClearHierarchyInfo();
4258 if (!IS_PRESENTATION(this))
4260 // removed element need not invalidation !
4263 if (NEED_SURFACE(pChild))
4265 pChild->ExposeRectangle(null, false);
4269 pChild->InvalidateVisibleRectToRenderTarget(null);
4275 if (GetSharedData().pNativeNode && pChild->GetSharedData().pNativeNode)
4277 GetSharedData().pNativeNode->RemoveChild(*pChild->GetSharedData().pNativeNode);
4282 // Because some properties such as root, visible rect and etc. can be accessed detached, invalidating is needed here !
4283 // (Will be invalidated again on attaching)
4285 pChild->InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false);
4291 _VisualElementImpl::CreateElementTreeForDetachImplicitAnimation(_VisualElementImpl& child)
4293 result r = E_SYSTEM;
4295 VisualElement* pRoot = child.CreateElementForImplicitAnimationN();
4301 pRoot->_pVisualElementImpl->SetInternal(true);
4303 #if defined(SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION)
4304 VisualElementAnimation* pAnimation = child.InvokeCreateAnimationForProperty(*pVePropActionDetach);
4306 VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
4307 pAnimation->SetPropertyName(*pVePropOpacity);
4308 pAnimation->SetEndValue(Variant(0.0f));
4312 _VisualElementImplicitAnimationEventListener* pListener = new (std::nothrow) _VisualElementImplicitAnimationEventListener();
4315 pAnimation->SetVisualElementAnimationStatusEventListener(pListener);
4317 r = pRoot->AddAnimation(*pVePropActionDetach, *pAnimation);
4325 r = GetPublic()->AttachChild(*pRoot);
4344 _VisualElementImpl::CreateElementForImplicitAnimationN(void) const
4346 VisualElement* pElement = new (std::nothrow) VisualElement(*GetPublic());
4347 if (pElement == null)
4352 result r = pElement->Construct();
4355 pElement->Destroy();
4359 pElement->SetImplicitAnimationEnabled(false);
4361 if (HAVE_SURFACE(this))
4363 VisualElementSurface* pSurface = GetSurfaceN();
4366 pElement->SetSurface(pSurface);
4371 int count = __children.GetCount();
4372 for (int i = 0; i < count; i++)
4374 _VisualElementImpl* pVisualElementImpl = __children.GetChildAt(i);
4375 if (likely(pVisualElementImpl))
4377 r = pElement->AttachChild(*pVisualElementImpl->CreateElementForImplicitAnimationN());
4378 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4391 _VisualElementImpl::RemoveChild(_VisualElementImpl& child, bool deallocate)
4393 //SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
4394 SysTryReturnResult(NID_UI_ANIM, child.__isAllowedTreeModification == true, E_INVALID_OPERATION, "Z-order cannot be modified inside the OnAttached() or OnDetached() method of VisualElementEventListener.");
4396 int indexChild = GetChildIndex(child);
4397 SysTryReturnResult(NID_UI_ANIM, indexChild >= 0, E_OBJ_NOT_FOUND, "child is not a child of this instance.");
4398 if (unlikely(indexChild < 0))
4399 return E_OBJ_NOT_FOUND;
4402 result r = RemoveChildWithoutReconfiguring(indexChild, true);
4403 if (unlikely(r != E_SUCCESS))
4405 return E_OBJ_NOT_FOUND;
4408 if (!IS_PRESENTATION(this) && (_AnimationManager::GetInstance()->IsImplicitAnimationEnabled()
4409 && child.__isImplicitAnimationEnabled) && child.IsAncestorDestroying() == false)
4411 r = CreateElementTreeForDetachImplicitAnimation(child);
4412 if (unlikely(r != E_SUCCESS))
4414 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Dummy VisualElement cannot be attached.");
4419 // Because tree hierarchy is not a property, VE hierarchy tree changes are not
4420 // notified by property observer. So, we invoke method in presentation VE directly.
4422 if (!IS_PRESENTATION(this))
4424 UpdatePresentationWhenChildRemoved(child,deallocate);
4435 _VisualElementImpl::RemoveAllChild(void)
4437 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
4443 _VisualElementImpl::RebuildNativeNodeTree(_VisualElementImpl& parent)
4445 if (!IS_PRESENTATION(this))
4450 _INativeNode* pNode = GetNativeNode();
4451 _INativeNode* pParentNode = parent.GetNativeNode();
4453 if (!pNode || !pParentNode)
4458 pNode->RebuildIfNeeded(*pParentNode);
4460 //TODO : must check ,don't you need to rebuild???
4461 // RebuildCoordinates();
4463 const int nativeProps = _VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES
4464 | _VisualElementImpl::HIERARCHY_PROPERTY_OPACITY
4465 | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY
4466 | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS;
4469 InvalidateHierarchyProps(nativeProps, false, false);
4471 int count = __children.GetCount();
4472 for ( int i = 0 ; i < count ; i++ )
4474 _VisualElementImpl* pVe = __children.GetChildAt(i);
4477 pVe->RebuildNativeNodeTree(*this);
4478 _INativeNode* pChildNode = pVe->GetNativeNode();
4479 pNode->InsertChild(*pChildNode,null, true);
4487 _VisualElementImpl::GetName(void) const
4492 return InvokeOnGetPropertyRequested(*pVePropName).ToString();
4494 return GetSharedData().name;
4499 _VisualElementImpl::SetName(const Tizen::Base::String& name)
4501 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
4502 result r = InvokeOnSetPropertyRequested(*pVePropName, Variant(name));
4503 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
4510 _VisualElementImpl::GetNameProperty(void) const
4514 return Variant(GetSharedData().name);
4518 _VisualElementImpl::SetNameProperty(const Variant& v)
4520 SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_STRING, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE);
4522 const Tizen::Base::String& name = v.ToString();
4523 if (name == GetSharedData().name)
4528 GetSharedData().name = name;
4534 _VisualElementImpl::SetUserData(void* pUserData)
4536 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
4538 GetSharedData().pUserData = pUserData;
4544 _VisualElementImpl::GetUserData(void) const
4548 return GetSharedData().pUserData;
4552 _VisualElementImpl::GetChild(const Tizen::Base::String& name, bool searchAllDescendants) const
4556 int count = __children.GetCount();
4558 // for performance, look children directly
4559 for (int i = 0; i < count; i++)
4561 const _VisualElementImpl* pChild = __children.GetChildAt(i);
4562 if (unlikely(pChild->GetSharedData().name == name))
4564 return const_cast< _VisualElementImpl* >(pChild);
4568 if (searchAllDescendants)
4570 for (int i = 0; i < count; i++)
4572 const _VisualElementImpl* pChild = __children.GetChildAt(i)->GetChild(name, true);
4575 return const_cast< _VisualElementImpl* >(pChild);
4580 SetLastResult(E_OBJ_NOT_FOUND);
4586 _VisualElementImpl::GetVisibleRect(void) const
4588 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
4590 if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
4591 pThis->RebuildCoordinates();
4594 return FloatRectangle();
4596 if (likely(__visibleRectValid))
4597 return __visibleRect;
4601 FloatRectangle parentVisibleRect(__pClipSource->GetVisibleRect());
4602 ConvertCoordinates(parentVisibleRect, __pClipSource);
4603 pThis->__visibleRect = parentVisibleRect.GetIntersection(__visibleRect);
4606 pThis->__visibleRectValid = true;
4608 return __visibleRect;
4612 _VisualElementImpl::GetDrawableRect(void) const
4614 // If VE has backing-buffer, visible status is not important for drawing...
4615 bool needSurface = NEED_SURFACE(this);
4617 if (unlikely(!needSurface))
4619 return FloatRectangle();
4622 if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
4624 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
4625 pThis->RebuildCoordinates();
4629 // Even when surface exists, the size might be invalidated by changing bounds.
4632 RebuildHierarchyProps(HIERARCHY_PROPERTY_MASK & (~HIERARCHY_PROPERTY_CONTENT), true);
4633 if (!HAVE_SURFACE(this))
4635 return __visibleRect;
4638 if (HAVE_SURFACE(this) && GetSharedData().fixedSurfaceSize)
4640 return FloatRectangle(0.0f, 0.0f, static_cast< float >(GetSharedData().pSurface->GetSize().width), static_cast< float >(GetSharedData().pSurface->GetSize().height));
4643 return FloatRectangle(0.0f, 0.0f, __bounds.width, __bounds.height);
4647 _VisualElementImpl::GetOpacityFromRoot(void) const
4649 float opacity = __contentOpacity * __opacity * __showOpacity;
4650 const _VisualElementImpl* pElement = __pParent;
4653 if (!VE_VISIBLE(pElement))
4658 opacity *= pElement->__opacity * pElement->__showOpacity;
4659 pElement = pElement->__pParent;
4665 const FloatRectangle&
4666 _VisualElementImpl::GetBoundingBoxI(void) const
4668 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
4670 if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
4672 pThis->RebuildCoordinates();
4675 if (unlikely(!__boundingBoxValid))
4678 float x[4] = { 0.0f, __bounds.width, 0.0f, __bounds.width };
4679 float y[4] = { 0.0f, 0.0f, __bounds.height, __bounds.height };
4680 float z[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
4682 for (int i = 0; i < 4; i++)
4684 _MatrixUtilTransform(GetMatrixToTop(), &x[i], &y[i], &z[i]);
4687 pThis->__boundingBox.SetBounds(x[0], y[0], x[0], y[0]);
4693 for (int i = 1; i < 4; i++)
4716 pThis->__boundingBox.SetBounds(l, t, r - l, b - t);
4718 float x[4] = { 0.0f, __bounds.width, 0.0f, __bounds.width };
4719 float y[4] = { 0.0f, 0.0f, __bounds.height, __bounds.height };
4720 CalculateBoundingBox(x, y, pThis->__boundingBox);
4723 pThis->__boundingBoxValid = true;
4726 return __boundingBox;
4730 _VisualElementImpl::GetMatrixToSuper(void) const
4732 if (unlikely(__matrixToSuperValid))
4733 return __matrixToSuper;
4736 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
4738 pThis->__matrixToSuperValid = true;
4740 if (unlikely(__pParent == null))
4742 _MatrixUtilSetIdentity(pThis->__matrixToSuper);
4743 return __matrixToSuper;
4746 const bool needSurface = NEED_SURFACE(this);
4748 // apply subprojection && translation
4749 if (likely(needSurface))
4751 MatrixUtilCopy(pThis->__matrixToSuper, __pParent->__childrenTransform);
4752 _MatrixUtilTranslate(pThis->__matrixToSuper, __bounds.x, __bounds.y, __zPosition);
4756 _MatrixUtilSetTranslation(pThis->__matrixToSuper, __bounds.x, __bounds.y, __zPosition);
4761 if (likely(needSurface))
4763 if (likely(__decomposedTransform.GetMatrixType() != MATRIX4_Identity))
4765 bool needAnchor = (unlikely(__anchorZ != 0.0f) || unlikely(__anchor.x != 0.0f) || unlikely(__anchor.y != 0.0f));
4766 if (unlikely(needAnchor))
4767 _MatrixUtilTranslate(pThis->__matrixToSuper, __anchor.x * __bounds.width, __anchor.y * __bounds.height, __anchorZ);
4769 _MatrixUtilMultiply(pThis->__matrixToSuper, __matrixToSuper, __transform);
4771 if (unlikely(needAnchor))
4772 _MatrixUtilTranslate(pThis->__matrixToSuper, -__anchor.x * __bounds.width, -__anchor.y * __bounds.height, -__anchorZ);
4776 return __matrixToSuper;
4780 _VisualElementImpl::GetMatrixToTop(void) const
4782 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
4784 if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
4786 pThis->RebuildCoordinates();
4790 if (unlikely(!__matrixToTopValid))
4792 _MatrixUtilMultiply(pThis->__matrixToTop, __pParent->GetMatrixToTop(), GetMatrixToSuper());
4793 pThis->__matrixToTopValid = true;
4796 return __matrixToTop;
4800 _VisualElementImpl::GetMatrixFromTop(void) const
4802 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
4804 if (IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES))
4806 pThis->RebuildCoordinates();
4809 if (!__matrixFromTopValid)
4811 MatrixUtilCopy(pThis->__matrixFromTop, GetMatrixToTop());
4812 pThis->__matrixFromTopInvertible = _MatrixUtilInvert(pThis->__matrixFromTop);
4813 pThis->__matrixFromTopValid = true;
4816 return __matrixFromTop;
4820 _VisualElementImpl::CalcMatrixToBase(const _VisualElementImpl& base) const
4823 return FloatMatrix4();
4825 FloatMatrix4 matrixToBase(GetMatrixToSuper());
4827 const _VisualElementImpl* pParent = GetParent();
4830 pParent = pParent->GetParent();
4833 _MatrixUtilMultiply(matrixToBase, pParent->GetMatrixToSuper(), matrixToBase);
4834 pParent = pParent->GetParent();
4838 return matrixToBase;
4842 _VisualElementImpl::GetMatrixToClipSource(void) const
4844 _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this);
4846 if (IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES))
4848 pThis->RebuildCoordinates();
4852 if (unlikely(!__matrixToClipSourceValid))
4854 if (likely(__pParent))
4856 if (__pParent->__isClipChildren)
4858 MatrixUtilCopy(pThis->__matrixToClipSource, GetMatrixToSuper());
4862 _MatrixUtilMultiply(pThis->__matrixToClipSource, __pParent->GetMatrixToClipSource(), GetMatrixToSuper());
4867 _MatrixUtilSetIdentity(pThis->__matrixToClipSource);
4870 pThis->__matrixToClipSourceValid = true;
4873 return __matrixToClipSource;
4877 _VisualElementImpl::InvalidateVisibleRectToRenderTarget(const FloatRectangle* pDirtyRectangle)
4879 if (unlikely(GetSharedData().invalidationLockCount > 0))
4882 if (!IsDrawingObject())
4885 FloatRectangle bounds;
4887 bounds = __pPresentation->GetVisibleRect();
4888 if (pDirtyRectangle)
4890 bounds = bounds.GetIntersection(*pDirtyRectangle);
4893 if (!bounds.IsEmpty())
4895 _VisualElementImpl* pRenderTarget = __pPresentation->GetRenderTarget();
4898 pRenderTarget->ConvertCoordinates(bounds, this);
4899 pRenderTarget->InvalidateRectangleI(&bounds);
4905 _VisualElementImpl::RebuildCoordinates(void)
4907 if (unlikely(!IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
4912 SetPropsValidaty(HIERARCHY_PROPERTY_COORDINATES, 0);
4914 __visibleRect.x = 0.0f;
4915 __visibleRect.y = 0.0f;
4916 __visibleRect.width = __bounds.width;
4917 __visibleRect.height = __bounds.height;
4920 if (unlikely(!__pParent))
4923 // Need to allowing transform to root element !
4925 _MatrixUtilSetIdentity(__matrixToTop);
4926 _MatrixUtilSetIdentity(__matrixFromTop);
4927 _MatrixUtilSetIdentity(__matrixToClipSource);
4928 __pClipSource = null;
4932 RectUtilCopy(__boundingBox, __bounds);
4933 RectUtilCopy(__boundingBoxToClipSource, __bounds);
4935 _RootVisualElement* pRoot = dynamic_cast< _RootVisualElement* >(__pPublicInstance);
4939 __pRoot = pRoot->_pVisualElementImpl;
4946 __needTransform = false;
4947 __needClipForUntransformed = false;
4950 __matrixFromTopValid = true;
4951 __matrixToTopValid = true;
4952 __matrixToClipSourceValid = true;
4953 __matrixToSuperValid = true;
4955 __boundingBoxValid = true;
4956 __visibleRectValid = true;
4960 if (unlikely(__pParent->IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
4962 __pParent->RebuildCoordinates();
4965 __pRoot = __pParent->__pRoot;
4967 Matrix4Type transformType = __decomposedTransform.GetMatrixType();
4968 const Matrix4Type parentChildrenTransformType = __pParent->__decomposedChildrenTransform.GetMatrixType();
4970 if (parentChildrenTransformType > MATRIX4_Translation)
4971 transformType = MATRIX4_Generic;
4974 if (unlikely(__pParent->__isClipChildren))
4976 __pClipSource = __pParent;
4978 __needTransform = (transformType > MATRIX4_Translation);
4979 if (likely(!__needTransform))
4981 __boundingBoxToClipSource.x = __bounds.x + __transform.matrix[3][0];
4982 __boundingBoxToClipSource.y = __bounds.y + __transform.matrix[3][1];
4983 __boundingBoxToClipSource.width = __bounds.width;
4984 __boundingBoxToClipSource.height = __bounds.height;
4989 __pClipSource = __pParent->__pClipSource;
4991 if (unlikely(transformType > MATRIX4_Translation))
4992 __needTransform = true;
4994 __needTransform = __pParent->__needTransform;
4996 if (likely(!__needTransform))
4998 __boundingBoxToClipSource.x = __pParent->__boundingBoxToClipSource.x + __bounds.x + __transform.matrix[3][0];
4999 __boundingBoxToClipSource.y = __pParent->__boundingBoxToClipSource.y + __bounds.y + __transform.matrix[3][1];
5000 __boundingBoxToClipSource.width = __bounds.width;
5001 __boundingBoxToClipSource.height = __bounds.height;
5003 if (unlikely(parentChildrenTransformType == MATRIX4_Translation))
5005 __boundingBoxToClipSource.x += __pParent->__childrenTransform.matrix[3][0];
5006 __boundingBoxToClipSource.y += __pParent->__childrenTransform.matrix[3][1];
5012 if (likely(!__needTransform))
5014 if (unlikely(parentChildrenTransformType == MATRIX4_Translation))
5016 __boundingBoxToClipSource.x += __pParent->__childrenTransform.matrix[3][0];
5017 __boundingBoxToClipSource.y += __pParent->__childrenTransform.matrix[3][1];
5021 __needClipForUntransformed = __pParent->__needClipForUntransformed;
5022 if (likely(!__needClipForUntransformed) && likely(__pClipSource))
5024 if (likely(__boundingBoxToClipSource.x >= 0.0f) &&
5025 likely(__boundingBoxToClipSource.y >= 0.0f) &&
5026 likely(__boundingBoxToClipSource.x + __boundingBoxToClipSource.width <= __pClipSource->__bounds.width) &&
5027 likely(__boundingBoxToClipSource.y + __boundingBoxToClipSource.height <= __pClipSource->__bounds.height))
5028 __needClipForUntransformed = false;
5030 __needClipForUntransformed = true;
5034 __needClipForUntransformed = true;
5038 __matrixFromTopValid = false;
5039 __matrixToTopValid = false;
5040 __matrixToClipSourceValid = false;
5041 __matrixToSuperValid = false;
5043 __boundingBoxValid = false;
5044 __visibleRectValid = false;
5049 _VisualElementImpl::RebuildVisibility(void)
5051 const int mask = HIERARCHY_PROPERTY_COORDINATES | HIERARCHY_PROPERTY_SHOWSTATE | HIERARCHY_PROPERTY_OPACITY | HIERARCHY_PROPERTY_CONTENTOPACITY;
5053 if (unlikely(!IsPropsInvalidated(mask)))
5058 if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
5060 RebuildCoordinates();
5064 SetPropsValidaty(mask, 0);
5066 if (unlikely(!__pParent))
5069 // Need to allowing transform to root element !
5072 __isVisible = false;
5074 __isVisible = VE_VISIBLE(this);
5078 if (unlikely(__pParent->IsPropsInvalidated(mask)))
5080 __pParent->RebuildVisibility();
5083 if (likely(__pParent->__isVisible))
5084 __isVisible = VE_VISIBLE(this);
5086 __isVisible = false;
5091 _VisualElementImpl::LockInvalidate(bool lock)
5093 GetSharedData().LockInvalidate(lock);
5097 _VisualElementImpl::InvalidateHierarchyPropsDownward(int invalidProps, bool broadcastToChildren, bool propagateToParentsOnly)
5099 invalidProps &= HIERARCHY_PROPERTY_MASK;
5101 __childrenNeedsUpdateProps |= invalidProps;
5103 if (likely(!propagateToParentsOnly))
5105 SetPropsValidaty(0, invalidProps);
5107 if (likely(invalidProps & HIERARCHY_PROPERTY_COORDINATES))
5109 __matrixFromTopValid = false;
5110 __matrixToSuperValid = false;
5111 __boundingBoxValid = false;
5115 if (unlikely(!broadcastToChildren))
5120 int count = __children.GetCount();
5121 for (int i = 0; i < count; i++)
5123 __children.GetChildAt(i)->InvalidateHierarchyPropsDownward(invalidProps, broadcastToChildren, propagateToParentsOnly);
5126 // may need update some attribute variables for other hierarchy properties
5130 _VisualElementImpl::InvalidateHierarchyProps(int invalidProps, bool broadcastToChildren, bool propagateToParentsOnly)
5132 invalidProps &= HIERARCHY_PROPERTY_MASK;
5134 // // For model tree, it is not needed to invalidate children-opacity and show-state
5135 // if (!IS_PRESENTATION(this))
5137 // invalidProps &= ~(HIERARCHY_PROPERTY_OPACITY | HIERARCHY_PROPERTY_SHOWSTATE);
5140 if (unlikely(!invalidProps))
5145 InvalidateHierarchyPropsDownward(invalidProps, broadcastToChildren, propagateToParentsOnly);
5147 _VisualElementImpl* pElement = __pParent; // WARNING: 'this' is updated in '__InvalidateHierarchyPropsDownward'
5150 pElement->__childrenNeedsUpdateProps |= invalidProps;
5151 pElement = pElement->__pParent;
5155 // HIERARCHY_PROPERTY_CONTENT is not handled here, but in drawing logic
5157 _VisualElementImpl::RebuildHierarchyProps(int props, bool checkSurface, bool reconfSurfaceOnly)
5159 if (likely(__pParent) && (unlikely(__pParent->IsPropsInvalidated(props)) || unlikely(__pParent->GetSharedData().NeedNativeReconfigure())))
5162 // 'checkSurface' for parent will make surface !
5163 __pParent->RebuildHierarchyProps(props, false, false);
5167 // TBD: Recreating surface may have to be done in presentation layer (thread!)
5168 if (unlikely(checkSurface))
5170 if (likely(IsDrawingObject()))
5172 ResetSurfaceIfNeeded(); // may invalidate GetSharedData().surfaceChanged
5176 const bool needApplyNatives = GetSharedData().NeedNativeReconfigure();
5178 props &= HIERARCHY_PROPERTY_MASK;
5179 if (unlikely(!IsPropsInvalidated(props)) && likely(!checkSurface) && unlikely(needApplyNatives == 0))
5184 if (unlikely(props & HIERARCHY_PROPERTY_SURFACE) && unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_SURFACE)))
5186 SetPropsValidaty(HIERARCHY_PROPERTY_SURFACE, 0);
5189 if (likely(props & HIERARCHY_PROPERTY_CONTENTBOUNDS) && likely(IsPropsInvalidated(HIERARCHY_PROPERTY_CONTENTBOUNDS)))
5191 SetPropsValidaty(HIERARCHY_PROPERTY_CONTENTBOUNDS, 0);
5194 if (likely(props & HIERARCHY_PROPERTY_COORDINATES) && likely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)))
5196 RebuildCoordinates();
5197 //__SetPropsValidaty(HIERARCHY_PROPERTY_COORDINATES, 0); --> need not. __RebuildCoordinates will validate.
5201 // 'Visibility' should be checked after validating tree-hierarchy information.
5202 // (For example, attaching/detaching may affect visibility.)
5203 const int mask = HIERARCHY_PROPERTY_OPACITY | HIERARCHY_PROPERTY_SHOWSTATE | HIERARCHY_PROPERTY_CONTENTOPACITY;
5204 if (unlikely((props & mask) != 0) && unlikely(IsPropsInvalidated(props & mask)))
5206 RebuildVisibility();
5209 if (likely(__pPresentation) && likely(needApplyNatives))
5211 if (unlikely(!IS_PRESENTATION(this)))
5214 // In model, native nodes are updated only when the surface was changed.
5215 //if (unlikely(GetSharedData().surfaceChanged))
5217 __pPresentation->FlushNativeChanges();
5222 GetSharedData().NodeReconfigure(*__pPresentation, false);
5228 _VisualElementImpl::FlushNativeChanges(void)
5230 if (unlikely(!IS_PRESENTATION(this)))
5233 if (likely(__pPresentation))
5234 GetSharedData().NodeReconfigure(*__pPresentation, false);
5238 _VisualElementImpl::UpdateHierarchyProps(void)
5241 // HIERARCHY_PROPERTY_CONTENT is not handled here, but in drawing logic.
5242 const int mask = HIERARCHY_PROPERTY_MASK & (~HIERARCHY_PROPERTY_CONTENT);
5244 if (unlikely((__childrenNeedsUpdateProps & mask) == 0))
5247 // Node will be reconfigured later(before OnDraw, or DrawRectangle, ...)
5248 if (likely(IsPropsInvalidated(mask)) || likely(GetSharedData().NeedNativeReconfigure()))
5249 RebuildHierarchyProps(mask, false, false);
5252 // __childrenNeedsUpdateProps should be cleared *ONLY AFTER* flushing native nodes !
5253 __childrenNeedsUpdateProps &= ~mask;
5255 int count = __children.GetCount();
5256 for (int i = 0; i < count; i++)
5258 _VisualElementImpl* pChild = __children.GetChildAt(i);
5259 if (likely((pChild->__childrenNeedsUpdateProps & mask) != 0))
5260 pChild->UpdateHierarchyProps();
5265 _VisualElementImpl::ExposeRectangle(const FloatRectangle* pDirtyRectangle, bool invalidate)
5267 if (unlikely(!IsDrawingObject()))
5270 if (unlikely(invalidate))
5272 InvalidateRectangleI(pDirtyRectangle);
5274 #if 0 // exposing object without content changes is not needed for EFL
5283 _VisualElementImpl::SetFlushNeeded(void)
5285 FloatRectangle rect;
5287 if (!IS_PRESENTATION(this))
5289 return __pPresentation->SetFlushNeeded();
5293 rect.SetPosition(0.0f, 0.0f);
5295 if (likely(HAVE_SURFACE(this)))
5297 GetSharedData().pNativeNode->SetFlushNeeded();
5301 _VisualElementImpl* pRenderTarget = GetRenderTarget();
5303 if (likely(pRenderTarget && pRenderTarget->GetSharedData().pNativeNode))
5305 pRenderTarget->__pPresentation->ConvertCoordinates(rect, this->__pPresentation);
5306 pRenderTarget->GetSharedData().pNativeNode->SetFlushNeeded();
5314 _VisualElementImpl::Flush(void)
5316 if (likely(GetSharedData().pNativeNode))
5318 GetSharedData().pNativeNode->Flush();
5325 _VisualElementImpl::InvalidateRectangle(const FloatRectangle* pRectangle)
5327 //!!! don't have to check attached state
5328 // SysTryReturnResult(NID_UI_ANIM, IS_ATTACHED(this), E_INVALID_STATE, "Invalidating VisualElement should be attached to the root tree.");
5330 return InvalidateRectangleI(pRectangle);
5334 _VisualElementImpl::InvalidateRectangleI(const FloatRectangle* pRectangle)
5336 SysTryReturnResult(NID_UI_ANIM, !GetSharedData().fixedSurfaceSize, E_INVALID_OPERATION, "VisualElement with User-Surface do not allow invalidating and redrawing.");
5337 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "Invalidating VisualElement should be performed on a model layer.");
5339 if (unlikely(GetSharedData().invalidationLockCount > 0))
5345 FloatRectangle invRect;
5347 if (unlikely(pRectangle))
5349 if (unlikely(pRectangle->IsEmpty()))
5354 invRect = *pRectangle;
5359 invRect.SetPosition(0.0f, 0.0f);
5362 if (unlikely(invRect.IsEmpty()))
5369 // 'GetUnion' method will not behave as our intention.
5370 // If the parameter or self is empty, the union of rectangle should ignore it !
5371 //invRect = GetSharedData().invalidatedRegion.GetUnion(invRect);
5372 RectUtilUnion(invRect, GetSharedData().invalidatedRegion);
5376 // If new requested invalidate region is already included currently,
5377 // we can skip the following calculations (but invalidating flags are STILL needed !)
5379 _VisualElementImpl* pRenderTarget = GetRenderTarget();
5381 if (likely(pRenderTarget == this))
5383 // Make invalidated area a bit larger to be aligned on the render target
5384 RectUtilMakeIntegral(invRect);
5387 GetSharedData().invalidatedRegion = invRect;
5389 InvalidateHierarchyProps(HIERARCHY_PROPERTY_CONTENT, false, false);
5390 SetRootNeedsContentUpdate();
5396 _VisualElementImpl::GetInvalidatedRectangle(void) const
5400 if (IS_PRESENTATION(this))
5404 return __pModel->GetInvalidatedRectangle();
5408 return GetSharedData().invalidatedRegion;
5412 _VisualElementImpl::GetUpdateRectangle(void) const
5416 return GetSharedData().updateRegion;
5420 _VisualElementImpl::IsOpaque(void) const
5424 if (HAVE_SURFACE(this))
5426 return IsSurfaceOpaque();
5433 _VisualElementImpl::Draw(void)
5435 SysTryReturnResult(NID_UI_ANIM, IS_ATTACHED(this), E_INVALID_STATE, "Drawing VisualElement should be attached to the root tree.");
5436 if (!IS_MODEL(this))
5438 //SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
5442 // Not a good position to apply property changes into native(EFL) system.
5443 // Because of no-compositor in VE, we cannot control each element's
5444 // visibilities (show-state, bounds, opacity, etc.) !
5445 // Is there any good idea ?
5447 // if (IS_PRESENTATION(this))
5448 // __UpdateHierarchyProps();
5450 if (unlikely((__childrenNeedsUpdateProps & HIERARCHY_PROPERTY_CONTENT) != 0))
5452 // if (unlikely(!IS_PRESENTATION(this)))
5453 // __UpdateHierarchyProps();
5457 // Drawing must be done from first opaque.
5458 // But, because we assume all VE's are transparent, all drawings are done from root !!!
5460 _VisualElementImpl* pRenderTarget = GetRenderTarget();
5461 bool needFullScreenDraw = __isRoot;
5463 if (unlikely(!pRenderTarget))
5465 // On no render target, flush invalidated area from root
5466 pRenderTarget = GetRoot();
5467 SysTryReturnResult(NID_UI_ANIM, pRenderTarget, E_SYSTEM, "A system error has been occurred. This VisualElement doesn't have rendering target.");
5468 needFullScreenDraw = true;
5473 // To minimize drawing area(with clip), use '__DrawRectangleIfNeeded'
5474 // To reduce drawing calls such as 'OnDraw', use '__DrawRectangle' directly
5476 int maxScreenSize = _Max(_VisualElementCoordinateSystem::logScreenWidth, _VisualElementCoordinateSystem::logScreenHeight);
5477 pRenderTarget->DrawRectangleIfNeeded(
5478 needFullScreenDraw ? FloatRectangle(0.0f, 0.0f, maxScreenSize, maxScreenSize) : GetDrawableRect()
5482 if (IS_PRESENTATION(this))
5483 UpdateHierarchyProps();
5489 _VisualElementImpl::DrawRectangleIfNeeded(const FloatRectangle& drawRect)
5491 if ((__childrenNeedsUpdateProps & HIERARCHY_PROPERTY_CONTENT) == 0 || unlikely(!IsVisibleI()))
5497 // VE with surface redraws *ALL INVALIDATED* region !! --> TBD: make an option/flags for this???
5499 FloatRectangle drawableRect;
5501 if (NEED_SURFACE(this))
5504 // Redraw only if the request has some valid region to draw.
5505 drawableRect = GetDrawableRect();
5506 if (!drawRect.IsIntersected(drawableRect))
5507 drawableRect.SetSize(0.0f, 0.0f); // Make empty
5511 drawableRect = drawRect;
5514 DrawRectangle(drawableRect.GetIntersection(GetSharedData().invalidatedRegion));
5517 // needUpdate flag may be 'true' after drawring invalidated region.
5518 // This means that some children still need to be updated !
5520 if (likely((__childrenNeedsUpdateProps & HIERARCHY_PROPERTY_CONTENT) == 0))
5526 // Some children still need to update in case that invalidated rect of this
5527 // is smaller than 'drawRect' which can overlap the invalid rect of children
5531 // Because user can do anything in drawing logic,
5532 // adding-reference may be safe.......
5534 _VisualElementImpl* pChild = null;
5535 FloatRectangle updateRect, childBounds;
5536 bool childrenNeedUpdate = false;
5537 int count = __children.GetCount();
5538 for (int i = 0; i < count; i++)
5540 pChild = __children.GetChildAt(i);
5546 if ((pChild->__childrenNeedsUpdateProps & HIERARCHY_PROPERTY_CONTENT) == 0)
5553 // Draw all children with surface.
5554 // Children with empty invalidated region will ignore re-drawing.
5556 updateRect = drawRect;
5557 pChild->__pPresentation->ConvertCoordinates(updateRect, this->__pPresentation);
5559 if (likely(NEED_SURFACE(pChild)))
5561 pChild->DrawRectangleIfNeeded(updateRect);
5565 childBounds = pChild->__pPresentation->__bounds;
5566 childBounds.SetPosition(0.0f, 0.0f);
5567 updateRect = updateRect.GetIntersection(childBounds);
5568 if (unlikely(!updateRect.IsEmpty()))
5569 pChild->DrawRectangleIfNeeded(updateRect);
5572 if ((pChild->__childrenNeedsUpdateProps & HIERARCHY_PROPERTY_CONTENT) != 0)
5574 childrenNeedUpdate = true;
5578 // update 'needUpdate' flag regarding children only if no invalidated-region
5579 if (GetSharedData().invalidatedRegion.IsEmpty())
5581 SetPropsValidaty(HIERARCHY_PROPERTY_CONTENT, 0);
5582 if (childrenNeedUpdate)
5584 __childrenNeedsUpdateProps |= HIERARCHY_PROPERTY_CONTENT;
5588 __childrenNeedsUpdateProps &= ~HIERARCHY_PROPERTY_CONTENT;
5593 // TODO: change name(remove 'rectangle')
5595 _VisualElementImpl::DrawRectangle(const FloatRectangle& drawRect)
5597 if (unlikely(!GetRootPublic()) || unlikely(!IsVisibleI()) || unlikely(drawRect.IsEmpty()))
5602 //SysLog(NID_UI_ANIM, "DrawRectangle");
5604 bool needDraw = false;
5605 bool fullValidated = false;
5606 FloatRectangle drawableRect(GetDrawableRect());
5607 FloatRectangle drawRectVisible(drawRect.GetIntersection(drawableRect));
5608 FloatRectangle invalidatedRectVisible(GetSharedData().invalidatedRegion.GetIntersection(drawableRect));
5610 if (unlikely(!drawRectVisible.IsEmpty()))
5613 // Draw full-invalidated-content (not partial) if VE has surface.
5614 if (likely(NEED_SURFACE(this)))
5615 drawRectVisible = drawableRect;
5622 // Make dirty/draw area a bit larger to be pixel-aligned and prevent drawing-artifacts caused by float-error.
5623 RectUtilMakeIntegral(drawRectVisible);
5624 RectUtilMakeIntegral(invalidatedRectVisible);
5626 // DO NOT USE drawRectVisible.Contains(invalidatedRectVisible))
5627 if (invalidatedRectVisible.IsEmpty() || (drawRectVisible.x <= invalidatedRectVisible.x &&
5628 drawRectVisible.y <= invalidatedRectVisible.y &&
5629 drawRectVisible.x + drawRectVisible.width >= invalidatedRectVisible.x + invalidatedRectVisible.width &&
5630 drawRectVisible.y + drawRectVisible.height >= invalidatedRectVisible.y + invalidatedRectVisible.height))
5632 fullValidated = true;
5638 // VisualElement with User-Set surface does not allow invalidating and redrawing.
5639 // Because there should be no invalidated region in this case, checking User-Surface may redundant.
5641 if (GetSharedData().fixedSurfaceSize)
5644 fullValidated = true;
5645 drawRectVisible = GetSharedData().invalidatedRegion;
5650 // Set update region before 'CanDraw' and 'OnDraw' delegations to check real-update region
5652 GetSharedData().updateRegion = drawRectVisible;
5657 // Clear *BEFORE* drawing because 'OnDraw' may add invalidated regions...
5659 GetSharedData().invalidatedRegion.SetBounds(0.0f, 0.0f, 0.0f, 0.0f); // SetEmpty()
5661 SetPropsValidaty(HIERARCHY_PROPERTY_CONTENT, 0);
5662 __childrenNeedsUpdateProps &= ~HIERARCHY_PROPERTY_CONTENT;
5668 if (!VE_DELEGATE(this, InvokePrepareDraw))
5676 Canvas* pCanvas = null;
5677 pCanvas = GetCanvasN();
5681 result r = pCanvas->SetClipBounds(Rectangle(drawRectVisible.x,
5683 drawRectVisible.width,
5684 drawRectVisible.height));
5687 SysLogException(NID_UI_ANIM, r, "[%s] Failed to set clip-bounds on canvas", GetErrorMessage(r));
5690 VE_DELEGATE(this, InvokeOnDraw, *pCanvas);
5695 // Flushing canvas is done at GetCanvasN.
5701 // Clear update region after drawing
5702 GetSharedData().updateRegion.SetBounds(0.0f, 0.0f, 0.0f, 0.0f);
5706 // Because user can do anything in drawing logic,
5707 // adding-reference/copying-list may be safe.......
5709 _VisualElementImpl* pChild = null;
5710 int count = __children.GetCount();
5711 bool childrenNeedUpdate = false;
5712 FloatRectangle childBounds;
5713 for (int i = 0; i < count; i++)
5715 pChild = __children.GetChildAt(i);
5716 if (likely(!NEED_SURFACE(pChild)))
5718 drawRectVisible = drawRect;
5719 pChild->__pPresentation->ConvertCoordinates(drawRectVisible, this->__pPresentation);
5720 childBounds = pChild->__pPresentation->__bounds;
5722 childBounds.SetPosition(0.0f, 0.0f);
5724 drawRectVisible = drawRectVisible.GetIntersection(childBounds);
5725 if (likely(!drawRectVisible.IsEmpty()))
5726 pChild->DrawRectangle(drawRectVisible);
5729 if ((pChild->__childrenNeedsUpdateProps & HIERARCHY_PROPERTY_CONTENT) != 0)
5731 childrenNeedUpdate = true;
5736 // If not all children have been validated during update,
5737 // we should not clear update flag to flush them later.
5739 if (childrenNeedUpdate)
5741 __childrenNeedsUpdateProps |= HIERARCHY_PROPERTY_CONTENT;
5745 // for a cumstom property animation
5747 _VisualElementImpl::SetPropertyI(const String& property, const Variant& value)
5749 result r = E_SUCCESS;
5751 if (likely(__pPublicInstance))
5753 r = __pPublicInstance->OnSetPropertyRequested(property, value);
5754 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
5761 _VisualElementImpl::InvokeOnSetPropertyRequested(const String& property, const Variant& value)
5763 SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object.");
5764 result r = E_SUCCESS;
5766 if (likely(__pPublicInstance))
5768 r = __pPublicInstance->OnSetPropertyRequested(property, value);
5769 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
5776 _VisualElementImpl::HitTestI(const FloatPoint& point)
5780 return HITTEST_NOWHERE;
5783 if (//NEED_SURFACE(&target) &&
5784 !GetSharedData().isSurfaceOpaque &&
5785 _FloatHardCompare(GetOpacityFromRoot(), 0.0f))
5787 return HITTEST_NOWHERE;
5790 if (!GetVisibleRect().Contains(point))
5792 return HITTEST_NOWHERE;
5795 _VisualElementImpl* pClipSource = GetClipSource();
5798 FloatPoint pt = point;
5799 pClipSource->ConvertCoordinates(pt, this);
5801 if (!pClipSource->GetVisibleRect().Contains(pt))
5803 return HITTEST_NOWHERE;
5807 pClipSource = pClipSource->GetClipSource();
5811 return HITTEST_MATCH;
5815 _VisualElementImpl::GetChildAtPointI(const FloatPoint& point, int parentHitTest)
5817 _VisualElementImpl* pHitTarget = null;
5818 FloatPoint hitPoint = point;
5821 hitTest = VE_DELEGATE(this, InvokeHitTest, point);
5822 if ((hitTest & HITTEST_MATCH) != 0)
5828 if ((hitTest & HITTEST_NOMORECHILDREN) == 0)
5830 int count = __children.GetCount();
5831 for (int i = count - 1; i >= 0; i--) // from top to bottom
5833 _VisualElementImpl* pChild = __children.GetChildAt(i);
5839 FloatPoint childHitPoint = point;
5840 pChild->ConvertCoordinates(childHitPoint, this);
5842 _VisualElementImpl* pChildHitTarget = pChild->GetChildAtPointI(childHitPoint, hitTest);
5843 if (pChildHitTarget)
5845 pHitTarget = pChildHitTarget;
5846 hitPoint = childHitPoint;
5855 // point = hitPoint;
5863 // Because Hit-Testing from self, clipping flags of self will be ignored.
5866 _VisualElementImpl::GetChildAt(const FloatPoint& point)
5868 _VisualElementImpl* pHitTarget = GetChildAtPointI(point, HITTEST_MATCH);
5869 if (unlikely(!pHitTarget))
5871 SetLastResult(E_OBJ_NOT_FOUND);
5882 _VisualElementImpl::ScrollByPoint(const FloatPoint& pointOffset, bool scrollSelf)
5884 if (_FloatCompare(pointOffset.x, 0.0f) && _FloatCompare(pointOffset.y, 0.0f))
5890 FloatMatrix4 xform = __childrenTransform;
5891 FloatMatrix4 xformOrg = xform;
5892 FloatRectangle rectInvalidated;
5894 _MatrixUtilTranslate(xform, pointOffset.x, pointOffset.y, 0.0f);
5896 if (HAVE_SURFACE(this))
5898 int count = __children.GetCount();
5900 LockInvalidate(true);
5901 for (int i = 0; i < count; i++)
5903 __children.GetChildAt(i)->LockInvalidate(true);
5906 r = SetChildrenTransformMatrix(xform);
5908 LockInvalidate(false);
5909 for (int i = 0; i < count; i++)
5911 __children.GetChildAt(i)->LockInvalidate(false);
5916 r = SetChildrenTransformMatrix(xform);
5919 SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, E_SYSTEM, "Failed to translate matrix for scrolling ");
5921 if (!NEED_SURFACE(this))
5923 InvalidateVisibleRectToRenderTarget(null);
5925 else if (scrollSelf)
5927 Canvas* pCanvas = null;
5928 _CanvasImpl* pCanvasImpl = null;
5930 pCanvas = GetCanvasN(); // TODO: clip rect......
5933 pCanvasImpl = _CanvasImpl::GetInstance(*pCanvas);
5937 Rectangle rectSource;
5939 rectSource.SetBounds(0, 0, __bounds.width, __bounds.height);
5941 rectInvalidated = __bounds;
5942 rectInvalidated.SetPosition(0.0f, 0.0f);
5943 if (pointOffset.x > 0)
5945 rectSource.width -= pointOffset.x;
5946 pointDest.x = pointOffset.x;
5947 rectInvalidated.width = pointOffset.x;
5951 rectSource.x += -pointOffset.x;
5952 rectSource.width -= -pointOffset.x;
5954 rectInvalidated.x = rectSource.width;
5955 rectInvalidated.width = -pointOffset.x;
5958 InvalidateVisibleRectToRenderTarget(&rectInvalidated);
5961 rectInvalidated = __bounds;
5962 rectInvalidated.SetPosition(0.0f, 0.0f);
5963 if (pointOffset.y > 0)
5965 rectSource.height -= pointOffset.y;
5966 pointDest.y = pointOffset.y;
5967 rectInvalidated.height = pointOffset.y;
5971 rectSource.y += -pointOffset.y;
5972 rectSource.height -= -pointOffset.y;
5974 rectInvalidated.y = rectSource.height;
5975 rectInvalidated.height = -pointOffset.y;
5978 InvalidateVisibleRectToRenderTarget(&rectInvalidated);
5981 r = pCanvasImpl->CopyEx(pointDest, *pCanvasImpl, rectSource);
5985 SysLogException(NID_UI_ANIM, r, "[%s] Can't copy area.", GetErrorMessage(r));
5986 SetChildrenTransformMatrix(xformOrg); // ???????????????????
6002 _VisualElementImpl::ConvertCoordinates(FloatPoint& point, const _VisualElementImpl* pFromElement) const
6004 if (unlikely(this == pFromElement))
6009 _VisualElementImpl* pFromRoot = null;
6014 if (likely(pFromElement))
6016 pFromRoot = pFromElement->GetRoot();
6017 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.");
6018 SysTryReturnResult(NID_UI_ANIM, pFromRoot || pFromElement->IsChildOf(*this) || IsChildOf(*pFromElement),
6019 E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement(%p) and pFromElement(%p) is not related.", this, pFromElement);
6023 pFromRoot = GetRoot();
6024 SysTryReturnResult(NID_UI_ANIM, pFromRoot, E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement is not attached to main tree.");
6028 const FloatMatrix4& toTopMatrix = (pFromElement ? pFromElement->GetMatrixToTop() : pFromRoot->GetMatrixToTop());
6029 _MatrixUtilTransform(toTopMatrix, &x, &y, &z);
6031 if (this != pFromRoot)
6033 const FloatMatrix4& fromTopMatrix = GetMatrixFromTop();
6035 if (!__matrixFromTopInvertible)
6036 return E_INVALID_OPERATION;
6040 // We should calculate z of world-coordinate mapped x-y plane of depth==0 in VE coordinate !
6041 z = -(fromTopMatrix.matrix[0][2] * x + fromTopMatrix.matrix[1][2] * y + fromTopMatrix.matrix[3][2]) / fromTopMatrix.matrix[2][2];
6043 _MatrixUtilTransform(fromTopMatrix, &x, &y, &z);
6047 point.SetPosition(x, y); // z is omitted
6053 _VisualElementImpl::ConvertCoordinates(FloatRectangle& rectangle, const _VisualElementImpl* pFromElement) const
6055 if (unlikely(this == pFromElement))
6060 _VisualElementImpl* pFromRoot = null;
6061 float x[4] = { rectangle.x, rectangle.x + rectangle.width, rectangle.x, rectangle.x + rectangle.width };
6062 float y[4] = { rectangle.y, rectangle.y, rectangle.y + rectangle.height, rectangle.y + rectangle.height };
6063 float z[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
6065 if (likely(pFromElement))
6067 pFromRoot = pFromElement->GetRoot();
6068 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.");
6069 SysTryReturnResult(NID_UI_ANIM, pFromRoot || pFromElement->IsChildOf(*this) || IsChildOf(*pFromElement),
6070 E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement(%p) and pFromElement(%p) is not related.", this, pFromElement);
6074 pFromRoot = GetRoot();
6075 SysTryReturnResult(NID_UI_ANIM, pFromRoot, E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement is not attached to main tree.");
6078 const FloatMatrix4& toTopMatrix = (pFromElement ? pFromElement->GetMatrixToTop() : pFromRoot->GetMatrixToTop());
6080 for (int i = 0; i < 4; i++)
6082 _MatrixUtilTransform(toTopMatrix, &x[i], &y[i], &z[i]);
6085 if (this != pFromRoot)
6087 const FloatMatrix4& fromTopMatrix = GetMatrixFromTop();
6089 if (!__matrixFromTopInvertible)
6090 return E_INVALID_OPERATION;
6092 for (int i = 0; i < 4; i++)
6095 // We should calculate z of world-coordinate mapped x-y plane of depth==0 in VE coordinate !
6096 z[i] = -(fromTopMatrix.matrix[0][2] * x[i] + fromTopMatrix.matrix[1][2] * y[i] + fromTopMatrix.matrix[3][2]) / fromTopMatrix.matrix[2][2];
6097 _MatrixUtilTransform(fromTopMatrix, &x[i], &y[i], &z[i]);
6102 CalculateBoundingBox(x, y, rectangle);
6108 _VisualElementImpl::ConvertCoordinates(float* x, float* y, float* z, int count, const _VisualElementImpl* pFromElement) const
6110 if (unlikely(this == pFromElement) || unlikely(count <= 0))
6115 _VisualElementImpl* pFromRoot = null;
6117 if (likely(pFromElement))
6119 pFromRoot = pFromElement->GetRoot();
6120 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.");
6121 SysTryReturnResult(NID_UI_ANIM, pFromRoot || pFromElement->IsChildOf(*this) || IsChildOf(*pFromElement),
6122 E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement(%p) and pFromElement(%p) is not related.", this, pFromElement);
6126 pFromRoot = GetRoot();
6127 SysTryReturnResult(NID_UI_ANIM, pFromRoot, E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement is not attached to main tree.");
6131 bool isUpwardConvertOnly = (pFromElement && pFromElement->IsChildOf(*this));
6132 const FloatMatrix4& toTopMatrix = (isUpwardConvertOnly ? pFromElement->CalcMatrixToBase(*this) :
6133 pFromElement ? pFromElement->GetMatrixToTop() : pFromRoot->GetMatrixToTop());
6135 for (int i = 0; i < count; i++)
6137 _MatrixUtilTransform(toTopMatrix, &x[i], &y[i], &z[i]);
6140 if (!isUpwardConvertOnly)
6142 const FloatMatrix4& fromTopMatrix = GetMatrixFromTop();
6144 if (!__matrixFromTopInvertible)
6145 return E_INVALID_OPERATION;
6147 for (int i = 0; i < count; i++)
6150 // We should calculate z of world-coordinate mapped x-y plane of depth==0 in VE coordinate !
6151 z[i] = -(fromTopMatrix.matrix[0][2] * x[i] + fromTopMatrix.matrix[1][2] * y[i] + fromTopMatrix.matrix[3][2]) / fromTopMatrix.matrix[2][2];
6152 _MatrixUtilTransform(fromTopMatrix, &x[i], &y[i], &z[i]);
6160 _VisualElementImpl::CaptureI(Canvas& outputCanvas, const FloatRectangle& rectDest, _VisualElementImpl& reference, const FloatRectangle& clipRect, bool withChilren, int depth)
6162 _CanvasImpl* pOutput = _CanvasImpl::GetInstance(outputCanvas);
6164 SysTryReturnResult(NID_UI_ANIM, pOutput, E_INVALID_ARG, "Invalid argument(s) is used. Output canvas is invalid.");
6165 SysTryReturnResult(NID_UI_ANIM, GetRoot(), E_INVALID_STATE, "Invalid argument(s) is used. VisualElement is not attached to main tree.");
6167 FloatRectangle bounds = __bounds;//GetDrawableRect();
6172 reference.ConvertCoordinates(bounds, this);
6173 FloatRectangle drawRect = bounds;
6175 _VisualElementImpl* pRenderTarget = this->GetRenderTarget();
6176 drawRect = bounds.GetIntersection(clipRect);
6178 FloatRectangle tempRect = drawRect;
6181 drawRect.x -= bounds.x;
6182 drawRect.y -= bounds.y; //--> 0 - -20 = 20 : 20 - 20 = 0
6187 if (!drawRect.IsEmpty())
6189 if (pRenderTarget && HAVE_SURFACE(pRenderTarget)) // If element have surface , justly draw to the canvas
6191 //Canvas* pCanvas = GetCanvasN(elementbounds);
6192 #ifdef USE_CANVAS_FOR_CAPTURE
6193 Canvas* pCanvas = GetCanvasN();
6197 bitmap.Construct(*pCanvas, Rectangle(drawRect.x, drawRect.y, drawRect.width, drawRect.height));
6198 bitmap.SetAlphaConstant((int)(pRenderTarget->GetOpacityFromRoot()*255));
6201 point.x = rectDest.x + bounds.x;
6202 point.y = rectDest.y + bounds.y;
6203 outputCanvas.DrawBitmap(point, bitmap);
6207 if (__pSharedData->pSurface)
6210 __pSharedData->pSurface->GetBufferInfo(info);
6212 _VisualElementSurfaceImpl* pSurfImpl = _VisualElementSurfaceImpl::GetInstance(*__pSharedData->pSurface);
6214 if(pSurfImpl && pSurfImpl->GetNativeHandle())
6216 byte* pStart = (byte*)evas_object_image_data_get((Evas_Object*)pSurfImpl->GetNativeHandle(), false);
6220 byte* pCopy = new (std::nothrow) byte[info.height*(info.pitch)];
6223 memcpy(pCopy, pStart, info.height*(info.pitch));
6225 for (int y = 0; y < info.height; y++)
6227 for (int x = 0; x < info.width; x++)
6229 unsigned int* pAddr = (unsigned int*)((unsigned char*)pCopy + info.pitch * y + x * 4);
6230 int a = ((*pAddr) >> 24) & 0xff;
6231 int r = ((*pAddr) >> 16) & 0xff;
6232 int g = ((*pAddr) >> 8) & 0xff;
6233 int b = ((*pAddr) >> 0) & 0xff;
6236 float fa = (float)a / 255.0f;
6240 *pAddr = (a << 24) | (r << 16) | (g << 8) | b;
6246 result r = buffer.Construct(pCopy, 0, info.height*(info.pitch), info.height*(info.pitch));
6250 Bitmap* pBitmap = Bitmap::GetNonScaledBitmapN(buffer, Dimension(info.width, info.height), BITMAP_PIXEL_FORMAT_ARGB8888);
6253 pBitmap->SetAlphaConstant((int)(pRenderTarget->GetOpacityFromRoot() * 255.0f));
6254 Rectangle outputR(drawRect.x, drawRect.y, drawRect.width, drawRect.height);
6255 Rectangle srcRect = outputR;
6256 outputR.x = rectDest.x + bounds.x;
6257 outputR.y = rectDest.y + bounds.y;
6258 outputCanvas.DrawBitmap(outputR, *pBitmap, srcRect);
6273 _EflNode* pNativeNode = dynamic_cast< _EflNode* >(GetNativeNode());
6275 SysTryReturnResult(NID_UI_ANIM, pNativeNode, E_INVALID_STATE, "No object for background"); // CHECKME: Default BG?
6276 _Colorf bgcolorf = pNativeNode->GetBackgroundColor();
6277 Color color(bgcolorf.Red()*255, bgcolorf.Green()*255, bgcolorf.Blue()*255, bgcolorf.Alpha()*255);
6280 point.x = rectDest.x + bounds.x;
6281 point.y = rectDest.y + bounds.y;
6283 //pOutput->FillRectangle(color, Rectangle(drawRect.x + bounds.x, drawRect.y + bounds.y, drawRect.width, drawRect.height));
6284 pOutput->FillRectangle(color, Rectangle(point.x, point.y, drawRect.width, drawRect.height));
6288 if (withChilren) // child draw
6290 _VisualElementImpl* pChild = null;
6292 FloatRectangle clipBounds = clipRect;
6294 int count = __children.GetCount();
6296 if(count > 0 && __isClipChildren)
6298 clipBounds = clipRect.GetIntersection(bounds);
6301 for (int i = 0; i < count; i++)
6303 pChild = __children.GetChildAt(i);
6304 if (unlikely(!pChild) || unlikely(!VE_VISIBLE(pChild)))
6308 pChild->CaptureI(outputCanvas, rectDest, reference, clipBounds, true, depth + 1);
6318 _VisualElementImpl::Capture(Canvas& outputCanvas, const FloatRectangle& rectDest, bool withChildren)
6320 FloatRectangle tempDestRect = rectDest;
6321 tempDestRect.x = __bounds.x;
6322 tempDestRect.y = __bounds.y;
6323 FloatRectangle clipBounds = __bounds;
6325 clipBounds = tempDestRect.GetIntersection(__bounds);
6329 if(!VE_VISIBLE(this))
6332 return CaptureI(outputCanvas, rectDest, *this, clipBounds, withChildren, 0);
6334 // Rectangle cBounds = outputCanvas.GetBounds();
6335 // outputCanvas.SetForegroundColor(Color(10,110,20));
6336 // outputCanvas.DrawRectangle(Rectangle(cBounds.x+1,cBounds.y+1,cBounds.width-2,cBounds.height-2));
6337 // outputCanvas.SetForegroundColor(Color(10,20,20));
6338 // outputCanvas.DrawRectangle(Rectangle(rectDest.x+1,rectDest.y+1,rectDest.width-2,rectDest.height-2));
6339 // return E_SUCCESS;
6343 _VisualElementImpl::Capture(Canvas& outputCanvas, const FloatRectangle& rectDest, bool withChildren)
6345 result r = E_SUCCESS;
6349 rect.x = rectDest.x;
6350 rect.y = rectDest.y;
6351 rect.width = rectDest.width;
6352 rect.height = rectDest.height;
6356 Canvas* pCanvas = GetCanvasN();
6359 r = outputCanvas.Copy(Point(0,0), *pCanvas, rect);
6364 return GetLastResult();
6368 _EflNode* pNode = dynamic_cast<_EflNode*>(GetNativeNode());
6369 SysTryReturnResult(pNode, E_INVALID_STATE, "VisualElement is invalid.");
6372 r = pNode->Capture(outputCanvas, Point(0,0), rect);
6375 SysTryReturn(r == E_SUCCESS, r, r,"[%s] Propagating.", GetErrorMessage(r));
6382 _VisualElementImpl::AddAnimation(const Tizen::Base::String* pKeyName, VisualElementAnimation& animation)
6384 SysTryReturnResult(NID_UI_ANIM, !IS_PRESENTATION(this), E_INVALID_OPERATION, "This is not model.");
6386 result r = E_SUCCESS;
6388 bool isPropertyPropagationEnabled = __isPropertyPropagationEnabled;
6390 __isPropertyPropagationEnabled = false;
6392 if (dynamic_cast< VisualElementAnimationGroup* >(&animation) != null)
6394 VisualElementAnimation* pCloned = animation.CloneN();
6395 SysTryReturnResult(NID_UI_ANIM, pCloned != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
6397 r = AddAnimationGroupI(pKeyName, *pCloned);
6398 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
6407 r = AddAnimationI(pKeyName, animation);
6408 SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
6411 __isPropertyPropagationEnabled = isPropertyPropagationEnabled;
6417 _VisualElementImpl::AddAnimationI(const Tizen::Base::String* pKeyName, VisualElementAnimation& animation)
6419 result r = E_SUCCESS;
6421 IVisualElementAnimationTickEventListener* pTickListener = null;
6424 VisualElementValueAnimation* pValueAnimation = dynamic_cast< VisualElementValueAnimation* >(&animation);
6425 if (pValueAnimation != null)
6427 _VisualElementValueAnimationImpl* pValueAnimationImpl = _VisualElementValueAnimationImpl::GetInstance(*pValueAnimation);
6428 SysTryReturnResult(NID_UI_ANIM, (pValueAnimationImpl->IsValid()), E_INVALID_ARG, "Invalid argument(s) is used. Animation value is invalid.");
6430 pTickListener = pValueAnimationImpl->GetTickEventListener();
6434 VisualElementAnimation* pCloned = animation.CloneN();
6435 SysTryReturnResult(NID_UI_ANIM, (pCloned != null), E_OUT_OF_MEMORY, "Memory allocation failed.");
6437 _VisualElementAnimationImpl* pAnimationImpl = _VisualElementAnimationImpl::GetInstance(*pCloned);
6439 if (pAnimationImpl->GetStatusEventListener() != null || pTickListener != null)
6441 pAnimationImpl->SetEventTarget(*GetPublic());
6444 // Use presentation tree for animation
6445 VisualElement* pPresentation = __pPresentation->__pPublicInstance;
6447 r = _AnimationManager::GetInstance()->AddAnimation(*pPresentation, pKeyName, *pCloned);
6450 SysTryLog(NID_UI_ANIM, "[%s] Failed to add animation.", GetErrorMessage(r));
6456 // Change model tree value if endValueApplied is true
6457 VisualElementPropertyAnimation* pPropertyAnimation = dynamic_cast< VisualElementPropertyAnimation* >(pCloned);
6459 if (pPropertyAnimation
6460 && pPropertyAnimation->IsEndValueApplied()
6461 && !pPropertyAnimation->IsAutoReverseEnabled()
6462 && pPropertyAnimation->GetRepeatCount() != 0)
6464 const String& propertyName = pPropertyAnimation->GetPropertyName();
6465 const Variant& endValue = pPropertyAnimation->GetEndValue();
6467 if (endValue.IsEmpty() == false && InvokeOnGetPropertyRequested(propertyName) != endValue)
6469 (void) InvokeOnSetPropertyRequested(propertyName, endValue);
6477 _VisualElementImpl::AddAnimationGroupI(const Tizen::Base::String* pKeyName, VisualElementAnimation& animation)
6479 _AnimationManager* pAnimationManager = _AnimationManager::GetInstance();
6481 // Get presentation tree
6482 VisualElement* pPresentation = __pPresentation->__pPublicInstance;
6484 VisualElementAnimationGroup* pAnimationGroup = dynamic_cast< VisualElementAnimationGroup* >(&animation);
6486 SysTryReturnResult(NID_UI_ANIM, (pAnimationGroup != null), E_INVALID_ARG, "Invalid argument(s) is used. Failed to add animation group.");
6487 SysTryReturnResult(NID_UI_ANIM, (pAnimationGroup->GetAnimationCount() > 0), E_INVALID_ARG, "Invalid argument(s) is used. Animation group has no animation.");
6489 _VisualElementAnimationGroupImpl* pAnimationGroupImpl = _VisualElementAnimationGroupImpl::GetInstance(*pAnimationGroup);
6491 if (pAnimationGroupImpl->GetStatusEventListener() != null)
6493 pAnimationGroupImpl->SetEventTarget(*GetPublic());
6496 result r = E_SUCCESS;
6498 VisualElementAnimation* pAnimation = null;
6499 Tizen::Base::String name;
6500 int animationCount = 0;
6502 int transactionID = pAnimationManager->BeginGroupTransaction(*pPresentation, pKeyName, *pAnimationGroup);
6504 r = GetLastResult();
6505 SysTryCatch(NID_UI_ANIM, (transactionID > 0), , r, "[%s] Transaction is not created.", GetErrorMessage(r));
6507 animationCount = pAnimationGroupImpl->GetAnimationCount();
6509 for (int index = 0; index < animationCount; index++)
6511 pAnimation = pAnimationGroupImpl->GetAnimation(index);
6513 if (pAnimation == null)
6518 if (dynamic_cast< VisualElementAnimationGroup* >(pAnimation) != null)
6520 r = AddAnimationGroupI(&name, *pAnimation);
6524 r = AddAnimationI(&name, *pAnimation);
6527 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] animation manager is null.", GetErrorMessage(r));
6530 pAnimationManager->CommitTransaction();
6536 if (transactionID > 0)
6538 pAnimationManager->CancelTransaction(transactionID);
6545 _VisualElementImpl::RemoveAnimation(const Tizen::Base::String& keyName)
6547 VisualElement* pPresentation = __pPresentation->__pPublicInstance;
6549 return _AnimationManager::GetInstance()->RemoveAnimation(*pPresentation, keyName);
6553 _VisualElementImpl::RemoveAllAnimations(void)
6555 VisualElement* pPresentation = __pPresentation->__pPublicInstance;
6557 _AnimationManager::GetInstance()->RemoveAllAnimations(*pPresentation);
6562 VisualElementAnimation*
6563 _VisualElementImpl::GetAnimationN(const Tizen::Base::String& keyName) const
6565 VisualElement* pPresentation = __pPresentation->__pPublicInstance;
6569 return _AnimationManager::GetInstance()->GetAnimationN(*pPresentation, keyName);
6572 VisualElementAnimation*
6573 _VisualElementImpl::GetAnimationForPropertyN(const Tizen::Base::String& property) const
6575 VisualElement* pPresentation = __pPresentation->__pPublicInstance;
6579 return _AnimationManager::GetInstance()->GetAnimationForPropertyN(*pPresentation, property);
6583 _VisualElementImpl::CheckIfAnimatable(const String& property) const
6586 // Optimize using map or other algorithms !
6590 static const wchar_t* supportedProperties[] = {
6591 VeSubPropTransformScaleXY,
6594 VePropContentOpacity,
6597 VePropChildrenTransform,
6598 VePropZPosition, // TBD:
6599 VeSubPropBoundsPosition,
6600 VeSubPropBoundsSize,
6602 VeSubPropTransformRotationX,
6603 VeSubPropTransformRotationY,
6604 VeSubPropTransformRotationZ,
6605 VeSubPropTransformRotationXY,
6606 VeSubPropTransformScaleX,
6607 VeSubPropTransformScaleY,
6608 VeSubPropTransformScaleZ,
6610 VeSubPropTransformTranslationX,
6611 VeSubPropTransformTranslationY,
6612 VeSubPropTransformTranslationZ,
6613 VeSubPropTransformTranslationXY,
6614 VeSubPropChildrenTransformRotationX,
6615 VeSubPropChildrenTransformRotationY,
6616 VeSubPropChildrenTransformRotationZ,
6617 VeSubPropChildrenTransformRotationXY,
6618 VeSubPropChildrenTransformScaleX,
6619 VeSubPropChildrenTransformScaleY,
6620 VeSubPropChildrenTransformScaleZ,
6621 VeSubPropChildrenTransformScaleXY,
6622 VeSubPropChildrenTransformTranslationX,
6623 VeSubPropChildrenTransformTranslationY,
6624 VeSubPropChildrenTransformTranslationZ,
6625 VeSubPropChildrenTransformTranslationXY
6628 static String* const* supportedProperties[] = {
6630 &pVePropContentOpacity,
6633 &pVePropChildrenTransform,
6634 &pVePropZPosition, // TBD:
6635 &pVeSubPropBoundsPosition,
6636 &pVeSubPropBoundsSize,
6638 &pVePropContentBounds,
6639 #if defined(SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION)
6640 &pVePropActionDetach,
6641 &pVePropActionAttach,
6643 &pVeSubPropTransformRotationX,
6644 &pVeSubPropTransformRotationY,
6645 &pVeSubPropTransformRotationZ,
6646 &pVeSubPropTransformRotationXY,
6647 &pVeSubPropTransformScaleX,
6648 &pVeSubPropTransformScaleY,
6649 &pVeSubPropTransformScaleZ,
6650 &pVeSubPropTransformScaleXY,
6651 &pVeSubPropTransformTranslationX,
6652 &pVeSubPropTransformTranslationY,
6653 &pVeSubPropTransformTranslationZ,
6654 &pVeSubPropTransformTranslationXY,
6655 &pVeSubPropChildrenTransformRotationX,
6656 &pVeSubPropChildrenTransformRotationY,
6657 &pVeSubPropChildrenTransformRotationZ,
6658 &pVeSubPropChildrenTransformRotationXY,
6659 &pVeSubPropChildrenTransformScaleX,
6660 &pVeSubPropChildrenTransformScaleY,
6661 &pVeSubPropChildrenTransformScaleZ,
6662 &pVeSubPropChildrenTransformScaleXY,
6663 &pVeSubPropChildrenTransformTranslationX,
6664 &pVeSubPropChildrenTransformTranslationY,
6665 &pVeSubPropChildrenTransformTranslationZ,
6666 &pVeSubPropChildrenTransformTranslationXY
6670 for (int i = 0; i < static_cast< int >(sizeof(supportedProperties) / sizeof(supportedProperties[0])); i++)
6672 //if (wcscmp(property.GetPointer(), supportedProperties[i]) == 0)
6673 if (property.GetPointer() == (*supportedProperties[i])->GetPointer() || property == **supportedProperties[i])
6682 VisualElementAnimation*
6683 _VisualElementImpl::CreateAnimationForPropertyI(const Tizen::Base::String& property)
6685 if (IS_PRESENTATION(this) || !CheckIfAnimatable(property))
6691 if (property.CompareTo(String(VePropBounds)) == 0)
6693 //ToDo: default implementation
6695 else if (property.CompareTo(String(VePropOpacity)) == 0)
6697 //ToDo: default implementation
6699 else if (property.CompareTo(String(VePropChildrenOpacity)) == 0)
6701 //ToDo: default implementation
6703 else if (property.CompareTo(String(VePropShowState)) == 0)
6705 //ToDo: default implementation
6707 else if (property.CompareTo(String(VePropTransform)) == 0)
6709 //ToDo: default implementation
6711 else if (property.CompareTo(String(VePropChildrenTransform)) == 0)
6713 //ToDo: default implementation
6715 else if (property.CompareTo(String(VePropZPosition)) == 0)
6717 //ToDo: default implementation
6722 VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
6723 SysTryReturn(NID_UI_ANIM, pAnimation != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
6725 #if defined(SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION)
6726 if (unlikely(property == *pVePropActionAttach))
6728 pAnimation->SetPropertyName(*pVePropOpacity);
6729 pAnimation->SetStartValue(Variant(0.0f));
6731 else if (unlikely(property == *pVePropActionDetach))
6733 pAnimation->SetPropertyName(*pVePropOpacity);
6734 pAnimation->SetEndValue(Variant(0.0f));
6739 _VisualElementImpl* pPresentation = GetPresentation();
6741 const Variant& curValue = pPresentation->InvokeOnGetPropertyRequested(property);
6742 result r = GetLastResult();
6743 SysTryCatch(NID_UI_ANIM, !IsFailed(r), , r, "[%s] No property for animation exists.", GetErrorMessage(r));
6745 pAnimation->SetPropertyName(property);
6746 pAnimation->SetStartValue(curValue);
6759 _VisualElementImpl::SetBoundsChangedCallback(BoundsChangedCallback pCallback, void* pData)
6761 __pBoundsChangedCallback = pCallback;
6762 __pBoundsChangedCallbackData = pData;
6766 // delegate---------------------------------------------------------------------------------
6769 _VisualElementImpl::InvokeOnConstructed(void)
6771 if (__pPublicInstance)
6775 __pPublicInstance->OnConstructed();
6783 _VisualElementImpl::InvokeOnDestructing(void)
6785 if (__pPublicInstance)
6789 __pPublicInstance->OnDestructing();
6797 _VisualElementImpl::InvokeHitTest(const Tizen::Graphics::FloatPoint& point)
6799 int hitTest = _VisualElementImpl::HITTEST_NOWHERE;
6801 if (__pPublicInstance && !__isInternal)
6803 HitTestResult hitResult = HIT_TEST_NOWHERE;
6805 if (GetSharedData().pContentProvider)
6807 hitResult = GetSharedData().pContentProvider->HitTest(*__pPublicInstance, point);
6811 hitResult = __pPublicInstance->OnHitTest(point);
6814 if (hitResult == HIT_TEST_NOWHERE)
6816 hitTest = _VisualElementImpl::HITTEST_NOWHERE;
6820 hitTest = _VisualElementImpl::HITTEST_MATCH;
6825 return HitTestI(point);
6834 _VisualElementImpl::InvokePrepareDraw(void)
6838 if (__pPublicInstance)
6840 if (GetSharedData().pContentProvider)
6842 result = GetSharedData().pContentProvider->PrepareDraw(*__pPublicInstance);
6846 result = __pPublicInstance->OnPrepareDraw();
6856 _VisualElementImpl::InvokeOnDraw(Tizen::Graphics::Canvas& canvas)
6858 if (__pPublicInstance)
6860 if (GetSharedData().pContentProvider)
6862 GetSharedData().pContentProvider->DrawContent(*__pPublicInstance, canvas);
6866 __pPublicInstance->OnDraw(canvas);
6873 VisualElementAnimation*
6874 _VisualElementImpl::InvokeCreateAnimationForProperty(const Tizen::Base::String& property)
6876 VisualElementAnimation* pAnimation = null;
6878 if (__pPublicInstance)
6880 if (GetSharedData().pAnimationProvider)
6882 pAnimation = GetSharedData().pAnimationProvider->CreateAnimationForProperty(*__pPublicInstance, property);
6886 pAnimation = __pPublicInstance->OnCreateAnimationForProperty(property);
6896 _VisualElementImpl::InvokeOnChildAttaching(_VisualElementImpl& child)
6903 _VisualElementImpl::InvokeOnChildAttached(_VisualElementImpl& child)
6905 if (__pPublicInstance && !__isInternal)
6907 VisualElement* pChild = child.__pPublicInstance;
6909 if (GetSharedData().pEventListener)
6911 GetSharedData().pEventListener->OnChildAttached(*__pPublicInstance, *pChild);
6919 _VisualElementImpl::InvokeOnChildDetaching(_VisualElementImpl& child)
6926 _VisualElementImpl::InvokeOnChildDetached(_VisualElementImpl& child)
6928 if (__pPublicInstance && !__isInternal)
6930 VisualElement* pChild = child.__pPublicInstance;
6932 if (GetSharedData().pEventListener)
6934 GetSharedData().pEventListener->OnChildDetached(*__pPublicInstance, *pChild);
6942 _VisualElementImpl::InvokeOnAttaching(_VisualElementImpl& parent)
6949 _VisualElementImpl::InvokeOnAttached(void)
6951 if (__pPublicInstance && !__isInternal)
6953 _VisualElementImpl* pParentInternal = GetParent();
6954 if (pParentInternal)
6956 VisualElement* pParent = pParentInternal->__pPublicInstance;
6958 if (GetSharedData().pEventListener)
6960 __isAllowedTreeModification = false;
6961 GetSharedData().pEventListener->OnAttached(*__pPublicInstance, *pParent);
6962 __isAllowedTreeModification = true;
6971 _VisualElementImpl::InvokeOnDetaching(void)
6978 _VisualElementImpl::InvokeOnDetached(_VisualElementImpl& parent)
6980 if (__pPublicInstance && !__isInternal)
6982 VisualElement* pParent = parent.__pPublicInstance;
6984 if (GetSharedData().pEventListener)
6986 __isAllowedTreeModification = false;
6987 GetSharedData().pEventListener->OnDetached(*__pPublicInstance, *pParent);
6988 __isAllowedTreeModification = true;
6994 _VisualElementImpl::InvokeOnAnimationAdded(const VisualElementAnimation* pAnimation)
6996 //TODO: Implementation
7002 _VisualElementImpl::InvokeOnAnimationRemoved(const VisualElementAnimation* pAnimation)
7004 //TODO: Implementation
7010 _VisualElementImpl::InvokeOnShowStateChanged(bool showState)
7012 if (__pPublicInstance && !__isInternal)
7014 if (GetSharedData().pEventListener)
7016 GetSharedData().pEventListener->OnShowStateChanged(*__pPublicInstance, showState);
7024 _VisualElementImpl::InvokeOnTransformMatrixChanging(FloatMatrix4& newTransform)
7026 if (__pPublicInstance && !__isInternal)
7028 if (GetSharedData().pEventListener)
7030 return GetSharedData().pEventListener->OnTransformChanging(*__pPublicInstance, newTransform);
7036 return E_INVALID_STATE;
7040 _VisualElementImpl::InvokeOnTransformMatrixChanged(const FloatMatrix4& oldTransform)
7042 if (__pPublicInstance && !__isInternal)
7044 if (GetSharedData().pEventListener)
7046 GetSharedData().pEventListener->OnTransformChanged(*__pPublicInstance, oldTransform);
7054 _VisualElementImpl::InvokeOnChildrenTransformMatrixChanging(FloatMatrix4& newTransform)
7056 if (__pPublicInstance && !__isInternal)
7058 if (GetSharedData().pEventListener)
7060 return GetSharedData().pEventListener->OnChildrenTransformChanging(*__pPublicInstance, newTransform);
7066 return E_INVALID_STATE;
7070 _VisualElementImpl::InvokeOnChildrenTransformMatrixChanged(const FloatMatrix4& oldTransform)
7072 if (__pPublicInstance && !__isInternal)
7074 if (GetSharedData().pEventListener)
7076 GetSharedData().pEventListener->OnChildrenTransformChanged(*__pPublicInstance, oldTransform);
7084 _VisualElementImpl::InvokeOnBoundsChanging(FloatRectangle& newBounds)
7086 if (__pPublicInstance && !__isInternal)
7088 if (GetSharedData().pEventListener)
7090 return GetSharedData().pEventListener->OnBoundsChanging(*__pPublicInstance, newBounds);
7096 return E_INVALID_STATE;
7100 _VisualElementImpl::InvokeOnBoundsChanged(const FloatRectangle& oldBounds)
7102 if (__pPublicInstance && !__isInternal)
7104 if (GetSharedData().pEventListener)
7106 GetSharedData().pEventListener->OnBoundsChanged(*__pPublicInstance, oldBounds);