From 9e1677a45c8648371f0274d9697748800a656095 Mon Sep 17 00:00:00 2001
From: Paul Wisbey
Date: Tue, 11 Mar 2014 18:15:39 +0000
Subject: [PATCH] Provide object to connect scrollable containers & scroll-bars
etc.
[Issue#] N/A
[Problem] ItemView does too much
[Cause] Scroll-bars etc. implemented inside of ItemView
[Solution] Provide an object to connect scrollable containers to scroll
components. The scroll-bar should not know anything about ItemView and
vice versa.
Change-Id: Ibe7b2e9c03f0f31b656b712837a861d8eeffc954
Signed-off-by: Paul Wisbey
---
.../controls/scrollable/item-view/item-view.h | 7 ++
.../scrollable/item-view/item-view-impl.cpp | 63 ++++++----
.../controls/scrollable/item-view/item-view-impl.h | 10 +-
.../controls/scrollable/scroll-connector-impl.cpp | 64 ++++++++++
.../controls/scrollable/scroll-connector-impl.h | 139 +++++++++++++++++++++
dali-toolkit/internal/file.list | 1 +
.../controls/scrollable/item-view/item-view.cpp | 5 +
.../controls/scrollable/scroll-connector.cpp | 88 +++++++++++++
.../controls/scrollable/scroll-connector.h | 134 ++++++++++++++++++++
dali-toolkit/public-api/file.list | 4 +-
10 files changed, 486 insertions(+), 29 deletions(-)
create mode 100644 dali-toolkit/internal/controls/scrollable/scroll-connector-impl.cpp
create mode 100644 dali-toolkit/internal/controls/scrollable/scroll-connector-impl.h
create mode 100644 dali-toolkit/public-api/controls/scrollable/scroll-connector.cpp
create mode 100644 dali-toolkit/public-api/controls/scrollable/scroll-connector.h
diff --git a/capi/dali-toolkit/public-api/controls/scrollable/item-view/item-view.h b/capi/dali-toolkit/public-api/controls/scrollable/item-view/item-view.h
index 8ea9690..fc24681 100644
--- a/capi/dali-toolkit/public-api/controls/scrollable/item-view/item-view.h
+++ b/capi/dali-toolkit/public-api/controls/scrollable/item-view/item-view.h
@@ -38,6 +38,7 @@ namespace Internal DALI_INTERNAL
class ItemView;
}
+class ScrollConnector;
class ItemFactory;
class ItemLayout;
@@ -90,6 +91,12 @@ public:
static ItemView DownCast( BaseHandle handle );
/**
+ * Retrieve a scroll-connector; this can be used to connect scroll components e.g. scroll bars.
+ * @return The connector.
+ */
+ ScrollConnector GetScrollConnector() const;
+
+ /**
* Query the number of layouts.
* @return The number of layouts.
*/
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 a0d3be3..acb74dc 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,6 +23,7 @@
// INTERNAL INCLUDES
#include
#include
+#include
using namespace std;
using namespace Dali;
@@ -516,7 +517,9 @@ void ItemView::OnInitialize()
mOvershootOverlay.SetPixelArea(OVERSHOOT_BOUNCE_IMAGE_1_PIXEL_AREA);
self.Add(mOvershootOverlay);
- mPropertyLayoutPosition = self.RegisterProperty(LAYOUT_POSITION_PROPERTY_NAME, 0.0f);
+ mScrollConnector = Dali::Toolkit::ScrollConnector::New();
+ mScrollPositionObject = mScrollConnector.GetScrollPositionObject();
+
mPropertyMinimumLayoutPosition = self.RegisterProperty(MINIMUM_LAYOUT_POSITION_PROPERTY_NAME, 0.0f);
mPropertyPosition = self.RegisterProperty(POSITION_PROPERTY_NAME, 0.0f);
mPropertyScrollSpeed = self.RegisterProperty(SCROLL_SPEED_PROPERTY_NAME, 0.0f);
@@ -545,6 +548,11 @@ ItemView::~ItemView()
{
}
+Dali::Toolkit::ScrollConnector ItemView::GetScrollConnector() const
+{
+ return mScrollConnector;
+}
+
unsigned int ItemView::GetLayoutCount() const
{
return mLayouts.size();
@@ -579,7 +587,7 @@ ItemLayoutPtr ItemView::GetActiveLayout() const
float ItemView::GetCurrentLayoutPosition(unsigned int itemId) const
{
- return Self().GetProperty(mPropertyLayoutPosition) + static_cast(itemId);
+ return mScrollPositionObject.GetProperty( ScrollConnector::SCROLL_POSITION ) + static_cast( itemId );
}
void ItemView::ActivateLayout(unsigned int layoutIndex, const Vector3& targetSize, float durationSeconds)
@@ -657,7 +665,7 @@ void ItemView::ActivateLayout(unsigned int layoutIndex, const Vector3& targetSiz
bool scrollAnimationNeeded(false);
float firstItemScrollPosition(0.0f);
- float current = self.GetProperty(mPropertyLayoutPosition);
+ float current = GetCurrentLayoutPosition(0);
float minimum = ClampFirstItemPosition(current, targetSize, *mActiveLayout);
self.SetProperty(mPropertyPosition, GetScrollPosition(current, targetSize));
@@ -676,7 +684,7 @@ void ItemView::ActivateLayout(unsigned int layoutIndex, const Vector3& targetSiz
{
RemoveAnimation(mScrollAnimation);
mScrollAnimation = Animation::New(mAnchoringDuration);
- mScrollAnimation.AnimateTo( Property(self, mPropertyLayoutPosition), firstItemScrollPosition, AlphaFunctions::EaseOut );
+ mScrollAnimation.AnimateTo( Property( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ), firstItemScrollPosition, AlphaFunctions::EaseOut );
mScrollAnimation.AnimateTo( Property(self, mPropertyPosition), GetScrollPosition(firstItemScrollPosition, targetSize), AlphaFunctions::EaseOut );
mScrollAnimation.Play();
}
@@ -884,7 +892,7 @@ ItemRange ItemView::GetItemRange(ItemLayout& layout, const Vector3& layoutSize,
ItemRange available(0u, itemCount);
- ItemRange range = layout.GetItemsWithinArea(Self().GetProperty(mPropertyLayoutPosition), layoutSize);
+ ItemRange range = layout.GetItemsWithinArea( GetCurrentLayoutPosition(0), layoutSize );
if (reserveExtra)
{
@@ -932,9 +940,10 @@ bool ItemView::OnMouseWheelEvent(const MouseWheelEvent& event)
{
Actor self = Self();
const Vector3 layoutSize = Self().GetCurrentSize();
- float layoutPositionDelta = self.GetProperty(mPropertyLayoutPosition) + (event.z * mMouseWheelScrollDistanceStep * mActiveLayout->GetScrollSpeedFactor());
+ float layoutPositionDelta = GetCurrentLayoutPosition(0) + (event.z * mMouseWheelScrollDistanceStep * mActiveLayout->GetScrollSpeedFactor());
float firstItemScrollPosition = ClampFirstItemPosition(layoutPositionDelta, layoutSize, *mActiveLayout);
- self.SetProperty(mPropertyLayoutPosition, firstItemScrollPosition);
+
+ mScrollPositionObject.SetProperty( ScrollConnector::SCROLL_POSITION, firstItemScrollPosition );
self.SetProperty(mPropertyPosition, GetScrollPosition(firstItemScrollPosition, layoutSize));
mScrollStartedSignalV2.Emit(GetCurrentScrollPosition());
StartRefreshTimer();
@@ -985,7 +994,7 @@ void ItemView::ApplyConstraints(Actor& actor, ItemLayout& layout, unsigned int i
WrappedVector3Constraint wrapped(positionConstraint, itemId);
Constraint constraint = Constraint::New( Actor::POSITION,
- ParentSource( mPropertyLayoutPosition ),
+ Source( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ),
ParentSource( mPropertyScrollSpeed ),
ParentSource( Actor::SIZE ),
wrapped );
@@ -1000,7 +1009,7 @@ void ItemView::ApplyConstraints(Actor& actor, ItemLayout& layout, unsigned int i
WrappedQuaternionConstraint wrapped(rotationConstraint, itemId);
Constraint constraint = Constraint::New( Actor::ROTATION,
- ParentSource( mPropertyLayoutPosition ),
+ Source( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ),
ParentSource( mPropertyScrollSpeed ),
ParentSource( Actor::SIZE ),
wrapped );
@@ -1015,7 +1024,7 @@ void ItemView::ApplyConstraints(Actor& actor, ItemLayout& layout, unsigned int i
WrappedVector3Constraint wrapped(scaleConstraint, itemId);
Constraint constraint = Constraint::New( Actor::SCALE,
- ParentSource( mPropertyLayoutPosition ),
+ Source( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ),
ParentSource( mPropertyScrollSpeed ),
ParentSource( Actor::SIZE ),
wrapped );
@@ -1030,7 +1039,7 @@ void ItemView::ApplyConstraints(Actor& actor, ItemLayout& layout, unsigned int i
WrappedVector4Constraint wrapped(colorConstraint, itemId);
Constraint constraint = Constraint::New( Actor::COLOR,
- ParentSource( mPropertyLayoutPosition ),
+ Source( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ),
ParentSource( mPropertyScrollSpeed ),
ParentSource( Actor::SIZE ),
wrapped );
@@ -1049,7 +1058,7 @@ void ItemView::ApplyConstraints(Actor& actor, ItemLayout& layout, unsigned int i
WrappedBoolConstraint wrapped(visibilityConstraint, itemId);
Constraint constraint = Constraint::New( Actor::VISIBLE,
- ParentSource( mPropertyLayoutPosition ),
+ Source( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ),
ParentSource( mPropertyScrollSpeed ),
ParentSource( Actor::SIZE ),
wrapped );
@@ -1102,7 +1111,7 @@ void ItemView::OnPan(PanGesture gesture)
mRefreshOrderHint = true;
- float currentLayoutPosition = self.GetProperty(mPropertyLayoutPosition);
+ float currentLayoutPosition = GetCurrentLayoutPosition(0);
float firstItemScrollPosition = ClampFirstItemPosition(currentLayoutPosition + mScrollSpeed * direction,
layoutSize,
*mActiveLayout);
@@ -1116,7 +1125,7 @@ void ItemView::OnPan(PanGesture gesture)
float flickAnimationDuration = mActiveLayout->GetItemFlickAnimationDuration() * max(1.0f, fabsf(firstItemScrollPosition - GetCurrentLayoutPosition(0)));
mScrollAnimation = Animation::New(flickAnimationDuration);
- mScrollAnimation.AnimateTo( Property(self, mPropertyLayoutPosition), firstItemScrollPosition, AlphaFunctions::EaseOut );
+ mScrollAnimation.AnimateTo( Property( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ), firstItemScrollPosition, AlphaFunctions::EaseOut );
mScrollAnimation.AnimateTo( Property(self, mPropertyPosition), GetScrollPosition(firstItemScrollPosition, layoutSize), AlphaFunctions::EaseOut );
mScrollAnimation.AnimateTo( Property(self, mPropertyScrollSpeed), 0.0f, AlphaFunctions::EaseOut );
@@ -1162,11 +1171,11 @@ void ItemView::OnPan(PanGesture gesture)
mScrollSpeedAnimation.AnimateTo( Property(self, mPropertyScrollSpeed), mScrollSpeed, AlphaFunctions::Linear );
mScrollSpeedAnimation.Play();
- float layoutPositionDelta = self.GetProperty(mPropertyLayoutPosition) + (mScrollDistance * mActiveLayout->GetScrollSpeedFactor());
+ float layoutPositionDelta = GetCurrentLayoutPosition(0) + (mScrollDistance * mActiveLayout->GetScrollSpeedFactor());
float firstItemScrollPosition = ClampFirstItemPosition(layoutPositionDelta, layoutSize, *mActiveLayout);
- self.SetProperty(mPropertyLayoutPosition, firstItemScrollPosition);
+ mScrollPositionObject.SetProperty( ScrollConnector::SCROLL_POSITION, firstItemScrollPosition );
self.SetProperty(mPropertyPosition, GetScrollPosition(firstItemScrollPosition, layoutSize));
mScrollStartedSignalV2.Emit(GetCurrentScrollPosition());
@@ -1236,7 +1245,7 @@ Actor ItemView::GetNextKeyboardFocusableActor(Actor actor, Control::KeyboardFocu
return nextFocusActor;
}
}
- float layoutPosition = mActiveLayout->GetClosestAnchorPosition(Self().GetProperty(mPropertyLayoutPosition));
+ float layoutPosition = mActiveLayout->GetClosestAnchorPosition( GetCurrentLayoutPosition(0) );
Vector3 layoutSize = Self().GetCurrentSize();
if(!nextFocusActor)
{
@@ -1255,7 +1264,7 @@ void ItemView::OnKeyboardFocusChangeCommitted(Actor commitedFocusableActor)
if(commitedFocusableActor)
{
int nextItemID = GetItemId(commitedFocusableActor);
- float layoutPosition = Self().GetProperty(mPropertyLayoutPosition);
+ float layoutPosition = GetCurrentLayoutPosition(0);
Vector3 layoutSize = Self().GetCurrentSize();
Vector3 focusItemPosition = Vector3::ZERO;
ItemLayout::Vector3Function itemPositionConstraint;
@@ -1276,10 +1285,10 @@ Animation ItemView::DoAnchoring()
if (mActiveLayout && mAnchoringEnabled)
{
- float anchorPosition = mActiveLayout->GetClosestAnchorPosition(Self().GetProperty(mPropertyLayoutPosition));
+ float anchorPosition = mActiveLayout->GetClosestAnchorPosition( GetCurrentLayoutPosition(0) );
anchoringAnimation = Animation::New(mAnchoringDuration);
- anchoringAnimation.AnimateTo( Property(self, mPropertyLayoutPosition), anchorPosition, AlphaFunctions::EaseOut );
+ anchoringAnimation.AnimateTo( Property( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ), anchorPosition, AlphaFunctions::EaseOut );
anchoringAnimation.AnimateTo( Property(self, mPropertyPosition), GetScrollPosition(anchorPosition, self.GetCurrentSize()), AlphaFunctions::EaseOut );
anchoringAnimation.AnimateTo( Property(self, mPropertyScrollSpeed), 0.0f, AlphaFunctions::EaseOut );
if(!mIsFlicking)
@@ -1358,14 +1367,14 @@ void ItemView::ScrollToItem(unsigned int itemId, float durationSeconds)
{
RemoveAnimation(mScrollAnimation);
mScrollAnimation = Animation::New(durationSeconds);
- mScrollAnimation.AnimateTo( Property(self, mPropertyLayoutPosition), firstItemScrollPosition, AlphaFunctions::EaseOut );
+ mScrollAnimation.AnimateTo( Property( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ), firstItemScrollPosition, AlphaFunctions::EaseOut );
mScrollAnimation.AnimateTo( Property(self, mPropertyPosition), GetScrollPosition(firstItemScrollPosition, layoutSize), AlphaFunctions::EaseOut );
mScrollAnimation.FinishedSignal().Connect(this, &ItemView::OnScrollFinished);
mScrollAnimation.Play();
}
else
{
- self.SetProperty(mPropertyLayoutPosition, firstItemScrollPosition);
+ mScrollPositionObject.SetProperty( ScrollConnector::SCROLL_POSITION, firstItemScrollPosition );
AnimateScrollOvershoot(0.0f);
}
@@ -1435,7 +1444,7 @@ bool ItemView::IsLayoutScrollable(const Vector3& layoutSize)
{
Actor self = Self();
- float currentLayoutPosition = ClampFirstItemPosition(self.GetProperty(mPropertyLayoutPosition), layoutSize, *mActiveLayout);
+ float currentLayoutPosition = ClampFirstItemPosition( GetCurrentLayoutPosition(0), layoutSize, *mActiveLayout );
float forwardClampedPosition = ClampFirstItemPosition(currentLayoutPosition + 1.0, layoutSize, *mActiveLayout);
float backwardClampedPosition = ClampFirstItemPosition(currentLayoutPosition - 1.0, layoutSize, *mActiveLayout);
@@ -1456,7 +1465,7 @@ float ItemView::GetScrollPosition(float layoutPosition, const Vector3& layoutSiz
Vector3 ItemView::GetCurrentScrollPosition() const
{
- float currentLayoutPosition = Self().GetProperty(mPropertyLayoutPosition);
+ float currentLayoutPosition = GetCurrentLayoutPosition(0);
return Vector3(0.0f, GetScrollPosition(currentLayoutPosition, Self().GetCurrentSize()), 0.0f);
}
@@ -1483,14 +1492,14 @@ void ItemView::ScrollTo(const Vector3& position, float duration)
{
RemoveAnimation(mScrollAnimation);
mScrollAnimation = Animation::New(duration);
- mScrollAnimation.AnimateTo( Property(self, mPropertyLayoutPosition), firstItemScrollPosition, AlphaFunctions::EaseOut );
+ mScrollAnimation.AnimateTo( Property( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ), firstItemScrollPosition, AlphaFunctions::EaseOut );
mScrollAnimation.AnimateTo( Property(self, mPropertyPosition), GetScrollPosition(firstItemScrollPosition, layoutSize), AlphaFunctions::EaseOut );
mScrollAnimation.FinishedSignal().Connect(this, &ItemView::OnScrollFinished);
mScrollAnimation.Play();
}
else
{
- self.SetProperty(mPropertyLayoutPosition, firstItemScrollPosition);
+ mScrollPositionObject.SetProperty( ScrollConnector::SCROLL_POSITION, firstItemScrollPosition );
AnimateScrollOvershoot(0.0f);
}
@@ -1543,7 +1552,7 @@ float ItemView::CalculateScrollOvershoot()
// since the pan gesture starts.
Actor self = Self();
float scrollDistance = CalculateScrollDistance(mTotalPanDisplacement, *mActiveLayout) * mActiveLayout->GetScrollSpeedFactor();
- float positionDelta = self.GetProperty(mPropertyLayoutPosition) + scrollDistance;
+ float positionDelta = GetCurrentLayoutPosition(0) + scrollDistance;
float minLayoutPosition = mActiveLayout->GetMinimumLayoutPosition(mItemFactory.GetNumberOfItems(), Self().GetCurrentSize());
self.SetProperty(mPropertyMinimumLayoutPosition, minLayoutPosition);
float clamppedPosition = min(0.0f, max(minLayoutPosition, positionDelta));
diff --git a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h
index 00262f2..2012081 100644
--- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h
+++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h
@@ -24,6 +24,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -143,6 +144,11 @@ public:
static Dali::Toolkit::ItemView New(ItemFactory& factory);
/**
+ * @copydoc Toolkit::ItemView::GetScrollConnector
+ */
+ Dali::Toolkit::ScrollConnector GetScrollConnector() const;
+
+ /**
* @copydoc Toolkit::ItemView::GetLayoutCount
*/
unsigned int GetLayoutCount() const;
@@ -559,7 +565,9 @@ private:
ImageActor mOvershootOverlay; ///< The overlay actor for overshoot effect
OvershootRippleEffect mOvershootEffect; ///< The vertex/fragment shader used to display the overshoot ripple effect
- Property::Index mPropertyLayoutPosition; ///< The logical position of the first item within the layout
+ Dali::Toolkit::ScrollConnector mScrollConnector; ///< Connects ItemView with scrollable components e.g. scroll bars
+ Constrainable mScrollPositionObject; ///< From mScrollConnector
+
Property::Index mPropertyPosition; ///< The physical position of the first item within the layout
Property::Index mPropertyMinimumLayoutPosition; ///< The minimum valid layout position in the layout.
Property::Index mPropertyScrollSpeed; ///< The current scroll speed of item view
diff --git a/dali-toolkit/internal/controls/scrollable/scroll-connector-impl.cpp b/dali-toolkit/internal/controls/scrollable/scroll-connector-impl.cpp
new file mode 100644
index 0000000..7983fa5
--- /dev/null
+++ b/dali-toolkit/internal/controls/scrollable/scroll-connector-impl.cpp
@@ -0,0 +1,64 @@
+//
+// 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
+
+// EXTERNAL INCLUDES
+#include
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+const Property::Index ScrollConnector::SCROLL_POSITION = 50000000; // TODO - expose CUSTOM_PROPERTY_START from Core
+
+ScrollConnector* ScrollConnector::New()
+{
+ return new ScrollConnector();
+}
+
+void ScrollConnector::SetLimits( float min, float max )
+{
+ mMinLimit = min;
+ mMaxLimit = max;
+
+ mLimitsChangedSignal.Emit( mMinLimit, mMaxLimit );
+}
+
+ScrollConnector::ScrollConnector()
+: mMinLimit( 0.0f ),
+ mMaxLimit( 0.0f )
+{
+ mScrollPositionObject = Constrainable::New();
+
+ mScrollPositionObject.RegisterProperty( Toolkit::ScrollConnector::SCROLL_POSITION_PROPERTY_NAME, 0.0f );
+}
+
+ScrollConnector::~ScrollConnector()
+{
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/internal/controls/scrollable/scroll-connector-impl.h b/dali-toolkit/internal/controls/scrollable/scroll-connector-impl.h
new file mode 100644
index 0000000..7545fc5
--- /dev/null
+++ b/dali-toolkit/internal/controls/scrollable/scroll-connector-impl.h
@@ -0,0 +1,139 @@
+#ifndef __DALI_TOOLKIT_INTERNAL_SCROLL_CONNECTOR_H__
+#define __DALI_TOOLKIT_INTERNAL_SCROLL_CONNECTOR_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
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+/**
+ * @copydoc Toolkit::ScrollConnector
+ */
+class ScrollConnector : public Dali::BaseObject
+{
+public:
+
+ typedef Toolkit::ScrollConnector::LimitsChangedSignalType LimitsChangedSignalType;
+
+ static const Property::Index SCROLL_POSITION;
+
+ /**
+ * Create a ScrollConnector.
+ * @return A newly allocated ScrollConnector.
+ */
+ static ScrollConnector* New();
+
+ /**
+ * @copydoc Toolkit::ScrollConnector::SetLimits()
+ */
+ void SetLimits( float min, float max );
+
+ /**
+ * @copydoc Toolkit::ScrollConnector::GetMinLimit()
+ */
+ float GetMinLimit() const
+ {
+ return mMinLimit;
+ }
+
+ /**
+ * @copydoc Toolkit::ScrollConnector::GetMaxLimit()
+ */
+ float GetMaxLimit() const
+ {
+ return mMaxLimit;
+ }
+
+ /**
+ * Signal emitted after the SetLimits() method has been called.
+ */
+ LimitsChangedSignalType& LimitsChangedSignal()
+ {
+ return mLimitsChangedSignal;
+ }
+
+ /**
+ * Retrieve the object which provides the "scroll-position" property.
+ * @return The scroll-position object.
+ */
+ Constrainable GetScrollPositionObject() const
+ {
+ return mScrollPositionObject;
+ }
+
+private:
+
+ /**
+ * Create a new ScrollConnector.
+ */
+ ScrollConnector();
+
+ /**
+ * Virtual destructor
+ */
+ virtual ~ScrollConnector();
+
+ // Undefined
+ ScrollConnector(const ScrollConnector&);
+
+ // Undefined
+ ScrollConnector& operator=(const ScrollConnector& rhs);
+
+private:
+
+ Constrainable mScrollPositionObject;
+
+ LimitsChangedSignalType mLimitsChangedSignal;
+
+ float mMinLimit;
+ float mMaxLimit;
+};
+
+} // namespace Internal
+
+inline Internal::ScrollConnector& GetImpl(Dali::Toolkit::ScrollConnector& obj)
+{
+ DALI_ASSERT_ALWAYS(obj);
+
+ Dali::BaseObject& handle = obj.GetBaseObject();
+
+ return static_cast(handle);
+}
+
+inline const Internal::ScrollConnector& GetImpl(const Dali::Toolkit::ScrollConnector& obj)
+{
+ DALI_ASSERT_ALWAYS(obj);
+
+ const Dali::BaseObject& handle = obj.GetBaseObject();
+
+ return static_cast(handle);
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_INTERNAL_SCROLL_CONNECTOR_H__
diff --git a/dali-toolkit/internal/file.list b/dali-toolkit/internal/file.list
index 8ab1395..352076d 100644
--- a/dali-toolkit/internal/file.list
+++ b/dali-toolkit/internal/file.list
@@ -38,6 +38,7 @@ toolkit_src_files = \
$(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 \
$(toolkit_src_dir)/controls/scrollable/scroll-view/scroll-base-impl.cpp \
$(toolkit_src_dir)/controls/scrollable/scroll-view/scroll-overshoot-indicator-impl.cpp \
$(toolkit_src_dir)/controls/scrollable/scroll-view/scroll-view-impl.cpp \
diff --git a/dali-toolkit/public-api/controls/scrollable/item-view/item-view.cpp b/dali-toolkit/public-api/controls/scrollable/item-view/item-view.cpp
index ddafb28..c951b0c 100644
--- a/dali-toolkit/public-api/controls/scrollable/item-view/item-view.cpp
+++ b/dali-toolkit/public-api/controls/scrollable/item-view/item-view.cpp
@@ -63,6 +63,11 @@ ItemView ItemView::DownCast( BaseHandle handle )
return Control::DownCast(handle);
}
+ScrollConnector ItemView::GetScrollConnector() const
+{
+ return GetImpl(*this).GetScrollConnector();
+}
+
ItemView::~ItemView()
{
}
diff --git a/dali-toolkit/public-api/controls/scrollable/scroll-connector.cpp b/dali-toolkit/public-api/controls/scrollable/scroll-connector.cpp
new file mode 100644
index 0000000..6a4ee68
--- /dev/null
+++ b/dali-toolkit/public-api/controls/scrollable/scroll-connector.cpp
@@ -0,0 +1,88 @@
+//
+// 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.
+//
+
+#include
+#include
+
+using namespace Dali;
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+const char* const ScrollConnector::SCROLL_POSITION_PROPERTY_NAME = "scroll-position";
+const Property::Index SCROLL_POSITION = Internal::ScrollConnector::SCROLL_POSITION;
+
+const char* const ScrollConnector::LIMITS_CHANGED_SIGNAL_NAME = "limits-changed";
+
+ScrollConnector ScrollConnector::New()
+{
+ return ScrollConnector( Internal::ScrollConnector::New() );
+}
+
+ScrollConnector::ScrollConnector()
+{
+}
+
+ScrollConnector::ScrollConnector( const ScrollConnector& handle )
+: BaseHandle( handle )
+{
+}
+
+ScrollConnector::~ScrollConnector()
+{
+}
+
+ScrollConnector ScrollConnector::DownCast( BaseHandle handle )
+{
+ return ScrollConnector( dynamic_cast(handle.GetObjectPtr()) );
+}
+
+void ScrollConnector::SetLimits( float min, float max )
+{
+ GetImpl(*this).SetLimits( min, max );
+}
+
+float ScrollConnector::GetMinLimit() const
+{
+ return GetImpl(*this).GetMinLimit();
+}
+
+float ScrollConnector::GetMaxLimit() const
+{
+ return GetImpl(*this).GetMaxLimit();
+}
+
+Constrainable ScrollConnector::GetScrollPositionObject() const
+{
+ return GetImpl(*this).GetScrollPositionObject();
+}
+
+ScrollConnector::LimitsChangedSignalType& ScrollConnector::LimitsChangedSignal()
+{
+ return GetImpl(*this).LimitsChangedSignal();
+}
+
+ScrollConnector::ScrollConnector( Internal::ScrollConnector* impl )
+: BaseHandle( impl )
+{
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/public-api/controls/scrollable/scroll-connector.h b/dali-toolkit/public-api/controls/scrollable/scroll-connector.h
new file mode 100644
index 0000000..fad7fb2
--- /dev/null
+++ b/dali-toolkit/public-api/controls/scrollable/scroll-connector.h
@@ -0,0 +1,134 @@
+#ifndef __DALI_TOOLKIT_SCROLL_CONNECTOR_H__
+#define __DALI_TOOLKIT_SCROLL_CONNECTOR_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
+
+namespace Dali DALI_IMPORT_API
+{
+
+namespace Toolkit
+{
+
+namespace Internal DALI_INTERNAL
+{
+class ScrollConnector;
+}
+
+/**
+ * ScrollConnector is used to connect scrollable containers with components such as scroll bars, indicators etc.
+ *
+ * This basically consists of:
+ * - A "scroll-position" property which controls which part of the scrollable content is visible
+ * - The minimum/maximum limits of the scroll position, which corresponds to the start & end points of the scollable list etc.
+ *
+ * The provider of the scrollable content is responsible for calling SetLimits(). Scroll-bar components are then expected to
+ * receive these values via the LIMITS_CHANGED signal.
+ *
+ * The scroll-position property is accessible via GetScrollPositionObject(). This is intended to be shared by multiple controls
+ * e.g. a list control may be scrolled by panning the list content, or indirectly by dragging a connected scroll-bar control.
+ */
+class ScrollConnector : public BaseHandle
+{
+public:
+
+ static const char* const SCROLL_POSITION_PROPERTY_NAME; ///< This float "scroll-position" property is available via GetScrollPositionObject()
+ static const Property::Index SCROLL_POSITION; ///< The index of the "scroll-position" property
+
+ // Signals
+ static const char* const LIMITS_CHANGED_SIGNAL_NAME; ///< "limits-changed" signal name
+ typedef SignalV2< void ( float min, float max ) > LimitsChangedSignalType;
+
+ /**
+ * Create a ScrollConnector.
+ * @return A handle to a newly allocated ScrollConnector.
+ */
+ static ScrollConnector New();
+
+ /**
+ * Create an empty handle.
+ */
+ ScrollConnector();
+
+ /**
+ * Copy constructor.
+ * @param handle A handle to copy.
+ */
+ ScrollConnector( const ScrollConnector& handle );
+
+ /**
+ * @copydoc Dali::BaseHandle::operator=
+ */
+ using Dali::BaseHandle::operator=;
+
+ /**
+ * Virtual destructor.
+ */
+ virtual ~ScrollConnector();
+
+ /**
+ * Downcast a BaseHandle to ScrollConnector handle.
+ * @return A handle to a ScrollConnector or an empty handle.
+ */
+ static ScrollConnector DownCast( BaseHandle handle );
+
+ /**
+ * Set The min/max values, corresponding to the start & end position of the scrollable content.
+ * @param[in] min The minimum value.
+ * @param[in] max The maximum value.
+ */
+ void SetLimits( float min, float max );
+
+ /**
+ * Retrieve the min limit.
+ * @return The minimum value.
+ */
+ float GetMinLimit() const;
+
+ /**
+ * Retrieve the max limit.
+ * @return The maximum value.
+ */
+ float GetMaxLimit() const;
+
+ /**
+ * Signal emitted after the SetLimits() method has been called.
+ */
+ ScrollConnector::LimitsChangedSignalType& LimitsChangedSignal();
+
+ /**
+ * Retrieve the object which provides the "scroll-position" property.
+ * @return The scroll-position object.
+ */
+ Constrainable GetScrollPositionObject() const;
+
+public: // Not intended for application developers
+
+ /**
+ * Creates a handle using the Toolkit::Internal implementation.
+ * @param[in] impl The Control implementation.
+ */
+ ScrollConnector( Internal::ScrollConnector* impl );
+};
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_SCROLL_CONNECTOR_H__
diff --git a/dali-toolkit/public-api/file.list b/dali-toolkit/public-api/file.list
index 2debf20..9fc10f2 100755
--- a/dali-toolkit/public-api/file.list
+++ b/dali-toolkit/public-api/file.list
@@ -34,6 +34,7 @@ public_api_src_files = \
$(public_api_src_dir)/controls/scrollable/item-view/spiral-layout.cpp \
$(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-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,7 +150,8 @@ 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-connector.h
public_api_scroll_view_header_files = \
$(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-constraints.h \
--
2.7.4