Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / animations / FUiAnim_VisualElementPropertyAnimationImpl.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FUiAnim_VisualElementPropertyAnimationImpl.cpp
20  * @brief       This file contains implementation of _VisualElementPropertyAnimationImpl class
21  *
22  * This file contains implementation _VisualElementValueAnimationImpl class.
23  */
24
25 #include <FBaseSysLog.h>
26
27 #include <FUiAnimVisualElementPropertyAnimation.h>
28 #include <FUiAnimVisualElement.h>
29 #include <FUiAnim_VisualElementImpl.h>
30
31 #include "FUiAnim_VisualElementPropertyAnimationImpl.h"
32
33 namespace Tizen { namespace Ui { namespace Animations
34 {
35
36
37 _VisualElementPropertyAnimationImpl::_VisualElementPropertyAnimationImpl(void)
38 {
39
40 }
41
42 _VisualElementPropertyAnimationImpl::_VisualElementPropertyAnimationImpl(const _VisualElementPropertyAnimationImpl& animationImpl)
43 {
44         result r = CopyAnimationValue(animationImpl);
45
46         SysTryReturnVoidResult(NID_UI_ANIM, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
47 }
48
49 _VisualElementPropertyAnimationImpl::~_VisualElementPropertyAnimationImpl(void)
50 {
51
52 }
53
54 bool
55 _VisualElementPropertyAnimationImpl::Equals(const Tizen::Base::Object& obj) const
56 {
57         if (this == &obj)
58         {
59                 return true;
60         }
61
62         const _VisualElementPropertyAnimationImpl* pAnimationImpl = dynamic_cast< const _VisualElementPropertyAnimationImpl* >(&obj);
63
64         if (pAnimationImpl == null)
65         {
66                 return false;
67         }
68
69         return (_VisualElementValueAnimationImpl::Equals(obj) && __property == pAnimationImpl->__property);
70 }
71
72 int
73 _VisualElementPropertyAnimationImpl::GetHashCode(void) const
74 {
75         return (_VisualElementValueAnimationImpl::GetHashCode() + __property.GetHashCode());
76 }
77
78 result
79 _VisualElementPropertyAnimationImpl::CopyAnimationValue(const _VisualElementPropertyAnimationImpl& animationImpl)
80 {
81         result r = _VisualElementValueAnimationImpl::CopyAnimationValue(animationImpl);
82         SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating.");
83
84         __property = animationImpl.__property;
85
86         return E_SUCCESS;
87 }
88
89 void
90 _VisualElementPropertyAnimationImpl::SetPropertyName(const Tizen::Base::String& property)
91 {
92         __property = property;
93 }
94
95 Tizen::Base::String
96 _VisualElementPropertyAnimationImpl::GetPropertyName(void) const
97 {
98         return __property;
99 }
100
101 _VisualElementPropertyAnimationImpl*
102 _VisualElementPropertyAnimationImpl::GetInstance(VisualElementPropertyAnimation& animation)
103 {
104         return dynamic_cast<_VisualElementPropertyAnimationImpl*>(animation._pAnimationImpl);
105 }
106
107 const _VisualElementPropertyAnimationImpl*
108 _VisualElementPropertyAnimationImpl::GetInstance(const VisualElementPropertyAnimation& animation)
109 {
110         return dynamic_cast<const _VisualElementPropertyAnimationImpl*>(animation._pAnimationImpl);
111 }
112
113 bool
114 _VisualElementPropertyAnimationImpl::IsValidValues(void) const
115 {
116         SysTryReturn(NID_UI_ANIM, (__property.IsEmpty() == false), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. The property name is not set.");
117         SysTryReturn(NID_UI_ANIM, (__start.IsEmpty() == false || __end.IsEmpty() == false), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. The start value and end value is invalid.");
118
119         if (__start.IsEmpty() == false && __end.IsEmpty() == false)
120         {
121                 SysTryReturn(NID_UI_ANIM, (__start.GetType() == __end.GetType()), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. The types of variant are different.");
122         }
123
124         return true;
125 }
126
127 void
128 _VisualElementPropertyAnimationImpl::OnTickOccurred(VisualElement& target, const Tizen::Ui::Variant& currentValue)
129 {
130         _VisualElementImpl::GetInstance(target)->SetPropertyI(__property, currentValue);
131 }
132
133 }}}   // Tizen::Ui::Animations
134