Remove obsolete and non functional SizeChanged signal from actor
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / scrollable / scroll-view / scroll-view-constraints.cpp
1 /*
2  * Copyright (c) 2014 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 // INTERNAL INCLUDES
19
20 #include <dali/public-api/common/constants.h>
21 #include <dali/public-api/math/math-utils.h>
22 #include <dali/public-api/object/property-input.h>
23 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-constraints.h>
24
25 using namespace Dali;
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 Vector3 MoveActorConstraint(const Vector3&    current,
34                             const PropertyInput& scrollPositionProperty)
35 {
36   return current + scrollPositionProperty.GetVector3();
37 }
38
39 Vector3 WrapActorConstraint(const Vector3&    current,
40                             const PropertyInput& actorScaleProperty,
41                             const PropertyInput& actorAnchorPointProperty,
42                             const PropertyInput& actorSizeProperty,
43                             const PropertyInput& scrollPositionMin,
44                             const PropertyInput& scrollPositionMax,
45                             const PropertyInput& scrollWrap)
46 {
47   Vector3 position = current;
48   bool wrap = scrollWrap.GetBoolean();
49
50   if(wrap)
51   {
52     const Vector3& min = scrollPositionMin.GetVector3();
53     const Vector3& max = scrollPositionMax.GetVector3();
54
55     const Vector3& anchor = actorAnchorPointProperty.GetVector3();
56     const Vector3 scale = actorScaleProperty.GetVector3();
57     const Vector3 size = actorSizeProperty.GetVector3();
58
59     if(fabsf(min.x - max.x) > Math::MACHINE_EPSILON_1)
60     {
61       // WRAP X (based on the position of the right side)
62       float offsetX = (1.0f - anchor.x) * size.x * scale.x;
63       position.x = WrapInDomain(position.x + offsetX, min.x, max.x) - offsetX;
64     }
65
66     if(fabsf(min.y - max.y) > Math::MACHINE_EPSILON_1)
67     {
68       // WRAP Y (based on the position of the bottom side)
69       float offsetY = (1.0f - anchor.y) * size.y * scale.y;
70       position.y = WrapInDomain(position.y + offsetY, min.y, max.y) - offsetY;
71     }
72   }
73
74   return position;
75 }
76
77 } // namespace Toolkit
78
79 } // namespace Dali
80