Merge "Remove unnecessary stream operators from radian and degree as well as unnecess...
[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 PropertyCondition::ArgumentContainer PropertyCondition::GetArguments()
51 {
52   return GetImplementation(*this).arguments;
53 }
54
55 const PropertyCondition::ArgumentContainer& PropertyCondition::GetArguments() const
56 {
57   return GetImplementation(*this).arguments;
58 }
59
60 PropertyCondition LessThanCondition(float arg)
61 {
62   PropertyCondition condition;
63   GetImplementation(condition).type = Internal::PropertyCondition::LessThan;
64   GetImplementation(condition).arguments.push_back(Property::Value(arg));
65
66   return condition;
67 }
68
69 PropertyCondition GreaterThanCondition(float arg)
70 {
71   PropertyCondition condition;
72   GetImplementation(condition).type = Internal::PropertyCondition::GreaterThan;
73   GetImplementation(condition).arguments.push_back(Property::Value(arg));
74
75   return condition;
76 }
77
78 PropertyCondition InsideCondition(float arg0, float arg1)
79 {
80   PropertyCondition condition;
81   GetImplementation(condition).type = Internal::PropertyCondition::Inside;
82   GetImplementation(condition).arguments.push_back(Property::Value(arg0));
83   GetImplementation(condition).arguments.push_back(Property::Value(arg1));
84
85   return condition;
86 }
87
88 PropertyCondition OutsideCondition(float arg0, float arg1)
89 {
90   PropertyCondition condition;
91   GetImplementation(condition).type = Internal::PropertyCondition::Outside;
92   GetImplementation(condition).arguments.push_back(Property::Value(arg0));
93   GetImplementation(condition).arguments.push_back(Property::Value(arg1));
94
95   return condition;
96 }
97
98 PropertyCondition StepCondition(float stepAmount, float referenceValue)
99 {
100   PropertyCondition condition;
101   GetImplementation(condition).type = Internal::PropertyCondition::Step;
102   GetImplementation(condition).arguments.push_back(Property::Value(referenceValue));
103   GetImplementation(condition).arguments.push_back(Property::Value(1.0f / stepAmount));
104   GetImplementation(condition).arguments.push_back(Property::Value(0.0f)); // current step
105
106   return condition;
107 }
108
109 PropertyCondition VariableStepCondition(const std::vector<float>& stepAmount)
110 {
111   PropertyCondition condition;
112   GetImplementation(condition).type = Internal::PropertyCondition::VariableStep;
113   GetImplementation(condition).arguments.push_back(Property::Value(0.0f)); // current step
114   int size = stepAmount.size();
115   GetImplementation(condition).arguments.push_back(Property::Value(static_cast<float>(size))); // store number of steps
116   for( std::vector<float>::const_iterator it = stepAmount.begin(), endIt = stepAmount.end(); it != endIt; ++it )
117   {
118     GetImplementation(condition).arguments.push_back(Property::Value( *it ));
119   }
120
121   return condition;
122 }
123
124 } // namespace Dali