2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/public-api/object/property-conditions.h>
22 #include <dali/internal/event/common/property-conditions-impl.h>
23 #include <dali/public-api/object/property-value.h>
27 PropertyCondition::PropertyCondition()
28 : BaseHandle(new Internal::PropertyCondition())
32 PropertyCondition::~PropertyCondition()
36 PropertyCondition::PropertyCondition(const PropertyCondition& handle) = default;
38 PropertyCondition& PropertyCondition::operator=(const PropertyCondition& rhs) = default;
40 PropertyCondition::PropertyCondition(PropertyCondition&& rhs) = default;
42 PropertyCondition& PropertyCondition::operator=(PropertyCondition&& rhs) = default;
44 std::size_t PropertyCondition::GetArgumentCount() const
46 return GetImplementation(*this).arguments.Count();
49 float PropertyCondition::GetArgument(std::size_t index) const
51 return GetImplementation(*this).arguments[index];
54 PropertyCondition LessThanCondition(float arg)
56 PropertyCondition condition;
57 Internal::PropertyCondition& impl = GetImplementation(condition);
58 impl.type = Internal::PropertyCondition::LessThan;
59 impl.arguments.PushBack(arg);
64 PropertyCondition GreaterThanCondition(float arg)
66 PropertyCondition condition;
67 Internal::PropertyCondition& impl = GetImplementation(condition);
68 impl.type = Internal::PropertyCondition::GreaterThan;
69 impl.arguments.PushBack(arg);
74 PropertyCondition InsideCondition(float arg0, float arg1)
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);
85 PropertyCondition OutsideCondition(float arg0, float arg1)
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);
96 PropertyCondition StepCondition(float stepAmount, float referenceValue)
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
108 PropertyCondition VariableStepCondition(const Dali::Vector<float>& stepAmount)
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)
118 impl.arguments.PushBack(stepAmount[index]);