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.
19 #include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-helper-functions.h>
22 #include <dali/public-api/math/math-utils.h>
33 namespace ScrollViewHelperFunctions
36 bool IsStraightOnView( const Vector3& position )
38 return ( fabsf(position.x) < Math::MACHINE_EPSILON_1 ) && ( fabsf( position.y ) < Math::MACHINE_EPSILON_1 );
41 void WrapPositionWithinDomain( Vector3& position, const Vector3& pageSize, const Vector3& min, const Vector3& max )
43 if( fabsf( min.x - max.x ) > Math::MACHINE_EPSILON_1 )
45 // WRAP X (based on the position of the right side)
46 position.x = WrapInDomain( position.x + pageSize.width, min.x, max.x ) - pageSize.width;
49 if( fabsf( min.y - max.y ) > Math::MACHINE_EPSILON_1 )
51 // WRAP Y (based on the position of the bottom side)
52 position.y = WrapInDomain( position.y + pageSize.height, min.y, max.y ) - pageSize.height;
56 bool IsOutsideView( const Vector3& position, const Vector3& pageSize )
58 return ( fabsf( position.x ) >= pageSize.width ) || ( fabsf( position.y ) >= pageSize.height );
61 } // namespace ScrollViewHelperFunctions
63 } // namespace Internal
65 } // namespace Toolkit