1 #ifndef __DALI_TOOLKIT_SCROLL_CONNECTOR_H__
2 #define __DALI_TOOLKIT_SCROLL_CONNECTOR_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/object/handle.h>
30 namespace Internal DALI_INTERNAL
32 class ScrollConnector;
36 * ScrollConnector is used to connect scrollable containers with components such as scroll bars, indicators etc.
38 * This basically consists of:
39 * - A "scroll-position" property which controls which part of the scrollable content is visible
40 * - The minimum/maximum limits of the scroll position, which corresponds to the start & end points of the scollable list etc.
41 * - An "overshoot" property which shows any attempts to exceed the start & end points.
42 * - The scrollable content size, which corresponds to the length of the scrollable content in the scrollable container in actor coordinates.
44 * The provider of the scrollable content is responsible for calling SetScrollDomain(). Scroll-bar components are then expected to
45 * receive these values via the DOMAIN_CHANGED signal.
47 * The scroll-position property is accessible via GetScrollPositionObject(). This is intended to be shared by multiple controls
48 * e.g. a list control may be scrolled by panning the list content, or indirectly by dragging a connected scroll-bar control.
50 * The overshoot property is intended for implementing 'end of list' style indicators. This property is expected to be in the range
51 * -1 to 1, where -1 shows an attempt the scroll beyond the minimum limit, and 1 shows an attempt the scroll beyond the maximum limit.
52 * Zero indicates normal scrolling i.e. when overshoot indicators should be hidden.
55 * | %Signal Name | Method |
56 * |-------------------------|------------------------------------|
57 * | domain-changed | @ref DomainChangedSignal() |
58 * | scroll-position-changed | @ref ScrollPositionChangedSignal() |
60 class DALI_IMPORT_API ScrollConnector : public BaseHandle
64 static const char* const SCROLL_POSITION_PROPERTY_NAME; ///< This float "scroll-position" property is available via GetScrollPositionObject()
65 static const char* const OVERSHOOT_PROPERTY_NAME; ///< This float "overshoot" property is available via GetScrollPositionObject()
67 static const Property::Index SCROLL_POSITION; ///< The index of the "scroll-position" property
68 static const Property::Index OVERSHOOT; ///< The index of the "overshoot" property
71 typedef Signal< void ( float min, float max, float size ) > DomainChangedSignalType;
72 typedef Signal< void ( float position ) > ScrollPositionChangedSignalType;
75 * Create a ScrollConnector.
76 * @return A handle to a newly allocated ScrollConnector.
78 static ScrollConnector New();
81 * Create an empty handle.
87 * @param handle A handle to copy.
89 ScrollConnector( const ScrollConnector& handle );
92 * @copydoc Dali::BaseHandle::operator=
94 using Dali::BaseHandle::operator=;
99 * This is non-virtual since derived Handle types must not contain data or virtual methods.
104 * @brief Downcast a BaseHandle to ScrollConnector handle.
105 * @return A handle to a ScrollConnector or an empty handle.
107 static ScrollConnector DownCast( BaseHandle handle );
110 * @brief Set the scroll domain, corresponding to the start & end position, and size of the scrollable content in actor coordinates.
111 * @param[in] min The minimum scroll position limit.
112 * @param[in] max The maximum scroll position limit.
113 * @param[in] length The length of the scrollable content in actor coordinates.
115 void SetScrollDomain( float min, float max, float length );
118 * @brief Retrieve the min limit.
119 * @return The minimum value.
121 float GetMinLimit() const;
124 * @brief Retrieve the max limit.
125 * @return The maximum value.
127 float GetMaxLimit() const;
130 * @brief Retrieve the length of the scrollable content in actor coordinates.
131 * @return The length of the scrollable content.
133 float GetContentLength() const;
136 * @brief Set the scroll position.
138 * This will set the "scroll-position" property and emit the ScrollPositionChanged signal.
140 * @param[in] position The scroll position.
142 void SetScrollPosition( float position );
145 * @brief Retrieve the scroll position.
146 * @return The scroll position.
148 float GetScrollPosition() const;
151 * @brief Signal emitted after the SetScrollPosition() method has been called.
153 ScrollConnector::ScrollPositionChangedSignalType& ScrollPositionChangedSignal();
156 * @brief Signal emitted after the SetScrollDomain() method has been called.
158 ScrollConnector::DomainChangedSignalType& DomainChangedSignal();
161 * @brief Retrieve the object which provides the "scroll-position" property.
162 * @return The scroll-position object.
164 Handle GetScrollPositionObject() const;
166 public: // Not intended for application developers
169 * Creates a handle using the Toolkit::Internal implementation.
170 * @param[in] impl The Control implementation.
172 explicit DALI_INTERNAL ScrollConnector( Internal::ScrollConnector* impl );
175 } // namespace Toolkit
179 #endif // __DALI_TOOLKIT_SCROLL_CONNECTOR_H__