Ensure BaseHandle class move noexcept (core public-api)
[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() = default;
33
34 PropertyCondition::PropertyCondition(const PropertyCondition& handle) = default;
35
36 PropertyCondition& PropertyCondition::operator=(const PropertyCondition& rhs) = default;
37
38 PropertyCondition::PropertyCondition(PropertyCondition&& rhs) noexcept = default;
39
40 PropertyCondition& PropertyCondition::operator=(PropertyCondition&& rhs) noexcept = default;
41
42 std::size_t PropertyCondition::GetArgumentCount() const
43 {
44   return GetImplementation(*this).arguments.Count();
45 }
46
47 float PropertyCondition::GetArgument(std::size_t index) const
48 {
49   return GetImplementation(*this).arguments[index];
50 }
51
52 PropertyCondition LessThanCondition(float arg)
53 {
54   PropertyCondition            condition;
55   Internal::PropertyCondition& impl = GetImplementation(condition);
56   impl.type                         = Internal::PropertyCondition::LessThan;
57   impl.arguments.PushBack(arg);
58
59   return condition;
60 }
61
62 PropertyCondition GreaterThanCondition(float arg)
63 {
64   PropertyCondition            condition;
65   Internal::PropertyCondition& impl = GetImplementation(condition);
66   impl.type                         = Internal::PropertyCondition::GreaterThan;
67   impl.arguments.PushBack(arg);
68
69   return condition;
70 }
71
72 PropertyCondition InsideCondition(float arg0, float arg1)
73 {
74   PropertyCondition            condition;
75   Internal::PropertyCondition& impl = GetImplementation(condition);
76   impl.type                         = Internal::PropertyCondition::Inside;
77   impl.arguments.PushBack(arg0);
78   impl.arguments.PushBack(arg1);
79
80   return condition;
81 }
82
83 PropertyCondition OutsideCondition(float arg0, float arg1)
84 {
85   PropertyCondition            condition;
86   Internal::PropertyCondition& impl = GetImplementation(condition);
87   impl.type                         = Internal::PropertyCondition::Outside;
88   impl.arguments.PushBack(arg0);
89   impl.arguments.PushBack(arg1);
90
91   return condition;
92 }
93
94 PropertyCondition StepCondition(float stepAmount, float referenceValue)
95 {
96   PropertyCondition            condition;
97   Internal::PropertyCondition& impl = GetImplementation(condition);
98   impl.type                         = Internal::PropertyCondition::Step;
99   impl.arguments.PushBack(referenceValue);
100   impl.arguments.PushBack(1.0f / stepAmount);
101   impl.arguments.PushBack(0.0f); // current step
102
103   return condition;
104 }
105
106 PropertyCondition VariableStepCondition(const Dali::Vector<float>& stepAmount)
107 {
108   PropertyCondition            condition;
109   Internal::PropertyCondition& impl = GetImplementation(condition);
110   impl.type                         = Internal::PropertyCondition::VariableStep;
111   impl.arguments.PushBack(0.0f); // current step
112   Dali::Vector<float>::SizeType count = stepAmount.Count();
113   impl.arguments.PushBack(float(count)); // store number of steps
114   for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
115   {
116     impl.arguments.PushBack(stepAmount[index]);
117   }
118
119   return condition;
120 }
121
122 } // namespace Dali