From f77f0cb417df66a09f468c974e14b881142cf15b Mon Sep 17 00:00:00 2001 From: Paul Wisbey Date: Wed, 9 Apr 2014 16:46:49 +0100 Subject: [PATCH] Remove the dependency between ScrollBar & ItemView [Issue#] N/A [Problem] ItemView only works with one type of scroll bar i.e. Toolkit::ScrollBar [Cause] Direct dependency from ItemView to ScrollBar [Solution] Use the ScrollComponent interface instead. The idea is that custom scroll components can be implemented and connected without changing ItemView Change-Id: Ie059b6453f38b7a2baccd7ced135b1a49fc6ab88 Signed-off-by: Paul Wisbey --- dali-toolkit/dali-toolkit.h | 3 +- .../controls/scroll-bar/scroll-bar-impl.cpp | 21 ++-- .../internal/controls/scroll-bar/scroll-bar-impl.h | 9 +- .../scroll-component/scroll-bar-internal-impl.h | 5 +- .../scroll-component/scroll-bar-internal.h | 2 +- .../scroll-component/scroll-component-impl.cpp | 82 --------------- .../scroll-component/scroll-component-impl.h | 112 -------------------- .../scrollable/item-view/item-view-impl.cpp | 7 +- .../scrollable/scroll-view/scroll-view-impl.cpp | 4 +- .../controls/scrollable/scrollable-impl.cpp | 32 +++++- .../internal/controls/scrollable/scrollable-impl.h | 10 +- dali-toolkit/internal/file.list | 2 - .../public-api/controls/scroll-bar/scroll-bar.cpp | 11 +- .../public-api/controls/scroll-bar/scroll-bar.h | 13 +-- .../controls/scrollable/scroll-component-impl.cpp | 72 +++++++++++++ .../controls/scrollable/scroll-component-impl.h | 114 +++++++++++++++++++++ .../controls/scrollable}/scroll-component.cpp | 39 ++++--- .../controls/scrollable}/scroll-component.h | 31 ++++-- dali-toolkit/public-api/file.list | 8 +- 19 files changed, 305 insertions(+), 272 deletions(-) delete mode 100644 dali-toolkit/internal/controls/scroll-component/scroll-component-impl.cpp delete mode 100644 dali-toolkit/internal/controls/scroll-component/scroll-component-impl.h create mode 100644 dali-toolkit/public-api/controls/scrollable/scroll-component-impl.cpp create mode 100644 dali-toolkit/public-api/controls/scrollable/scroll-component-impl.h rename dali-toolkit/{internal/controls/scroll-component => public-api/controls/scrollable}/scroll-component.cpp (53%) rename dali-toolkit/{internal/controls/scroll-component => public-api/controls/scrollable}/scroll-component.h (74%) diff --git a/dali-toolkit/dali-toolkit.h b/dali-toolkit/dali-toolkit.h index b4f8455..7a7d089 100644 --- a/dali-toolkit/dali-toolkit.h +++ b/dali-toolkit/dali-toolkit.h @@ -39,7 +39,8 @@ #include #include -#include +#include +#include #include #include #include diff --git a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp index f9473b9..7ae50af 100755 --- a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp +++ b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp @@ -126,8 +126,7 @@ TypeRegistration mType( typeid(Toolkit::ScrollBar), typeid(Toolkit::Control), Cr } ScrollBar::ScrollBar() -: ControlImpl(true/*requires touch*/), - mScrollStart(0.0f) +: mScrollStart(0.0f) { } @@ -153,18 +152,22 @@ void ScrollBar::OnInitialize() EnableGestureDetection(Gesture::Type(Gesture::Pan)); } -void ScrollBar::SetScrollConnector( Toolkit::ScrollConnector connector ) +void ScrollBar::OnScrollConnectorSet( Toolkit::ScrollConnector oldConnector ) { - if(mScrollConnector) + if( oldConnector ) { - mScrollConnector.DomainChangedSignal().Disconnect(this, &ScrollBar::OnScrollDomainChanged); + oldConnector.DomainChangedSignal().Disconnect(this, &ScrollBar::OnScrollDomainChanged); + + mScrollPositionObject.Reset(); } - mScrollConnector = connector; - mScrollPositionObject = mScrollConnector.GetScrollPositionObject(); + if( mScrollConnector ) + { + mScrollPositionObject = mScrollConnector.GetScrollPositionObject(); - ApplyConstraints(); - mScrollConnector.DomainChangedSignal().Connect(this, &ScrollBar::OnScrollDomainChanged); + ApplyConstraints(); + mScrollConnector.DomainChangedSignal().Connect(this, &ScrollBar::OnScrollDomainChanged); + } } void ScrollBar::SetBackgroundImage( Image image, const Vector4& border ) diff --git a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h index 1da0474..c938c7e 100755 --- a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h +++ b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h @@ -18,7 +18,7 @@ // // INTERNAL INCLUDES -#include +#include #include #include @@ -39,7 +39,7 @@ typedef IntrusivePtr ScrollBarPtr; * ScrollBar is a UI component that can be added to the scrollable controls * indicating the current scroll position of the scrollable content. */ -class ScrollBar : public ControlImpl +class ScrollBar : public ScrollComponentImpl { public: @@ -64,9 +64,9 @@ public: static Toolkit::ScrollBar New(); /** - * @copydoc Toolkit::ScrollBar::SetScrollConnector() + * @copydoc Toolkit::ScrollComponentImpl::OnScrollConnectorSet() */ - void SetScrollConnector( Toolkit::ScrollConnector connector ); + void OnScrollConnectorSet( Toolkit::ScrollConnector connector ); /** * @copydoc Toolkit::ScrollBar::SetBackgroundImage() @@ -143,7 +143,6 @@ private: private: - Toolkit::ScrollConnector mScrollConnector; ///< Connects scroll bar with the scrollable container. Constrainable mScrollPositionObject; ///< From mScrollConnector ImageActor mBackground; ///< Background image of scroll bar. diff --git a/dali-toolkit/internal/controls/scroll-component/scroll-bar-internal-impl.h b/dali-toolkit/internal/controls/scroll-component/scroll-bar-internal-impl.h index 22e92ff..3e3f20d 100755 --- a/dali-toolkit/internal/controls/scroll-component/scroll-bar-internal-impl.h +++ b/dali-toolkit/internal/controls/scroll-component/scroll-bar-internal-impl.h @@ -18,10 +18,9 @@ // // INTERNAL INCLUDES -#include +#include #include #include -#include namespace Dali { @@ -36,7 +35,7 @@ namespace Internal * ScrollBarInternal is a UI component that can be added to the sides of the ScrollView * indicating the current scroll position within the domain. */ -class ScrollBarInternal : public ScrollComponent +class ScrollBarInternal : public ScrollComponentImpl { public: diff --git a/dali-toolkit/internal/controls/scroll-component/scroll-bar-internal.h b/dali-toolkit/internal/controls/scroll-component/scroll-bar-internal.h index ea98a94..47cf67c 100755 --- a/dali-toolkit/internal/controls/scroll-component/scroll-bar-internal.h +++ b/dali-toolkit/internal/controls/scroll-component/scroll-bar-internal.h @@ -18,7 +18,7 @@ // // INTERNAL INCLUDES -#include +#include #include namespace Dali DALI_IMPORT_API diff --git a/dali-toolkit/internal/controls/scroll-component/scroll-component-impl.cpp b/dali-toolkit/internal/controls/scroll-component/scroll-component-impl.cpp deleted file mode 100644 index 729ee54..0000000 --- a/dali-toolkit/internal/controls/scroll-component/scroll-component-impl.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// -// 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. -// - -// CLASS HEADER -#include -#include - -namespace Dali -{ - -namespace Toolkit -{ - -namespace Internal -{ - -namespace -{ -BaseHandle Create() -{ - // empty handle as we cannot create ScrollComponent - return Toolkit::ScrollComponent::New(); -} - -TypeRegistration mType( typeid(Toolkit::ScrollComponent), typeid(Toolkit::Control), Create ); - -} - -ScrollComponent::ScrollComponent() -: ControlImpl(true/*requires touch*/) -{ - -} - -ScrollComponent::~ScrollComponent() -{ -} - -Toolkit::ScrollComponent ScrollComponent::New(Toolkit::Scrollable& scrollable, Toolkit::Scrollable::ScrollComponentType type) -{ - Toolkit::ScrollComponent instance; - - switch(type) - { - case Toolkit::Scrollable::VerticalScrollBar: - { - instance = static_cast(Toolkit::ScrollBarInternal::New(scrollable, true)); - break; - } - case Toolkit::Scrollable::HorizontalScrollBar: - { - instance = static_cast(Toolkit::ScrollBarInternal::New(scrollable, false)); - break; - } - default: - { - DALI_ASSERT_ALWAYS(true && "Unrecognized component type"); - } - } - - return instance; -} - - -} // namespace Internal - -} // namespace Toolkit - -} // namespace Dali diff --git a/dali-toolkit/internal/controls/scroll-component/scroll-component-impl.h b/dali-toolkit/internal/controls/scroll-component/scroll-component-impl.h deleted file mode 100644 index 2f93012..0000000 --- a/dali-toolkit/internal/controls/scroll-component/scroll-component-impl.h +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef __DALI_TOOLKIT_INTERNAL_SCROLL_COMPONENTS_H__ -#define __DALI_TOOLKIT_INTERNAL_SCROLL_COMPONENTS_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. -// - -// INTERNAL INCLUDES -#include - -#include -#include - -namespace Dali -{ - -namespace Toolkit -{ - -namespace Internal -{ - -class ScrollComponent; - -typedef IntrusivePtr ScrollComponentPtr; - - -/** - * Base class for derived ScrollComponents - * ScrollComponents such as ScrollBarInternal are derived from this class. - * To instantiate these ScrollBarInternals and other derived components. - */ -class ScrollComponent : public ControlImpl -{ -public: - - /** - * Create an initialized ScrollComponent - * @param[in] scrollable reference to ScrollView implementation - * @param[in] type the type of scroll component to create. - * @return A pointer to the created ScrollComponent. - */ - static Toolkit::ScrollComponent New(Toolkit::Scrollable& scrollable, Toolkit::Scrollable::ScrollComponentType type); - - /** - * Called when the scroll component is disconnected from a Scrollable container. - */ - virtual void OnDisconnect() - { - } - -protected: - - /** - * Construct a new ScrollComponent. - */ - ScrollComponent(); - - /** - * A reference counted object may only be deleted by calling Unreference() - */ - virtual ~ScrollComponent(); - -private: - - // Undefined - ScrollComponent(const ScrollComponent&); - - // Undefined - ScrollComponent& operator=(const ScrollComponent& rhs); - -}; - -} // namespace Internal - -// Helpers for public-api forwarding methods - -inline Toolkit::Internal::ScrollComponent& GetImpl(Toolkit::ScrollComponent& scrollComponent) -{ - DALI_ASSERT_ALWAYS(scrollComponent); - - Dali::RefObject& handle = scrollComponent.GetImplementation(); - - return static_cast(handle); -} - -inline const Toolkit::Internal::ScrollComponent& GetImpl(const Toolkit::ScrollComponent& scrollComponent) -{ - DALI_ASSERT_ALWAYS(scrollComponent); - - const Dali::RefObject& handle = scrollComponent.GetImplementation(); - - return static_cast(handle); -} - -} // namespace Toolkit - -} // namespace Dali - -#endif // __DALI_TOOLKIT_INTERNAL_SCROLL_COMPONENTS_H__ diff --git a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp index 289290c..5caa208 100644 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp @@ -23,7 +23,6 @@ // INTERNAL INCLUDES #include #include -#include #include using namespace std; @@ -1055,11 +1054,11 @@ void ItemView::OnChildAdd(Actor& child) if(!mAddingItems) { // We don't want to do this downcast check for any item added by ItemView itself. - Dali::Toolkit::ScrollBar scrollBar = Dali::Toolkit::ScrollBar::DownCast(child); - if(scrollBar) + Dali::Toolkit::ScrollComponent scrollComponent = Dali::Toolkit::ScrollComponent::DownCast(child); + if(scrollComponent) { // Set the scroll connector when scroll bar is being added - scrollBar.SetScrollConnector(mScrollConnector); + scrollComponent.SetScrollConnector(mScrollConnector); } } } diff --git a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp index 1acf2a6..82b647f 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp @@ -17,10 +17,10 @@ // INTERNAL INCLUDES #include -#include #include +#include +#include #include -#include #include // TODO: Change to two class system: diff --git a/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp b/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp index b506dd4..d122835 100644 --- a/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp @@ -109,8 +109,8 @@ void Scrollable::EnableScrollComponent(Toolkit::Scrollable::ScrollComponentType { // Create ScrollComponent Toolkit::Scrollable scrollable = Toolkit::Scrollable::DownCast(Self()); - Toolkit::ScrollComponent scrollComponent = ScrollComponent::New(scrollable, type); - Toolkit::Internal::ScrollComponent& component = static_cast(scrollComponent.GetImplementation()); + Toolkit::ScrollComponent scrollComponent = NewScrollComponent(scrollable, type); + Toolkit::ScrollComponentImpl& component = static_cast(scrollComponent.GetImplementation()); ScrollComponentPtr componentPtr(&component); mComponents[type] = componentPtr; @@ -131,9 +131,6 @@ void Scrollable::DisableScrollComponent(Toolkit::Scrollable::ScrollComponentType { ScrollComponentPtr component = pair->second; - // Disconnect the scroll component first. - component->OnDisconnect(); - // Destroy ScrollComponent. mComponents.erase( type ); } @@ -191,6 +188,31 @@ bool Scrollable::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface return connected; } +Toolkit::ScrollComponent Scrollable::NewScrollComponent(Toolkit::Scrollable& scrollable, Toolkit::Scrollable::ScrollComponentType type) +{ + Toolkit::ScrollComponent instance; + + switch(type) + { + case Toolkit::Scrollable::VerticalScrollBar: + { + instance = static_cast(Toolkit::ScrollBarInternal::New(scrollable, true)); + break; + } + case Toolkit::Scrollable::HorizontalScrollBar: + { + instance = static_cast(Toolkit::ScrollBarInternal::New(scrollable, false)); + break; + } + default: + { + DALI_ASSERT_ALWAYS(true && "Unrecognized component type"); + } + } + + return instance; +} + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/controls/scrollable/scrollable-impl.h b/dali-toolkit/internal/controls/scrollable/scrollable-impl.h index b784c02..72cc47a 100644 --- a/dali-toolkit/internal/controls/scrollable/scrollable-impl.h +++ b/dali-toolkit/internal/controls/scrollable/scrollable-impl.h @@ -22,7 +22,7 @@ #include #include -#include +#include namespace Dali { @@ -181,6 +181,14 @@ private: // Undefined Scrollable& operator=(const Scrollable& rhs); + /** + * Helper to create an initialized ScrollComponent + * @param[in] scrollable reference to ScrollView implementation + * @param[in] type the type of scroll component to create. + * @return A pointer to the created ScrollComponent. + */ + Toolkit::ScrollComponent NewScrollComponent(Toolkit::Scrollable& scrollable, Toolkit::Scrollable::ScrollComponentType type); + protected: Property::Index mPropertyRelativePosition;///< Scroll Relative Position ("scroll-relative-position") [range from 0.0f - 1.0f in each axes] diff --git a/dali-toolkit/internal/file.list b/dali-toolkit/internal/file.list index e190fe4..e0e8ebc 100644 --- a/dali-toolkit/internal/file.list +++ b/dali-toolkit/internal/file.list @@ -34,9 +34,7 @@ toolkit_src_files = \ $(toolkit_src_dir)/controls/popup/popup-style-impl.cpp \ $(toolkit_src_dir)/controls/scroll-bar/scroll-bar-impl.cpp \ $(toolkit_src_dir)/controls/scroll-component/scroll-bar-internal-impl.cpp \ - $(toolkit_src_dir)/controls/scroll-component/scroll-component-impl.cpp \ $(toolkit_src_dir)/controls/scroll-component/scroll-bar-internal.cpp \ - $(toolkit_src_dir)/controls/scroll-component/scroll-component.cpp \ $(toolkit_src_dir)/controls/scrollable/item-view/item-view-impl.cpp \ $(toolkit_src_dir)/controls/scrollable/scrollable-impl.cpp \ $(toolkit_src_dir)/controls/scrollable/scroll-connector-impl.cpp \ diff --git a/dali-toolkit/public-api/controls/scroll-bar/scroll-bar.cpp b/dali-toolkit/public-api/controls/scroll-bar/scroll-bar.cpp index 8f93e2c..b0279de 100755 --- a/dali-toolkit/public-api/controls/scroll-bar/scroll-bar.cpp +++ b/dali-toolkit/public-api/controls/scroll-bar/scroll-bar.cpp @@ -30,18 +30,18 @@ ScrollBar::ScrollBar() } ScrollBar::ScrollBar(Internal::ScrollBar& implementation) -: Control( implementation ) +: ScrollComponent( implementation ) { } ScrollBar::ScrollBar( Dali::Internal::CustomActor* internal ) -: Control( internal ) +: ScrollComponent( internal ) { VerifyCustomActorPointer(internal); } ScrollBar::ScrollBar( const ScrollBar& scrollBar ) -: Control( scrollBar ) +: ScrollComponent( scrollBar ) { } @@ -68,11 +68,6 @@ ScrollBar::~ScrollBar() { } -void ScrollBar::SetScrollConnector( ScrollConnector connector ) -{ - GetImpl(*this).SetScrollConnector(connector); -} - void ScrollBar::SetBackgroundImage( Image image, const Vector4& border ) { GetImpl(*this).SetBackgroundImage(image, border); 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..12aa98b 100755 --- a/dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h +++ b/dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h @@ -19,7 +19,7 @@ // INTERNAL INCLUDES #include -#include +#include namespace Dali DALI_IMPORT_API { @@ -41,7 +41,7 @@ class ScrollBar; * ScrollBar is a UI component that can be added to the scrollable controls * indicating the current scroll position of the scrollable content. */ -class ScrollBar : public Control +class ScrollBar : public ScrollComponent { public: @@ -89,15 +89,6 @@ public: static ScrollBar DownCast( BaseHandle handle ); /** - * @brief Sets the scroll connector for the scroll bar. - * - * @pre The scroll bar actor has been initialised. - * - * @param[in] connector Scroll connector used to connect scrollable container with this ScrollBar - */ - void SetScrollConnector( ScrollConnector connector ); - - /** * @brief Sets the image for the background of scroll indicator. * * @pre The scroll bar actor has been initialised. diff --git a/dali-toolkit/public-api/controls/scrollable/scroll-component-impl.cpp b/dali-toolkit/public-api/controls/scrollable/scroll-component-impl.cpp new file mode 100644 index 0000000..654322d --- /dev/null +++ b/dali-toolkit/public-api/controls/scrollable/scroll-component-impl.cpp @@ -0,0 +1,72 @@ +// +// 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. +// + +// CLASS HEADER +#include + +namespace Dali +{ + +namespace Toolkit +{ + +namespace // unnamed namespace +{ + +BaseHandle Create() +{ + // empty handle as we cannot create ScrollComponent + return BaseHandle(); +} + +TypeRegistration mType( typeid(Toolkit::ScrollComponent), typeid(Toolkit::Control), Create ); + +} // unnamed namespace + +void ScrollComponentImpl::SetScrollConnector( Toolkit::ScrollConnector connector ) +{ + if( mScrollConnector != connector ) + { + Toolkit::ScrollConnector oldConnector = mScrollConnector; + mScrollConnector = connector; + + // Notify derived classes + OnScrollConnectorSet( oldConnector ); + } +} + +Toolkit::ScrollConnector ScrollComponentImpl::GetScrollConnector() const +{ + return mScrollConnector; +} + +ScrollComponentImpl::ScrollComponentImpl() +: ControlImpl(true/*requires touch*/) +{ +} + +ScrollComponentImpl::~ScrollComponentImpl() +{ +} + +void ScrollComponentImpl::OnScrollConnectorSet( Toolkit::ScrollConnector connector ) +{ + // Do nothing (override in derived classes) +} + +} // namespace Toolkit + +} // namespace Dali diff --git a/dali-toolkit/public-api/controls/scrollable/scroll-component-impl.h b/dali-toolkit/public-api/controls/scrollable/scroll-component-impl.h new file mode 100644 index 0000000..1cb2354 --- /dev/null +++ b/dali-toolkit/public-api/controls/scrollable/scroll-component-impl.h @@ -0,0 +1,114 @@ +#ifndef __DALI_TOOLKIT_SCROLL_COMPONENT_IMPL_H__ +#define __DALI_TOOLKIT_SCROLL_COMPONENT_IMPL_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. +// + +// INTERNAL INCLUDES +#include + +#include +#include +#include + +namespace Dali +{ + +namespace Toolkit +{ + +class ScrollComponentImpl; +typedef IntrusivePtr ScrollComponentPtr; + +/** + * Base class for scroll component implementations. + * Scroll-components such as scroll bars, indicators etc. are connected to scrollable containers via ScrollConnector. + */ +class ScrollComponentImpl : public ControlImpl +{ +public: + + /** + * @brief Sets the scroll connector. + * + * @param[in] connector The scroll-connector used to connect with a scrollable container. + */ + void SetScrollConnector( Toolkit::ScrollConnector connector ); + + /** + * @brief Retrieve the scroll connector. + * + * @return The scroll-connector used to connect with a scrollable container. + */ + Toolkit::ScrollConnector GetScrollConnector() const; + +protected: + + /** + * Construct a new ScrollComponentImpl. + */ + ScrollComponentImpl(); + + /** + * A reference counted object may only be deleted by calling Unreference() + */ + virtual ~ScrollComponentImpl(); + + /** + * @brief Called when a scroll component is connected to a scrollable UI control. + * + * @param[in] oldConnector The previous connector, or an empty handle. + */ + virtual void OnScrollConnectorSet( Toolkit::ScrollConnector oldConnector ); + +private: + + // Undefined + ScrollComponentImpl(const ScrollComponentImpl&); + + // Undefined + ScrollComponentImpl& operator=(const ScrollComponentImpl& rhs); + +protected: + + Toolkit::ScrollConnector mScrollConnector; +}; + +// Helpers for public-api forwarding methods + +inline Toolkit::ScrollComponentImpl& GetImpl(Toolkit::ScrollComponent& scrollComponent) +{ + DALI_ASSERT_ALWAYS(scrollComponent); + + Dali::RefObject& handle = scrollComponent.GetImplementation(); + + return static_cast(handle); +} + +inline const Toolkit::ScrollComponentImpl& GetImpl(const Toolkit::ScrollComponent& scrollComponent) +{ + DALI_ASSERT_ALWAYS(scrollComponent); + + const Dali::RefObject& handle = scrollComponent.GetImplementation(); + + return static_cast(handle); +} + +} // namespace Toolkit + +} // namespace Dali + +#endif // __DALI_TOOLKIT_SCROLL_COMPONENT_IMPL_H__ diff --git a/dali-toolkit/internal/controls/scroll-component/scroll-component.cpp b/dali-toolkit/public-api/controls/scrollable/scroll-component.cpp similarity index 53% rename from dali-toolkit/internal/controls/scroll-component/scroll-component.cpp rename to dali-toolkit/public-api/controls/scrollable/scroll-component.cpp index 22e891e..7852f06 100644 --- a/dali-toolkit/internal/controls/scroll-component/scroll-component.cpp +++ b/dali-toolkit/public-api/controls/scrollable/scroll-component.cpp @@ -14,8 +14,11 @@ // limitations under the License. // -#include -#include +// CLASS HEADER +#include + +// INTERNAL INCLUDES +#include namespace Dali { @@ -27,40 +30,50 @@ ScrollComponent::ScrollComponent() { } -ScrollComponent::ScrollComponent(Internal::ScrollComponent& implementation) -: Control(implementation) +ScrollComponent::ScrollComponent( ScrollComponentImpl& implementation ) +: Control( implementation ) { } -ScrollComponent::ScrollComponent( Dali::Internal::CustomActor* internal ) -: Control( internal ) +ScrollComponent::ScrollComponent( Dali::Internal::CustomActor* actor ) +: Control( actor ) { - VerifyCustomActorPointer(internal); + VerifyCustomActorPointer( actor ); } -ScrollComponent::ScrollComponent( const ScrollComponent& scrollComponentNew ) -: Control(scrollComponentNew) +ScrollComponent::ScrollComponent( const ScrollComponent& scrollComponent ) +: Control( scrollComponent ) { } -ScrollComponent& ScrollComponent::operator=( const ScrollComponent& scrollComponentNew ) +ScrollComponent& ScrollComponent::operator=( const ScrollComponent& scrollComponent ) { - if( &scrollComponentNew != this ) + if( &scrollComponent != this ) { - Control::operator=( scrollComponentNew ); + Control::operator=( scrollComponent ); } return *this; } ScrollComponent ScrollComponent::DownCast( BaseHandle handle ) { - return Control::DownCast(handle); + return Control::DownCast(handle); } ScrollComponent::~ScrollComponent() { } +void ScrollComponent::SetScrollConnector( ScrollConnector connector ) +{ + GetImpl(*this).SetScrollConnector(connector); +} + +ScrollConnector ScrollComponent::GetScrollConnector() const +{ + return GetImpl(*this).GetScrollConnector(); +} + } // namespace Toolkit } // namespace Dali diff --git a/dali-toolkit/internal/controls/scroll-component/scroll-component.h b/dali-toolkit/public-api/controls/scrollable/scroll-component.h similarity index 74% rename from dali-toolkit/internal/controls/scroll-component/scroll-component.h rename to dali-toolkit/public-api/controls/scrollable/scroll-component.h index 640200a..ab7d195 100644 --- a/dali-toolkit/internal/controls/scroll-component/scroll-component.h +++ b/dali-toolkit/public-api/controls/scrollable/scroll-component.h @@ -27,15 +27,12 @@ namespace Dali DALI_IMPORT_API namespace Toolkit { -namespace Internal DALI_INTERNAL -{ -class ScrollComponent; -} +class ScrollComponentImpl; +class ScrollConnector; /** - * Base class for derived ScrollComponents - * ScrollComponents such as ScrollBarInternal are derived from this class. - * To instantiate these ScrollBarInternals and other derived components + * Base class for scroll component handles. + * Scroll-components such as scroll bars, indicators etc. are connected to scrollable containers via ScrollConnector. */ class ScrollComponent : public Control { @@ -71,13 +68,27 @@ public: */ static ScrollComponent DownCast( BaseHandle handle ); + /** + * @brief Sets the scroll connector. + * + * @param[in] connector The scroll-connector used to connect with scrollable container. + */ + void SetScrollConnector( ScrollConnector connector ); + + /** + * @brief Retrieve the scroll connector. + * + * @return The scroll-connector used to connect with a scrollable container. + */ + ScrollConnector GetScrollConnector() const; + public: // Not intended for application developers /** - * Creates a handle using the Toolkit::Internal implementation. - * @param[in] implementation The Control implementation. + * Creates a handle using the implementation. + * @param[in] implementation The Control implementation. */ - ScrollComponent( Internal::ScrollComponent& implementation ); + ScrollComponent( ScrollComponentImpl& implementation ); /** * Allows the creation of this Control from an Internal::CustomActor pointer. diff --git a/dali-toolkit/public-api/file.list b/dali-toolkit/public-api/file.list index 7942f20..638fdf2 100755 --- a/dali-toolkit/public-api/file.list +++ b/dali-toolkit/public-api/file.list @@ -36,6 +36,8 @@ public_api_src_files = \ $(public_api_src_dir)/controls/scrollable/item-view/album-layout.cpp \ $(public_api_src_dir)/controls/scrollable/scrollable.cpp \ $(public_api_src_dir)/controls/scrollable/scroll-connector.cpp \ + $(public_api_src_dir)/controls/scrollable/scroll-component-impl.cpp \ + $(public_api_src_dir)/controls/scrollable/scroll-component.cpp \ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view.cpp \ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-constraints.cpp \ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-effect.cpp \ @@ -149,9 +151,9 @@ public_api_page_turn_view_header_files = \ public_api_popup_header_files = -public_api_scroll_component_header_files = - -public_api_scrollable_header_files = +public_api_scrollable_header_files = \ + $(public_api_src_dir)/controls/scrollable/scroll-component-impl.h \ + $(public_api_src_dir)/controls/scrollable/scroll-component.h public_api_scroll_bar_header_files = \ $(public_api_src_dir)/controls/scroll-bar/scroll-bar.h -- 2.7.4