X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=dali-toolkit%2Fpublic-api%2Fcontrols%2Fscroll-bar%2Fscroll-bar.h;h=819d42dc8813a316d1d640362b368dcfb079ca4f;hb=0031ca8312dba666109e4f7fbb62a3a5e288b7c2;hp=5adb04c425a9a643747e7c82950c91806c697653;hpb=818994dc0acac601b0b27c0b715259b504ef4ceb;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h b/dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h index 5adb04c..819d42d 100755 --- a/dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h +++ b/dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h @@ -1,60 +1,112 @@ #ifndef __DALI_TOOLKIT_SCROLL_BAR_H__ #define __DALI_TOOLKIT_SCROLL_BAR_H__ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ // INTERNAL INCLUDES -#include #include -namespace Dali DALI_IMPORT_API +namespace Dali { namespace Toolkit { -// Forward declarations -class ScrollConnector; - namespace Internal DALI_INTERNAL { // Forward declarations class ScrollBar; } +/** + * @addtogroup dali_toolkit_controls_scroll_bar + * @{ + */ /** - * ScrollBar is a UI component that can be added to the scrollable controls - * indicating the current scroll position of the scrollable content. + * ScrollBar is a UI component that can be linked to the scrollable objects + * indicating the current scroll position of the scrollable object. + * + * Signals + * | %Signal Name | Method | + * |-------------------------------|--------------------------------------------| + * | panFinished | @ref PanFinishedSignal() | + * | scrollPositionIntervalReached | @ref ScrollPositionIntervalReachedSignal() | */ -class ScrollBar : public Control +class DALI_IMPORT_API ScrollBar : public Control { public: + // Properties + + /** + * @brief The start and end property ranges for this control. + */ + enum PropertyRange + { + PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, + PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property indices + }; + + /** + * @brief An enumeration of properties belonging to the ScrollBar class. + */ + struct Property + { + enum + { + SCROLL_DIRECTION = PROPERTY_START_INDEX, ///< name "scrollDirection", @see SetScrollDirection(), type std::string + INDICATOR_HEIGHT_POLICY, ///< name "indicatorHeightPolicy", @see SetIndicatorHeightPolicy(), type std::string + INDICATOR_FIXED_HEIGHT, ///< name "indicatorFixedHeight", @see SetIndicatorFixedHeight(), type float + INDICATOR_SHOW_DURATION, ///< name "indicatorShowDuration", @see SetIndicatorShowDuration(), type float + INDICATOR_HIDE_DURATION, ///< name "indicatorHideDuration", @see SetIndicatorHideDuration(), type float + SCROLL_POSITION_INTERVALS ///< name "scrollPositionIntervals", @see SetScrollPositionIntervals() type Property::Array + }; + }; + // Signals - static const char* const SCROLL_POSITION_NOTIFIED_SIGNAL_NAME; ///< "scroll-position-notified" signal name - typedef SignalV2< void ( float ) > ScrollPositionNotifiedSignalType; + + typedef Signal< void () > PanFinishedSignalType; + typedef Signal< void ( float ) > ScrollPositionIntervalReachedSignalType; public: /** + * @brief Direction. + */ + enum Direction + { + Vertical = 0, ///< Scroll in the vertical direction + Horizontal ///< Scroll in the horizontal direction + }; + + /** + * @brief Indicator height policy. + */ + enum IndicatorHeightPolicy + { + Variable = 0, ///< Variable height changed dynamically according to the length of scroll content + Fixed ///< Fixed height regardless of the length of scroll content + }; + + /** * @brief Create an uninitialized ScrollBar; this can be initialized with ScrollBar::New() * Calling member functions with an uninitialized Dali::Object is not allowed. - * or horizontally (false) */ ScrollBar(); @@ -69,16 +121,18 @@ public: ScrollBar& operator=( const ScrollBar& scrollBar ); /** - * @brief Virtual destructor. - * Dali::Object derived classes typically do not contain member data. + * @brief Destructor + * + * This is non-virtual since derived Handle types must not contain data or virtual methods. */ - virtual ~ScrollBar(); + ~ScrollBar(); /** * @brief Create an initialized ScrollBar + * @param[in] direction The direction of scroll bar (either vertically or horizontally). * @return A pointer to the created ScrollBar. */ - static ScrollBar New(); + static ScrollBar New(Direction direction = Vertical); /** * @brief Downcast an Object handle to ScrollBar. If handle points to a ScrollBar the @@ -89,73 +143,165 @@ public: static ScrollBar DownCast( BaseHandle handle ); /** - * @brief Sets the scroll connector for the scroll bar. + * @brief Set the source of the scroll position properties. + * + * * @pre The handle to the object owing the scroll properties has been initialised and the property index must be vaild. + * + * @param[in] handle The handle of the object owing the scroll properties. + * @param[in] propertyScrollPosition The index of the scroll position property (The scroll position, type float). + * @param[in] propertyMinScrollPosition The index of the minimum scroll position property (The minimum scroll position, type float). + * @param[in] propertyMaxScrollPosition The index of the maximum scroll position property (The maximum scroll position, type float). + * @param[in] propertyScrollContentSize The index of the scroll content size property (The size of the scrollable content in actor coordinates, type float). + */ + void SetScrollPropertySource( Handle handle, Dali::Property::Index propertyScrollPosition, Dali::Property::Index propertyMinScrollPosition, Dali::Property::Index propertyMaxScrollPosition, Dali::Property::Index propertyScrollContentSize ); + + /** + * @brief Sets the indicator of scroll bar. * * @pre The scroll bar actor has been initialised. * - * @param[in] connector Scroll connector used to connect scrollable container with this ScrollBar + * @param[in] indicator The indicator that moves to indicate the current scroll position. */ - void SetScrollConnector( ScrollConnector connector ); + void SetScrollIndicator( Actor indicator ); /** - * @brief Sets the image for the background of scroll indicator. + * @brief Gets the indicator of scroll bar. * * @pre The scroll bar actor has been initialised. * - * The background image is resized (stretched according to scale settings), - * to the size of the ScrollBar. + * @return The indicator indicates the current scroll position of the scrollable content. + */ + Actor GetScrollIndicator(); + + /** + * @brief Sets the list of values to get notification when the current scroll position of the scrollable + * object goes above or below any of these values. + * + * @pre The scroll bar actor has been initialised. * - * @param[in] image The image to cover background - * @param[in] border The nine patch border for the image. + * @param[in] positions List of values to receive notifications for when the current scroll position crosses them */ - void SetBackgroundImage( Image image, const Vector4& border ); + void SetScrollPositionIntervals( const Dali::Vector& positions ); /** - * @brief Sets the image for the indicator of scroll bar. + * @brief Gets the list of values to receive notifications when the current scroll position of the scrollable + * object goes above or below any of these values. * * @pre The scroll bar actor has been initialised. * - * The indicator image is resized (stretched according to scale settings), - * to reflect the size of the scroll indicator and minimum/maximum limits - * of the scroll position. + * @return The list of values to receive notifications for when the current scroll position crosses them + */ + Dali::Vector GetScrollPositionIntervals() const; + + /** + * @brief Sets the direction of scroll bar to scroll either vertically or horizontally. + * + * @pre The scroll bar actor has been initialised. * - * @param[in] image The image of indicator that moves to indicate the current scroll position. - * @param[in] border The nine patch border for the image. + * @param[in] direction The direction of scroll bar (either vertically or horizontally). */ - void SetIndicatorImage( Image image, const Vector4& border ); + void SetScrollDirection( Direction direction ); /** - * @brief Gets the indicator of scroll bar. + * @brief Gets the direction of scroll bar. + * + * @return The direction of scroll bar. + */ + Direction GetScrollDirection() const; + + /** + * @brief Sets the height policy of scroll indicator to have either variable or fixed height. * * @pre The scroll bar actor has been initialised. * - * The indicator indicates the current scroll position of the scrollable content. + * @param[in] policy The height policy of scroll indicator */ - Actor GetScrollIndicator(); + void SetIndicatorHeightPolicy( IndicatorHeightPolicy policy ); + + /** + * @brief Gets the height policy of scroll indicator. + * + * @return The height policy of scroll indicator + */ + IndicatorHeightPolicy GetIndicatorHeightPolicy() const; /** - * @brief Sets the values to get notification when the current scroll position of the scrollable - * content goes above or below any of these values. + * @brief Sets the fixed height of scroll indicator. + * Normally the height of scroll indicator is changed dynamically according to the length of scroll content. + * However, when the height policy of scroll indicator is set to be fixed, the height will keep fixed + * regardless of the length of scroll content. * * @pre The scroll bar actor has been initialised. * - * @param[in] positions List of values to receive notifications for when the current scroll position crosses them + * @param[in] height The fixed height of the scroll indicator + */ + void SetIndicatorFixedHeight( float height ); + + /** + * @brief Gets the fix height of scroll indicator. + * @return The fixed height of the scroll indicator + */ + float GetIndicatorFixedHeight() const; + + /** + * @brief Sets the duration in second for the scroll indicator to become fully visible + * + * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be shown instantly. + * + * @param[in] durationSeconds The duration for the scroll indicator to become fully visible + */ + void SetIndicatorShowDuration( float durationSeconds ); + + /** + * @brief Gets the duration in second for the scroll indicator to become fully visible + * @return The duration for the scroll indicator to become fully visible + */ + float GetIndicatorShowDuration() const; + + /** + * @brief Sets the duration in second for the scroll indicator to become fully invisible + * + * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be hidden instantly. + * + * @param[in] durationSeconds The duration for the scroll indicator to become fully invisible + */ + void SetIndicatorHideDuration( float durationSeconds ); + + /** + * @brief Gets the duration in second for the scroll indicator to become fully invisible + * @return The duration for the scroll indicator to become fully invisible */ - void SetPositionNotifications( const std::vector& positions ); + float GetIndicatorHideDuration() const; /** * @brief Shows the scroll indicator */ - void Show(); + void ShowIndicator(); /** * @brief Hides the scroll indicator */ - void Hide(); + void HideIndicator(); + +public: // Signals /** - * @brief Signal emitted when the current scroll position of the scrollable content goes above or below the values - * specified by SetPositionNotifications. + * @brief Signal emitted when panning is finished on the scroll indicator. + * Signal only emitted when the source of the scroll position properties are set. + * + * A callback of the following type may be connected: + * @code + * void YourCallbackName(); + * @endcode + * @pre The Object has been initialized. + * @return The signal to connect to. + */ + ScrollBar::PanFinishedSignalType& PanFinishedSignal(); + + /** + * @brief Signal emitted when the current scroll position of the scrollable content + * goes above or below the values specified by SCROLL_POSITION_INTERVALS property. + * Signal only emitted when the source of the scroll position properties are set. * * A callback of the following type may be connected: * @code @@ -164,7 +310,7 @@ public: * @pre The Object has been initialized. * @return The signal to connect to. */ - ScrollBar::ScrollPositionNotifiedSignalType& ScrollPositionNotifiedSignal(); + ScrollBar::ScrollPositionIntervalReachedSignalType& ScrollPositionIntervalReachedSignal(); public: // Not intended for application developers @@ -172,20 +318,20 @@ public: // Not intended for application developers * Creates a handle using the Toolkit::Internal implementation. * @param[in] implementation The Control implementation. */ - ScrollBar( Internal::ScrollBar& implementation ); + DALI_INTERNAL ScrollBar( Internal::ScrollBar& implementation ); /** * Allows the creation of this Control from an Internal::CustomActor pointer. * @param[in] internal A pointer to the internal CustomActor. */ - ScrollBar( Dali::Internal::CustomActor* internal ); + explicit DALI_INTERNAL ScrollBar( Dali::Internal::CustomActor* internal ); }; +/** + * @} + */ } // namespace Toolkit } // namespace Dali -/** - * @} - */ #endif // __DALI_TOOLKIT_SCROLL_BAR_H__