Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-core.git] / dali / public-api / object / property-conditions.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // CLASS HEADER
18 #include <dali/public-api/object/property-conditions.h>
19
20 // INTERNAL INCLUDES
21 #include <dali/public-api/object/property-value.h>
22 #include <dali/internal/event/common/property-conditions-impl.h>
23
24 namespace Dali
25 {
26
27 PropertyCondition::PropertyCondition()
28 : BaseHandle(new Internal::PropertyCondition())
29 {
30
31 }
32
33 PropertyCondition::~PropertyCondition()
34 {
35
36 }
37
38 PropertyCondition::ArgumentContainer PropertyCondition::GetArguments()
39 {
40   return GetImplementation(*this).arguments;
41 }
42
43 const PropertyCondition::ArgumentContainer& PropertyCondition::GetArguments() const
44 {
45   return GetImplementation(*this).arguments;
46 }
47
48 PropertyCondition LessThanCondition(float arg)
49 {
50   PropertyCondition condition;
51   GetImplementation(condition).type = Internal::PropertyCondition::LessThan;
52   GetImplementation(condition).arguments.push_back(Property::Value(arg));
53
54   return condition;
55 }
56
57 PropertyCondition GreaterThanCondition(float arg)
58 {
59   PropertyCondition condition;
60   GetImplementation(condition).type = Internal::PropertyCondition::GreaterThan;
61   GetImplementation(condition).arguments.push_back(Property::Value(arg));
62
63   return condition;
64 }
65
66 PropertyCondition InsideCondition(float arg0, float arg1)
67 {
68   PropertyCondition condition;
69   GetImplementation(condition).type = Internal::PropertyCondition::Inside;
70   GetImplementation(condition).arguments.push_back(Property::Value(arg0));
71   GetImplementation(condition).arguments.push_back(Property::Value(arg1));
72
73   return condition;
74 }
75
76 PropertyCondition OutsideCondition(float arg0, float arg1)
77 {
78   PropertyCondition condition;
79   GetImplementation(condition).type = Internal::PropertyCondition::Outside;
80   GetImplementation(condition).arguments.push_back(Property::Value(arg0));
81   GetImplementation(condition).arguments.push_back(Property::Value(arg1));
82
83   return condition;
84 }
85
86 PropertyCondition StepCondition(float stepAmount, float referenceValue)
87 {
88   PropertyCondition condition;
89   GetImplementation(condition).type = Internal::PropertyCondition::Step;
90   GetImplementation(condition).arguments.push_back(Property::Value(referenceValue));
91   GetImplementation(condition).arguments.push_back(Property::Value(1.0f / stepAmount));
92   GetImplementation(condition).arguments.push_back(Property::Value(0.0f)); // current step
93
94   return condition;
95 }
96
97 PropertyCondition VariableStepCondition(const std::vector<float>& stepAmount)
98 {
99   PropertyCondition condition;
100   GetImplementation(condition).type = Internal::PropertyCondition::VariableStep;
101   GetImplementation(condition).arguments.push_back(Property::Value(0.0f)); // current step
102   int size = stepAmount.size();
103   GetImplementation(condition).arguments.push_back(Property::Value(static_cast<float>(size))); // store number of steps
104   for( std::vector<float>::const_iterator it = stepAmount.begin(), endIt = stepAmount.end(); it != endIt; ++it )
105   {
106     GetImplementation(condition).arguments.push_back(Property::Value( *it ));
107   }
108
109   return condition;
110 }
111
112 } // namespace Dali