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_ControlVisualElement.cpp
20 * @brief This file contains implementation of _ControlVisualElement class
22 * This file contains implementation _ControlVisualElement class.
25 #include <FBaseSysLog.h>
27 #include "FUiAnim_EflNode.h"
28 #include "FUiAnim_ControlVisualElement.h"
29 #include "FUiAnim_VisualElementImpl.h"
31 using namespace Tizen::Base;
32 using namespace Tizen::Graphics;
35 namespace Tizen { namespace Ui { namespace Animations
39 //IMPLEMENT_PROPERTY(_ControlVisualElement);
41 _ControlVisualElement::_ControlVisualElement(void)
47 _ControlVisualElement::~_ControlVisualElement(void)
52 _ControlVisualElement::CloneN(void) const
54 return new (std::nothrow) _ControlVisualElement(*this);
57 _ControlVisualElement::_ControlVisualElement(const _ControlVisualElement& rhs)
59 , __autoResize(rhs.__autoResize)
64 _ControlVisualElement::ConstructControlVisualElement(void)
66 result r = VisualElement::Construct();
67 SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Propagating.");
69 _pVisualElementImpl->SetZOrderGroup(Z_ORDER_GROUP_CONTROL);
71 SetImplicitAnimationEnabled(false);
76 _ControlVisualElement*
77 _ControlVisualElement::__GetControlChildAtPoint(Tizen::Graphics::FloatPoint& point, int parentHitTest)
79 _ControlVisualElement* pHitTarget = null;
80 Tizen::Graphics::FloatPoint hitPoint = point;
81 int hitTest = _pVisualElementImpl->InvokeHitTest(point);
82 if ((hitTest & _VisualElementImpl::HITTEST_MATCH) != 0)
87 // this passed hittest, but not parent --> clipped out by parent
88 if (GetParent() && IsClipToParent())
90 if ((parentHitTest & HITTEST_MATCH) == 0)
96 if ((hitTest & _VisualElementImpl::HITTEST_NOMORECHILDREN) == 0)
98 int count = _pVisualElementImpl->__children.GetCount();
99 for (int i = count - 1; i >= 0; i--) // from top to bottom
101 // Skip non-ControlVisualElement
102 _VisualElementImpl* pTemp = _pVisualElementImpl->__children.GetChildAt(i);
103 _ControlVisualElement* pChild = null;
109 pChild = dynamic_cast< _ControlVisualElement* >(pTemp->GetPublic());
115 Tizen::Graphics::FloatPoint childHitPoint = point;
117 pChild->ConvertCoordinates(childHitPoint, this);
119 _ControlVisualElement* pChildHitTarget = pChild->__GetControlChildAtPoint(childHitPoint, hitTest);
122 pHitTarget = pChildHitTarget;
123 hitPoint = childHitPoint;
140 // Because Hit-Testing from self, clipping flags of self will be ignored.
141 _ControlVisualElement*
142 _ControlVisualElement::GetControlChildAtPoint(Tizen::Graphics::FloatPoint& point)
144 _ControlVisualElement* pHitTarget = __GetControlChildAtPoint(point, _VisualElementImpl::HITTEST_MATCH);
148 SetLastResult(E_OBJ_NOT_FOUND); // TBD: error code
158 _ControlVisualElement::IsAutoResizeChildrenEnabled(void) const
164 _ControlVisualElement::SetAutoResizeChildrenEnabled(bool autoResize)
168 __autoResize = autoResize;
169 // _ControlVisualElement* pVisualElement = dynamic_cast< _ControlVisualElement* >(__pPresentation->__pPublicInstance);
170 // pVisualElement->__autoResize = autoResize;
176 _ControlVisualElement::OnGetPropertyRequested(const Tizen::Base::String& property) const
178 if (property == *pVePropBounds)
180 return _PropGetControlBounds();
182 else if (property == *pVePropImplicitAnimationEnabled)
184 return _PropGetControlImplicitAnimationEnabled();
186 else if (property == *pVePropPropertyPropagationEnabled)
188 return _PropGetControlPropertyPropagationEnabled();
191 return VisualElement::OnGetPropertyRequested(property);
195 _ControlVisualElement::OnSetPropertyRequested(const Tizen::Base::String& property, const Variant& value)
197 if (property == *pVePropBounds)
199 return _PropSetControlBounds(value);
201 else if (property == *pVePropImplicitAnimationEnabled)
203 return _PropSetControlImplicitAnimationEnabled(value);
205 else if (property == *pVePropPropertyPropagationEnabled)
207 return _PropSetControlPropertyPropagationEnabled(value);
210 return VisualElement::OnSetPropertyRequested(property, value);
214 _ControlVisualElement::_PropGetControlBounds(void) const
216 return _VisualElementImpl::GetInstance(*this)->GetBoundsProperty();
220 _ControlVisualElement::_PropSetControlBounds(const Variant& v)
222 result r = _VisualElementImpl::GetInstance(*this)->SetBoundsProperty(v);
223 SysTryReturnResult(NID_UI_ANIM, !IsFailed(r), r,"Can't set bounds for control VisualElement.");
227 Tizen::Base::Collection::IList* pList = GetChildrenN();
233 Tizen::Graphics::FloatRectangle clientBounds = v.ToFloatRectangle();
234 clientBounds.x = 0.0f;
235 clientBounds.y = 0.0f;
237 for (int i = 0; i < pList->GetCount(); i++)
239 _ControlVisualElement* pChild = dynamic_cast< _ControlVisualElement* >(pList->GetAt(i));
242 pChild->SetBounds(clientBounds);
246 if (pList->GetCount() > 2)
248 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Invalid control state(root/system/client)");
258 _ControlVisualElement::_PropGetControlImplicitAnimationEnabled(void) const
260 return _VisualElementImpl::GetInstance(*this)->GetImplicitAnimationProperty();
264 _ControlVisualElement::_PropSetControlImplicitAnimationEnabled(const Variant& v)
266 result r = _VisualElementImpl::GetInstance(*this)->SetImplicitAnimationProperty(v);
267 SysTryReturnResult(NID_UI_ANIM, !IsFailed(r), r, "Can't enable or diable implicit animation for control VisualElement.");
271 Tizen::Base::Collection::IList* pList = GetChildrenN();
277 bool enable = v.ToBool();
279 for (int i = 0; i < pList->GetCount(); i++)
281 _ControlVisualElement* pChild = dynamic_cast< _ControlVisualElement* >(pList->GetAt(i));
284 pChild->SetImplicitAnimationEnabled(enable);
288 if (pList->GetCount() > 2)
290 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Invalid control state(root/system/client)");
300 _ControlVisualElement::_PropGetControlPropertyPropagationEnabled(void) const
302 return _VisualElementImpl::GetInstance(*this)->GetPropertyPropagationProperty();
306 _ControlVisualElement::_PropSetControlPropertyPropagationEnabled(const Variant& v)
308 result r = _VisualElementImpl::GetInstance(*this)->SetPropertyPropagationProperty(v);
309 SysTryReturnResult(NID_UI_ANIM, !IsFailed(r), r, "Can't enable or diable property propagation for control VisualElement.");
313 Tizen::Base::Collection::IList* pList = GetChildrenN();
319 bool enable = v.ToBool();
321 for (int i = 0; i < pList->GetCount(); i++)
323 _ControlVisualElement* pChild = dynamic_cast< _ControlVisualElement* >(pList->GetAt(i));
326 _VisualElementImpl::GetInstance(*pChild)->SetPropertyPropagationEnabled(enable);
330 if (pList->GetCount() > 2)
332 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Invalid control state(root/system/client)");
342 }}} // Tizen::Ui::Animations