[Tizen] Add codes for Dali Windows Backend
[platform/core/uifw/dali-core.git] / dali / public-api / object / property-conditions.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/public-api/object/property-conditions.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/object/property-value.h>
23 #include <dali/internal/event/common/property-conditions-impl.h>
24
25 namespace Dali
26 {
27
28 PropertyCondition::PropertyCondition()
29 : BaseHandle(new Internal::PropertyCondition())
30 {
31
32 }
33
34 PropertyCondition::~PropertyCondition()
35 {
36
37 }
38
39 PropertyCondition::PropertyCondition( const PropertyCondition& handle )
40 : BaseHandle(handle)
41 {
42 }
43
44 PropertyCondition& PropertyCondition::operator=( const PropertyCondition& rhs )
45 {
46   BaseHandle::operator=(rhs);
47   return *this;
48 }
49
50 std::size_t PropertyCondition::GetArgumentCount() const
51 {
52   return GetImplementation(*this).arguments.Count();
53 }
54
55 float PropertyCondition::GetArgument( std::size_t index ) const
56 {
57   return GetImplementation(*this).arguments[ index ];
58 }
59
60 PropertyCondition LessThanCondition( float arg )
61 {
62   PropertyCondition condition;
63   Internal::PropertyCondition& impl = GetImplementation( condition );
64   impl.type = Internal::PropertyCondition::LessThan;
65   impl.arguments.PushBack( arg );
66
67   return condition;
68 }
69
70 PropertyCondition GreaterThanCondition( float arg )
71 {
72   PropertyCondition condition;
73   Internal::PropertyCondition& impl = GetImplementation( condition );
74   impl.type = Internal::PropertyCondition::GreaterThan;
75   impl.arguments.PushBack( arg );
76
77   return condition;
78 }
79
80 PropertyCondition InsideCondition( float arg0, float arg1 )
81 {
82   PropertyCondition condition;
83   Internal::PropertyCondition& impl = GetImplementation( condition );
84   impl.type = Internal::PropertyCondition::Inside;
85   impl.arguments.PushBack( arg0 );
86   impl.arguments.PushBack( arg1 );
87
88   return condition;
89 }
90
91 PropertyCondition OutsideCondition( float arg0, float arg1 )
92 {
93   PropertyCondition condition;
94   Internal::PropertyCondition& impl = GetImplementation( condition );
95   impl.type = Internal::PropertyCondition::Outside;
96   impl.arguments.PushBack( arg0 );
97   impl.arguments.PushBack( arg1 );
98
99   return condition;
100 }
101
102 PropertyCondition StepCondition( float stepAmount, float referenceValue )
103 {
104   PropertyCondition condition;
105   Internal::PropertyCondition& impl = GetImplementation( condition );
106   impl.type = Internal::PropertyCondition::Step;
107   impl.arguments.PushBack( referenceValue );
108   impl.arguments.PushBack( 1.0f / stepAmount );
109   impl.arguments.PushBack( 0.0f ); // current step
110
111   return condition;
112 }
113
114 PropertyCondition VariableStepCondition( const Dali::Vector<float>& stepAmount )
115 {
116   PropertyCondition condition;
117   Internal::PropertyCondition& impl = GetImplementation( condition );
118   impl.type = Internal::PropertyCondition::VariableStep;
119   impl.arguments.PushBack( 0.0f ); // current step
120   Dali::Vector<float>::SizeType count = stepAmount.Count();
121   impl.arguments.PushBack( float( count ) ); // store number of steps
122   for( Dali::Vector<float>::SizeType index = 0; index < count; ++index )
123   {
124     impl.arguments.PushBack( stepAmount[index] );
125   }
126
127   return condition;
128 }
129
130 } // namespace Dali