Clean up the code to build successfully on macOS
[platform/core/uifw/dali-core.git] / dali / public-api / object / property-conditions.cpp
1 /*
2  * Copyright (c) 2020 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/internal/event/common/property-conditions-impl.h>
23 #include <dali/public-api/object/property-value.h>
24
25 namespace Dali
26 {
27 PropertyCondition::PropertyCondition()
28 : BaseHandle(new Internal::PropertyCondition())
29 {
30 }
31
32 PropertyCondition::~PropertyCondition()
33 {
34 }
35
36 PropertyCondition::PropertyCondition(const PropertyCondition& handle) = default;
37
38 PropertyCondition& PropertyCondition::operator=(const PropertyCondition& rhs) = default;
39
40 PropertyCondition::PropertyCondition(PropertyCondition&& rhs) = default;
41
42 PropertyCondition& PropertyCondition::operator=(PropertyCondition&& rhs) = default;
43
44 std::size_t PropertyCondition::GetArgumentCount() const
45 {
46   return GetImplementation(*this).arguments.Count();
47 }
48
49 float PropertyCondition::GetArgument(std::size_t index) const
50 {
51   return GetImplementation(*this).arguments[index];
52 }
53
54 PropertyCondition LessThanCondition(float arg)
55 {
56   PropertyCondition            condition;
57   Internal::PropertyCondition& impl = GetImplementation(condition);
58   impl.type                         = Internal::PropertyCondition::LessThan;
59   impl.arguments.PushBack(arg);
60
61   return condition;
62 }
63
64 PropertyCondition GreaterThanCondition(float arg)
65 {
66   PropertyCondition            condition;
67   Internal::PropertyCondition& impl = GetImplementation(condition);
68   impl.type                         = Internal::PropertyCondition::GreaterThan;
69   impl.arguments.PushBack(arg);
70
71   return condition;
72 }
73
74 PropertyCondition InsideCondition(float arg0, float arg1)
75 {
76   PropertyCondition            condition;
77   Internal::PropertyCondition& impl = GetImplementation(condition);
78   impl.type                         = Internal::PropertyCondition::Inside;
79   impl.arguments.PushBack(arg0);
80   impl.arguments.PushBack(arg1);
81
82   return condition;
83 }
84
85 PropertyCondition OutsideCondition(float arg0, float arg1)
86 {
87   PropertyCondition            condition;
88   Internal::PropertyCondition& impl = GetImplementation(condition);
89   impl.type                         = Internal::PropertyCondition::Outside;
90   impl.arguments.PushBack(arg0);
91   impl.arguments.PushBack(arg1);
92
93   return condition;
94 }
95
96 PropertyCondition StepCondition(float stepAmount, float referenceValue)
97 {
98   PropertyCondition            condition;
99   Internal::PropertyCondition& impl = GetImplementation(condition);
100   impl.type                         = Internal::PropertyCondition::Step;
101   impl.arguments.PushBack(referenceValue);
102   impl.arguments.PushBack(1.0f / stepAmount);
103   impl.arguments.PushBack(0.0f); // current step
104
105   return condition;
106 }
107
108 PropertyCondition VariableStepCondition(const Dali::Vector<float>& stepAmount)
109 {
110   PropertyCondition            condition;
111   Internal::PropertyCondition& impl = GetImplementation(condition);
112   impl.type                         = Internal::PropertyCondition::VariableStep;
113   impl.arguments.PushBack(0.0f); // current step
114   Dali::Vector<float>::SizeType count = stepAmount.Count();
115   impl.arguments.PushBack(float(count)); // store number of steps
116   for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
117   {
118     impl.arguments.PushBack(stepAmount[index]);
119   }
120
121   return condition;
122 }
123
124 } // namespace Dali