Merge "Fix an issue where TapGesture Events are not being received." into devel/master
[platform/core/uifw/dali-core.git] / dali / public-api / animation / alpha-function.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/animation/alpha-function.h>
20
21 // INTERNAL INCLUDES
22
23 namespace Dali
24 {
25 AlphaFunction::AlphaFunction()
26 : mMode(BUILTIN_FUNCTION),
27   mBuiltin(DEFAULT)
28 {
29 }
30
31 AlphaFunction::AlphaFunction(BuiltinFunction function)
32 : mMode(BUILTIN_FUNCTION),
33   mBuiltin(function)
34 {
35 }
36
37 AlphaFunction::AlphaFunction(AlphaFunctionPrototype function)
38 : mMode(CUSTOM_FUNCTION),
39   mBuiltin(DEFAULT),
40   mCustom(function)
41 {
42 }
43
44 AlphaFunction::AlphaFunction(const Vector2& controlPoint0, const Vector2& controlPoint1)
45 : mMode(BEZIER),
46   mBuiltin(DEFAULT),
47   mBezierControlPoints(
48     Vector4(Clamp(controlPoint0.x, 0.0f, 1.0f),
49             controlPoint0.y,
50             Clamp(controlPoint1.x, 0.0f, 1.0f),
51             controlPoint1.y))
52 {
53 }
54
55 Vector4 AlphaFunction::GetBezierControlPoints() const
56 {
57   return (mMode == BEZIER) ? mBezierControlPoints : Vector4::ZERO;
58 }
59
60 AlphaFunctionPrototype AlphaFunction::GetCustomFunction() const
61 {
62   return (mMode == CUSTOM_FUNCTION) ? mCustom : nullptr;
63 }
64
65 AlphaFunction::BuiltinFunction AlphaFunction::GetBuiltinFunction() const
66 {
67   return mBuiltin;
68 }
69
70 AlphaFunction::Mode AlphaFunction::GetMode() const
71 {
72   return mMode;
73 }
74
75 } // namespace Dali