[SRUK] Initial copy from Tizen 2.2 version
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / scrollable / scroll-view / scroll-view-helper-functions.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 #include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-helper-functions.h>
18
19 namespace Dali
20 {
21
22 namespace Toolkit
23 {
24
25 namespace Internal
26 {
27
28 namespace ScrollViewHelperFunctions
29 {
30
31 bool IsStraightOnView( const Vector3& position )
32 {
33   return ( fabsf(position.x) < Math::MACHINE_EPSILON_1 ) && ( fabsf( position.y ) < Math::MACHINE_EPSILON_1 );
34 }
35
36 void WrapPositionWithinDomain( Vector3& position, const Vector3& pageSize, const Vector3& min, const Vector3& max )
37 {
38   if( fabsf( min.x - max.x ) > Math::MACHINE_EPSILON_1 )
39   {
40     // WRAP X (based on the position of the right side)
41     position.x = WrapInDomain( position.x + pageSize.width, min.x, max.x ) - pageSize.width;
42   }
43
44   if( fabsf( min.y - max.y ) > Math::MACHINE_EPSILON_1 )
45   {
46     // WRAP Y (based on the position of the bottom side)
47     position.y = WrapInDomain( position.y + pageSize.height, min.y, max.y ) - pageSize.height;
48   }
49 }
50
51 bool IsOutsideView( const Vector3& position, const Vector3& pageSize )
52 {
53   return ( fabsf( position.x ) >= pageSize.width ) || ( fabsf( position.y ) >= pageSize.height );
54 }
55
56 } // namespace ScrollViewHelperFunctions
57
58 } // namespace Internal
59
60 } // namespace Toolkit
61
62 } // namespace Dali