2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-helper-functions.h>
29 namespace ScrollViewHelperFunctions
32 bool IsStraightOnView( const Vector3& position )
34 return ( fabsf(position.x) < Math::MACHINE_EPSILON_1 ) && ( fabsf( position.y ) < Math::MACHINE_EPSILON_1 );
37 void WrapPositionWithinDomain( Vector3& position, const Vector3& pageSize, const Vector3& min, const Vector3& max )
39 if( fabsf( min.x - max.x ) > Math::MACHINE_EPSILON_1 )
41 // WRAP X (based on the position of the right side)
42 position.x = WrapInDomain( position.x + pageSize.width, min.x, max.x ) - pageSize.width;
45 if( fabsf( min.y - max.y ) > Math::MACHINE_EPSILON_1 )
47 // WRAP Y (based on the position of the bottom side)
48 position.y = WrapInDomain( position.y + pageSize.height, min.y, max.y ) - pageSize.height;
52 bool IsOutsideView( const Vector3& position, const Vector3& pageSize )
54 return ( fabsf( position.x ) >= pageSize.width ) || ( fabsf( position.y ) >= pageSize.height );
57 } // namespace ScrollViewHelperFunctions
59 } // namespace Internal
61 } // namespace Toolkit