utc-Dali-OverlayEffect.cpp
utc-Dali-PageTurnEffect.cpp
utc-Dali-PageTurnView.cpp
+ utc-Dali-ScrollBar.cpp
utc-Dali-ScrollView.cpp
utc-Dali-ShadowView.cpp
utc-Dali-ShearEffect.cpp
--- /dev/null
+/*
+ * 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.
+ *
+ */
+
+#include <iostream>
+#include <stdlib.h>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali/integration-api/events/pan-gesture-event.h>
+
+using namespace Dali;
+using namespace Toolkit;
+
+void dali_scrollbar_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void dali_scrollbar_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+namespace
+{
+
+const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
+
+// Generate a PanGestureEvent to send to Core
+Integration::PanGestureEvent GeneratePan(
+ Gesture::State state,
+ const Vector2& previousPosition,
+ const Vector2& currentPosition,
+ unsigned long timeDelta,
+ unsigned int numberOfTouches = 1)
+{
+ Integration::PanGestureEvent pan(state);
+
+ pan.previousPosition = previousPosition;
+ pan.currentPosition = currentPosition;
+ pan.timeDelta = timeDelta;
+ pan.numberOfTouches = numberOfTouches;
+
+ return pan;
+}
+
+/**
+ * Helper to generate PanGestureEvent
+ *
+ * @param[in] application Application instance
+ * @param[in] state The Gesture State
+ * @param[in] pos The current position of touch.
+ */
+static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
+{
+ static Vector2 last;
+
+ if( (state == Gesture::Started) ||
+ (state == Gesture::Possible) )
+ {
+ last.x = pos.x;
+ last.y = pos.y;
+ }
+
+ application.ProcessEvent(GeneratePan(state, last, pos, RENDER_FRAME_INTERVAL));
+
+ last.x = pos.x;
+ last.y = pos.y;
+}
+
+/*
+ * Simulate time passed by.
+ *
+ * @note this will always process at least 1 frame (1/60 sec)
+ *
+ * @param application Test application instance
+ * @param duration Time to pass in milliseconds.
+ * @return The actual time passed in milliseconds
+ */
+int Wait(ToolkitTestApplication& application, int duration = 0)
+{
+ int time = 0;
+
+ for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
+ {
+ application.SendNotification();
+ application.Render(RENDER_FRAME_INTERVAL);
+ time += RENDER_FRAME_INTERVAL;
+ }
+
+ return time;
+}
+
+// Callback probes.
+
+static bool gOnPanFinishedCalled; ///< Whether the PanFinished signal was invoked.
+static bool gOnScrollPositionIntervalReachedSignalCalled; ///< Whether the ScrollPositionIntervalReached signal was invoked.
+
+/**
+ * Invoked when pan gesture is finished on the scroll indicator.
+ */
+static void OnPanFinished()
+{
+ gOnPanFinishedCalled = true;
+}
+
+/**
+ * Invoked when the current scroll position of the scrollable content goes above or below the values
+ * specified by SCROLL_POSITION_INTERVALS property.
+ *
+ * @param[in] position The current scroll position.
+ */
+static void OnScrollPositionIntervalReached( float position )
+{
+ gOnScrollPositionIntervalReachedSignalCalled = true;
+}
+
+static Vector2 PerformGestureSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames)
+{
+ gOnPanFinishedCalled = false;
+
+ // Now do a pan starting from (start) and heading (direction)
+ Vector2 pos(start);
+ SendPan(application, Gesture::Possible, pos);
+ SendPan(application, Gesture::Started, pos);
+ Wait(application);
+
+ for(int i = 0; i < frames; i++)
+ {
+ pos += direction; // Move in this direction
+ SendPan(application, Gesture::Continuing, pos);
+ Wait(application);
+ }
+
+ pos += direction; // Move in this direction.
+ SendPan(application, Gesture::Finished, pos);
+ Wait(application);
+
+ return pos;
+}
+
+} // namespace
+
+int UtcDaliToolkitScrollBarConstructorP(void)
+{
+ ToolkitTestApplication application;
+
+ ScrollBar scrollBar;
+ DALI_TEST_CHECK( !scrollBar );
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarCopyConstructorP(void)
+{
+ ToolkitTestApplication application;
+
+ ScrollBar scrollBar = ScrollBar::New();
+ scrollBar.SetProperty( ScrollBar::Property::INDICATOR_FIXED_HEIGHT, 38.2f );
+
+ ScrollBar copy( scrollBar );
+ DALI_TEST_CHECK( copy );
+ DALI_TEST_CHECK( copy.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) == scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) );
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarAssignmentOperatorP(void)
+{
+ ToolkitTestApplication application;
+
+ ScrollBar scrollBar = ScrollBar::New();
+ scrollBar.SetProperty( ScrollBar::Property::INDICATOR_FIXED_HEIGHT, 38.2f );
+
+ ScrollBar copy = scrollBar;
+ DALI_TEST_CHECK( copy );
+ DALI_TEST_CHECK( copy.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) == scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) );
+ END_TEST;
+}
+
+int UtcDaliScrollBarDestructorP(void)
+{
+ ToolkitTestApplication application;
+
+ ScrollBar* scrollBar = new ScrollBar();
+ delete scrollBar;
+
+ DALI_TEST_CHECK( true );
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarNewP(void)
+{
+ ToolkitTestApplication application;
+
+ ScrollBar scrollBar = ScrollBar::New();
+ DALI_TEST_CHECK( scrollBar );
+ END_TEST;
+
+ ScrollBar vertical = ScrollBar::New(ScrollBar::Vertical);
+ DALI_TEST_CHECK( vertical );
+ DALI_TEST_CHECK( vertical.GetScrollDirection() == ScrollBar::Vertical );
+
+ ScrollBar horizontal = ScrollBar::New(ScrollBar::Horizontal);
+ DALI_TEST_CHECK( horizontal );
+ DALI_TEST_CHECK( horizontal.GetScrollDirection() == ScrollBar::Horizontal );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarDownCastP(void)
+{
+ ToolkitTestApplication application;
+
+ ScrollBar scrollBar1 = ScrollBar::New();
+ BaseHandle object( scrollBar1 );
+
+ ScrollBar scrollBar2 = ScrollBar::DownCast( object );
+ DALI_TEST_CHECK( scrollBar2 );
+
+ ScrollBar scrollBar3 = DownCast< ScrollBar >( object );
+ DALI_TEST_CHECK( scrollBar3 );
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarDownCastN(void)
+{
+ ToolkitTestApplication application;
+
+ BaseHandle uninitializedObject;
+ ScrollBar scrollBar1 = ScrollBar::DownCast( uninitializedObject );
+ DALI_TEST_CHECK( !scrollBar1 );
+
+ ScrollBar scrollBar2 = DownCast< ScrollBar >( uninitializedObject );
+ DALI_TEST_CHECK( !scrollBar2 );
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarSetScrollPropertySourceP(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a vertical scroll bar
+ ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
+ DALI_TEST_CHECK( scrollBar );
+ DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Vertical );
+
+ float scrollBarHeight = 100.0f;
+ scrollBar.SetSize(20.0f, scrollBarHeight, 0.0f);
+ Stage::GetCurrent().Add( scrollBar );
+
+ // Create a source actor that owns the scroll properties required by the scroll bar
+ Actor sourceActor = Actor::New();
+ Stage::GetCurrent().Add( sourceActor );
+
+ // Register the scroll properties
+ Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "source-position", 0.0f );
+ Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "source-position-min", 0.0f );
+ Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "source-position-max", 100.0f );
+ Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "source-content-size", 500.0f );
+
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-position" ), propertyScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-position-min" ), propertyMinScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-position-max" ), propertyMaxScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-content-size" ), propertyScrollContentSize, TEST_LOCATION );
+
+ // Set the source of the scroll position properties.
+ scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ Actor indicator = scrollBar.GetScrollIndicator();
+ DALI_TEST_CHECK( indicator );
+
+ // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
+ // i.e. The bigger the content size, the smaller the indicator size
+ float indicatorHeight = indicator.GetCurrentSize().y;
+ DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
+
+ // Decrease the content length
+ sourceActor.SetProperty( propertyScrollContentSize, 250.0f );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator size is changed accordingly
+ indicatorHeight = indicator.GetCurrentSize().y;
+ DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 250.0f, TEST_LOCATION );
+
+ // As scroll position is 0, check that the indicator position should be 0.0f.
+ float indicatorPosition = indicator.GetCurrentPosition().y;
+ DALI_TEST_EQUALS( indicatorPosition, 0.0f, TEST_LOCATION );
+
+ // Set the scroll position to the middle
+ sourceActor.SetProperty( propertyScrollPosition, -50.0f );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator should be in the middle of the scroll bar
+ indicatorPosition = indicator.GetCurrentPosition().y;
+ DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.5f, TEST_LOCATION );
+
+ // Set the scroll position to the maximum
+ sourceActor.SetProperty( propertyScrollPosition, -100.0f );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator should be in the end of the scroll bar
+ indicatorPosition = indicator.GetCurrentPosition().y;
+ DALI_TEST_EQUALS( indicatorPosition, scrollBarHeight - indicatorHeight, TEST_LOCATION );
+
+ // Increase the maximum scroll position to double
+ sourceActor.SetProperty( propertyMaxScrollPosition, 200.0f );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator should be now in the middle of the scroll bar
+ indicatorPosition = indicator.GetCurrentPosition().y;
+ DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.5f, TEST_LOCATION );
+
+ // Create another source actor
+ Actor newSourceActor = Actor::New();
+ Stage::GetCurrent().Add( newSourceActor );
+
+ // Register the scroll properties
+ Property::Index newPropertyScrollPosition = newSourceActor.RegisterProperty( "source-position", 0.0f );
+ Property::Index newPropertyMinScrollPosition = newSourceActor.RegisterProperty( "source-position-min", 0.0f );
+ Property::Index newPropertyMaxScrollPosition = newSourceActor.RegisterProperty( "source-position-max", 200.0f );
+ Property::Index newPropertyScrollContentSize = newSourceActor.RegisterProperty( "source-content-size", 400.0f );
+
+ DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "source-position" ), newPropertyScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "source-position-min" ), newPropertyMinScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "source-position-max" ), newPropertyMaxScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "source-content-size" ), newPropertyScrollContentSize, TEST_LOCATION );
+
+ // Change the source of the scroll position properties to be the new source actor.
+ scrollBar.SetScrollPropertySource(newSourceActor, newPropertyScrollPosition, newPropertyMinScrollPosition, newPropertyMaxScrollPosition, newPropertyScrollContentSize);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator size is changed accordingly
+ indicatorHeight = indicator.GetCurrentSize().y;
+ DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 400.0f, TEST_LOCATION );
+
+ // Check that the indicator position goes back to the beginning of the scroll bar
+ indicatorPosition = indicator.GetCurrentPosition().y;
+ DALI_TEST_EQUALS( indicatorPosition, 0.0f, TEST_LOCATION );
+
+ // Set the scroll position to one fifth of the maximum
+ newSourceActor.SetProperty( propertyScrollPosition, -40.0f );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator should be in one fifth from the beginning of the scroll bar
+ indicatorPosition = indicator.GetCurrentPosition().y;
+ DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.2f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarSetScrollPropertySourceN(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a scroll bar
+ ScrollBar scrollBar = ScrollBar::New();
+ DALI_TEST_CHECK( scrollBar );
+
+ // Set empty handle of source object and invalid source property index.
+ Actor sourceActor;
+ scrollBar.SetScrollPropertySource(sourceActor, Property::INVALID_INDEX, Property::INVALID_INDEX, Property::INVALID_INDEX, Property::INVALID_INDEX);
+
+ DALI_TEST_CHECK( true );
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarSetScrollIndicatorP(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a scroll bar
+ ScrollBar scrollBar = ScrollBar::New();
+ DALI_TEST_CHECK( scrollBar );
+
+ Actor indicator = scrollBar.GetScrollIndicator();
+ DALI_TEST_CHECK( indicator );
+
+ // Set a new indicator
+ Actor newIndicator = Actor::New();
+ scrollBar.SetScrollIndicator(newIndicator);
+
+ // Check that the new indicator is successfully set
+ DALI_TEST_CHECK( indicator != scrollBar.GetScrollIndicator() );
+ DALI_TEST_CHECK( newIndicator == scrollBar.GetScrollIndicator() );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarSetScrollIndicatorN(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a scroll bar
+ ScrollBar scrollBar = ScrollBar::New();
+ DALI_TEST_CHECK( scrollBar );
+
+ Actor indicator = scrollBar.GetScrollIndicator();
+ DALI_TEST_CHECK( indicator );
+
+ // Try to set an uninitialized actor as the indicator
+ Actor uninitializedIndicator;
+ scrollBar.SetScrollIndicator(uninitializedIndicator);
+
+ // Check that the uninitialized actor can not be set as the indicator
+ DALI_TEST_CHECK( indicator == scrollBar.GetScrollIndicator() );
+ DALI_TEST_CHECK( uninitializedIndicator != scrollBar.GetScrollIndicator() );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarGetScrollIndicatorP(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a scroll bar
+ ScrollBar scrollBar = ScrollBar::New();
+ DALI_TEST_CHECK( scrollBar );
+
+ Actor indicator = scrollBar.GetScrollIndicator();
+ DALI_TEST_CHECK( indicator );
+
+ // Set a new indicator
+ Actor newIndicator = Actor::New();
+ scrollBar.SetScrollIndicator(newIndicator);
+
+ // Check that the new indicator is successfully set
+ DALI_TEST_CHECK( scrollBar.GetScrollIndicator() );
+ DALI_TEST_CHECK( indicator != scrollBar.GetScrollIndicator() );
+ DALI_TEST_CHECK( newIndicator == scrollBar.GetScrollIndicator() );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarGetScrollIndicatorN(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a scroll bar
+ ScrollBar scrollBar = ScrollBar::New();
+ DALI_TEST_CHECK( scrollBar );
+
+ Actor indicator = scrollBar.GetScrollIndicator();
+ DALI_TEST_CHECK( indicator );
+
+ // Try to set an uninitialized actor as the indicator
+ Actor uninitializedIndicator;
+ scrollBar.SetScrollIndicator(uninitializedIndicator);
+
+ // Check that the indicator has not been changed
+ DALI_TEST_CHECK( indicator == scrollBar.GetScrollIndicator() );
+ DALI_TEST_CHECK( uninitializedIndicator != scrollBar.GetScrollIndicator() );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarSetScrollPositionIntervalsP(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a vertical scroll bar
+ ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
+ DALI_TEST_CHECK( scrollBar );
+
+ scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
+ scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ scrollBar.SetSize(20.0f, 800.0f, 0.0f);
+
+ Stage::GetCurrent().Add( scrollBar );
+
+ // Connect to the ScrollPositionIntervalReached signal
+ scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Create a source actor that owns the scroll properties required by the scroll bar
+ Actor sourceActor = Actor::New();
+ Stage::GetCurrent().Add( sourceActor );
+
+ // Register the scroll properties
+ Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "source-position", 0.0f );
+ Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "source-position-min", 0.0f );
+ Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "source-position-max", 800.0f );
+ Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "source-content-size", 2000.0f );
+
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-position" ), propertyScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-position-min" ), propertyMinScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-position-max" ), propertyMaxScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-content-size" ), propertyScrollContentSize, TEST_LOCATION );
+
+ // Set the source of the scroll position properties.
+ scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Set the values to get notified when the scroll positions of the source actor goes above or below these values
+ Dali::Vector<float> positionIntervals;
+ for( size_t i = 0; i != 10; ++i )
+ {
+ positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
+ }
+ scrollBar.SetScrollPositionIntervals(positionIntervals);
+
+ // Get the list of scroll position intervals for notification
+ Dali::Vector<float> results = scrollBar.GetScrollPositionIntervals();
+
+ // Check that the result is the same as the list previously set.
+ DALI_TEST_EQUALS( positionIntervals.Count(), results.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( positionIntervals[0], results[0], TEST_LOCATION );
+ DALI_TEST_EQUALS( positionIntervals[1], results[1], TEST_LOCATION );
+ DALI_TEST_EQUALS( positionIntervals[2], results[2], TEST_LOCATION );
+ DALI_TEST_EQUALS( positionIntervals[3], results[3], TEST_LOCATION );
+ DALI_TEST_EQUALS( positionIntervals[4], results[4], TEST_LOCATION );
+ DALI_TEST_EQUALS( positionIntervals[5], results[5], TEST_LOCATION );
+ DALI_TEST_EQUALS( positionIntervals[6], results[6], TEST_LOCATION );
+ DALI_TEST_EQUALS( positionIntervals[7], results[7], TEST_LOCATION );
+ DALI_TEST_EQUALS( positionIntervals[8], results[8], TEST_LOCATION );
+ DALI_TEST_EQUALS( positionIntervals[9], results[9], TEST_LOCATION );
+
+ // Reset the flag
+ gOnScrollPositionIntervalReachedSignalCalled = false;
+
+ // Animate the scroll position to cross the specified value
+ Animation animation = Animation::New(0.1f);
+ animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
+ animation.Play();
+
+ // Wait for 0.1 second
+ Wait(application, 100);
+
+ // Check that the signal callback is called
+ DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
+
+ // Reset the flag
+ gOnScrollPositionIntervalReachedSignalCalled = false;
+
+ // Rest and clear the animation
+ animation.Clear();
+ animation.Reset();
+
+ // Animate the scroll position to cross another specified value
+ animation = Animation::New(0.1f);
+ animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -170.0f );
+ animation.Play();
+
+ // Wait for 0.1 second
+ Wait(application, 100);
+
+ // Check that the signal callback is called
+ DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
+
+ // Reset the flag
+ gOnScrollPositionIntervalReachedSignalCalled = false;
+
+ // Rest and clear the animation
+ animation.Clear();
+ animation.Reset();
+
+ // Animate the scroll position back to the previous value
+ animation = Animation::New(0.1f);
+ animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
+ animation.Play();
+
+ // Wait for 0.1 second
+ Wait(application, 100);
+
+ // Check that the signal callback is called
+ DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarGetScrollPositionIntervalsP(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a vertical scroll bar
+ ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
+ DALI_TEST_CHECK( scrollBar );
+
+ // Set the values to get notified when the scroll positions of the source actor goes above or below these values
+ Dali::Vector<float> positionIntervals;
+ for( size_t i = 0; i != 10; ++i )
+ {
+ positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
+ }
+ scrollBar.SetScrollPositionIntervals(positionIntervals);
+
+ // Get the list of scroll position intervals for notification
+ Dali::Vector<float> results = scrollBar.GetScrollPositionIntervals();
+
+ // Check that the result is the same as the list previously set.
+ DALI_TEST_EQUALS( positionIntervals.Count(), results.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( positionIntervals[0], results[0], TEST_LOCATION );
+ DALI_TEST_EQUALS( positionIntervals[1], results[1], TEST_LOCATION );
+ DALI_TEST_EQUALS( positionIntervals[2], results[2], TEST_LOCATION );
+ DALI_TEST_EQUALS( positionIntervals[3], results[3], TEST_LOCATION );
+ DALI_TEST_EQUALS( positionIntervals[4], results[4], TEST_LOCATION );
+ DALI_TEST_EQUALS( positionIntervals[5], results[5], TEST_LOCATION );
+ DALI_TEST_EQUALS( positionIntervals[6], results[6], TEST_LOCATION );
+ DALI_TEST_EQUALS( positionIntervals[7], results[7], TEST_LOCATION );
+ DALI_TEST_EQUALS( positionIntervals[8], results[8], TEST_LOCATION );
+ DALI_TEST_EQUALS( positionIntervals[9], results[9], TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarGetScrollDirectionP(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a vertical scroll bar
+ ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
+ DALI_TEST_CHECK( scrollBar );
+ DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Vertical );
+
+ // Change the direction of scroll bar to horizontal
+ scrollBar.SetScrollDirection(ScrollBar::Horizontal);
+ DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Horizontal );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarSetIndicatorHeightPolicyP(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a scroll bar
+ ScrollBar scrollBar = ScrollBar::New();
+ DALI_TEST_CHECK( scrollBar );
+
+ float scrollBarHeight = 100.0f;
+ scrollBar.SetSize(20.0f, scrollBarHeight, 0.0f);
+ Stage::GetCurrent().Add( scrollBar );
+
+ // Create a source actor that owns the scroll properties required by the scroll bar
+ Actor sourceActor = Actor::New();
+ Stage::GetCurrent().Add( sourceActor );
+
+ // Register the scroll properties
+ Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "source-position", 0.0f );
+ Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "source-position-min", 0.0f );
+ Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "source-position-max", 100.0f );
+ Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "source-content-size", 500.0f );
+
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-position" ), propertyScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-position-min" ), propertyMinScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-position-max" ), propertyMaxScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-content-size" ), propertyScrollContentSize, TEST_LOCATION );
+
+ // Set the source of the scroll position properties.
+ scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ Actor indicator = scrollBar.GetScrollIndicator();
+ DALI_TEST_CHECK( indicator );
+
+ // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
+ // i.e. The bigger the content size, the smaller the indicator size
+ float indicatorHeight = indicator.GetCurrentSize().y;
+ DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
+
+ // Set the indicator height to be fixed to 50.0f
+ scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
+ scrollBar.SetIndicatorFixedHeight(50.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator size should be 50.0f
+ indicatorHeight = indicator.GetCurrentSize().y;
+ DALI_TEST_EQUALS( indicatorHeight, 50.0f, TEST_LOCATION );
+
+ // Set the indicator height to be variable
+ scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Variable);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
+ indicatorHeight = indicator.GetCurrentSize().y;
+ DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarGetIndicatorHeightPolicyP(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a scroll bar
+ ScrollBar scrollBar = ScrollBar::New();
+ DALI_TEST_CHECK( scrollBar );
+
+ // Set the indicator height to be fixed
+ scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
+ DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Fixed, TEST_LOCATION );
+
+ // Set the indicator height to be variable
+ scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Variable);
+ DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Variable, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarSetIndicatorFixedHeightP(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a scroll bar
+ ScrollBar scrollBar = ScrollBar::New();
+ DALI_TEST_CHECK( scrollBar );
+
+ float scrollBarHeight = 100.0f;
+ scrollBar.SetSize(20.0f, scrollBarHeight, 0.0f);
+ Stage::GetCurrent().Add( scrollBar );
+
+ Actor indicator = scrollBar.GetScrollIndicator();
+ DALI_TEST_CHECK( indicator );
+
+ // Set the indicator height to be fixed to 50.0f
+ scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
+ scrollBar.SetIndicatorFixedHeight(50.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator size should be 50.0f
+ DALI_TEST_EQUALS( indicator.GetCurrentSize().y, 50.0f, TEST_LOCATION );
+
+ // Set the indicator height to be fixed to 25.0f
+ scrollBar.SetIndicatorFixedHeight(25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator size should be 25.0f
+ DALI_TEST_EQUALS( indicator.GetCurrentSize().y, 25.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarGetIndicatorFixedHeightP(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a scroll bar
+ ScrollBar scrollBar = ScrollBar::New();
+ DALI_TEST_CHECK( scrollBar );
+
+ // Set the fixed indicator height to be 50.0f
+ scrollBar.SetIndicatorFixedHeight(50.0f);
+
+ // Check that the indicator size should be 50.0f
+ DALI_TEST_EQUALS( scrollBar.GetIndicatorFixedHeight(), 50.0f, TEST_LOCATION );
+
+ // Set the indicator height to be fixed to 25.0f
+ scrollBar.SetIndicatorFixedHeight(25.0f);
+
+ // Check that the indicator size should be 50.0f
+ DALI_TEST_EQUALS( scrollBar.GetIndicatorFixedHeight(), 25.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarSetIndicatorShowDurationP(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a scroll bar
+ ScrollBar scrollBar = ScrollBar::New();
+ DALI_TEST_CHECK( scrollBar );
+
+ Stage::GetCurrent().Add( scrollBar );
+
+ Actor indicator = scrollBar.GetScrollIndicator();
+ DALI_TEST_CHECK( indicator );
+
+ // Set the duration to show the indicator to be 0.35 second
+ scrollBar.SetIndicatorShowDuration(0.35);
+ DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION );
+
+ // Make the indicator invisible
+ indicator.SetOpacity(0.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is invisible
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
+
+ // Show the indicator
+ scrollBar.ShowIndicator();
+
+ // Wait for 0.35 second
+ Wait(application, 350);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is now visible
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
+
+ // Set the duration to show the indicator to be 0.75 second
+ scrollBar.SetIndicatorShowDuration(0.75);
+ DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION );
+
+ // Make the indicator invisible
+ indicator.SetOpacity(0.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is invisible
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
+
+ // Show the indicator
+ scrollBar.ShowIndicator();
+
+ // Wait for 0.35 second first
+ Wait(application, 350);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is not fully visible yet
+ DALI_TEST_CHECK( indicator.GetCurrentOpacity() != 1.0f );
+
+ // Wait for another 0.4 second
+ Wait(application, 400);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is now fully visible
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarSetIndicatorShowDurationN(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a scroll bar
+ ScrollBar scrollBar = ScrollBar::New();
+ DALI_TEST_CHECK( scrollBar );
+
+ Stage::GetCurrent().Add( scrollBar );
+
+ Actor indicator = scrollBar.GetScrollIndicator();
+ DALI_TEST_CHECK( indicator );
+
+ // Get the default duration to show the indicator
+ float duration = scrollBar.GetIndicatorShowDuration();
+
+ // Check that the default duration is greater than 0
+ DALI_TEST_CHECK( duration > 0.0f );
+
+ // Make the indicator invisible
+ indicator.SetOpacity(0.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is invisible
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
+
+ // Show the indicator
+ scrollBar.ShowIndicator();
+
+ // Wait for the specified duration
+ Wait(application, duration * 1000);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is now visible
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
+
+ // Now set the duration to show the indicator to be a negative value (which should be ignored and therefore means instant)
+ scrollBar.SetIndicatorShowDuration(-0.25f);
+ DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), -0.25f, TEST_LOCATION );
+
+ // Make the indicator invisible
+ indicator.SetOpacity(0.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is invisible
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
+
+ // Show the indicator
+ scrollBar.ShowIndicator();
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator becomes instantly visible in the next frame
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarGetIndicatorShowDurationP(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a scroll bar
+ ScrollBar scrollBar = ScrollBar::New();
+ DALI_TEST_CHECK( scrollBar );
+
+ // Set the duration to show the indicator to be 0.35 second
+ scrollBar.SetIndicatorShowDuration(0.35f);
+
+ // Check that the duration to show the indicator is 0.35 second
+ DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION );
+
+ // Set the duration to show the indicator to be 0.75 second
+ scrollBar.SetIndicatorShowDuration(0.75f);
+
+ // Check that the duration to show the indicator is 0.75 second
+ DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarSetIndicatorHideDurationP(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a scroll bar
+ ScrollBar scrollBar = ScrollBar::New();
+ DALI_TEST_CHECK( scrollBar );
+
+ Stage::GetCurrent().Add( scrollBar );
+
+ Actor indicator = scrollBar.GetScrollIndicator();
+ DALI_TEST_CHECK( indicator );
+
+ // Set the duration to hide the indicator to be 0.15 second
+ scrollBar.SetIndicatorHideDuration(0.15f);
+ DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION );
+
+ // Make the indicator visible
+ indicator.SetOpacity(1.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is visible
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
+
+ // Hide the indicator
+ scrollBar.HideIndicator();
+
+ // Wait for 0.15 second
+ Wait(application, 150);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is now invisible
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
+
+ // Set the duration to hide the indicator to be 0.65 second
+ scrollBar.SetIndicatorHideDuration(0.65f);
+ DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION );
+
+ // Make the indicator visible
+ indicator.SetOpacity(1.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is visible
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
+
+ // Hide the indicator
+ scrollBar.HideIndicator();
+
+ // Wait for 0.15 second first
+ Wait(application, 150);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is not fully invisible yet
+ DALI_TEST_CHECK( indicator.GetCurrentOpacity() != 0.0f );
+
+ // Wait for another 0.5 second
+ Wait(application, 500);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is now fully invisible
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarSetIndicatorHideDurationN(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a scroll bar
+ ScrollBar scrollBar = ScrollBar::New();
+ DALI_TEST_CHECK( scrollBar );
+
+ Stage::GetCurrent().Add( scrollBar );
+
+ Actor indicator = scrollBar.GetScrollIndicator();
+ DALI_TEST_CHECK( indicator );
+
+ // Get the default duration to hide the indicator
+ float duration = scrollBar.GetIndicatorHideDuration();
+
+ // Check that the default duration is greater than 0
+ DALI_TEST_CHECK( duration > 0.0f );
+
+ // Make the indicator visible
+ indicator.SetOpacity(1.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is visible
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
+
+ // Hide the indicator
+ scrollBar.HideIndicator();
+
+ // Wait for the specified duration
+ Wait(application, duration * 1000);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is now invisible
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
+
+ // Now set the duration to hide the indicator to be a negative value (which should be ignored and therefore means instant)
+ scrollBar.SetIndicatorHideDuration(-0.25f);
+ DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), -0.25f, TEST_LOCATION );
+
+ // Make the indicator visible
+ indicator.SetOpacity(1.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is visible
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
+
+ // Hide the indicator
+ scrollBar.HideIndicator();
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator becomes instantly invisible in the next frame
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarGetIndicatorHideDurationP(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a scroll bar
+ ScrollBar scrollBar = ScrollBar::New();
+ DALI_TEST_CHECK( scrollBar );
+
+ // Set the duration to hide the indicator to be 0.15 second
+ scrollBar.SetIndicatorHideDuration(0.15f);
+
+ // Check that the duration to hide the indicator is 0.15 second
+ DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION );
+
+ // Set the duration to hide the indicator to be 0.65 second
+ scrollBar.SetIndicatorHideDuration(0.65f);
+
+ // Check that the duration to hide the indicator is 0.65 second
+ DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarShowIndicatorP(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a scroll bar
+ ScrollBar scrollBar = ScrollBar::New();
+ DALI_TEST_CHECK( scrollBar );
+
+ Stage::GetCurrent().Add( scrollBar );
+
+ Actor indicator = scrollBar.GetScrollIndicator();
+ DALI_TEST_CHECK( indicator );
+
+ // Get the default duration to show the indicator
+ float duration = scrollBar.GetIndicatorShowDuration();
+
+ // Check that the default duration is greater than 0
+ DALI_TEST_CHECK( duration > 0.0f );
+
+ // Make the indicator invisible
+ indicator.SetOpacity(0.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is invisible
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
+
+ // Show the indicator
+ scrollBar.ShowIndicator();
+
+ // Wait for the specified duration
+ Wait(application, duration * 1000);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is now visible
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarShowIndicatorN(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a scroll bar
+ ScrollBar scrollBar = ScrollBar::New();
+ DALI_TEST_CHECK( scrollBar );
+
+ Stage::GetCurrent().Add( scrollBar );
+
+ Actor indicator = scrollBar.GetScrollIndicator();
+ DALI_TEST_CHECK( indicator );
+
+ // Make the indicator initially visible
+ indicator.SetOpacity(1.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is initially visible
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
+
+ // Get the default duration to show the indicator
+ float duration = scrollBar.GetIndicatorShowDuration();
+
+ // Check that the default duration is greater than 0
+ DALI_TEST_CHECK( duration > 0.0f );
+
+ // Show the indicator
+ scrollBar.ShowIndicator();
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is still visible in the very next frame
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarHideIndicatorP(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a scroll bar
+ ScrollBar scrollBar = ScrollBar::New();
+ DALI_TEST_CHECK( scrollBar );
+
+ Stage::GetCurrent().Add( scrollBar );
+
+ Actor indicator = scrollBar.GetScrollIndicator();
+ DALI_TEST_CHECK( indicator );
+
+ // Get the default duration to hide the indicator
+ float duration = scrollBar.GetIndicatorHideDuration();
+
+ // Check that the default duration is greater than 0
+ DALI_TEST_CHECK( duration > 0.0f );
+
+ // Make the indicator visible
+ indicator.SetOpacity(1.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is visible
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
+
+ // Hide the indicator
+ scrollBar.HideIndicator();
+
+ // Wait for the specified duration
+ Wait(application, duration * 1000);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is now invisible
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarHideIndicatorN(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a scroll bar
+ ScrollBar scrollBar = ScrollBar::New();
+ DALI_TEST_CHECK( scrollBar );
+
+ Stage::GetCurrent().Add( scrollBar );
+
+ Actor indicator = scrollBar.GetScrollIndicator();
+ DALI_TEST_CHECK( indicator );
+
+ // Make the indicator initially invisible
+ indicator.SetOpacity(0.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is initially invisible
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
+
+ // Get the default duration to hide the indicator
+ float duration = scrollBar.GetIndicatorHideDuration();
+
+ // Check that the default duration is greater than 0
+ DALI_TEST_CHECK( duration > 0.0f );
+
+ // Hide the indicator
+ scrollBar.HideIndicator();
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Check that the indicator is still invisible in the very next frame
+ DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarPanFinishedSignalP(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a vertical scroll bar
+ ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
+ DALI_TEST_CHECK( scrollBar );
+
+ scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
+ scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ scrollBar.SetSize(20.0f, 800.0f, 0.0f);
+
+ // Set the indicator height to be fixed to 50.0f
+ scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
+ scrollBar.SetIndicatorFixedHeight(50.0f);
+
+ Stage::GetCurrent().Add( scrollBar );
+
+ // Connect the pan finished signal
+ scrollBar.PanFinishedSignal().Connect( &OnPanFinished );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Create a source actor that owns the scroll properties required by the scroll bar
+ Actor sourceActor = Actor::New();
+ Stage::GetCurrent().Add( sourceActor );
+
+ // Register the scroll properties
+ Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "source-position", 0.0f );
+ Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "source-position-min", 0.0f );
+ Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "source-position-max", 100.0f );
+ Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "source-content-size", 500.0f );
+
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-position" ), propertyScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-position-min" ), propertyMinScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-position-max" ), propertyMaxScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-content-size" ), propertyScrollContentSize, TEST_LOCATION );
+
+ // Set the source of the scroll position properties.
+ scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Perform a swipe gesture on the indicator
+ PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20);
+ DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarPanFinishedSignalN(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a vertical scroll bar
+ ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
+ DALI_TEST_CHECK( scrollBar );
+
+ scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
+ scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ scrollBar.SetSize(20.0f, 800.0f, 0.0f);
+
+ // Set the indicator height to be fixed to 50.0f
+ scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
+ scrollBar.SetIndicatorFixedHeight(50.0f);
+
+ Stage::GetCurrent().Add( scrollBar );
+
+ // Connect the pan finished signal
+ scrollBar.PanFinishedSignal().Connect( &OnPanFinished );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Perform a vertical swipe gesture on the indicator when there is no source object set on the scroll bar
+ PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20);
+ DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION );
+
+ // Create a source actor that owns the scroll properties required by the scroll bar
+ Actor sourceActor = Actor::New();
+ Stage::GetCurrent().Add( sourceActor );
+
+ // Register the scroll properties
+ Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "source-position", 0.0f );
+ Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "source-position-min", 0.0f );
+ Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "source-position-max", 100.0f );
+ Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "source-content-size", 500.0f );
+
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-position" ), propertyScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-position-min" ), propertyMinScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-position-max" ), propertyMaxScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-content-size" ), propertyScrollContentSize, TEST_LOCATION );
+
+ // Set the source of the scroll position properties.
+ scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Perform a swipe gesture on the scroll bar but not on the indicator
+ PerformGestureSwipe(application, Vector2(1.0f, 780.0f), Vector2(Vector2::YAXIS * -1.0f), 20);
+ DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION );
+
+ // Perform a swipe gesture on the indicator
+ PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20);
+ DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalP(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a vertical scroll bar
+ ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
+ DALI_TEST_CHECK( scrollBar );
+
+ scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
+ scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ scrollBar.SetSize(20.0f, 800.0f, 0.0f);
+
+ Stage::GetCurrent().Add( scrollBar );
+
+ // Connect to the ScrollPositionIntervalReached signal
+ scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Create a source actor that owns the scroll properties required by the scroll bar
+ Actor sourceActor = Actor::New();
+ Stage::GetCurrent().Add( sourceActor );
+
+ // Register the scroll properties
+ Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "source-position", 0.0f );
+ Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "source-position-min", 0.0f );
+ Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "source-position-max", 800.0f );
+ Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "source-content-size", 2000.0f );
+
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-position" ), propertyScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-position-min" ), propertyMinScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-position-max" ), propertyMaxScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-content-size" ), propertyScrollContentSize, TEST_LOCATION );
+
+ // Set the source of the scroll position properties.
+ scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Set the values to get notified when the scroll positions of the source actor goes above or below these values
+ Dali::Vector<float> positionIntervals;
+ for( size_t i = 0; i != 10; ++i )
+ {
+ positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
+ }
+ scrollBar.SetScrollPositionIntervals(positionIntervals);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Reset the flag
+ gOnScrollPositionIntervalReachedSignalCalled = false;
+
+ // Animate the scroll position to cross the specified value
+ Animation animation = Animation::New(0.1f);
+ animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
+ animation.Play();
+
+ // Wait for 0.1 second
+ Wait(application, 100);
+
+ // Check that the signal callback is called
+ DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
+
+ // Reset the flag
+ gOnScrollPositionIntervalReachedSignalCalled = false;
+
+ // Rest and clear the animation
+ animation.Clear();
+ animation.Reset();
+
+ // Animate the scroll position to cross another specified value
+ animation = Animation::New(0.1f);
+ animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -170.0f );
+ animation.Play();
+
+ // Wait for 0.1 second
+ Wait(application, 100);
+
+ // Check that the signal callback is called
+ DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
+
+ // Reset the flag
+ gOnScrollPositionIntervalReachedSignalCalled = false;
+
+ // Rest and clear the animation
+ animation.Clear();
+ animation.Reset();
+
+ // Animate the scroll position back to the previous value
+ animation = Animation::New(0.1f);
+ animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
+ animation.Play();
+
+ // Wait for 0.1 second
+ Wait(application, 100);
+
+ // Check that the signal callback is called
+ DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalN(void)
+{
+ ToolkitTestApplication application;
+
+ // Create a vertical scroll bar
+ ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
+ DALI_TEST_CHECK( scrollBar );
+
+ scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
+ scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ scrollBar.SetSize(20.0f, 800.0f, 0.0f);
+
+ Stage::GetCurrent().Add( scrollBar );
+
+ // Connect to the ScrollPositionIntervalReached signal
+ scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Create a source actor that owns the scroll properties required by the scroll bar
+ Actor sourceActor = Actor::New();
+ Stage::GetCurrent().Add( sourceActor );
+
+ // Register the scroll properties
+ Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "source-position", 0.0f );
+ Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "source-position-min", 0.0f );
+ Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "source-position-max", 800.0f );
+ Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "source-content-size", 2000.0f );
+
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-position" ), propertyScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-position-min" ), propertyMinScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-position-max" ), propertyMaxScrollPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "source-content-size" ), propertyScrollContentSize, TEST_LOCATION );
+
+ // Set the source of the scroll position properties.
+ scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Set the values to get notified when the scroll positions of the source actor goes above or below these values
+ Dali::Vector<float> positionIntervals;
+ for( size_t i = 0; i != 10; ++i )
+ {
+ positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
+ }
+ scrollBar.SetScrollPositionIntervals(positionIntervals);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Reset the flag
+ gOnScrollPositionIntervalReachedSignalCalled = false;
+
+ // Animate the scroll position not to cross the specified value
+ Animation animation = Animation::New(0.1f);
+ animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -70.0f );
+ animation.Play();
+
+ // Wait for 0.1 second
+ Wait(application, 100);
+
+ // Check that the signal callback is not called
+ DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, false, TEST_LOCATION );
+
+ // Rest and clear the animation
+ animation.Clear();
+ animation.Reset();
+
+ // Animate the scroll position to cross another specified value
+ animation = Animation::New(0.1f);
+ animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
+ animation.Play();
+
+ // Wait for 0.1 second
+ Wait(application, 100);
+
+ // Check that the signal callback is called
+ DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
const int CLAMP_STEP_1_CHECK_CLAMPED_WEST = 1; ///< FSM: "Next check that scrollview clamps against left side"
const int CLAMP_STEP_2_CHECK_CLAMPED_SOUTH_WEST = 2; ///< FSM: "Then check that scrollview clamps against bottom-left side"
const int CLAMP_STEP_3_SUCCESS = 3; ///< FSM: "Finished (Success)"
-const Vector3 CLAMP_START_SCROLL_POSITION(30.0f, 100.0f, 0.0f); ///< Scroll start position for the Clamping tests.
+const Vector2 CLAMP_START_SCROLL_POSITION(30.0f, 100.0f); ///< Scroll start position for the Clamping tests.
const Vector2 CLAMP_TOUCH_START( 100.0f, 100.0f ); ///< Start point to touch from for the Clamping tests.
const Vector2 CLAMP_TOUCH_MOVEMENT( 5.0f, -5.0f ); ///< Amount to move touch for each frame for the Clamping tests.
const int CLAMP_GESTURE_FRAMES = 100; ///< Number of Frames to synthesize a gesture for the Clamping tests.
const Vector3 TEST_CONSTRAINT_OFFSET(1.0f, 2.0f, 0.0f); ///< A Test constraint offset (arbitrary value to test effects)
const float TEST_RATIO_TOLERANCE = 0.05; ///< +/-5% tolerance for ratio comparisons.
-const int MAX_FRAMES_TO_TEST_OVERSHOOT = 600; ///< 10 seconds (at 60 frames per second).
-const Vector3 OVERSHOOT_START_SCROLL_POSITION(100.0f, 100.0f, 0.0f); ///< Scroll start position for the Overshoot tests.
-const float SCROLL_ANIMATION_DURATION(0.33f); ///< Duration of scroll animation in Overshoot tests (i.e. 100 pixels of overshoot in the speed of 500 pixels per 100 frames, 100/(500/(60/100)) = 0.33)
-const Vector3 SNAP_POSITION_WITH_DECELERATED_VELOCITY(74.0f, 74.0f, 0.0f); ///< the snap position for Overshoot tests with the decelerated velocity (i.e. Decelerated from 500 pixels per 100 frames).
-const float TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION = 0.05f; ///< a Test duration
-const float TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION = 1.5f; ///< another Test duration
+const float DEFAULT_SNAP_OVERSHOOT_DURATION(0.5f); ///< Default overshoot snapping animation time.
+const float DEFAULT_MAX_OVERSHOOT(100.0f); ///< Default maximum allowed overshoot in pixels
+
+const int MAX_FRAMES_TO_TEST_OVERSHOOT = 600; ///< 10 seconds (at 60 frames per second).
+const Vector2 OVERSHOOT_START_SCROLL_POSITION(100.0f, 100.0f); ///< Scroll start position for the Overshoot tests.
+const float SCROLL_ANIMATION_DURATION(0.33f); ///< Duration of scroll animation in Overshoot tests (i.e. 100 pixels of overshoot in the speed of 500 pixels per 100 frames, 100/(500/(100/60)) = 0.33)
+const Vector2 SNAP_POSITION_WITH_DECELERATED_VELOCITY(74.0f, 74.0f); ///< the snap position for Overshoot tests with the decelerated velocity (i.e. Decelerated from 500 pixels per 100 frames).
+const float TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION = 0.05f; ///< a Test duration
+const float TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION = 1.5f; ///< another Test duration
const float TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION = TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * 0.5f; // Same as above, but different alpha function.
-const float TIME_TOLERANCE = 0.05f; ///< Allow testing tolerance between a 10th of second (+/- 3 frames)
+const float TIME_TOLERANCE = 0.05f; ///< Allow testing tolerance between a 10th of second (+/- 3 frames)
// Generate a PanGestureEvent to send to Core
*
* @param[in] position The current scroll position.
*/
-static void OnScrollStart( const Vector3& position )
+static void OnScrollStart( const Vector2& position )
{
gOnScrollStartCalled = true;
}
*
* @param[in] position The current scroll position.
*/
-static void OnScrollUpdate( const Vector3& position )
+static void OnScrollUpdate( const Vector2& position )
{
gOnScrollUpdateCalled = true;
}
*
* @param[in] position The current scroll position.
*/
-static void OnScrollComplete( const Vector3& position )
+static void OnScrollComplete( const Vector2& position )
{
gOnScrollCompleteCalled = true;
}
*/
void operator()( Vector3& current, const PropertyInputContainer& inputs )
{
- gConstraintResult = current + inputs[0]->GetVector3() + mOffset;
+ gConstraintResult = current + Vector3(inputs[0]->GetVector2()) + mOffset;
current = gConstraintResult;
}
ScrollView scrollView = ScrollView::New();
Stage::GetCurrent().Add( scrollView );
- const Vector3 target = Vector3(100.0f, 200.0f, 0.0f);
- const Vector3 target2 = Vector3(300.0f, 100.0f, 0.0f);
+ const Vector2 target = Vector2(100.0f, 200.0f);
+ const Vector2 target2 = Vector2(300.0f, 100.0f);
scrollView.ScrollTo( target, 0.0f );
Wait(application);
scrollView.ScrollTo( 1, 0.0f );
Wait(application);
- DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(100.0f, 0.0f, 0.0f), TEST_LOCATION );
+ DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
scrollView.ScrollTo( 5, 0.0f );
Wait(application);
- DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(500.0f, 0.0f, 0.0f), TEST_LOCATION );
+ DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(500.0f, 0.0f), TEST_LOCATION );
scrollView.ScrollTo( 10, 0.0f );
Wait(application);
- DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(200.0f, 100.0f, 0.0f), TEST_LOCATION );
+ DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 100.0f), TEST_LOCATION );
scrollView.ScrollTo( 15, 0.0f );
Wait(application);
- DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(700.0f, 100.0f, 0.0f), TEST_LOCATION );
+ DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(700.0f, 100.0f), TEST_LOCATION );
DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
scrollView.ScrollTo( 3 );
Wait(application, RENDER_DELAY_SCROLL);
- DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(300.0f, 0.0f, 0.0f), TEST_LOCATION );
+ DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(300.0f, 0.0f), TEST_LOCATION );
DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
scrollView.ScrollTo( 9 );
Wait(application, RENDER_DELAY_SCROLL);
- DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION );
+ DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 100.0f), TEST_LOCATION );
DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
// Apply DefaultRulers instead and see what happens.
// This time should always scroll to origin (0.0f, 0.0f)
scrollView.ScrollTo( 1, 0.0f );
Wait(application);
- DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
+ DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
Wait(application);
scrollView.ScrollTo(actorA, 0.0f);
Wait(application);
- DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA, TEST_LOCATION );
+ DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
Wait(application);
scrollView.ScrollTo(actorB, 0.0f);
Wait(application);
- DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB, TEST_LOCATION );
+ DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
scrollView.ScrollTo(actorA);
Wait(application, RENDER_DELAY_SCROLL);
- DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA, TEST_LOCATION );
+ DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
scrollView.ScrollTo(actorB);
Wait(application, RENDER_DELAY_SCROLL);
- DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB, TEST_LOCATION );
+ DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
END_TEST;
}
scrollView.SetRulerX( rulerX );
scrollView.SetRulerY( rulerY );
- scrollView.ScrollTo( Vector3(120.0f, 190.0f, 0.0f), 0.0f );
+ scrollView.ScrollTo( Vector2(120.0f, 190.0f), 0.0f );
Wait(application);
- DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(120.0f, 190.0f, 0.0f), TEST_LOCATION );
+ DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(120.0f, 190.0f), TEST_LOCATION );
scrollView.ScrollToSnapPoint();
Wait(application, RENDER_DELAY_SCROLL);
- DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(100.0f, 200.0f, 0.0f), TEST_LOCATION );
+ DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 200.0f), TEST_LOCATION );
END_TEST;
}
scrollView.SetRulerY(rulerY);
scrollView.SetWrapMode(false);
- scrollView.ScrollTo(Vector3(225.0f, 125.0f, 0.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
+ scrollView.ScrollTo(Vector2(225.0f, 125.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
Wait(application);
DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 17, TEST_LOCATION );
scrollView.SetWrapMode(true);
b.SetPosition(bPosition);
// Goto a random position, and execute snap (should not move)
- Vector3 targetScroll = Vector3(500.0f, 500.0f, 0.0f);
+ Vector2 targetScroll = Vector2(500.0f, 500.0f);
scrollView.ScrollTo(targetScroll, 0.0f);
Wait(application);
scrollView.ScrollToSnapPoint();
scrollView.SetActorAutoSnap(true);
scrollView.ScrollToSnapPoint();
Wait(application, RENDER_DELAY_SCROLL);
- DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), bPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), bPosition.GetVectorXY(), TEST_LOCATION );
- scrollView.ScrollTo(Vector3(0.0f, 0.0f, 0.0f), 0.0f);
+ scrollView.ScrollTo(Vector2(0.0f, 0.0f), 0.0f);
Wait(application);
scrollView.ScrollToSnapPoint();
Wait(application, RENDER_DELAY_SCROLL);
- DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), aPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), aPosition.GetVectorXY(), TEST_LOCATION );
END_TEST;
}
scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
- scrollView.ScrollTo( Vector3(100.0f, 100.0f, 0.0f) );
+ scrollView.ScrollTo( Vector2(100.0f, 100.0f) );
Wait(application, RENDER_DELAY_SCROLL);
DALI_TEST_CHECK(gOnScrollStartCalled);
scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
// Normal
- scrollView.ScrollTo(Vector3(100.0f, 100.0f, 0.0f), 0.0f); // move in a little.
+ scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
Wait(application);
- Vector3 startPosition = scrollView.GetCurrentScrollPosition();
+ Vector2 startPosition = scrollView.GetCurrentScrollPosition();
PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
- const Vector3 positionAfterNormal = scrollView.GetCurrentScrollPosition();
+ const Vector2 positionAfterNormal = scrollView.GetCurrentScrollPosition();
// Autolock
scrollView.SetAxisAutoLock(true);
DALI_TEST_CHECK(scrollView.GetAxisAutoLock());
- scrollView.ScrollTo(Vector3(100.0f, 100.0f, 0.0f), 0.0f); // move in a little.
+ scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
Wait(application);
PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
- const Vector3 positionAfterAutoLock = scrollView.GetCurrentScrollPosition();
+ const Vector2 positionAfterAutoLock = scrollView.GetCurrentScrollPosition();
// compare how much the Y position has deviated for normal and autolock.
const float devianceNormal = fabsf(startPosition.y - positionAfterNormal.y);
currentPos = PerformGestureDiagonalSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, false);
float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
- Vector3 positionValue = scrollView.GetProperty<Vector3>(ScrollView::Property::SCROLL_POSITION);
+ Vector2 positionValue = scrollView.GetProperty<Vector2>(ScrollView::Property::SCROLL_POSITION);
DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
- DALI_TEST_EQUALS(positionValue, Vector3::ZERO, TEST_LOCATION);
+ DALI_TEST_EQUALS(positionValue, Vector2::ZERO, TEST_LOCATION);
float timeToReachOrigin;
SendPan(application, Gesture::Finished, currentPos);
timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
- float minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + Toolkit::ScrollView::DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / Toolkit::ScrollView::DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
- float maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + Toolkit::ScrollView::DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / Toolkit::ScrollView::DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
+ float minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
+ float maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
(timeToReachOrigin < maxTimeToReachOrigin) );
SendPan(application, Gesture::Finished, currentPos);
timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
- minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / Toolkit::ScrollView::DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
- maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / Toolkit::ScrollView::DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
+ minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
+ maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
(timeToReachOrigin < maxTimeToReachOrigin) );
SendPan(application, Gesture::Finished, currentPos);
timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
- minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / Toolkit::ScrollView::DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
- maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / Toolkit::ScrollView::DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
+ minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
+ maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
(timeToReachOrigin < maxTimeToReachOrigin) );
SendPan(application, Gesture::Finished, currentPos);
timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
- minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / Toolkit::ScrollView::DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
- maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / Toolkit::ScrollView::DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
+ minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
+ maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
(timeToReachOrigin < maxTimeToReachOrigin) );
*
* @param[in] position The current scroll position.
*/
-static void OnScrollStart( const Vector3& position )
+static void OnScrollStart( const Vector2& position )
{
gOnScrollStartCalled = true;
}
*
* @param[in] position The current scroll position.
*/
-static void OnScrollUpdate( const Vector3& position )
+static void OnScrollUpdate( const Vector2& position )
{
gOnScrollUpdateCalled = true;
}
*
* @param[in] position The current scroll position.
*/
-static void OnScrollComplete( const Vector3& position )
+static void OnScrollComplete( const Vector2& position )
{
gOnScrollCompleteCalled = true;
}
effect.ApplyToActor( actor, Vector2(1.2f, 1.2f) );
- scrollView.ScrollTo(Vector3(size.x, 0.0f, 0.0f), 0.5f, DirectionBiasNone, DirectionBiasNone);
+ scrollView.ScrollTo(Vector2(size.x, 0.0f), 0.5f, DirectionBiasNone, DirectionBiasNone);
while(!gOnScrollCompleteCalled)
{
Wait(application);
#include <dali-toolkit/public-api/controls/page-turn-view/page-turn-portrait-view.h>
#include <dali-toolkit/public-api/controls/popup/popup.h>
#include <dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h>
-#include <dali-toolkit/public-api/controls/scrollable/scroll-component.h>
-#include <dali-toolkit/public-api/controls/scrollable/scroll-component-impl.h>
-#include <dali-toolkit/public-api/controls/scrollable/scroll-connector.h>
#include <dali-toolkit/public-api/controls/scrollable/item-view/depth-layout.h>
#include <dali-toolkit/public-api/controls/scrollable/item-view/grid-layout.h>
#include <dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h>
// EXTERNAL INCLUDES
#include <cstring> // for strcmp
+#include <dali/integration-api/debug.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/animation/constraints.h>
#include <dali/public-api/object/type-registry.h>
const float DEFAULT_INDICATOR_FIXED_HEIGHT(80.0f);
/**
+ * Indicator size constraint
* Indicator size depends on both indicator's parent size and the scroll content size
*/
-Vector3 IndicatorSize( const Vector3& parentSize, float contentSize)
+struct IndicatorSizeConstraint
{
- float height = contentSize > parentSize.height ?
- parentSize.height * ( parentSize.height / contentSize ) :
- parentSize.height * ( (parentSize.height - contentSize * 0.5f) / parentSize.height);
- return Vector3( parentSize.width, std::max(MINIMUM_INDICATOR_HEIGHT, height), parentSize.depth );
-}
+ IndicatorSizeConstraint()
+ {
+ }
+
+ /**
+ * Constraint operator
+ * @param[in] current The current indicator size
+ * @param[in] parentSizeProperty The parent size of scroll indicator.
+ * @return The new scroll indicator size.
+ */
+ void operator()(Vector3& current, const PropertyInputContainer& inputs )
+ {
+ const Vector3& parentSize = inputs[0]->GetVector3();
+ const float contentSize = inputs[1]->GetFloat();
+
+ float height = contentSize > parentSize.height ?
+ parentSize.height * ( parentSize.height / contentSize ) :
+ parentSize.height * ( (parentSize.height - contentSize * 0.5f) / parentSize.height);
+
+ current.y = std::max(MINIMUM_INDICATOR_HEIGHT, height);
+ }
+};
/**
* Indicator position constraint
* @param[in] minPosition The minimum limit of scroll position
* @param[in] maxPosition the maximum limit of scroll position
*/
- IndicatorPositionConstraint(float minPosition, float maxPosition)
- : mMinPosition(minPosition),
- mMaxPosition(maxPosition)
+ IndicatorPositionConstraint()
{
}
{
const Vector3& indicatorSize = inputs[0]->GetVector3();
const Vector3& parentSize = inputs[1]->GetVector3();
- float scrollPosition = inputs[2]->GetFloat();
+ const float scrollPosition = -inputs[2]->GetFloat();
+ const float minScrollPosition = inputs[3]->GetFloat();
+ const float maxScrollPosition = inputs[4]->GetFloat();
- const float domainSize = fabs(mMaxPosition - mMinPosition);
- float relativePosition = (mMaxPosition - scrollPosition) / domainSize;
-
- current.y = relativePosition * ( parentSize.height - indicatorSize.height );
+ float relativePosition = std::max( 0.0f, std::min( 1.0f, (scrollPosition - minScrollPosition) / (maxScrollPosition - minScrollPosition) ) );
+ current.y = ( parentSize.height - indicatorSize.height ) * relativePosition;
current.z = DEFAULT_SLIDER_DEPTH;
}
-
- float mMinPosition; ///< The minimum scroll position
- float mMaxPosition; ///< The maximum scroll position
};
} // unnamed namespace
}
// Setup properties, signals and actions using the type-registry.
-DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ScrollBar, Toolkit::ScrollComponent, Create );
+DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ScrollBar, Toolkit::Control, Create );
-DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicator-height-policy", STRING, INDICATOR_HEIGHT_POLICY )
-DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicator-fixed-height", FLOAT, INDICATOR_FIXED_HEIGHT )
-DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicator-show-duration", FLOAT, INDICATOR_SHOW_DURATION )
-DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicator-hide-duration", FLOAT, INDICATOR_HIDE_DURATION )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "scroll-direction", STRING, SCROLL_DIRECTION )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicator-height-policy", STRING, INDICATOR_HEIGHT_POLICY )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicator-fixed-height", FLOAT, INDICATOR_FIXED_HEIGHT )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicator-show-duration", FLOAT, INDICATOR_SHOW_DURATION )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicator-hide-duration", FLOAT, INDICATOR_HIDE_DURATION )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "scroll-position-intervals", ARRAY, SCROLL_POSITION_INTERVALS )
-DALI_SIGNAL_REGISTRATION( Toolkit, ScrollBar, "scroll-position-notified", SCROLL_POSITION_NOTIFIED_SIGNAL )
+DALI_SIGNAL_REGISTRATION( Toolkit, ScrollBar, "pan-finished", PAN_FINISHED_SIGNAL )
+DALI_SIGNAL_REGISTRATION( Toolkit, ScrollBar, "scroll-position-interval-reached", SCROLL_POSITION_INTERVAL_REACHED_SIGNAL )
DALI_TYPE_REGISTRATION_END()
+const char* SCROLL_DIRECTION_NAME[] = {"Vertical", "Horizontal"};
const char* INDICATOR_HEIGHT_POLICY_NAME[] = {"Variable", "Fixed"};
}
-ScrollBar::ScrollBar()
-: mIndicatorShowDuration(DEFAULT_INDICATOR_SHOW_DURATION),
+ScrollBar::ScrollBar(Toolkit::ScrollBar::Direction direction)
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
+ mDirection(direction),
+ mScrollableObject(Handle()),
+ mPropertyScrollPosition(Property::INVALID_INDEX),
+ mPropertyMinScrollPosition(Property::INVALID_INDEX),
+ mPropertyMaxScrollPosition(Property::INVALID_INDEX),
+ mPropertyScrollContentSize(Property::INVALID_INDEX),
+ mIndicatorShowDuration(DEFAULT_INDICATOR_SHOW_DURATION),
mIndicatorHideDuration(DEFAULT_INDICATOR_HIDE_DURATION),
mScrollStart(0.0f),
mIsPanning(false),
mCurrentScrollPosition(0.0f),
mIndicatorHeightPolicy(Toolkit::ScrollBar::Variable),
- mIndicatorFixedHeight(DEFAULT_INDICATOR_FIXED_HEIGHT),
- mPropertyIndicatorPosition(Property::INVALID_INDEX)
+ mIndicatorFixedHeight(DEFAULT_INDICATOR_FIXED_HEIGHT)
{
}
void ScrollBar::OnInitialize()
{
- Actor self = Self();
-
- Image indicatorImage = ResourceImage::New( DEFAULT_INDICATOR_IMAGE_PATH );
- mIndicator = ImageActor::New( indicatorImage );
- mIndicator.SetNinePatchBorder( DEFAULT_INDICATOR_NINE_PATCH_BORDER );
- mIndicator.SetStyle( ImageActor::STYLE_NINE_PATCH );
- mIndicator.SetParentOrigin( ParentOrigin::TOP_LEFT );
- mIndicator.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- self.Add(mIndicator);
-
- self.SetDrawMode(DrawMode::OVERLAY);
-
- // Enable the pan gesture which is attached to the control
- EnableGestureDetection(Gesture::Type(Gesture::Pan));
+ CreateDefaultIndicatorActor();
}
-void ScrollBar::OnScrollConnectorSet( Toolkit::ScrollConnector oldConnector )
+void ScrollBar::SetScrollPropertySource( Handle handle, Property::Index propertyScrollPosition, Property::Index propertyMinScrollPosition, Property::Index propertyMaxScrollPosition, Property::Index propertyScrollContentSize )
{
- if( oldConnector )
+ if( handle
+ && propertyScrollPosition != Property::INVALID_INDEX
+ && propertyMinScrollPosition != Property::INVALID_INDEX
+ && propertyMaxScrollPosition != Property::INVALID_INDEX
+ && propertyScrollContentSize != Property::INVALID_INDEX )
{
- oldConnector.DomainChangedSignal().Disconnect(this, &ScrollBar::OnScrollDomainChanged);
+ mScrollableObject = handle;
+ mPropertyScrollPosition = propertyScrollPosition;
+ mPropertyMinScrollPosition = propertyMinScrollPosition;
+ mPropertyMaxScrollPosition = propertyMaxScrollPosition;
+ mPropertyScrollContentSize = propertyScrollContentSize;
- mScrollPositionObject.Reset();
+ ApplyConstraints();
}
-
- if( mScrollConnector )
+ else
{
- mScrollPositionObject = mScrollConnector.GetScrollPositionObject();
-
- ApplyConstraints();
- mScrollConnector.DomainChangedSignal().Connect(this, &ScrollBar::OnScrollDomainChanged);
+ DALI_LOG_ERROR("Can not set empty handle of source object or invalid source property index\n");
}
}
-void ScrollBar::SetIndicatorImage( Image image )
+void ScrollBar::CreateDefaultIndicatorActor()
+{
+ Image indicatorImage = ResourceImage::New( DEFAULT_INDICATOR_IMAGE_PATH );
+ ImageActor indicator = ImageActor::New( indicatorImage );
+ indicator.SetNinePatchBorder( DEFAULT_INDICATOR_NINE_PATCH_BORDER );
+ indicator.SetStyle( ImageActor::STYLE_NINE_PATCH );
+ indicator.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ indicator.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+
+ SetScrollIndicator(indicator);
+}
+
+void ScrollBar::SetScrollIndicator( Actor indicator )
{
- mIndicator.SetImage(image);
+ // Don't allow empty handle
+ if( indicator )
+ {
+ mIndicator = indicator;
+
+ Actor self = Self();
+ self.Add(mIndicator);
+ self.SetDrawMode(DrawMode::OVERLAY);
+
+ if( !mPanGestureDetector )
+ {
+ mPanGestureDetector = PanGestureDetector::New();
+ mPanGestureDetector.DetectedSignal().Connect(this, &ScrollBar::OnPan);
+ }
+
+ mPanGestureDetector.DetachAll();
+ mPanGestureDetector.Attach( mIndicator );
+
+ unsigned int childCount = mIndicator.GetChildCount();
+ for ( unsigned int index = 0; index < childCount; index++ )
+ {
+ Actor child = mIndicator.GetChildAt( index );
+ if ( child )
+ {
+ mPanGestureDetector.Attach( child );
+ }
+ }
+ }
+ else
+ {
+ DALI_LOG_ERROR("Empty handle of scroll indicator\n");
+ }
}
Actor ScrollBar::GetScrollIndicator()
void ScrollBar::ApplyConstraints()
{
- if( mScrollConnector )
+ if( mScrollableObject )
{
+ if(mIndicatorSizeConstraint)
+ {
+ mIndicatorSizeConstraint.Remove();
+ }
+
// Set indicator height according to the indicator's height policy
if(mIndicatorHeightPolicy == Toolkit::ScrollBar::Fixed)
{
}
else
{
- mIndicator.SetSize( IndicatorSize( Self().GetCurrentSize(), mScrollConnector.GetContentLength() ) );
+ mIndicatorSizeConstraint = Constraint::New<Vector3>( mIndicator, Actor::Property::SIZE, IndicatorSizeConstraint() );
+ mIndicatorSizeConstraint.AddSource( ParentSource( Actor::Property::SIZE ) );
+ mIndicatorSizeConstraint.AddSource( Source( mScrollableObject, mPropertyScrollContentSize ) );
+ mIndicatorSizeConstraint.Apply();
}
if(mIndicatorPositionConstraint)
mIndicatorPositionConstraint.Remove();
}
- mIndicatorPositionConstraint = Constraint::New<Vector3>( mIndicator, Actor::Property::POSITION, IndicatorPositionConstraint( mScrollConnector.GetMinLimit(), mScrollConnector.GetMaxLimit() ) );
+ mIndicatorPositionConstraint = Constraint::New<Vector3>( mIndicator, Actor::Property::POSITION, IndicatorPositionConstraint() );
mIndicatorPositionConstraint.AddSource( LocalSource( Actor::Property::SIZE ) );
mIndicatorPositionConstraint.AddSource( ParentSource( Actor::Property::SIZE ) );
- mIndicatorPositionConstraint.AddSource( Source( mScrollPositionObject, Toolkit::ScrollConnector::SCROLL_POSITION ) );
+ mIndicatorPositionConstraint.AddSource( Source( mScrollableObject, mPropertyScrollPosition ) );
+ mIndicatorPositionConstraint.AddSource( Source( mScrollableObject, mPropertyMinScrollPosition ) );
+ mIndicatorPositionConstraint.AddSource( Source( mScrollableObject, mPropertyMaxScrollPosition ) );
mIndicatorPositionConstraint.Apply();
}
}
-void ScrollBar::SetPositionNotifications( const Dali::Vector<float>& positions )
+void ScrollBar::SetScrollPositionIntervals( const Dali::Vector<float>& positions )
{
- if(mScrollPositionObject)
+ mScrollPositionIntervals = positions;
+
+ if( mScrollableObject )
{
- if(mPositionNotification)
+ if( mPositionNotification )
{
- mScrollPositionObject.RemovePropertyNotification(mPositionNotification);
+ mScrollableObject.RemovePropertyNotification(mPositionNotification);
}
- mPositionNotification = mScrollPositionObject.AddPropertyNotification( Toolkit::ScrollConnector::SCROLL_POSITION, VariableStepCondition(positions) );
- mPositionNotification.NotifySignal().Connect( this, &ScrollBar::OnScrollPositionNotified );
+
+ mPositionNotification = mScrollableObject.AddPropertyNotification( mPropertyScrollPosition, VariableStepCondition(mScrollPositionIntervals) );
+ mPositionNotification.NotifySignal().Connect( this, &ScrollBar::OnScrollPositionIntervalReached );
}
}
-void ScrollBar::OnScrollPositionNotified(PropertyNotification& source)
+Dali::Vector<float> ScrollBar::GetScrollPositionIntervals() const
{
- // Emit the signal to notify the scroll position crossing
- mScrollPositionNotifiedSignal.Emit(mScrollConnector.GetScrollPosition());
+ return mScrollPositionIntervals;
}
-void ScrollBar::Show()
+void ScrollBar::OnScrollPositionIntervalReached(PropertyNotification& source)
{
- Actor self = Self();
+ // Emit the signal to notify the scroll position crossing
+ if(mScrollableObject)
+ {
+ mScrollPositionIntervalReachedSignal.Emit(mScrollableObject.GetProperty<float>(mPropertyScrollPosition));
+ }
+}
+void ScrollBar::ShowIndicator()
+{
// Cancel any animation
if(mAnimation)
{
if(mIndicatorShowDuration > 0.0f)
{
mAnimation = Animation::New( mIndicatorShowDuration );
- mAnimation.AnimateTo( Property( self, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunction::EASE_IN );
+ mAnimation.AnimateTo( Property( mIndicator, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunction::EASE_IN );
mAnimation.Play();
}
else
{
- self.SetOpacity(1.0f);
+ mIndicator.SetOpacity(1.0f);
}
}
-void ScrollBar::Hide()
+void ScrollBar::HideIndicator()
{
- Actor self = Self();
-
// Cancel any animation
if(mAnimation)
{
if(mIndicatorHideDuration > 0.0f)
{
mAnimation = Animation::New( mIndicatorHideDuration );
- mAnimation.AnimateTo( Property( self, Actor::Property::COLOR_ALPHA ), 0.0f, AlphaFunction::EASE_IN );
+ mAnimation.AnimateTo( Property( mIndicator, Actor::Property::COLOR_ALPHA ), 0.0f, AlphaFunction::EASE_IN );
mAnimation.Play();
}
else
{
- self.SetOpacity(0.0f);
+ mIndicator.SetOpacity(0.0f);
}
}
bool ScrollBar::OnPanGestureProcessTick()
{
// Update the scroll position property.
- if( mScrollConnector )
+ if( mScrollableObject )
{
- mScrollConnector.SetScrollPosition(mCurrentScrollPosition);
+ mScrollableObject.SetProperty(mPropertyScrollPosition, mCurrentScrollPosition);
}
return true;
}
-void ScrollBar::OnPan( PanGesture gesture )
+void ScrollBar::OnPan( Actor source, const PanGesture& gesture )
{
- if(mScrollConnector)
+ if(mScrollableObject)
{
- Dali::Toolkit::ItemView itemView = Dali::Toolkit::ItemView::DownCast(Self().GetParent());
+ Dali::Toolkit::ItemView itemView = Dali::Toolkit::ItemView::DownCast(mScrollableObject);
switch(gesture.state)
{
case Gesture::Started:
{
- if( !mTimer )
+ if( !mPanProcessTimer )
{
// Make sure the pan gesture is only being processed once per frame.
- mTimer = Timer::New( DEFAULT_PAN_GESTURE_PROCESS_TIME );
- mTimer.TickSignal().Connect( this, &ScrollBar::OnPanGestureProcessTick );
- mTimer.Start();
+ mPanProcessTimer = Timer::New( DEFAULT_PAN_GESTURE_PROCESS_TIME );
+ mPanProcessTimer.TickSignal().Connect( this, &ScrollBar::OnPanGestureProcessTick );
+ mPanProcessTimer.Start();
}
- Show();
- mScrollStart = mScrollConnector.GetScrollPosition();
+ ShowIndicator();
+ mScrollStart = mScrollableObject.GetProperty<float>(mPropertyScrollPosition);
mGestureDisplacement = Vector3::ZERO;
mIsPanning = true;
mGestureDisplacement+=delta;
Vector3 span = Self().GetCurrentSize() - mIndicator.GetCurrentSize();
- const float domainSize = fabs(mScrollConnector.GetMaxLimit() - mScrollConnector.GetMinLimit());
+ float minScrollPosition = mScrollableObject.GetProperty<float>(mPropertyMinScrollPosition);
+ float maxScrollPosition = mScrollableObject.GetProperty<float>(mPropertyMaxScrollPosition);
+ float domainSize = maxScrollPosition - minScrollPosition;
+
mCurrentScrollPosition = mScrollStart - mGestureDisplacement.y * domainSize / span.y;
- mCurrentScrollPosition = std::min(mScrollConnector.GetMaxLimit(), std::max(mCurrentScrollPosition, mScrollConnector.GetMinLimit()));
+ mCurrentScrollPosition = 0.0f - std::min(maxScrollPosition, std::max(-mCurrentScrollPosition, minScrollPosition));
break;
}
{
mIsPanning = false;
- if( mTimer )
+ if( mPanProcessTimer )
{
// Destroy the timer when pan gesture is finished.
- mTimer.Stop();
- mTimer.TickSignal().Disconnect( this, &ScrollBar::OnPanGestureProcessTick );
- mTimer.Reset();
+ mPanProcessTimer.Stop();
+ mPanProcessTimer.TickSignal().Disconnect( this, &ScrollBar::OnPanGestureProcessTick );
+ mPanProcessTimer.Reset();
}
if(itemView)
GetImpl(itemView).DoRefresh(mCurrentScrollPosition, true);
}
+ mPanFinishedSignal.Emit();
+
break;
}
}
if(itemView)
{
// Disable automatic refresh in ItemView during fast scrolling
- GetImpl(itemView).SetRefreshEnabled(!mIsPanning);
+ GetImpl(itemView).SetRefreshEnabled(true);//!mIsPanning);
}
}
}
void ScrollBar::OnControlSizeSet( const Vector3& size )
{
- if(mIndicatorHeightPolicy != Toolkit::ScrollBar::Fixed && mScrollConnector)
+ if(mIndicatorHeightPolicy == Toolkit::ScrollBar::Fixed)
{
- mIndicator.SetSize( IndicatorSize( size, mScrollConnector.GetContentLength() ) );
+ mIndicator.SetSize(Self().GetCurrentSize().width, mIndicatorFixedHeight);
}
}
-void ScrollBar::OnScrollDomainChanged(float minPosition, float maxPosition, float contentSize)
+void ScrollBar::SetScrollDirection( Toolkit::ScrollBar::Direction direction )
{
- // Reapply constraints when the scroll domain is changed
- ApplyConstraints();
+ mDirection = direction;
+}
+
+Toolkit::ScrollBar::Direction ScrollBar::GetScrollDirection() const
+{
+ return mDirection;
}
void ScrollBar::SetIndicatorHeightPolicy( Toolkit::ScrollBar::IndicatorHeightPolicy policy )
ApplyConstraints();
}
-Toolkit::ScrollBar::IndicatorHeightPolicy ScrollBar::GetIndicatorHeightPolicy()
+Toolkit::ScrollBar::IndicatorHeightPolicy ScrollBar::GetIndicatorHeightPolicy() const
{
return mIndicatorHeightPolicy;
}
void ScrollBar::SetIndicatorFixedHeight( float height )
{
mIndicatorFixedHeight = height;
- ApplyConstraints();
+
+ if(mIndicatorHeightPolicy == Toolkit::ScrollBar::Fixed)
+ {
+ mIndicator.SetSize(Self().GetCurrentSize().width, mIndicatorFixedHeight);
+ }
}
-float ScrollBar::GetIndicatorFixedHeight()
+float ScrollBar::GetIndicatorFixedHeight() const
{
return mIndicatorFixedHeight;
}
mIndicatorShowDuration = durationSeconds;
}
-float ScrollBar::GetIndicatorShowDuration()
+float ScrollBar::GetIndicatorShowDuration() const
{
return mIndicatorShowDuration;
}
mIndicatorHideDuration = durationSeconds;
}
-float ScrollBar::GetIndicatorHideDuration()
+float ScrollBar::GetIndicatorHideDuration() const
{
return mIndicatorHideDuration;
}
+void ScrollBar::OnScrollDirectionPropertySet( Property::Value propertyValue )
+{
+ std::string directionName( propertyValue.Get<std::string>() );
+ if(directionName == "Vertical")
+ {
+ SetScrollDirection(Toolkit::ScrollBar::Vertical);
+ }
+ else if(directionName == "Horizontal")
+ {
+ SetScrollDirection(Toolkit::ScrollBar::Horizontal);
+ }
+ else
+ {
+ DALI_ASSERT_ALWAYS( !"ScrollBar::OnScrollDirectionPropertySet(). Invalid Property value." );
+ }
+}
+
void ScrollBar::OnIndicatorHeightPolicyPropertySet( Property::Value propertyValue )
{
std::string policyName( propertyValue.Get<std::string>() );
bool connected( true );
Toolkit::ScrollBar scrollBar = Toolkit::ScrollBar::DownCast( handle );
- if( 0 == strcmp( signalName.c_str(), SCROLL_POSITION_NOTIFIED_SIGNAL ) )
+ if( 0 == strcmp( signalName.c_str(), PAN_FINISHED_SIGNAL ) )
{
- scrollBar.ScrollPositionNotifiedSignal().Connect( tracker, functor );
+ scrollBar.PanFinishedSignal().Connect( tracker, functor );
+ }
+ else if( 0 == strcmp( signalName.c_str(), SCROLL_POSITION_INTERVAL_REACHED_SIGNAL ) )
+ {
+ scrollBar.ScrollPositionIntervalReachedSignal().Connect( tracker, functor );
}
else
{
ScrollBar& scrollBarImpl( GetImpl( scrollBar ) );
switch( index )
{
+ case Toolkit::ScrollBar::Property::SCROLL_DIRECTION:
+ {
+ scrollBarImpl.OnScrollDirectionPropertySet( value );
+ break;
+ }
case Toolkit::ScrollBar::Property::INDICATOR_HEIGHT_POLICY:
{
scrollBarImpl.OnIndicatorHeightPolicyPropertySet( value );
scrollBarImpl.SetIndicatorHideDuration(value.Get<float>());
break;
}
+ case Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS:
+ {
+ Property::Array propertyArray;
+ value.Get(propertyArray);
+
+ Dali::Vector<float> positions;
+ size_t positionCount = propertyArray.size();
+ positions.Resize( positionCount );
+
+ for( size_t i = 0; i != positionCount; ++i )
+ {
+ propertyArray[i].Get( positions[i]);
+ }
+
+ scrollBarImpl.SetScrollPositionIntervals(positions);
+ break;
+ }
}
}
}
ScrollBar& scrollBarImpl( GetImpl( scrollBar ) );
switch( index )
{
+ case Toolkit::ScrollBar::Property::SCROLL_DIRECTION:
+ {
+ value = SCROLL_DIRECTION_NAME[ scrollBarImpl.GetScrollDirection() ];
+ break;
+ }
case Toolkit::ScrollBar::Property::INDICATOR_HEIGHT_POLICY:
{
value = INDICATOR_HEIGHT_POLICY_NAME[ scrollBarImpl.GetIndicatorHeightPolicy() ];
value = scrollBarImpl.GetIndicatorHideDuration();
break;
}
+ case Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS:
+ {
+ Property::Value value;
+ Dali::Vector<float> positions = scrollBarImpl.GetScrollPositionIntervals();
+ size_t positionCount( positions.Size() );
+ for( size_t i( 0 ); i != positionCount; ++i )
+ {
+ value.AppendItem( positions[i] );
+ }
+ break;
+ }
}
}
return value;
}
-Toolkit::ScrollBar ScrollBar::New()
+Toolkit::ScrollBar ScrollBar::New(Toolkit::ScrollBar::Direction direction)
{
// Create the implementation, temporarily owned by this handle on stack
- IntrusivePtr< ScrollBar > impl = new ScrollBar();
+ IntrusivePtr< ScrollBar > impl = new ScrollBar(direction);
// Pass ownership to CustomActor handle
Toolkit::ScrollBar handle( *impl );
#include <dali/public-api/actors/image-actor.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/animation/animation.h>
+#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/object/property-notification.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/scrollable/scroll-component-impl.h>
-#include <dali-toolkit/public-api/controls/scrollable/scroll-connector.h>
+#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h>
namespace Dali
* 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 ScrollComponentImpl
+class ScrollBar : public Control
{
public:
// Signals
- typedef Toolkit::ScrollBar::ScrollPositionNotifiedSignalType ScrollPositionNotifiedSignalType;
+ typedef Toolkit::ScrollBar::PanFinishedSignalType PanFinishedSignalType;
+ typedef Toolkit::ScrollBar::ScrollPositionIntervalReachedSignalType ScrollPositionIntervalReachedSignalType;
public:
/**
- * @copydoc Toolkit::ScrollBar::ScrollBar()
+ * @copydoc Toolkit::ScrollBar::New()
*/
- ScrollBar();
+ static Toolkit::ScrollBar New(Toolkit::ScrollBar::Direction direction);
/**
- * @copydoc Toolkit::ScrollBar::~ScrollBar()
+ * @copydoc Toolkit::ScrollBar::SetScrollPropertySource()
*/
- virtual ~ScrollBar();
+ void SetScrollPropertySource( Handle handle, Property::Index propertyScrollPosition, Property::Index propertyMinScrollPosition, Property::Index propertyMaxScrollPosition, Property::Index propertyScrollContentSize );
/**
- * @copydoc Toolkit::ScrollBar::New()
+ * @copydoc Toolkit::ScrollBar::SetScrollIndicator()
*/
- static Toolkit::ScrollBar New();
+ void SetScrollIndicator( Actor indicator );
/**
- * @copydoc Toolkit::ScrollComponentImpl::OnScrollConnectorSet()
+ * @copydoc Toolkit::ScrollBar::GetScrollIndicator()
*/
- void OnScrollConnectorSet( Toolkit::ScrollConnector connector );
+ Actor GetScrollIndicator();
/**
- * @copydoc Toolkit::ScrollBar::SetIndicatorImage()
+ * @copydoc Toolkit::ScrollBar::SetScrollPositionIntervals()
*/
- void SetIndicatorImage( Image image );
+ void SetScrollPositionIntervals( const Dali::Vector<float>& positions );
/**
- * @copydoc Toolkit::ScrollBar::GetScrollIndicator()
+ * @copydoc Toolkit::ScrollBar::GetScrollPositionIntervals()
*/
- Actor GetScrollIndicator();
+ Dali::Vector<float> GetScrollPositionIntervals() const;
/**
- * @copydoc Toolkit::ScrollBar::SetPositionNotifications()
+ * @copydoc Toolkit::ScrollBar::SetScrollDirection()
*/
- void SetPositionNotifications( const Dali::Vector<float>& positions );
+ void SetScrollDirection( Toolkit::ScrollBar::Direction direction );
+
+ /**
+ * @copydoc Toolkit::ScrollBar::GetScrollDirection()
+ */
+ Toolkit::ScrollBar::Direction GetScrollDirection() const;
/**
* @copydoc Toolkit::ScrollBar::SetIndicatorHeightPolicy()
/**
* @copydoc Toolkit::ScrollBar::GetIndicatorHeightPolicy()
*/
- Toolkit::ScrollBar::IndicatorHeightPolicy GetIndicatorHeightPolicy();
+ Toolkit::ScrollBar::IndicatorHeightPolicy GetIndicatorHeightPolicy() const;
/**
* @copydoc Toolkit::ScrollBar::SetIndicatorFixedHeight()
/**
* @copydoc Toolkit::ScrollBar::GetIndicatorFixedHeight()
*/
- float GetIndicatorFixedHeight();
+ float GetIndicatorFixedHeight() const;
/**
* @copydoc Toolkit::ScrollBar::SetIndicatorShowDuration()
/**
* @copydoc Toolkit::ScrollBar::GetIndicatorShowDuration()
*/
- float GetIndicatorShowDuration();
+ float GetIndicatorShowDuration() const;
/**
* @copydoc Toolkit::ScrollBar::SetIndicatorHideDuration()
/**
* @copydoc Toolkit::ScrollBar::GetIndicatorHideDuration()
*/
- float GetIndicatorHideDuration();
+ float GetIndicatorHideDuration() const;
/**
- * @copydoc Toolkit::ScrollBar::Show()
+ * @copydoc Toolkit::ScrollBar::ShowIndicator()
*/
- void Show();
+ void ShowIndicator();
/**
- * @copydoc Toolkit::ScrollBar::Hide()
+ * @copydoc Toolkit::ScrollBar::HideIndicator()
*/
- void Hide();
+ void HideIndicator();
/**
- * Signal emitted after the SetScrollDomain() method has been called.
+ * @copydoc Toolkit::ScrollBar::PanFinishedSignal()
*/
- ScrollPositionNotifiedSignalType& ScrollPositionNotifiedSignal()
+ PanFinishedSignalType& PanFinishedSignal()
{
- return mScrollPositionNotifiedSignal;
+ return mPanFinishedSignal;
+ }
+
+ /**
+ * @copydoc Toolkit::ScrollBar::ScrollPositionIntervalReachedSignal()
+ */
+ ScrollPositionIntervalReachedSignalType& ScrollPositionIntervalReachedSignal()
+ {
+ return mScrollPositionIntervalReachedSignal;
}
/**
virtual void OnInitialize();
/**
- * @copydoc Toolkit::Control::OnPan
- */
- virtual void OnPan( PanGesture gesture );
-
- /**
* @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& size )
*/
virtual void OnControlSizeSet( const Vector3& size );
private:
/**
- * Apply constraints for background and indicator.
- * These constraints are based on values from the scroll connector.
+ * Create the default indicator actor.
*/
- void ApplyConstraints();
+ void CreateDefaultIndicatorActor();
/**
- * Callback when the start & end position and size of the scrollable content are changed.
- * @param[in] minPosition The minimum position.
- * @param[in] maxPosition The maximum position.
- * @param[in] contentSize The size of scrollable content.
+ * Apply constraints for background and indicator.
+ * These constraints are based on values from the scroll connector.
*/
- void OnScrollDomainChanged(float minPosition, float maxPosition, float contentSize);
+ void ApplyConstraints();
/**
* Callback when the current scroll position of the scrollable content goes above or
- * below the values specified by SetPositionNotifications().
+ * below the values specified by SetScrollPositionIntervals().
* @param[in] source the property notification that triggered this callback
*/
- void OnScrollPositionNotified(PropertyNotification& source);
+ void OnScrollPositionIntervalReached(PropertyNotification& source);
/**
* Process the pan gesture per predefined timeout until the gesture is finished.
bool OnPanGestureProcessTick();
/**
+ * Handle SetProperty for scroll direction.
+ * @param[in] propertyValue The new property value.
+ */
+ void OnScrollDirectionPropertySet(Property::Value propertyValue);
+
+ /**
* Handle SetProperty for scroll indicator height policy.
* @param[in] propertyValue The new property value.
*/
void OnIndicatorHeightPolicyPropertySet(Property::Value propertyValue);
+ /**
+ * Pan gesture callback
+ *
+ * @param[in] actor The actor the event is raised for
+ * @param[in] gesture The pan event info
+ */
+ void OnPan(Actor source, const PanGesture& gesture);
+
private:
- Handle mScrollPositionObject; ///< From mScrollConnector
+ /**
+ * Constructor.
+ * It initializes ScrollBar members.
+ */
+ ScrollBar( Toolkit::ScrollBar::Direction direction );
+
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~ScrollBar();
- ImageActor mIndicator; ///< Image of scroll indicator.
+private:
+
+ Actor mIndicator; ///< Image of scroll indicator.
Animation mAnimation; ///< Scroll indicator Show/Hide Animation.
+ Toolkit::ScrollBar::Direction mDirection; ///< The direction of scroll bar (vertical or horizontal)
+
+ Handle mScrollableObject; ///< Object to be scrolled
+
+ Property::Index mPropertyScrollPosition; ///< Index of scroll position property owned by the object to be scrolled
+ Property::Index mPropertyMinScrollPosition; ///< Index of minimum scroll position property owned by the object to be scrolled
+ Property::Index mPropertyMaxScrollPosition; ///< Index of maximum scroll position property owned by the object to be scrolled
+ Property::Index mPropertyScrollContentSize; ///< Index of scroll content size property owned by the object to be scrolled
+
float mIndicatorShowDuration; ///< The duration of scroll indicator show animation
float mIndicatorHideDuration; ///< The duration of scroll indicator hide animation
- float mScrollStart; ///< Scroll Start position (start of drag)
+ float mScrollStart; ///< Scroll Start position (start of drag)
Vector3 mGestureDisplacement; ///< Gesture Displacement.
bool mIsPanning; ///< Whether the scroll bar is being panned.
Toolkit::ScrollBar::IndicatorHeightPolicy mIndicatorHeightPolicy; ///< The height policy of scroll indicator (variable or fixed)
float mIndicatorFixedHeight; ///< The fixed height of scroll indicator
- Timer mTimer; ///< The timer to process the pan gesture after the gesture is started.
+ PanGestureDetector mPanGestureDetector; ///< The pan gesture detector for scroll indicator
- Property::Index mPropertyIndicatorPosition; ///< Indicatore Position ("indicator-position")
+ Timer mContractDelayTimer; ///< Timer guarantee contract delay time.
+ Timer mPanProcessTimer; ///< The timer to process the pan gesture after the gesture is started.
+ Dali::Vector<float> mScrollPositionIntervals; ///< List of values to receive notification for when the current scroll position goes above or below them
PropertyNotification mPositionNotification; ///< Stores the property notification used for scroll position changes
- ScrollPositionNotifiedSignalType mScrollPositionNotifiedSignal;
+ PanFinishedSignalType mPanFinishedSignal;
+ ScrollPositionIntervalReachedSignalType mScrollPositionIntervalReachedSignal;
Constraint mIndicatorPositionConstraint;
+ Constraint mIndicatorSizeConstraint;
+ Constraint mScrollPositionInCurrentAxisConstraint;
};
} // namespace Internal
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- *
- */
-
-// CLASS HEADER
-#include <dali-toolkit/internal/controls/scroll-component/scroll-bar-internal-impl.h>
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/animation/constraint.h>
-#include <dali/public-api/object/property-input.h>
-#include <dali/public-api/object/type-registry.h>
-#include <dali/public-api/object/type-registry-helper.h>
-#include <dali/public-api/images/resource-image.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/enums.h>
-
-using namespace Dali;
-
-namespace
-{
-/**
- * Squares input value
- * i.e. y = x*x
- * @param[in] x Input value to be squared
- * @return Result (x*x)
- */
-template<typename T>
-inline T Square(T x)
-{
- return x*x;
-}
-
-const char* BAR_TAB_IMAGE_PATH = DALI_IMAGE_DIR "popup_scroll.png";
-const Vector4 BAR_TAB_NINE_PATCH_BORDER(0.0f, 12.0f, 14.0f, 14.0f);
-const Vector3 BAR_TAB_SIZE(18.0f, 72.0f, 0.0f);
-const Vector3 BAR_TAB_OFFSET_V(-18.0f, 0.0f, 0.1f);
-const Vector3 BAR_TAB_OFFSET_H(0.0f, -18.0f, 0.1f);
-const float BAR_CONTRACT_DELAY(0.8f);
-const float BAR_SHOW_TIME(0.4f);
-const float BAR_HIDE_TIME(0.5f);
-const int SECOND_UNIT(1000);
-
-/**
- * ScrollBarInternal Visibility Constraint
- * Returns whether scroll bar is visible
- */
-void ScrollBarInternalVisibilityConstraint( bool& current, const PropertyInputContainer& inputs )
-{
- current = inputs[0]->GetBoolean();
-}
-
-/**
- * ScrollBarInternal Size Constraint
- * Resize ScrollBarInternal Size depends on both ScrollSize and DomainSize
- */
-struct ScrollBarInternalSizeConstraint
-{
- /**
- * @param[in] vertical Whether this constraint controls a vertical scrollbar (true)
- * or a horizontal one (false)
- */
- ScrollBarInternalSizeConstraint(bool vertical)
- : mVertical(vertical)
- {
- }
-
- /**
- * Constraint operator
- * @param[in,out] current The current ScrollBarInternal size
- * @param[in] inputs Contains the container's minimum position, its maximum position, its scroll direction & its size of viewport.
- * @return The new ScrollBarInternal position is returned.
- */
- void operator()( Vector3& current, const PropertyInputContainer& inputs )
- {
- const Vector3& min = inputs[0]->GetVector3();
- const Vector3& max = inputs[1]->GetVector3();
- const Vector3& scrollDirection = inputs[2]->GetVector3();
- const Toolkit::ControlOrientation::Type& orientation = static_cast<Toolkit::ControlOrientation::Type>(scrollDirection.z);
- const Vector3& size = inputs[3]->GetVector3();
- const Vector3 domainSize = max - min;
-
- if (mVertical && Toolkit::IsVertical(orientation))
- {
- current.height = fabsf(domainSize.height) > size.height ? size.height * ( size.height / fabsf(domainSize.height) ) : size.height * ( (size.height - fabsf(domainSize.height * 0.5f)) / size.height);
- }
- else
- {
- current.height = fabsf(domainSize.height) > size.width ? size.width * ( size.width / fabsf(domainSize.height) ) : size.width * ( (size.width - fabsf(domainSize.height * 0.5f)) / size.width);
- }
- }
-
- bool mVertical; ///< Whether vertical or horizontal
-};
-
-/**
- * ScrollBarInternal rotation Constraint
- * Rotate ScrollBarInternal depends on the scroll direction
- */
-struct ScrollBarInternalRotationConstraint
-{
- /**
- * @param[in] vertical Whether this constraint controls a vertical scrollbar (true)
- * or a horizontal one (false)
- */
- ScrollBarInternalRotationConstraint(bool vertical)
- : mVertical(vertical)
- {
- }
-
- /**
- * Constraint operator
- * @param[in,out] current The current ScrollBarInternal rotation
- * @param[in] scrollDirectionProperty The container's scroll direction.
- * @return The new ScrollBarInternal rotation is returned.
- */
- void operator()( Quaternion& current, const PropertyInputContainer& inputs )
- {
- const Vector3& scrollDirection = inputs[0]->GetVector3();
- const Toolkit::ControlOrientation::Type& orientation = static_cast<Toolkit::ControlOrientation::Type>(scrollDirection.z);
-
- if( (mVertical && Toolkit::IsVertical(orientation)) || (!mVertical && Toolkit::IsHorizontal(orientation)) )
- {
- current = Quaternion( Radian( 0.0f ), Vector3::ZAXIS );
- }
- else
- {
- current = Quaternion( Radian( 0.5f * Math::PI ), Vector3::ZAXIS);
- }
- }
-
- bool mVertical; ///< Whether vertical or horizontal
-};
-
-/**
- * ScrollBarInternal Position Constraint
- * Positions the scroll bar to reflect the current scroll position
- * within the domain.
- */
-struct ScrollBarInternalPositionConstraint
-{
- /**
- * @param[in] vertical Whether this constraint controls a vertical scrollbar (true)
- * or a horizontal one (false)
- * @param[in] wrap Whether to base scrollbar on original position or wrapped position
- */
- ScrollBarInternalPositionConstraint(bool vertical, bool wrap = false)
- : mVertical(vertical),
- mWrap(wrap)
- {
- }
-
- /**
- * Constraint operator
- * @param[in] finalPosition The current ScrollBarInternal position
- * @param[in] inputs Contains:
- * The ScrollBarInternal size,
- * The container's relative position (from 0.0 -> 1.0 in each axis),
- * The container's minimum position,
- * The container's maximum position,
- * The container's scroll direction,
- * The container's size of viewport.
- * @return The new ScrollBarInternal position is returned.
- */
- void operator()( Vector3& finalPosition, const PropertyInputContainer& inputs )
- {
- const Vector3& barSize = inputs[0]->GetVector3();
- const Vector3& relativePosition = inputs[1]->GetVector3();
- const Vector3& min = inputs[2]->GetVector3();
- const Vector3& max = inputs[3]->GetVector3();
- const Vector3& scrollDirection = inputs[4]->GetVector3();
- const Vector3& size = inputs[5]->GetVector3();
- const Toolkit::ControlOrientation::Type& orientation = static_cast<Toolkit::ControlOrientation::Type>(scrollDirection.z);
-
- Vector3 domainSize = max - min;
- domainSize.x = fabsf(domainSize.x);
- domainSize.y = fabsf(domainSize.y);
- domainSize -= size;
-
- Vector3 mask; // Mask movement aspect of scroll bar
- Vector3 relativeOffset; // base position of scroll bar in relation to the container
- Vector3 absoluteOffset; // absolute offset position of scroll bar
-
- if(mVertical)
- {
- switch(orientation)
- {
- case Toolkit::ControlOrientation::Up:
- {
- mask = Vector3::YAXIS;
- relativeOffset = (scrollDirection.y < 0.0f && relativePosition.y <= 0.0f) ? Vector3(1.0f, 1.0f, 0.0f) : Vector3(1.0f, 0.0f, 0.0f); // Right side of stage.
- absoluteOffset = (scrollDirection.y < 0.0f && relativePosition.y <= 0.0f) ? BAR_TAB_OFFSET_V + Vector3( barSize.width * 0.5f, -barSize.height * 0.5f, 1.0f ) : BAR_TAB_OFFSET_V + Vector3( barSize.width * 0.5f, barSize.height * 0.5f, 1.0f );
- break;
- }
- case Toolkit::ControlOrientation::Left:
- {
- mask = Vector3::XAXIS;
- relativeOffset = (scrollDirection.x <= 0.0f && relativePosition.y <= 0.0f) ? Vector3(1.0f, 0.0f, 0.0f) : Vector3(0.0f, 0.0f, 0.0f); // Bottom side of stage.
- absoluteOffset = (scrollDirection.x <= 0.0f && relativePosition.y <= 0.0f) ? Vector3( -barSize.height * 0.5f, barSize.width * 0.5f, 1.0f ) : Vector3( barSize.height * 0.5f, barSize.width * 0.5f, 1.0f );
- break;
- }
- case Toolkit::ControlOrientation::Down:
- {
- mask = Vector3::YAXIS;
- relativeOffset = (scrollDirection.y <= 0.0f && relativePosition.y <= 0.0f) ? Vector3(0.0f, 1.0f, 0.0f) : Vector3(0.0f, 0.0f, 0.0f); // Left side of stage.
- absoluteOffset = (scrollDirection.y <= 0.0f && relativePosition.y <= 0.0f) ? Vector3( barSize.width * 0.5f, -barSize.height * 0.5f, 1.0f ) : Vector3( barSize.width * 0.5f, barSize.height * 0.5f, 1.0f );
- break;
- }
- case Toolkit::ControlOrientation::Right:
- {
- mask = Vector3::XAXIS;
- relativeOffset = (scrollDirection.x <= 0.0f && relativePosition.y <= 0.0f) ? Vector3(1.0f, 1.0f, 0.0f) : Vector3(0.0f, 1.0f, 0.0f); // Up side of stage.
- absoluteOffset = (scrollDirection.x <= 0.0f && relativePosition.y <= 0.0f) ? Vector3( -barSize.height * 0.5f, -barSize.width * 0.5f, 1.0f ) : Vector3( barSize.height * 0.5f, -barSize.width * 0.5f, 1.0f );
- break;
- }
- }
- }
- else
- {
- mask = Vector3::XAXIS;
- relativeOffset = Vector3(0.0f, 1.0f, 0.0f); // Bottom side of stage.
- absoluteOffset = BAR_TAB_OFFSET_H + Vector3( barSize.height * 0.5f, barSize.width * 0.5f, 1.0f );
- }
-
- Vector3 maskedRelativePosition = Toolkit::IsVertical(orientation) ? Vector3(relativePosition.x * (size.x-barSize.y), relativePosition.y * (size.y-barSize.y), 0.0f) * mask
- : Vector3(relativePosition.y * (size.x-barSize.y), relativePosition.x * (size.y-barSize.y), 0.0f) * mask;
-
- finalPosition = relativeOffset * size + absoluteOffset + maskedRelativePosition;
-
- // If Wrapped Slider, then position 1 domain either before or after current slider.
- if(mWrap)
- {
- if(finalPosition.x < 0.5f)
- {
- finalPosition.x += size.x;
- }
- else
- {
- finalPosition.x -= size.x;
- }
-
- if(finalPosition.y < 0.5f)
- {
- finalPosition.y += size.y;
- }
- else
- {
- finalPosition.y -= size.y;
- }
- }
- }
-
- bool mVertical; ///< Whether vertical or horizontal.
- bool mWrap; ///< Whether to wrap this position.
-};
-
-/**
- * ScrollBarInternal HitSize Constraint
- * Resizes HitArea to size of the container.
- */
-struct ScrollBarInternalHitSizeConstraint
-{
- /**
- * @param[in] vertical Whether this constraint controls a vertical scrollbar (true)
- * or a horizontal one (false)
- * @param[in] thickness The thickness of the scrollbar
- */
- ScrollBarInternalHitSizeConstraint(bool vertical,
- float thickness)
- : mVertical(vertical),
- mThickness(thickness)
- {
- }
-
- /**
- * Constraint operator
- * @param[in] current The current HitSize
- * @param[in] inputs Contains the container's scroll direction and size of its viewport.
- * @return The new ScrollBarInternal Hit Area size is returned.
- */
- void operator()( Vector3& current, const PropertyInputContainer& inputs )
- {
- const Vector3& scrollDirection = inputs[0]->GetVector3();
- const Toolkit::ControlOrientation::Type& orientation = static_cast<Toolkit::ControlOrientation::Type>(scrollDirection.z);
- const Vector3& size = inputs[1]->GetVector3();
-
- Vector3 mask; // Mask size aspect of hit area.
- Vector3 offset; // Add Offset size.
-
- if( (mVertical && Toolkit::IsVertical(orientation)) || (!mVertical && Toolkit::IsHorizontal(orientation)) )
- {
- mask = Vector3::YAXIS;
- offset = Vector3::XAXIS * mThickness;
- }
- else
- {
- mask = Vector3::XAXIS;
- offset = Vector3::YAXIS * mThickness;
- }
-
- current = size * mask + offset;
- }
-
- bool mVertical; ///< Whether vertical or horizontal.
- float mThickness; ///< Thickness of the scroll bar
-};
-
-} // unnamed namespace
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-namespace
-{
-
-using namespace Dali;
-
-BaseHandle Create()
-{
- return BaseHandle();
-}
-
-DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ScrollBarInternal, Toolkit::ScrollComponent, Create )
-DALI_TYPE_REGISTRATION_END()
-
-}
-
-ScrollBarInternal::ScrollBarInternal(Toolkit::Scrollable& container, bool vertical)
-: mContainer(static_cast<Toolkit::Internal::Scrollable&>(container.GetImplementation())),
- mVertical(vertical),
- mAxisMask(vertical ? Vector3::YAXIS : Vector3::XAXIS),
- mDragMode(false)
-{
- Image sliderImage = ResourceImage::New( BAR_TAB_IMAGE_PATH );
-
- mSlider = ImageActor::New( sliderImage );
- mSlider.SetParentOrigin( ParentOrigin::TOP_LEFT );
- mSlider.SetAnchorPoint( AnchorPoint::CENTER );
- mSlider.SetSize( BAR_TAB_SIZE );
- mSlider.SetStyle( ImageActor::STYLE_NINE_PATCH );
- mSlider.SetNinePatchBorder( BAR_TAB_NINE_PATCH_BORDER );
-
- // A duplicate Slider should appear 1 domain away from the original Slider
- mSliderWrap = ImageActor::New( sliderImage );
- mSliderWrap.SetParentOrigin( ParentOrigin::TOP_LEFT );
- mSliderWrap.SetAnchorPoint( AnchorPoint::CENTER );
- mSliderWrap.SetSize( BAR_TAB_SIZE );
- mSliderWrap.SetStyle( ImageActor::STYLE_NINE_PATCH );
- mSliderWrap.SetNinePatchBorder( BAR_TAB_NINE_PATCH_BORDER );
-
- // target the container to observe for scrolling
- Actor target = mContainer.Self();
- Constraint constraint = Constraint::New<bool>( mSlider, Actor::Property::VISIBLE, ScrollBarInternalVisibilityConstraint );
- constraint.AddSource( Source( target, vertical ? Toolkit::Scrollable::Property::CAN_SCROLL_VERTICAL : Toolkit::Scrollable::Property::CAN_SCROLL_HORIZONTAL ) );
- constraint.Apply();
-
- constraint = constraint.Clone( mSliderWrap );
- constraint.Apply();
-
- constraint = Constraint::New<Vector3>( mSlider, Actor::Property::SIZE, ScrollBarInternalSizeConstraint( vertical ) );
- constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
- constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
- constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_DIRECTION ) );
- constraint.AddSource( Source( target, Actor::Property::SIZE ) );
- constraint.Apply();
-
- constraint = constraint.Clone( mSliderWrap );
- constraint.Apply();
-
- constraint = Constraint::New<Quaternion>( mSlider, Actor::Property::ORIENTATION, ScrollBarInternalRotationConstraint( vertical ) );
- constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_DIRECTION ) );
- constraint.Apply();
-
- constraint = constraint.Clone( mSliderWrap );
- constraint.Apply();
-
- constraint = Constraint::New<Vector3>( mSlider, Actor::Property::POSITION, ScrollBarInternalPositionConstraint(vertical) );
- constraint.AddSource( Source( mSlider, Actor::Property::SIZE) );
- constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_RELATIVE_POSITION ) );
- constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
- constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
- constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_DIRECTION ) );
- constraint.AddSource( Source( target, Actor::Property::SIZE ) );
- constraint.Apply();
-
- constraint = Constraint::New<Vector3>( mSliderWrap, Actor::Property::POSITION, ScrollBarInternalPositionConstraint(vertical, true) );
- constraint.AddSource( Source( mSlider, Actor::Property::SIZE) );
- constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_RELATIVE_POSITION ) );
- constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
- constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
- constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_DIRECTION ) );
- constraint.AddSource( Source( target, Actor::Property::SIZE ) );
- constraint.Apply();
-
- // Add Sliders to internal Actor, to avoid mixing up with regular
- // Actors added by user.
- mContainer.AddOverlay( mSlider );
- mContainer.AddOverlay( mSliderWrap );
- mContainer.ScrollStartedSignal().Connect( this, &ScrollBarInternal::OnStarted );
- mContainer.ScrollCompletedSignal().Connect( this, &ScrollBarInternal::OnCompleted );
-
- // Hit Area for dragging slider /////////////////////////////////////////////
- mHitArea = Actor::New();
- mHitArea.SetPosition(0.0f, 0.0f, 0.2f);
-
- mContainer.AddOverlay( mHitArea );
- constraint = Constraint::New<Vector3>( mHitArea, Actor::Property::SIZE, ScrollBarInternalHitSizeConstraint(vertical, BAR_TAB_SIZE.width) );
- constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_DIRECTION ) );
- constraint.AddSource( Source( target, Actor::Property::SIZE ) );
- constraint.Apply();
-
- if(vertical)
- {
- mHitArea.SetParentOrigin(ParentOrigin::CENTER_RIGHT);
- mHitArea.SetAnchorPoint(AnchorPoint::CENTER_RIGHT);
- }
- else
- {
- mHitArea.SetParentOrigin(ParentOrigin::BOTTOM_CENTER);
- mHitArea.SetAnchorPoint(AnchorPoint::BOTTOM_CENTER);
- }
-
- WaitingContractDelay();
-}
-
-ScrollBarInternal::~ScrollBarInternal()
-{
- DestructTimer();
-}
-
-void ScrollBarInternal::OnInitialize()
-{
- EnableGestureDetection(Gesture::Type(Gesture::Pan));
-}
-
-void ScrollBarInternal::OnDisconnect()
-{
- // Disconnect all connected callback functions.
- mContainer.RemoveOverlay( mSlider );
- mContainer.RemoveOverlay( mSliderWrap );
-}
-
-void ScrollBarInternal::OnPanGesture(Actor actor, PanGesture gesture)
-{
- switch(gesture.state)
- {
- case Gesture::Started:
- {
- mDragMode = true;
- Show();
- mScrollStart = mContainer.GetCurrentScrollPosition();
- mGestureDisplacement = Vector3::ZERO;
- break;
- }
- case Gesture::Continuing:
- {
- Vector3 delta(gesture.displacement.x, gesture.displacement.y, 0.0f);
- mGestureDisplacement+=delta;
-
- Vector3 size = mContainer.Self().GetCurrentSize();
- Vector3 span = size - Vector3(BAR_TAB_SIZE.y, BAR_TAB_SIZE.y, 1.0f);
- Vector3 domainSize = mContainer.GetDomainSize();
-
- Vector3 position = mScrollStart + mGestureDisplacement * mAxisMask * domainSize / span;
- mContainer.ScrollTo(position, 0.0f);
- break;
- }
- default:
- {
- mDragMode = false;
- break;
- }
- }
-}
-
-void ScrollBarInternal::OnStarted(const Vector3& position)
-{
- // TODO: Need to disable this for the scrollbar which isn't being scrolled.
- if(!mDragMode)
- {
- mDragMode = true;
- Show();
- }
-}
-
-void ScrollBarInternal::OnCompleted(const Vector3& position)
-{
- if( mDragMode )
- {
- mDragMode = false;
-
- WaitingContractDelay();
- }
-}
-
-bool ScrollBarInternal::OnContractDelayExpired()
-{
- if ( !mDragMode )
- {
- Hide();
- }
-
- DestructTimer();
-
- return true;
-}
-
-void ScrollBarInternal::Show()
-{
- // Cancel any animation
- if(mAnimation)
- {
- mAnimation.Clear();
- mAnimation.Reset();
- }
-
- mAnimation = Animation::New( BAR_SHOW_TIME );
- mAnimation.AnimateTo( Property( mSlider, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunction::EASE_IN );
- mAnimation.AnimateTo( Property( mSliderWrap, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunction::EASE_IN );
- mAnimation.Play();
-
- DestructTimer();
-}
-
-void ScrollBarInternal::Hide()
-{
- // Cancel any animation
- if(mAnimation)
- {
- mAnimation.Clear();
- mAnimation.Reset();
- }
-
- mAnimation = Animation::New( BAR_HIDE_TIME );
- mAnimation.AnimateTo( Property( mSlider, Actor::Property::COLOR_ALPHA ), 0.0f, AlphaFunction::EASE_IN );
- mAnimation.AnimateTo( Property( mSliderWrap, Actor::Property::COLOR_ALPHA ), 0.0f, AlphaFunction::EASE_IN );
- mAnimation.Play();
-}
-
-void ScrollBarInternal::CreateTimer()
-{
- if( !mTimer )
- {
- // Create timer for contract delay
- mTimer = Timer::New( BAR_CONTRACT_DELAY * SECOND_UNIT );
- mTimer.TickSignal().Connect( this, &ScrollBarInternal::OnContractDelayExpired );
- }
-}
-
-void ScrollBarInternal::DestructTimer()
-{
- if( mTimer )
- {
- mTimer.Stop();
- mTimer.TickSignal().Disconnect( this, &ScrollBarInternal::OnContractDelayExpired );
- mTimer.Reset();
- }
-}
-
-void ScrollBarInternal::WaitingContractDelay()
-{
- CreateTimer();
- mTimer.Start();
-}
-
-Toolkit::ScrollBarInternal ScrollBarInternal::New(Toolkit::Scrollable& container, bool vertical)
-{
- // Create the implementation, temporarily owned by this handle on stack
- IntrusivePtr< ScrollBarInternal > impl = new ScrollBarInternal( container, vertical );
-
- // Pass ownership to CustomActor handle
- Toolkit::ScrollBarInternal handle( *impl );
-
- // Second-phase init of the implementation
- // This can only be done after the CustomActor connection has been made...
- impl->Initialize();
-
- return handle;
-}
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_TOOLKIT_INTERNAL_SCROLL_BAR_INTERNAL_H__
-#define __DALI_TOOLKIT_INTERNAL_SCROLL_BAR_INTERNAL_H__
-
-/*
- * Copyright (c) 2014 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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/timer.h>
-#include <dali/public-api/actors/image-actor.h>
-#include <dali/public-api/animation/animation.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/scrollable/scroll-component-impl.h>
-#include <dali-toolkit/internal/controls/scrollable/scrollable-impl.h>
-#include <dali-toolkit/internal/controls/scroll-component/scroll-bar-internal.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-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 ScrollComponentImpl
-{
-
-public:
-
- /**
- * ScrollBarInternal constructor.
- * @param[in] container Reference to the container of scroll bar
- * @param[in] vertical Whether ScrollBarInternal should be oriented vertically (true)
- * or horizontally (false)
- */
- ScrollBarInternal(Toolkit::Scrollable& container, bool vertical);
-
- /**
- * Virtual destructor
- */
- virtual ~ScrollBarInternal();
-
- /**
- * Create an initialized ScrollBarInternal
- * @param[in] container Reference to the container of scroll bar
- * @param[in] vertical Whether ScrollBarInternal should be oriented vertically (true)
- * or horizontally (false)
- * @return A pointer to the created ScrollBarInternal.
- */
- static Toolkit::ScrollBarInternal New(Toolkit::Scrollable& container, bool vertical);
-
- /**
- * Show ScrollBarInternal
- */
- void Show();
-
- /**
- * Hide ScrollBarInternal
- */
- void Hide();
-
-private:
-
- /**
- * @copydoc Toolkit::Control::OnInitialize()
- */
- virtual void OnInitialize();
-
- /**
- * @copydoc Toolkit::ScrollComponent::OnDisconnect()
- */
- virtual void OnDisconnect();
-
- /**
- * Called when scrollbar is dragged.
- * @param[in] actor Actor under touch
- * @param[in] gesture The pan gesture data.
- */
- void OnPanGesture(Actor actor, PanGesture gesture);
-
- /**
- * Called when scrolling starts (scroll bars should extend out)
- * @param[in] position current scroll position.
- */
- void OnStarted(const Vector3& position);
-
- /**
- * Called when scrolling ends (scroll bars should contract)
- * @param[in] position current scroll position.
- */
- void OnCompleted(const Vector3& position);
-
- /**
- * Called when timer is finished. This time guarantee contract animation time.
- * @return Timer is used or not.
- */
- bool OnContractDelayExpired(void);
-
- /**
- * Create timer. This timer used for wating contract.
- */
- void CreateTimer();
-
- /**
- * Destruct timer.
- */
- void DestructTimer();
-
- /**
- * Wait ContractTime
- */
- void WaitingContractDelay();
-
-private:
- Scrollable& mContainer; ///< Container of scroll bar
- ImageActor mSlider; ///< Scroll Slider.
- ImageActor mSliderWrap; ///< Scroll Slider (wrapped view).
- Actor mHitArea; ///< Hit Area for dragging scroll slider.
- PanGestureDetector mPanGesture; ///< Pan Gesture detector for dragging scrollbar.
- Animation mAnimation; ///< Scroll Contract/Expand Animation.
- bool mVertical; ///< Scroll Axis (Vertical or Horizontal)
- Vector3 mAxisMask; ///< Scroll Axis mask (Vector3::YAXIS for vert. or Vector3::XAXIS for horiz.)
- Vector3 mScrollStart; ///< Scroll Start position (start of drag)
- Vector3 mGestureDisplacement; ///< Gesture Displacement.
- bool mDragMode; ///< Flag indicating whether currently dragging or not.
- Timer mTimer; ///< Timer guarantee contract delay time.
-};
-
-} // namespace Internal
-
-// Helpers for public-api forwarding methods
-
-inline Toolkit::Internal::ScrollBarInternal& GetImpl(Toolkit::ScrollBarInternal& scrollBar)
-{
- DALI_ASSERT_ALWAYS(scrollBar);
-
- Dali::RefObject& handle = scrollBar.GetImplementation();
-
- return static_cast<Toolkit::Internal::ScrollBarInternal&>(handle);
-}
-
-inline const Toolkit::Internal::ScrollBarInternal& GetImpl(const Toolkit::ScrollBarInternal& scrollBar)
-{
- DALI_ASSERT_ALWAYS(scrollBar);
-
- const Dali::RefObject& handle = scrollBar.GetImplementation();
-
- return static_cast<const Toolkit::Internal::ScrollBarInternal&>(handle);
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_INTERNAL_SCROLL_BAR_INTERNAL_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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 <dali-toolkit/internal/controls/scroll-component/scroll-bar-internal.h>
-#include <dali-toolkit/internal/controls/scroll-component/scroll-bar-internal-impl.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-ScrollBarInternal::ScrollBarInternal()
-{
-}
-
-ScrollBarInternal::ScrollBarInternal(Internal::ScrollBarInternal& implementation)
-: ScrollComponent(implementation)
-{
-}
-
-ScrollBarInternal::ScrollBarInternal( Dali::Internal::CustomActor* internal )
-: ScrollComponent( internal )
-{
- VerifyCustomActorPointer<Internal::ScrollBarInternal>(internal);
-}
-
-ScrollBarInternal::ScrollBarInternal( const ScrollBarInternal& scrollBar )
-: ScrollComponent(scrollBar)
-{
-}
-
-ScrollBarInternal& ScrollBarInternal::operator=( const ScrollBarInternal& scrollBar )
-{
- if( &scrollBar != this )
- {
- Control::operator=( scrollBar );
- }
- return *this;
-}
-
-ScrollBarInternal ScrollBarInternal::New(Scrollable& container, bool vertical)
-{
- return Internal::ScrollBarInternal::New(container, vertical);
-}
-
-ScrollBarInternal ScrollBarInternal::DownCast( BaseHandle handle )
-{
- return Control::DownCast<ScrollBarInternal, Internal::ScrollBarInternal>(handle);
-}
-
-ScrollBarInternal::~ScrollBarInternal()
-{
-}
-
-void ScrollBarInternal::Show()
-{
- GetImpl(*this).Show();
-}
-
-void ScrollBarInternal::Hide()
-{
- GetImpl(*this).Hide();
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_TOOLKIT_SCROLL_BAR_INTERNAL_H__
-#define __DALI_TOOLKIT_SCROLL_BAR_INTERNAL_H__
-
-/*
- * Copyright (c) 2014 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 <dali-toolkit/public-api/controls/scrollable/scroll-component.h>
-#include <dali-toolkit/public-api/controls/scrollable/scrollable.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-// Forward declarations
-
-namespace Internal
-{
-// Forward declarations
-
-class ScrollBarInternal;
-}
-
-/**
- * ScrollBarInternal is a UI component that can be added to the sides of the scrollable controls
- * indicating the current scroll position.
- */
-class ScrollBarInternal : public ScrollComponent
-{
-
-public:
-
- /**
- * Create an uninitialized ScrollBarInternal; this can be initialized with ScrollBarInternal::New()
- * Calling member functions with an uninitialized Dali::Object is not allowed.
- * or horizontally (false)
- */
- ScrollBarInternal();
-
- /**
- * Copy constructor.
- */
- ScrollBarInternal( const ScrollBarInternal& scrollBar );
-
- /**
- * Assignment operator.
- */
- ScrollBarInternal& operator=( const ScrollBarInternal& scrollBar );
-
- /**
- * Virtual destructor.
- * Dali::Object derived classes typically do not contain member data.
- */
- virtual ~ScrollBarInternal();
-
- /**
- * Create an initialized ScrollBarInternal
- * @param[in] container Reference to the container of scroll bar
- * @param[in] vertical Whether ScrollBarInternal should be oriented vertically (true)
- * or horizontally (false)
- * @return A pointer to the created ScrollBarInternal.
- */
- static ScrollBarInternal New(Scrollable& container, bool vertical);
-
- /**
- * Downcast an Object handle to ScrollBarInternal. If handle points to a ScrollBarInternal the
- * downcast produces valid handle. If not the returned handle is left uninitialized.
- * @param[in] handle Handle to an object
- * @return handle to a ScrollBarInternal or an uninitialized handle
- */
- static ScrollBarInternal DownCast( BaseHandle handle );
-
- /**
- * Show ScrollBarInternal
- */
- void Show();
-
- /**
- * Hide ScrollBarInternal
- */
- void Hide();
-
-public: // Not intended for application developers
-
- /**
- * Creates a handle using the Toolkit::Internal implementation.
- * @param[in] implementation The Control implementation.
- */
- ScrollBarInternal( Internal::ScrollBarInternal& implementation );
-
- /**
- * Allows the creation of this Control from an Internal::CustomActor pointer.
- * @param[in] internal A pointer to the internal CustomActor.
- */
- ScrollBarInternal( Dali::Internal::CustomActor* internal );
-};
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_SCROLL_BAR_INTERNAL_H__
#include <dali/public-api/object/type-registry-helper.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h>
#include <dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h>
#include <dali-toolkit/internal/controls/scrollable/bouncing-effect-actor.h>
-#include <dali-toolkit/internal/controls/scrollable/scroll-connector-impl.h>
using std::string;
using std::set;
//Type registration
-DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ItemView, Toolkit::Scrollable, NULL )
+DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ItemView, Toolkit::Scrollable, NULL)
+
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ItemView, "layout-position", FLOAT, LAYOUT_POSITION)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ItemView, "scroll-speed", FLOAT, SCROLL_SPEED)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ItemView, "overshoot", FLOAT, OVERSHOOT)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ItemView, "scroll-direction", VECTOR2, SCROLL_DIRECTION)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ItemView, "layout-orientation", INTEGER, LAYOUT_ORIENTATION)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ItemView, "scroll-content-size", FLOAT, SCROLL_CONTENT_SIZE)
+
DALI_TYPE_REGISTRATION_END()
const float DEFAULT_MINIMUM_SWIPE_SPEED = 1.0f;
const Vector4 OVERSHOOT_OVERLAY_NINE_PATCH_BORDER(0.0f, 0.0f, 1.0f, 12.0f);
const float DEFAULT_KEYBOARD_FOCUS_SCROLL_DURATION = 0.2f;
-const string LAYOUT_POSITION_PROPERTY_NAME( "item-view-layout-position" );
-const string POSITION_PROPERTY_NAME( "item-view-position" );
-const string MINIMUM_LAYOUT_POSITION_PROPERTY_NAME( "item-view-minimum-layout-position" );
-const string SCROLL_SPEED_PROPERTY_NAME( "item-view-scroll-speed" );
-const string SCROLL_DIRECTION_PROPERTY_NAME( "item-view-scroll-direction" );
-const string OVERSHOOT_PROPERTY_NAME( "item-view-overshoot" );
-
/**
* Local helper to convert pan distance (in actor coordinates) to the layout-specific scrolling direction
*/
// Overshoot overlay constraints
void OvershootOverlaySizeConstraint( Vector3& current, const PropertyInputContainer& inputs )
{
- const Vector3& parentScrollDirection = inputs[0]->GetVector3();
- const Vector3& parentSize = inputs[1]->GetVector3();
- const Toolkit::ControlOrientation::Type& parentOrientation = static_cast<Toolkit::ControlOrientation::Type>(parentScrollDirection.z);
+ const Vector2& parentScrollDirection = inputs[0]->GetVector2();
+ const Toolkit::ControlOrientation::Type& layoutOrientation = static_cast<Toolkit::ControlOrientation::Type>(inputs[1]->GetInteger());
+ const Vector3& parentSize = inputs[2]->GetVector3();
- if(Toolkit::IsVertical(parentOrientation))
+ if(Toolkit::IsVertical(layoutOrientation))
{
current.width = fabsf(parentScrollDirection.y) > Math::MACHINE_EPSILON_1 ? parentSize.x : parentSize.y;
}
void OvershootOverlayRotationConstraint( Quaternion& current, const PropertyInputContainer& inputs )
{
- const Vector3& parentScrollDirection = inputs[0]->GetVector3();
- const float parentOvershoot = inputs[1]->GetFloat();
- const Toolkit::ControlOrientation::Type& parentOrientation = static_cast<Toolkit::ControlOrientation::Type>(parentScrollDirection.z);
+ const Vector2& parentScrollDirection = inputs[0]->GetVector2();
+ const Toolkit::ControlOrientation::Type& layoutOrientation = static_cast<Toolkit::ControlOrientation::Type>(inputs[1]->GetInteger());
+ const float parentOvershoot = inputs[2]->GetFloat();
float multiplier = 0;
- if(Toolkit::IsVertical(parentOrientation))
+ if(Toolkit::IsVertical(layoutOrientation))
{
if(fabsf(parentScrollDirection.y) <= Math::MACHINE_EPSILON_1)
{
- if( (parentOrientation == Toolkit::ControlOrientation::Up && parentOvershoot < Math::MACHINE_EPSILON_0)
- || (parentOrientation == Toolkit::ControlOrientation::Down && parentOvershoot > Math::MACHINE_EPSILON_0) )
+ if( (layoutOrientation == Toolkit::ControlOrientation::Up && parentOvershoot < Math::MACHINE_EPSILON_0)
+ || (layoutOrientation == Toolkit::ControlOrientation::Down && parentOvershoot > Math::MACHINE_EPSILON_0) )
{
multiplier = 0.5f;
}
{
if(fabsf(parentScrollDirection.x) <= Math::MACHINE_EPSILON_1)
{
- if( (parentOrientation == Toolkit::ControlOrientation::Left && parentOvershoot > Math::MACHINE_EPSILON_0)
- ||(parentOrientation == Toolkit::ControlOrientation::Right && parentOvershoot < Math::MACHINE_EPSILON_0) )
+ if( (layoutOrientation == Toolkit::ControlOrientation::Left && parentOvershoot > Math::MACHINE_EPSILON_0)
+ ||(layoutOrientation == Toolkit::ControlOrientation::Right && parentOvershoot < Math::MACHINE_EPSILON_0) )
{
multiplier = 1.0f;
}
void OvershootOverlayPositionConstraint( Vector3& current, const PropertyInputContainer& inputs )
{
const Vector3& parentSize = inputs[0]->GetVector3();
- const Vector3& parentScrollDirection = inputs[1]->GetVector3();
- const float parentOvershoot = inputs[2]->GetFloat();
- const Toolkit::ControlOrientation::Type& parentOrientation = static_cast<Toolkit::ControlOrientation::Type>(parentScrollDirection.z);
+ const Vector2& parentScrollDirection = inputs[1]->GetVector2();
+ const Toolkit::ControlOrientation::Type& layoutOrientation = static_cast<Toolkit::ControlOrientation::Type>(inputs[2]->GetInteger());
+ const float parentOvershoot = inputs[3]->GetFloat();
Vector3 relativeOffset;
- if(Toolkit::IsVertical(parentOrientation))
+ if(Toolkit::IsVertical(layoutOrientation))
{
if(fabsf(parentScrollDirection.y) <= Math::MACHINE_EPSILON_1)
{
- if( (parentOrientation == Toolkit::ControlOrientation::Up && parentOvershoot < Math::MACHINE_EPSILON_0)
- || (parentOrientation == Toolkit::ControlOrientation::Down && parentOvershoot > Math::MACHINE_EPSILON_0) )
+ if( (layoutOrientation == Toolkit::ControlOrientation::Up && parentOvershoot < Math::MACHINE_EPSILON_0)
+ || (layoutOrientation == Toolkit::ControlOrientation::Down && parentOvershoot > Math::MACHINE_EPSILON_0) )
{
relativeOffset = Vector3(1.0f, 0.0f, 0.0f);
}
{
if(fabsf(parentScrollDirection.x) <= Math::MACHINE_EPSILON_1)
{
- if( (parentOrientation == Toolkit::ControlOrientation::Left && parentOvershoot < Math::MACHINE_EPSILON_0)
- || (parentOrientation == Toolkit::ControlOrientation::Right && parentOvershoot > Math::MACHINE_EPSILON_0) )
+ if( (layoutOrientation == Toolkit::ControlOrientation::Left && parentOvershoot < Math::MACHINE_EPSILON_0)
+ || (layoutOrientation == Toolkit::ControlOrientation::Right && parentOvershoot > Math::MACHINE_EPSILON_0) )
{
relativeOffset = Vector3(0.0f, 0.0f, 0.0f);
}
current = inputs[0]->GetBoolean();
}
-/**
- * Relative position Constraint
- * Generates the relative position value of the item view based on the layout position,
- * and it's relation to the layout domain. This is a value from 0.0f to 1.0f in each axis.
- */
-void RelativePositionConstraint( Vector3& current, const PropertyInputContainer& inputs )
-{
- const Vector3& position = Vector3(0.0f, inputs[0]->GetFloat(), 0.0f);
- const Vector3& min = inputs[1]->GetVector3();
- const Vector3& max = inputs[2]->GetVector3();
-
- Vector3 domainSize = max - min;
-
- current.x = fabsf(domainSize.x) > Math::MACHINE_EPSILON_1 ? ((min.x - position.x) / fabsf(domainSize.x)) : 0.0f;
- current.y = fabsf(domainSize.y) > Math::MACHINE_EPSILON_1 ? ((min.y - position.y) / fabsf(domainSize.y)) : 0.0f;
- current.z = 0.0f;
-}
-
} // unnamed namespace
namespace Dali
mIsFlicking(false),
mGestureState(Gesture::Clear),
mAddingItems(false),
- mPropertyPosition(Property::INVALID_INDEX),
- mPropertyMinimumLayoutPosition(Property::INVALID_INDEX),
- mPropertyScrollSpeed(Property::INVALID_INDEX),
mRefreshEnabled(true),
mItemsParentOrigin( ParentOrigin::CENTER),
mItemsAnchorPoint( AnchorPoint::CENTER)
{
Actor self = Self();
- mScrollConnector = Dali::Toolkit::ScrollConnector::New();
- mScrollPositionObject = mScrollConnector.GetScrollPositionObject();
- mScrollConnector.ScrollPositionChangedSignal().Connect( this, &ItemView::OnScrollPositionChanged );
-
- 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);
-
- EnableScrollComponent(Toolkit::Scrollable::OvershootIndicator);
-
- Constraint constraint = Constraint::New<Vector3>( self, Toolkit::Scrollable::Property::SCROLL_RELATIVE_POSITION, RelativePositionConstraint );
- constraint.AddSource( LocalSource( mPropertyPosition ) );
- constraint.AddSource( LocalSource( Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
- constraint.AddSource( LocalSource( Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
- constraint.Apply();
+ SetOvershootEnabled(true);
Vector2 stageSize = Stage::GetCurrent().GetSize();
mMouseWheelScrollDistanceStep = stageSize.y * DEFAULT_MOUSE_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION;
{
}
-Dali::Toolkit::ScrollConnector ItemView::GetScrollConnector() const
-{
- return mScrollConnector;
-}
-
unsigned int ItemView::GetLayoutCount() const
{
return mLayouts.size();
float ItemView::GetCurrentLayoutPosition(unsigned int itemId) const
{
- return mScrollConnector.GetScrollPosition() + static_cast<float>( itemId );
+ return Self().GetProperty<float>( Toolkit::ItemView::Property::LAYOUT_POSITION ) + static_cast<float>( itemId );
}
void ItemView::ActivateLayout(unsigned int layoutIndex, const Vector3& targetSize, float durationSeconds)
actor.SetSize( size.GetVectorXY() );
}
- mActiveLayout->ApplyConstraints(actor, itemId, durationSeconds, mScrollPositionObject, Self() );
+ mActiveLayout->ApplyConstraints(actor, itemId, durationSeconds, Self() );
}
// Refresh the new layout
float current = GetCurrentLayoutPosition(0);
float minimum = ClampFirstItemPosition(current, targetSize, *mActiveLayout);
- self.SetProperty(mPropertyPosition, GetScrollPosition(current, targetSize));
if (current < minimum)
{
{
RemoveAnimation(mScrollAnimation);
mScrollAnimation = Animation::New(durationSeconds);
- mScrollAnimation.AnimateTo( Property( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ), firstItemScrollPosition, AlphaFunction::EASE_OUT );
- mScrollAnimation.AnimateTo( Property(self, mPropertyPosition), GetScrollPosition(firstItemScrollPosition, targetSize), AlphaFunction::EASE_OUT );
+ mScrollAnimation.AnimateTo( Property(self, Toolkit::ItemView::Property::LAYOUT_POSITION), firstItemScrollPosition, AlphaFunction::EASE_OUT );
mScrollAnimation.FinishedSignal().Connect(this, &ItemView::OnLayoutActivationScrollFinished);
mScrollAnimation.Play();
}
- self.SetProperty(mPropertyMinimumLayoutPosition, mActiveLayout->GetMinimumLayoutPosition(mItemFactory.GetNumberOfItems(), targetSize));
AnimateScrollOvershoot(0.0f);
mScrollOvershoot = 0.0f;
Radian scrollDirection(mActiveLayout->GetScrollDirection());
- float orientation = static_cast<float>(mActiveLayout->GetOrientation());
- self.SetProperty(Toolkit::Scrollable::Property::SCROLL_DIRECTION, Vector3(sinf(scrollDirection), cosf(scrollDirection), orientation));
-
- self.SetProperty(mPropertyScrollSpeed, mScrollSpeed);
+ self.SetProperty(Toolkit::ItemView::Property::SCROLL_DIRECTION, Vector2(sinf(scrollDirection), cosf(scrollDirection)));
+ self.SetProperty(Toolkit::ItemView::Property::LAYOUT_ORIENTATION, static_cast<int>(mActiveLayout->GetOrientation()));
+ self.SetProperty(Toolkit::ItemView::Property::SCROLL_SPEED, mScrollSpeed);
CalculateDomainSize(targetSize);
}
RemoveActorsOutsideRange( range );
AddActorsWithinRange( range, 0.0f/*immediate*/ );
- mScrollUpdatedSignal.Emit( Vector3(0.0f, currentLayoutPosition, 0.0f) );
+ mScrollUpdatedSignal.Emit( Vector2(0.0f, currentLayoutPosition) );
}
}
{
mRefreshIntervalLayoutPositions = intervalLayoutPositions;
+ Actor self = Self();
if(mRefreshNotification)
{
- mScrollPositionObject.RemovePropertyNotification(mRefreshNotification);
+ self.RemovePropertyNotification(mRefreshNotification);
}
- mRefreshNotification = mScrollPositionObject.AddPropertyNotification( ScrollConnector::SCROLL_POSITION, StepCondition(mRefreshIntervalLayoutPositions, 0.0f) );
+ mRefreshNotification = self.AddPropertyNotification( Toolkit::ItemView::Property::LAYOUT_POSITION, StepCondition(mRefreshIntervalLayoutPositions, 0.0f) );
mRefreshNotification.NotifySignal().Connect( this, &ItemView::OnRefreshNotification );
}
}
displacedActor = temp;
iter->second.RemoveConstraints();
- mActiveLayout->ApplyConstraints( iter->second, iter->first, durationSeconds, mScrollPositionObject, Self() );
+ mActiveLayout->ApplyConstraints( iter->second, iter->first, durationSeconds, Self() );
}
// Create last item
mItemPool.insert( lastItem );
lastItem.second.RemoveConstraints();
- mActiveLayout->ApplyConstraints( lastItem.second, lastItem.first, durationSeconds, mScrollPositionObject, Self() );
+ mActiveLayout->ApplyConstraints( lastItem.second, lastItem.first, durationSeconds, Self() );
}
}
else
{
iter->second.RemoveConstraints();
- mActiveLayout->ApplyConstraints( iter->second, iter->first, durationSeconds, mScrollPositionObject, Self() );
+ mActiveLayout->ApplyConstraints( iter->second, iter->first, durationSeconds, Self() );
}
}
item.second.SetSize( size.GetVectorXY() );
}
- mActiveLayout->ApplyConstraints( item.second, item.first, durationSeconds, mScrollPositionObject, Self() );
+ mActiveLayout->ApplyConstraints( item.second, item.first, durationSeconds, Self() );
}
}
if(!mAddingItems)
{
// We don't want to do this downcast check for any item added by ItemView itself.
- Dali::Toolkit::ScrollComponent scrollComponent = Dali::Toolkit::ScrollComponent::DownCast(child);
- if(scrollComponent)
+ Dali::Toolkit::ScrollBar scrollBar = Dali::Toolkit::ScrollBar::DownCast(child);
+ if(scrollBar)
{
- // Set the scroll connector when scroll bar is being added
- scrollComponent.SetScrollConnector(mScrollConnector);
+ scrollBar.SetScrollPropertySource(Self(),
+ Toolkit::ItemView::Property::LAYOUT_POSITION,
+ Toolkit::Scrollable::Property::SCROLL_POSITION_MIN_Y,
+ Toolkit::Scrollable::Property::SCROLL_POSITION_MAX_Y,
+ Toolkit::ItemView::Property::SCROLL_CONTENT_SIZE);
+ scrollBar.ScrollPositionIntervalReachedSignal().Connect( this, &ItemView::OnScrollPositionChanged );
}
}
}
mScrollDistance = 0.0f;
mScrollSpeed = 0.0f;
- Self().SetProperty(mPropertyScrollSpeed, mScrollSpeed);
+ Self().SetProperty(Toolkit::ItemView::Property::SCROLL_SPEED, mScrollSpeed);
mScrollOvershoot = 0.0f;
AnimateScrollOvershoot(0.0f);
float layoutPositionDelta = GetCurrentLayoutPosition(0) - (event.z * mMouseWheelScrollDistanceStep * mActiveLayout->GetScrollSpeedFactor());
float firstItemScrollPosition = ClampFirstItemPosition(layoutPositionDelta, layoutSize, *mActiveLayout);
- mScrollPositionObject.SetProperty( ScrollConnector::SCROLL_POSITION, firstItemScrollPosition );
- self.SetProperty(mPropertyPosition, GetScrollPosition(firstItemScrollPosition, layoutSize));
+ self.SetProperty(Toolkit::ItemView::Property::LAYOUT_POSITION, firstItemScrollPosition );
+
mScrollStartedSignal.Emit(GetCurrentScrollPosition());
mRefreshEnabled = true;
}
Actor actor = iter->second;
actor.RemoveConstraints();
- mActiveLayout->ApplyConstraints(actor, id, durationSeconds, mScrollPositionObject, Self());
+ mActiveLayout->ApplyConstraints(actor, id, durationSeconds, Self());
}
}
if( mActiveLayout )
{
float firstItemScrollPosition = ClampFirstItemPosition(GetCurrentLayoutPosition(0), Self().GetCurrentSize(), *mActiveLayout);
-
- mScrollPositionObject.SetProperty( ScrollConnector::SCROLL_POSITION, firstItemScrollPosition );
+ Self().SetProperty( Toolkit::ItemView::Property::LAYOUT_POSITION, firstItemScrollPosition );
}
}
float minLayoutPosition = layout.GetMinimumLayoutPosition(mItemFactory.GetNumberOfItems(), targetSize);
float clamppedPosition = std::min(0.0f, std::max(minLayoutPosition, targetPosition));
mScrollOvershoot = targetPosition - clamppedPosition;
- self.SetProperty(mPropertyMinimumLayoutPosition, minLayoutPosition);
+ self.SetProperty(Toolkit::Scrollable::Property::SCROLL_POSITION_MAX, Vector2(0.0f, -minLayoutPosition));
return clamppedPosition;
}
, DEFAULT_MINIMUM_SWIPE_DURATION, DEFAULT_MAXIMUM_SWIPE_DURATION);
mScrollAnimation = Animation::New(flickAnimationDuration);
- mScrollAnimation.AnimateTo( Property( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ), firstItemScrollPosition, AlphaFunction::EASE_OUT );
- mScrollAnimation.AnimateTo( Property(self, mPropertyPosition), GetScrollPosition(firstItemScrollPosition, layoutSize), AlphaFunction::EASE_OUT );
- mScrollAnimation.AnimateTo( Property(self, mPropertyScrollSpeed), 0.0f, AlphaFunction::EASE_OUT );
+ mScrollAnimation.AnimateTo( Property(self, Toolkit::ItemView::Property::LAYOUT_POSITION ), firstItemScrollPosition, AlphaFunction::EASE_OUT );
+ mScrollAnimation.AnimateTo( Property(self, Toolkit::ItemView::Property::SCROLL_SPEED), 0.0f, AlphaFunction::EASE_OUT );
mIsFlicking = true;
// Check whether it has already scrolled to the end
float firstItemScrollPosition = ClampFirstItemPosition(layoutPositionDelta, layoutSize, *mActiveLayout);
- float currentOvershoot = mScrollPositionObject.GetProperty<float>(ScrollConnector::OVERSHOOT);
+ float currentOvershoot = self.GetProperty<float>(Toolkit::ItemView::Property::OVERSHOOT);
- mScrollPositionObject.SetProperty( ScrollConnector::SCROLL_POSITION, firstItemScrollPosition );
- self.SetProperty(mPropertyPosition, GetScrollPosition(firstItemScrollPosition, layoutSize));
+ self.SetProperty(Toolkit::ItemView::Property::LAYOUT_POSITION, firstItemScrollPosition );
- if( (firstItemScrollPosition >= 0.0f && currentOvershoot < 1.0f) || (firstItemScrollPosition <= mActiveLayout->GetMinimumLayoutPosition(mItemFactory.GetNumberOfItems(), layoutSize) && currentOvershoot > -1.0f) )
+ if( (firstItemScrollPosition >= 0.0f && currentOvershoot < 1.0f) || (firstItemScrollPosition >= mActiveLayout->GetMinimumLayoutPosition(mItemFactory.GetNumberOfItems(), layoutSize) && currentOvershoot > -1.0f) )
{
mTotalPanDisplacement += gesture.displacement;
}
mScrollOvershoot = CalculateScrollOvershoot();
- mScrollPositionObject.SetProperty( ScrollConnector::OVERSHOOT, mScrollOvershoot );
+ self.SetProperty( Toolkit::ItemView::Property::OVERSHOOT, mScrollOvershoot );
}
break;
Vector3 layoutSize = Self().GetCurrentSize();
float scrollTo = mActiveLayout->GetClosestOnScreenLayoutPosition(nextItemID, layoutPosition, layoutSize);
- ScrollTo(Vector3(0.0f, scrollTo, 0.0f), DEFAULT_KEYBOARD_FOCUS_SCROLL_DURATION);
+ ScrollTo(Vector2(0.0f, scrollTo), DEFAULT_KEYBOARD_FOCUS_SCROLL_DURATION);
}
}
float anchorPosition = mActiveLayout->GetClosestAnchorPosition( GetCurrentLayoutPosition(0) );
anchoringAnimation = Animation::New(mAnchoringDuration);
- anchoringAnimation.AnimateTo( Property( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ), anchorPosition, AlphaFunction::EASE_OUT );
- anchoringAnimation.AnimateTo( Property(self, mPropertyPosition), GetScrollPosition(anchorPosition, self.GetCurrentSize()), AlphaFunction::EASE_OUT );
- anchoringAnimation.AnimateTo( Property(self, mPropertyScrollSpeed), 0.0f, AlphaFunction::EASE_OUT );
+ anchoringAnimation.AnimateTo( Property(self, Toolkit::ItemView::Property::LAYOUT_POSITION), -anchorPosition, AlphaFunction::EASE_OUT );
+ anchoringAnimation.AnimateTo( Property(self, Toolkit::ItemView::Property::SCROLL_SPEED), 0.0f, AlphaFunction::EASE_OUT );
if(!mIsFlicking)
{
AnimateScrollOvershoot(0.0f);
{
RemoveAnimation(mScrollAnimation);
mScrollAnimation = Animation::New(durationSeconds);
- mScrollAnimation.AnimateTo( Property( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ), firstItemScrollPosition, AlphaFunction::EASE_OUT );
- mScrollAnimation.AnimateTo( Property(self, mPropertyPosition), GetScrollPosition(firstItemScrollPosition, layoutSize), AlphaFunction::EASE_OUT );
+ mScrollAnimation.AnimateTo( Property(self, Toolkit::ItemView::Property::LAYOUT_POSITION), firstItemScrollPosition, AlphaFunction::EASE_OUT );
mScrollAnimation.FinishedSignal().Connect(this, &ItemView::OnScrollFinished);
mScrollAnimation.Play();
}
else
{
- mScrollPositionObject.SetProperty( ScrollConnector::SCROLL_POSITION, firstItemScrollPosition );
+ self.SetProperty( Toolkit::ItemView::Property::LAYOUT_POSITION, firstItemScrollPosition );
AnimateScrollOvershoot(0.0f);
}
firstItemPosition = mActiveLayout->GetItemPosition( 0,0,layoutSize );
float minLayoutPosition = mActiveLayout->GetMinimumLayoutPosition(mItemFactory.GetNumberOfItems(), layoutSize);
- self.SetProperty(mPropertyMinimumLayoutPosition, minLayoutPosition);
lastItemPosition = mActiveLayout->GetItemPosition( fabs(minLayoutPosition),fabs(minLayoutPosition),layoutSize );
float domainSize;
if(IsHorizontal(mActiveLayout->GetOrientation()))
{
- self.SetProperty(Toolkit::Scrollable::Property::SCROLL_POSITION_MIN, Vector3(0.0f, firstItemPosition.x, 0.0f));
- self.SetProperty(Toolkit::Scrollable::Property::SCROLL_POSITION_MAX, Vector3(0.0f, lastItemPosition.x, 0.0f));
domainSize = fabs(firstItemPosition.x - lastItemPosition.x);
}
else
{
- self.SetProperty(Toolkit::Scrollable::Property::SCROLL_POSITION_MIN, Vector3(0.0f, firstItemPosition.y, 0.0f));
- self.SetProperty(Toolkit::Scrollable::Property::SCROLL_POSITION_MAX, Vector3(0.0f, lastItemPosition.y, 0.0f));
domainSize = fabs(firstItemPosition.y - lastItemPosition.y);
}
- mScrollConnector.SetScrollDomain(minLayoutPosition, 0.0f, domainSize);
+ self.SetProperty(Toolkit::Scrollable::Property::SCROLL_POSITION_MIN, Vector2::ZERO);
+ self.SetProperty(Toolkit::Scrollable::Property::SCROLL_POSITION_MAX, Vector2(0.0f, -minLayoutPosition));
+
+ self.SetProperty(Toolkit::ItemView::Property::SCROLL_CONTENT_SIZE, domainSize);
bool isLayoutScrollable = IsLayoutScrollable(layoutSize);
self.SetProperty(Toolkit::Scrollable::Property::CAN_SCROLL_VERTICAL, isLayoutScrollable);
}
}
-Vector3 ItemView::GetDomainSize() const
+Vector2 ItemView::GetDomainSize() const
{
Actor self = Self();
- float minScrollPosition = self.GetProperty<float>(Toolkit::Scrollable::Property::SCROLL_POSITION_MIN);
- float maxScrollPosition = self.GetProperty<float>(Toolkit::Scrollable::Property::SCROLL_POSITION_MAX);
+ float minScrollPosition = self.GetProperty<float>(Toolkit::Scrollable::Property::SCROLL_POSITION_MIN_Y);
+ float maxScrollPosition = self.GetProperty<float>(Toolkit::Scrollable::Property::SCROLL_POSITION_MAX_Y);
- return Vector3(0.0f, fabs(maxScrollPosition - minScrollPosition), 0.0f);
+ return Vector2(0.0f, fabs(GetScrollPosition(minScrollPosition, self.GetCurrentSize()) - GetScrollPosition(-maxScrollPosition, self.GetCurrentSize())));
}
bool ItemView::IsLayoutScrollable(const Vector3& layoutSize)
return IsHorizontal(mActiveLayout->GetOrientation()) ? firstItemPosition.x: firstItemPosition.y;
}
-Vector3 ItemView::GetCurrentScrollPosition() const
+Vector2 ItemView::GetCurrentScrollPosition() const
{
- float currentLayoutPosition = GetCurrentLayoutPosition(0);
- return Vector3(0.0f, GetScrollPosition(currentLayoutPosition, Self().GetCurrentSize()), 0.0f);
+ return Vector2(0.0f, GetScrollPosition(GetCurrentLayoutPosition(0), Self().GetCurrentSize()));
}
void ItemView::AddOverlay(Actor actor)
Self().Remove(actor);
}
-void ItemView::ScrollTo(const Vector3& position, float duration)
+void ItemView::ScrollTo(const Vector2& position, float duration)
{
Actor self = Self();
const Vector3 layoutSize = Self().GetCurrentSize();
{
RemoveAnimation(mScrollAnimation);
mScrollAnimation = Animation::New(duration);
- mScrollAnimation.AnimateTo( Property( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ), firstItemScrollPosition, AlphaFunction::EASE_OUT );
- mScrollAnimation.AnimateTo( Property(self, mPropertyPosition), GetScrollPosition(firstItemScrollPosition, layoutSize), AlphaFunction::EASE_OUT );
+ mScrollAnimation.AnimateTo( Property(self, Toolkit::ItemView::Property::LAYOUT_POSITION), firstItemScrollPosition, AlphaFunction::EASE_OUT );
mScrollAnimation.FinishedSignal().Connect(this, &ItemView::OnScrollFinished);
mScrollAnimation.Play();
}
else
{
- mScrollPositionObject.SetProperty( ScrollConnector::SCROLL_POSITION, firstItemScrollPosition );
+ self.SetProperty( Toolkit::ItemView::Property::LAYOUT_POSITION, firstItemScrollPosition );
AnimateScrollOvershoot(0.0f);
}
}
}
-void ItemView::SetOvershootEnabled( bool enable )
+void ItemView::EnableScrollOvershoot( bool enable )
{
Actor self = Self();
if( enable )
self.Add(mOvershootOverlay);
Constraint constraint = Constraint::New<Vector3>( mOvershootOverlay, Actor::Property::SIZE, OvershootOverlaySizeConstraint );
- constraint.AddSource( ParentSource( Toolkit::Scrollable::Property::SCROLL_DIRECTION ) );
+ constraint.AddSource( ParentSource( Toolkit::ItemView::Property::SCROLL_DIRECTION ) );
+ constraint.AddSource( ParentSource( Toolkit::ItemView::Property::LAYOUT_ORIENTATION ) );
constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
constraint.Apply();
mOvershootOverlay.SetSize(OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.width, OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height);
constraint = Constraint::New<Quaternion>( mOvershootOverlay, Actor::Property::ORIENTATION, OvershootOverlayRotationConstraint );
- constraint.AddSource( ParentSource( Toolkit::Scrollable::Property::SCROLL_DIRECTION ) );
- constraint.AddSource( Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ) );
+ constraint.AddSource( ParentSource( Toolkit::ItemView::Property::SCROLL_DIRECTION ) );
+ constraint.AddSource( ParentSource( Toolkit::ItemView::Property::LAYOUT_ORIENTATION ) );
+ constraint.AddSource( ParentSource( Toolkit::ItemView::Property::OVERSHOOT ) );
constraint.Apply();
constraint = Constraint::New<Vector3>( mOvershootOverlay, Actor::Property::POSITION, OvershootOverlayPositionConstraint );
constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
- constraint.AddSource( ParentSource( Toolkit::Scrollable::Property::SCROLL_DIRECTION ) );
- constraint.AddSource( Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ) );
+ constraint.AddSource( ParentSource( Toolkit::ItemView::Property::SCROLL_DIRECTION ) );
+ constraint.AddSource( ParentSource( Toolkit::ItemView::Property::LAYOUT_ORIENTATION ) );
+ constraint.AddSource( ParentSource( Toolkit::ItemView::Property::OVERSHOOT ) );
constraint.Apply();
constraint = Constraint::New<bool>( mOvershootOverlay, Actor::Property::VISIBLE, OvershootOverlayVisibilityConstraint );
constraint.Apply();
constraint = Constraint::New<float>( mOvershootOverlay, effectOvershootPropertyIndex, EqualToConstraint() );
- constraint.AddSource( Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ) );
+ constraint.AddSource( ParentSource( Toolkit::ItemView::Property::OVERSHOOT ) );
constraint.Apply();
}
else
float scrollDistance = CalculateScrollDistance(mTotalPanDisplacement, *mActiveLayout) * mActiveLayout->GetScrollSpeedFactor();
float positionDelta = GetCurrentLayoutPosition(0) + scrollDistance;
float minLayoutPosition = mActiveLayout->GetMinimumLayoutPosition(mItemFactory.GetNumberOfItems(), Self().GetCurrentSize());
- self.SetProperty(mPropertyMinimumLayoutPosition, minLayoutPosition);
+ self.SetProperty(Toolkit::Scrollable::Property::SCROLL_POSITION_MAX, Vector2(0.0f, -minLayoutPosition));
float clamppedPosition = std::min(0.0f, std::max(minLayoutPosition, positionDelta));
overshoot = positionDelta - clamppedPosition;
}
return;
}
+ Actor self = Self();
+
if(mOvershootAnimationSpeed > Math::MACHINE_EPSILON_0)
{
- float currentOvershoot = mScrollPositionObject.GetProperty<float>(ScrollConnector::OVERSHOOT);
+ float currentOvershoot = self.GetProperty<float>(Toolkit::ItemView::Property::OVERSHOOT);
float duration = 0.0f;
if (mOvershootOverlay)
RemoveAnimation(mScrollOvershootAnimation);
mScrollOvershootAnimation = Animation::New(duration);
mScrollOvershootAnimation.FinishedSignal().Connect(this, &ItemView::OnOvershootOnFinished);
- mScrollOvershootAnimation.AnimateTo( Property(mScrollPositionObject, ScrollConnector::OVERSHOOT), overshootAmount, TimePeriod(0.0f, duration) );
+ mScrollOvershootAnimation.AnimateTo( Property(self, Toolkit::ItemView::Property::OVERSHOOT), overshootAmount, TimePeriod(0.0f, duration) );
mScrollOvershootAnimation.Play();
mAnimatingOvershootOn = animatingOn;
}
else
{
- mScrollPositionObject.SetProperty( ScrollConnector::OVERSHOOT, overshootAmount );
+ self.SetProperty( Toolkit::ItemView::Property::OVERSHOOT, overshootAmount );
}
}
// EXTERNAL INCLUDES
#include <dali/public-api/adaptor-framework/timer.h>
#include <dali/public-api/animation/animation.h>
+#include <dali/public-api/common/map-wrapper.h>
#include <dali/public-api/object/property-notification.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/public-api/controls/scrollable/item-view/item-view.h>
#include <dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h>
-#include <dali-toolkit/public-api/controls/scrollable/scroll-connector.h>
#include <dali-toolkit/internal/controls/scrollable/scrollable-impl.h>
#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
static Dali::Toolkit::ItemView New(ItemFactory& factory);
/**
- * @copydoc Toolkit::ItemView::GetScrollConnector
- */
- Dali::Toolkit::ScrollConnector GetScrollConnector() const;
-
- /**
* @copydoc Toolkit::ItemView::GetLayoutCount
*/
unsigned int GetLayoutCount() const;
/**
* @copydoc Toolkit::Scrollable::GetDomainSize
*/
- Vector3 GetDomainSize() const;
+ Vector2 GetDomainSize() const;
/**
* @copydoc Toolkit::Scrollable::GetCurrentScrollPosition
*/
- Vector3 GetCurrentScrollPosition() const;
+ Vector2 GetCurrentScrollPosition() const;
/**
* @copydoc Toolkit::Scrollable::AddOverlay()
void RemoveOverlay(Actor actor);
/**
- * @copydoc Toolkit::Scrollable::ScrollTo(const Vector3& position, float duration)
+ * @copydoc Toolkit::Scrollable::ScrollTo(const Vector2& position, float duration)
*/
- void ScrollTo(const Vector3& position, float duration);
+ void ScrollTo(const Vector2& position, float duration);
/**
* @copydoc Toolkit::Internal::Scrollable::SetOvershootEffectColor
void RemoveAnimation(Animation& animation);
/**
- * @copydoc Toolkit::Internal::Scrollable::SetOvershootEnabled
+ * @copydoc Toolkit::Internal::Scrollable::EnableScrollOvershoot
*/
- virtual void SetOvershootEnabled( bool enable );
+ virtual void EnableScrollOvershoot( bool enable );
/**
* Helper to calculate the scroll overshoot according to the pan gesture displacement.
void OnRefreshNotification(PropertyNotification& source);
/**
- * This is called when scroll position has been changed by ScrollConnector::SetScrollPosition.
+ * This is called when the change of scroll position is notified by ScrollBar.
* @param[in] position The new scroll position
*/
void OnScrollPositionChanged( float position );
Actor mOvershootOverlay; ///< The overlay actor for overshoot effect
- Dali::Toolkit::ScrollConnector mScrollConnector; ///< Connects ItemView with scrollable components e.g. scroll bars
- Handle mScrollPositionObject; ///< From mScrollConnector
-
bool mAddingItems;
- 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
-
bool mRefreshEnabled; ///< Whether to refresh the cache automatically
Vector3 mItemsParentOrigin;
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- *
- */
-
-// CLASS HEADER
-#include <dali-toolkit/internal/controls/scrollable/scroll-connector-impl.h>
-
-// EXTERNAL INCLUDES
-#include <cstring> // for strcmp
-#include <dali/public-api/object/property-index-ranges.h>
-#include <dali/public-api/object/type-registry.h>
-#include <dali/public-api/object/type-registry-helper.h>
-#include <dali/integration-api/debug.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-namespace
-{
-
-// Setup properties, signals and actions using the type-registry.
-DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ScrollConnector, Dali::BaseHandle, NULL )
-
-DALI_SIGNAL_REGISTRATION( Toolkit, ScrollConnector, "domain-changed", DOMAIN_CHANGED_SIGNAL_NAME )
-DALI_SIGNAL_REGISTRATION( Toolkit, ScrollConnector, "scroll-position-changed", SCROLL_POSITION_CHANGED_SIGNAL_NAME )
-
-DALI_TYPE_REGISTRATION_END()
-
-}
-
-const Property::Index ScrollConnector::SCROLL_POSITION = Dali::PROPERTY_CUSTOM_START_INDEX;
-const Property::Index ScrollConnector::OVERSHOOT = Dali::PROPERTY_CUSTOM_START_INDEX + 1;
-
-ScrollConnector* ScrollConnector::New()
-{
- return new ScrollConnector();
-}
-
-void ScrollConnector::SetScrollDomain( float min, float max, float length )
-{
- mMinLimit = min;
- mMaxLimit = max;
- mContentLength = length;
-
- mDomainChangedSignal.Emit( mMinLimit, mMaxLimit, mContentLength );
-}
-
-void ScrollConnector::SetScrollPosition( float position )
-{
- mScrollPositionObject.SetProperty( Toolkit::ScrollConnector::SCROLL_POSITION, position );
- mScrollPositionChangedSignal.Emit( position );
-}
-
-bool ScrollConnector::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
-{
- Dali::BaseHandle handle( object );
-
- bool connected( true );
- Toolkit::ScrollConnector scrollConnector = Toolkit::ScrollConnector::DownCast( handle );
-
- if( 0 == strcmp( signalName.c_str(), DOMAIN_CHANGED_SIGNAL_NAME ) )
- {
- scrollConnector.DomainChangedSignal().Connect( tracker, functor );
- }
- else if( 0 == strcmp( signalName.c_str(), SCROLL_POSITION_CHANGED_SIGNAL_NAME ) )
- {
- scrollConnector.ScrollPositionChangedSignal().Connect( tracker, functor );
- }
- else
- {
- // signalName does not match any signal
- connected = false;
- }
-
- return connected;
-}
-
-ScrollConnector::ScrollConnector()
-: mMinLimit( 0.0f ),
- mMaxLimit( 0.0f ),
- mContentLength( 0.0f )
-{
- mScrollPositionObject = Handle::New();
-
- mScrollPositionObject.RegisterProperty( Toolkit::ScrollConnector::SCROLL_POSITION_PROPERTY_NAME, 0.0f );
- mScrollPositionObject.RegisterProperty( Toolkit::ScrollConnector::OVERSHOOT_PROPERTY_NAME, 0.0f );
-}
-
-ScrollConnector::~ScrollConnector()
-{
-}
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_TOOLKIT_INTERNAL_SCROLL_CONNECTOR_H__
-#define __DALI_TOOLKIT_INTERNAL_SCROLL_CONNECTOR_H__
-
-/*
- * Copyright (c) 2014 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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/signals/dali-signal.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/scrollable/scroll-connector.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-/**
- * @copydoc Toolkit::ScrollConnector
- */
-class ScrollConnector : public Dali::BaseObject
-{
-public:
-
- typedef Toolkit::ScrollConnector::DomainChangedSignalType DomainChangedSignalType;
- typedef Toolkit::ScrollConnector::ScrollPositionChangedSignalType ScrollPositionChangedSignalType;
-
- static const Property::Index SCROLL_POSITION;
- static const Property::Index OVERSHOOT;
-
- /**
- * Create a ScrollConnector.
- * @return A newly allocated ScrollConnector.
- */
- static ScrollConnector* New();
-
- /**
- * @copydoc Toolkit::ScrollConnector::SetScrollDomain()
- */
- void SetScrollDomain( float min, float max, float length );
-
- /**
- * @copydoc Toolkit::ScrollConnector::GetMinLimit()
- */
- float GetMinLimit() const
- {
- return mMinLimit;
- }
-
- /**
- * @copydoc Toolkit::ScrollConnector::GetMaxLimit()
- */
- float GetMaxLimit() const
- {
- return mMaxLimit;
- }
-
- /**
- * @copydoc Toolkit::ScrollConnector::GetContentLength()
- */
- float GetContentLength() const
- {
- return mContentLength;
- }
-
- /**
- * @copydoc Toolkit::ScrollConnector::SetScrollPosition()
- */
- void SetScrollPosition( float position );
-
- /**
- * @copydoc Toolkit::ScrollConnector::GetScrollPosition()
- */
- float GetScrollPosition() const
- {
- return mScrollPositionObject.GetProperty<float>( Toolkit::ScrollConnector::SCROLL_POSITION );
- }
-
- /**
- * Signal emitted after the SetScrollPosition() method has been called.
- */
- ScrollPositionChangedSignalType& ScrollPositionChangedSignal()
- {
- return mScrollPositionChangedSignal;
- }
-
- /**
- * Signal emitted after the SetScrollDomain() method has been called.
- */
- DomainChangedSignalType& DomainChangedSignal()
- {
- return mDomainChangedSignal;
- }
-
- /**
- * Retrieve the object which provides the "scroll-position" property.
- * @return The scroll-position object.
- */
- Handle GetScrollPositionObject() const
- {
- return mScrollPositionObject;
- }
-
- /**
- * Connects a callback function with the object's signals.
- * @param[in] object The object providing the signal.
- * @param[in] tracker Used to disconnect the signal.
- * @param[in] signalName The signal to connect to.
- * @param[in] functor A newly allocated FunctorDelegate.
- * @return True if the signal was connected.
- * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
- */
- static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
-
-private:
-
- /**
- * Create a new ScrollConnector.
- */
- ScrollConnector();
-
- /**
- * Virtual destructor
- */
- virtual ~ScrollConnector();
-
- // Undefined
- ScrollConnector(const ScrollConnector&);
-
- // Undefined
- ScrollConnector& operator=(const ScrollConnector& rhs);
-
-private:
-
- Handle mScrollPositionObject;
-
- DomainChangedSignalType mDomainChangedSignal;
- ScrollPositionChangedSignalType mScrollPositionChangedSignal;
-
- float mMinLimit;
- float mMaxLimit;
- float mContentLength;
-};
-
-} // namespace Internal
-
-inline Internal::ScrollConnector& GetImpl(Dali::Toolkit::ScrollConnector& obj)
-{
- DALI_ASSERT_ALWAYS(obj);
-
- Dali::BaseObject& handle = obj.GetBaseObject();
-
- return static_cast<Internal::ScrollConnector&>(handle);
-}
-
-inline const Internal::ScrollConnector& GetImpl(const Dali::Toolkit::ScrollConnector& obj)
-{
- DALI_ASSERT_ALWAYS(obj);
-
- const Dali::BaseObject& handle = obj.GetBaseObject();
-
- return static_cast<const Internal::ScrollConnector&>(handle);
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_INTERNAL_SCROLL_CONNECTOR_H__
void VisibilityConstraint( bool& current, const PropertyInputContainer& inputs )
{
const Vector2& anchor(AnchorPoint::CENTER.GetVectorXY());
- Vector2 position( inputs[0]->GetVector3() + inputs[3]->GetVector3());
+ Vector2 position( inputs[0]->GetVector3().GetVectorXY() + inputs[3]->GetVector2());
Vector2 scaledSize( inputs[2]->GetVector3() * inputs[1]->GetVector3());
Vector2 domain( inputs[4]->GetVector3() );
}
const Vector2& anchor(AnchorPoint::CENTER.GetVectorXY());
- Vector2 position(inputs[0]->GetVector3() + inputs[3]->GetVector3());
+ Vector2 position( inputs[0]->GetVector3().GetVectorXY() + inputs[3]->GetVector2());
Vector2 scaledSize(inputs[2]->GetVector3() * inputs[1]->GetVector3());
Vector2 domain(inputs[4]->GetVector3());
return;
}
- position += inputs[2]->GetVector3();
+ position.GetVectorXY() += inputs[2]->GetVector2();
const Vector2& anchor(AnchorPoint::CENTER.GetVectorXY());
Vector2 scaledSize(inputs[1]->GetVector3() * inputs[0]->GetVector3());
void RotationConstraint( Quaternion& current, const PropertyInputContainer& inputs )
{
const Vector3& pagePosition = inputs[0]->GetVector3();
- const Vector3& scrollPosition = inputs[1]->GetVector3();
+ const Vector3& scrollPosition = Vector3(inputs[1]->GetVector2());
// Get position of page.
Vector3 position = pagePosition + scrollPosition;
if(wrap)
{
- const Vector3& min = inputs[2]->GetVector3();
- const Vector3& max = inputs[3]->GetVector3();
+ const Vector2& min = inputs[2]->GetVector2();
+ const Vector2& max = inputs[3]->GetVector2();
if(fabsf(min.x - max.x) > Math::MACHINE_EPSILON_1)
{
void ColorConstraint( Vector4& current, const PropertyInputContainer& inputs )
{
const Vector3& pagePosition = inputs[0]->GetVector3();
- const Vector3& scrollPosition = inputs[1]->GetVector3();
+ const Vector3& scrollPosition = Vector3(inputs[1]->GetVector2());
// Get position of page.
Vector3 position = pagePosition + scrollPosition;
if(wrap)
{
- const Vector3& min = inputs[2]->GetVector3();
- const Vector3& max = inputs[3]->GetVector3();
+ const Vector2& min = inputs[2]->GetVector2();
+ const Vector2& max = inputs[3]->GetVector2();
if(fabsf(min.x - max.x) > Math::MACHINE_EPSILON_1)
{
void PositionConstraint( Vector3& current, const PropertyInputContainer& inputs )
{
const Vector3& pagePosition = inputs[0]->GetVector3();
- const Vector3& scrollPosition = inputs[1]->GetVector3();
+ const Vector3& scrollPosition = Vector3(inputs[1]->GetVector2());
// Get position of page.
Vector3 relativePosition = pagePosition + scrollPosition;
// short circuit: for orthognal view.
if( (fabsf(relativePosition.x) < Math::MACHINE_EPSILON_1) && (fabsf(relativePosition.y) < Math::MACHINE_EPSILON_1) )
{
- current += scrollPosition;
+ current.x += scrollPosition.x;
+ current.y += scrollPosition.y;
return;
}
if(wrap)
{
- const Vector3& min = inputs[2]->GetVector3();
- const Vector3& max = inputs[3]->GetVector3();
+ const Vector2& min = inputs[2]->GetVector2();
+ const Vector2& max = inputs[3]->GetVector2();
if(fabsf(min.x - max.x) > Math::MACHINE_EPSILON_1)
{
relativePosition.x /= pageSize.x;
relativePosition.y /= pageSize.y;
- relativePosition.z = 0.0f;
Vector3 angle( Clamp(relativePosition.x, -1.0f,1.0f) * mAngleSwing.x,
Clamp(relativePosition.y, -1.0f,1.0f) * mAngleSwing.y,
{
const Vector3& currentPosition = inputs[0]->GetVector3();
const Vector3& pagePosition = inputs[1]->GetVector3();
- const Vector3& scrollPosition = inputs[2]->GetVector3();
+ const Vector2& scrollPosition = inputs[2]->GetVector2();
// Get position of page.
- Vector3 position = pagePosition + scrollPosition;
+ Vector2 position = pagePosition.GetVectorXY() + scrollPosition;
// short circuit: for orthognal view.
if( (fabsf(position.x) < Math::MACHINE_EPSILON_1) && (fabsf(position.y) < Math::MACHINE_EPSILON_1) )
// Don't have enough parameters, to provide Wrap mode (need a way of having 'uniforms' instead of scrollWrap.GetBoolean())
- const Vector3& min = inputs[3]->GetVector3();
- const Vector3& max = inputs[4]->GetVector3();
+ const Vector2& min = inputs[3]->GetVector2();
+ const Vector2& max = inputs[4]->GetVector2();
if(fabsf(min.x - max.x) > Math::MACHINE_EPSILON_1)
{
void operator()( Vector3& currentPosition, const PropertyInputContainer& inputs )
{
const Vector3& pagePosition = inputs[0]->GetVector3();
- const Vector3& scrollPosition = inputs[1]->GetVector3();
+ const Vector2& scrollPosition = inputs[1]->GetVector2();
// Get position of page.
- Vector3 position = pagePosition + scrollPosition;
+ Vector2 position = pagePosition.GetVectorXY() + scrollPosition;
// short circuit: for orthognal view.
if( (fabsf(position.x) < Math::MACHINE_EPSILON_1) && (fabsf(position.y) < Math::MACHINE_EPSILON_1) )
{
- currentPosition += scrollPosition;
+ currentPosition.GetVectorXY() += scrollPosition;
return;
}
if(wrap)
{
- const Vector3& min = inputs[2]->GetVector3();
- const Vector3& max = inputs[3]->GetVector3();
+ const Vector2& min = inputs[2]->GetVector2();
+ const Vector2& max = inputs[3]->GetVector2();
if(fabsf(min.x - max.x) > Math::MACHINE_EPSILON_1)
{
{
// position actors at: scrollposition (Property) + pagePosition (Parent) + current (this)
// they will be invisible so doesn't have to be precise, just away from stage.
- currentPosition += scrollPosition;
+ currentPosition.GetVectorXY() += scrollPosition;
return;
}
position.y = RampFunction(position.y, mOffsetExtent.y + extent.y);
currentPosition -= pagePosition;
- currentPosition += pageSize * position;
+ currentPosition += pageSize * Vector3(position);
}
const Vector2 mPositionExtent; ///< Determines how much of the Actor's X and Y position affects exponent value.
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/scrollable/scroll-component-impl.h>
+#include <dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h>
#include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
#include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-constraints.h>
#include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-overshoot-indicator-impl.h>
namespace
{
-
-const Vector2 DEFAULT_MIN_FLICK_DISTANCE(30.0f, 30.0f); ///< minimum distance for pan before flick allowed
-const float DEFAULT_MIN_FLICK_SPEED_THRESHOLD(500.0f); ///< Minimum pan speed required for flick in pixels/s
-const float FREE_FLICK_SPEED_THRESHOLD = 200.0f; ///< Free-Flick threshold in pixels/ms
-const float AUTOLOCK_AXIS_MINIMUM_DISTANCE2 = 100.0f; ///< Auto-lock axis after minimum distance squared.
-const float FLICK_ORTHO_ANGLE_RANGE = 75.0f; ///< degrees. (if >45, then supports diagonal flicking)
+const float DEFAULT_SLOW_SNAP_ANIMATION_DURATION(0.5f); ///< Default Drag-Release animation time.
+const float DEFAULT_FAST_SNAP_ANIMATION_DURATION(0.25f); ///< Default Drag-Flick animation time.
+const float DEFAULT_SNAP_OVERSHOOT_DURATION(0.5f); ///< Default Overshoot snapping animation time.
+const float DEFAULT_MAX_OVERSHOOT(100.0f); ///< Default maximum allowed overshoot in pixels
+
+const float DEFAULT_AXIS_AUTO_LOCK_GRADIENT(0.36f); ///< Default Axis-AutoLock gradient threshold. default is 0.36:1 (20 degrees)
+const float DEFAULT_FRICTION_COEFFICIENT(1.0f); ///< Default Friction Co-efficient. (in stage diagonals per second)
+const float DEFAULT_FLICK_SPEED_COEFFICIENT(1.0f); ///< Default Flick speed coefficient (multiples input touch velocity)
+const float DEFAULT_MAX_FLICK_SPEED(3.0f); ///< Default Maximum flick speed. (in stage diagonals per second)
+
+const Vector2 DEFAULT_MIN_FLICK_DISTANCE(30.0f, 30.0f); ///< minimum distance for pan before flick allowed
+const float DEFAULT_MIN_FLICK_SPEED_THRESHOLD(500.0f); ///< Minimum pan speed required for flick in pixels/s
+const float FREE_FLICK_SPEED_THRESHOLD = 200.0f; ///< Free-Flick threshold in pixels/ms
+const float AUTOLOCK_AXIS_MINIMUM_DISTANCE2 = 100.0f; ///< Auto-lock axis after minimum distance squared.
+const float FLICK_ORTHO_ANGLE_RANGE = 75.0f; ///< degrees. (if >45, then supports diagonal flicking)
const Vector2 DEFAULT_MOUSE_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION = Vector2(0.17f, 0.1f); ///< The step of horizontal scroll distance in the proportion of stage size for each mouse wheel event received.
const unsigned long MINIMUM_TIME_BETWEEN_DOWN_AND_UP_FOR_RESET( 150u );
const float TOUCH_DOWN_TIMER_INTERVAL = 100.0f;
-const float DEFAULT_SCROLL_UPDATE_DISTANCE( 30.0f ); ///< Default distance to travel in pixels for scroll update signal
+const float DEFAULT_SCROLL_UPDATE_DISTANCE( 30.0f ); ///< Default distance to travel in pixels for scroll update signal
+
+const std::string INTERNAL_MAX_POSITION_PROPERTY_NAME( "internal-max-position" );
// Helpers ////////////////////////////////////////////////////////////////////////////////////////
* scroll domain. This is a value from 0.0f to 1.0f in each
* scroll position axis.
*/
-void InternalRelativePositionConstraint( Vector3& relativePosition, const PropertyInputContainer& inputs)
+void InternalRelativePositionConstraint( Vector2& relativePosition, const PropertyInputContainer& inputs)
{
- Vector3 position = -inputs[0]->GetVector3();
- const Vector3& min = inputs[1]->GetVector3();
- const Vector3& max = inputs[2]->GetVector3();
+ Vector2 position = -inputs[0]->GetVector2();
+ const Vector2& min = inputs[1]->GetVector2();
+ const Vector2& max = inputs[2]->GetVector2();
const Vector3& size = inputs[3]->GetVector3();
position.x = WrapInDomain(position.x, min.x, max.x);
position.y = WrapInDomain(position.y, min.y, max.y);
- Vector3 domainSize = (max - min) - size;
+ Vector2 domainSize = (max - min) - size.GetVectorXY();
relativePosition.x = domainSize.x > Math::MACHINE_EPSILON_1 ? fabsf((position.x - min.x) / domainSize.x) : 0.0f;
relativePosition.y = domainSize.y > Math::MACHINE_EPSILON_1 ? fabsf((position.y - min.y) / domainSize.y) : 0.0f;
- relativePosition.z = 0.0f;
+}
+
+/**
+ * Internal scroll domain Constraint
+ * Generates the scroll domain of the scroll view.
+ */
+void InternalScrollDomainConstraint( Vector2& scrollDomain, const PropertyInputContainer& inputs)
+{
+ const Vector2& min = inputs[0]->GetVector2();
+ const Vector2& max = inputs[1]->GetVector2();
+ const Vector3& size = inputs[2]->GetVector3();
+
+ scrollDomain = (max - min) - size.GetVectorXY();
+}
+
+/**
+ * Internal maximum scroll position Constraint
+ * Generates the maximum scroll position of the scroll view.
+ */
+void InternalPrePositionMaxConstraint( Vector2& scrollMax, const PropertyInputContainer& inputs)
+{
+ const Vector2& max = inputs[0]->GetVector2();
+ const Vector3& size = inputs[1]->GetVector3();
+
+ scrollMax = max - size.GetVectorXY();
}
} // unnamed namespace
// Setup properties, signals and actions using the type-registry.
DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ScrollView, Toolkit::Scrollable, Create )
-DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "scroll-position", VECTOR3, SCROLL_POSITION )
-DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "scroll-pre-position", VECTOR3, SCROLL_PRE_POSITION )
-DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "overshoot-x", FLOAT, OVERSHOOT_X )
-DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "overshoot-y", FLOAT, OVERSHOOT_Y )
-DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "scroll-final", VECTOR3, SCROLL_FINAL )
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "scroll-position", VECTOR2, SCROLL_POSITION)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "scroll-pre-position", VECTOR2, SCROLL_PRE_POSITION)
+DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, ScrollView, "scroll-pre-position-x", SCROLL_PRE_POSITION_X, SCROLL_PRE_POSITION, 0)
+DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, ScrollView, "scroll-pre-position-y", SCROLL_PRE_POSITION_Y, SCROLL_PRE_POSITION, 1)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "scroll-pre-position-max", VECTOR2, SCROLL_PRE_POSITION_MAX)
+DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, ScrollView, "scroll-pre-position-max-x", SCROLL_PRE_POSITION_MAX_X, SCROLL_PRE_POSITION_MAX, 0)
+DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, ScrollView, "scroll-pre-position-max-y", SCROLL_PRE_POSITION_MAX_Y, SCROLL_PRE_POSITION_MAX, 1)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "overshoot-x", FLOAT, OVERSHOOT_X)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "overshoot-y", FLOAT, OVERSHOOT_Y)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "scroll-final", VECTOR2, SCROLL_FINAL)
DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, ScrollView, "scroll-final-x", SCROLL_FINAL_X, SCROLL_FINAL,0)
DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, ScrollView, "scroll-final-y", SCROLL_FINAL_Y, SCROLL_FINAL,1)
-DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "wrap", BOOLEAN, WRAP )
-DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "panning", BOOLEAN, PANNING )
-DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "scrolling", BOOLEAN, SCROLLING )
-DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "scroll-domain-offset", VECTOR3, SCROLL_DOMAIN_OFFSET )
-DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "scroll-position-delta", VECTOR3, SCROLL_POSITION_DELTA )
-DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "start-page-position", VECTOR3, START_PAGE_POSITION )
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "wrap", BOOLEAN, WRAP)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "panning", BOOLEAN, PANNING)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "scrolling", BOOLEAN, SCROLLING)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "scroll-domain-size", VECTOR2, SCROLL_DOMAIN_SIZE)
+DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, ScrollView, "scroll-domain-size-x", SCROLL_DOMAIN_SIZE_X, SCROLL_DOMAIN_SIZE, 0)
+DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, ScrollView, "scroll-domain-size-y", SCROLL_DOMAIN_SIZE_Y, SCROLL_DOMAIN_SIZE, 1)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "scroll-domain-offset", VECTOR2, SCROLL_DOMAIN_OFFSET)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "scroll-position-delta", VECTOR2, SCROLL_POSITION_DELTA)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "start-page-position", VECTOR3, START_PAGE_POSITION)
+
DALI_SIGNAL_REGISTRATION( Toolkit, ScrollView, "value-changed", SIGNAL_SNAP_STARTED )
DALI_TYPE_REGISTRATION_END()
{
}
- void operator()( Vector3& scrollPostPosition, const PropertyInputContainer& inputs )
+ void operator()( Vector2& scrollPostPosition, const PropertyInputContainer& inputs )
{
const Vector2& panPosition = inputs[0]->GetVector2();
// Perform Position transform based on input deltas...
scrollPostPosition = mPrePosition;
- scrollPostPosition.GetVectorXY() += panDelta;
+ scrollPostPosition += panDelta;
// if no wrapping then clamp preposition to maximum overshoot amount
const Vector3& size = inputs[1]->GetVector3();
}
}
- Vector3 mPrePosition;
+ Vector2 mPrePosition;
Vector2 mLocalStart;
Vector2 mInitialPanMask; ///< Initial pan mask (based on ruler settings)
Vector2 mCurrentPanMask; ///< Current pan mask that can be altered by axis lock mode.
{
}
- void operator()( Vector3& position, const PropertyInputContainer& inputs )
+ void operator()( Vector2& position, const PropertyInputContainer& inputs )
{
- position = inputs[0]->GetVector3();
+ position = inputs[0]->GetVector2();
const Vector2& size = inputs[3]->GetVector3().GetVectorXY();
- const Vector3& min = inputs[1]->GetVector3();
- const Vector3& max = inputs[2]->GetVector3();
+ const Vector2& min = inputs[1]->GetVector2();
+ const Vector2& max = inputs[2]->GetVector2();
if( mWrap )
{
{
if( inputs[2]->GetBoolean() )
{
- const Vector3& scrollPrePosition = inputs[0]->GetVector3();
- const Vector3& scrollPostPosition = inputs[1]->GetVector3();
+ const Vector2& scrollPrePosition = inputs[0]->GetVector2();
+ const Vector2& scrollPostPosition = inputs[1]->GetVector2();
float newOvershoot = scrollPrePosition.x - scrollPostPosition.x;
current = (newOvershoot > 0.0f ? std::min(newOvershoot, mMaxOvershoot) : std::max(newOvershoot, -mMaxOvershoot)) / mMaxOvershoot;
}
{
if( inputs[2]->GetBoolean() )
{
- const Vector3& scrollPrePosition = inputs[0]->GetVector3();
- const Vector3& scrollPostPosition = inputs[1]->GetVector3();
+ const Vector2& scrollPrePosition = inputs[0]->GetVector2();
+ const Vector2& scrollPostPosition = inputs[1]->GetVector2();
float newOvershoot = scrollPrePosition.y - scrollPostPosition.y;
current = (newOvershoot > 0.0f ? std::min(newOvershoot, mMaxOvershoot) : std::max(newOvershoot, -mMaxOvershoot)) / mMaxOvershoot;
}
*
* Generates position-delta property based on scroll-position + scroll-offset properties.
*/
-void InternalPositionDeltaConstraint( Vector3& current, const PropertyInputContainer& inputs )
+void InternalPositionDeltaConstraint( Vector2& current, const PropertyInputContainer& inputs )
{
- const Vector3& scrollPosition = inputs[0]->GetVector3();
- const Vector3& scrollOffset = inputs[1]->GetVector3();
+ const Vector2& scrollPosition = inputs[0]->GetVector2();
+ const Vector2& scrollOffset = inputs[1]->GetVector2();
current = scrollPosition + scrollOffset;
}
{
}
- void operator()( Vector3& current, const PropertyInputContainer& inputs )
+ void operator()( Vector2& current, const PropertyInputContainer& inputs )
{
const float& overshootx = inputs[1]->GetFloat();
const float& overshooty = inputs[2]->GetFloat();
- Vector3 offset( mFunctionX(overshootx),
- mFunctionY(overshooty),
- 0.0f);
+ Vector2 offset( mFunctionX(overshootx),
+ mFunctionY(overshooty) );
- current = inputs[0]->GetVector3() - offset;
+ current = inputs[0]->GetVector2() - offset;
}
AlphaFunctionPrototype mFunctionX;
mScrollStateFlags(0),
mLockAxis(LockPossible),
mScrollUpdateDistance(DEFAULT_SCROLL_UPDATE_DISTANCE),
- mMaxOvershoot(Toolkit::ScrollView::DEFAULT_MAX_OVERSHOOT, Toolkit::ScrollView::DEFAULT_MAX_OVERSHOOT),
- mUserMaxOvershoot(Toolkit::ScrollView::DEFAULT_MAX_OVERSHOOT, Toolkit::ScrollView::DEFAULT_MAX_OVERSHOOT),
- mSnapOvershootDuration(Toolkit::ScrollView::DEFAULT_SNAP_OVERSHOOT_DURATION),
+ mMaxOvershoot(DEFAULT_MAX_OVERSHOOT, DEFAULT_MAX_OVERSHOOT),
+ mUserMaxOvershoot(DEFAULT_MAX_OVERSHOOT, DEFAULT_MAX_OVERSHOOT),
+ mSnapOvershootDuration(DEFAULT_SNAP_OVERSHOOT_DURATION),
mSnapOvershootAlphaFunction(AlphaFunction::EASE_OUT),
- mSnapDuration(Toolkit::ScrollView::DEFAULT_SLOW_SNAP_ANIMATION_DURATION),
+ mSnapDuration(DEFAULT_SLOW_SNAP_ANIMATION_DURATION),
mSnapAlphaFunction(AlphaFunction::EASE_OUT),
mMinFlickDistance(DEFAULT_MIN_FLICK_DISTANCE),
mFlickSpeedThreshold(DEFAULT_MIN_FLICK_SPEED_THRESHOLD),
- mFlickDuration(Toolkit::ScrollView::DEFAULT_FAST_SNAP_ANIMATION_DURATION),
+ mFlickDuration(DEFAULT_FAST_SNAP_ANIMATION_DURATION),
mFlickAlphaFunction(AlphaFunction::EASE_OUT),
- mAxisAutoLockGradient(Toolkit::ScrollView::DEFAULT_AXIS_AUTO_LOCK_GRADIENT),
- mFrictionCoefficient(Toolkit::ScrollView::DEFAULT_FRICTION_COEFFICIENT),
- mFlickSpeedCoefficient(Toolkit::ScrollView::DEFAULT_FLICK_SPEED_COEFFICIENT),
- mMaxFlickSpeed(Toolkit::ScrollView::DEFAULT_MAX_FLICK_SPEED),
+ mAxisAutoLockGradient(DEFAULT_AXIS_AUTO_LOCK_GRADIENT),
+ mFrictionCoefficient(DEFAULT_FRICTION_COEFFICIENT),
+ mFlickSpeedCoefficient(DEFAULT_FLICK_SPEED_COEFFICIENT),
+ mMaxFlickSpeed(DEFAULT_MAX_FLICK_SPEED),
+ mMouseWheelScrollDistanceStep(Vector2::ZERO),
mInAccessibilityPan(false),
mInitialized(false),
mScrolling(false),
mInternalActor = Actor::New();
mInternalActor.SetDrawMode(DrawMode::OVERLAY);
self.Add(mInternalActor);
- Constraint constraint = Constraint::New<Vector3>( mInternalActor, Actor::Property::SIZE, EqualToConstraint() );
- constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
- constraint.Apply();
+
mInternalActor.SetParentOrigin(ParentOrigin::CENTER);
mInternalActor.SetAnchorPoint(AnchorPoint::CENTER);
+ mInternalActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
mAlterChild = true;
- mScrollPostPosition = mScrollPrePosition = Vector3::ZERO;
+ mScrollPostPosition = mScrollPrePosition = Vector2::ZERO;
mMouseWheelScrollDistanceStep = Stage::GetCurrent().GetSize() * DEFAULT_MOUSE_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION;
mRulerX = ruler;
mRulerY = ruler;
- EnableScrollComponent(Toolkit::Scrollable::OvershootIndicator);
+ SetOvershootEnabled(true);
self.SetProperty(Toolkit::Scrollable::Property::CAN_SCROLL_VERTICAL, mCanScrollVertical);
self.SetProperty(Toolkit::Scrollable::Property::CAN_SCROLL_HORIZONTAL, mCanScrollHorizontal);
SetScrollSensitive( false );
SetScrollSensitive( true );
}
- if(IsScrollComponentEnabled(Toolkit::Scrollable::OvershootIndicator))
+ if(IsOvershootEnabled())
{
// try and make sure property notifications are set
- EnableScrollComponent(Toolkit::Scrollable::OvershootIndicator);
+ EnableScrollOvershoot(true);
}
}
void ScrollView::UpdatePropertyDomain(const Vector3& size)
{
Actor self = Self();
- Vector3 min = mMinScroll;
- Vector3 max = mMaxScroll;
+ Vector2 min = mMinScroll;
+ Vector2 max = mMaxScroll;
bool scrollPositionChanged = false;
bool domainChanged = false;
unsigned int ScrollView::GetCurrentPage() const
{
// in case animation is currently taking place.
- Vector3 position = GetPropertyPosition();
+ Vector2 position = GetPropertyPosition();
Actor self = Self();
unsigned int page = 0;
return volume * pagesPerVolume + page;
}
-Vector3 ScrollView::GetCurrentScrollPosition() const
+Vector2 ScrollView::GetCurrentScrollPosition() const
{
return -GetPropertyPosition();
}
-void ScrollView::SetScrollPosition(const Vector3& position)
+void ScrollView::SetScrollPosition(const Vector2& position)
{
mScrollPrePosition = position;
}
-Vector3 ScrollView::GetDomainSize() const
+Vector2 ScrollView::GetDomainSize() const
{
Vector3 size = Self().GetCurrentSize();
const RulerDomain& xDomain = GetRulerX()->GetDomain();
const RulerDomain& yDomain = GetRulerY()->GetDomain();
- Vector3 domainSize = Vector3( xDomain.max - xDomain.min, yDomain.max - yDomain.min, 0.0f ) - size;
+ Vector2 domainSize;
+ domainSize.x = xDomain.max - xDomain.min - size.x;
+ domainSize.y = yDomain.max - yDomain.min - size.y;
return domainSize;
}
-void ScrollView::TransformTo(const Vector3& position,
+void ScrollView::TransformTo(const Vector2& position,
DirectionBias horizontalBias, DirectionBias verticalBias)
{
TransformTo(position, mSnapDuration, mSnapAlphaFunction, horizontalBias, verticalBias);
}
-void ScrollView::TransformTo(const Vector3& position, float duration, AlphaFunction alpha,
+void ScrollView::TransformTo(const Vector2& position, float duration, AlphaFunction alpha,
DirectionBias horizontalBias, DirectionBias verticalBias)
{
// If this is called while the timer is running, then cancel it
DALI_LOG_SCROLL_STATE("[0x%X] pos[%.2f,%.2f], duration[%.2f] bias[%d, %d]",
this, position.x, position.y, duration, int(horizontalBias), int(verticalBias));
- Vector3 currentScrollPosition = GetCurrentScrollPosition();
- self.SetProperty( Toolkit::ScrollView::Property::START_PAGE_POSITION, currentScrollPosition );
+ Vector2 currentScrollPosition = GetCurrentScrollPosition();
+ self.SetProperty( Toolkit::ScrollView::Property::START_PAGE_POSITION, Vector3(currentScrollPosition) );
if( mScrolling ) // are we interrupting a current scroll?
{
DALI_LOG_SCROLL_STATE("[0x%X] mScrollStartedSignal 1 [%.2f, %.2f]", this, currentScrollPosition.x, currentScrollPosition.y);
mScrollStartedSignal.Emit( currentScrollPosition );
bool animating = AnimateTo(-position,
- Vector3::ONE * duration,
+ Vector2::ONE * duration,
alpha,
true,
horizontalBias,
// If we have no duration, then in the next update frame, we will be at the position specified as we just set.
// In this scenario, we cannot return the currentScrollPosition as this is out-of-date and should instead return the requested final position
- Vector3 completedPosition( currentScrollPosition );
+ Vector2 completedPosition( currentScrollPosition );
if( duration <= Math::MACHINE_EPSILON_10 )
{
completedPosition = position;
}
}
-void ScrollView::ScrollTo(const Vector3& position)
+void ScrollView::ScrollTo(const Vector2& position)
{
ScrollTo(position, mSnapDuration );
}
-void ScrollView::ScrollTo(const Vector3& position, float duration)
+void ScrollView::ScrollTo(const Vector2& position, float duration)
{
ScrollTo(position, duration, DirectionBiasNone, DirectionBiasNone);
}
-void ScrollView::ScrollTo(const Vector3& position, float duration, AlphaFunction alpha)
+void ScrollView::ScrollTo(const Vector2& position, float duration, AlphaFunction alpha)
{
ScrollTo(position, duration, alpha, DirectionBiasNone, DirectionBiasNone);
}
-void ScrollView::ScrollTo(const Vector3& position, float duration,
+void ScrollView::ScrollTo(const Vector2& position, float duration,
DirectionBias horizontalBias, DirectionBias verticalBias)
{
ScrollTo(position, duration, mSnapAlphaFunction, horizontalBias, verticalBias);
}
-void ScrollView::ScrollTo(const Vector3& position, float duration, AlphaFunction alpha,
+void ScrollView::ScrollTo(const Vector2& position, float duration, AlphaFunction alpha,
DirectionBias horizontalBias, DirectionBias verticalBias)
{
DALI_LOG_SCROLL_STATE("[0x%X] position[%.2f, %.2f] duration[%.2f], bias[%d, %d]", this, position.x, position.y, duration, int(horizontalBias), int(verticalBias));
void ScrollView::ScrollTo(unsigned int page, float duration, DirectionBias bias)
{
- Vector3 position;
+ Vector2 position;
unsigned int volume;
unsigned int libraries;
Actor self = Self();
Vector3 size = self.GetCurrentSize();
Vector3 position = actor.GetCurrentPosition();
- position -= GetPropertyPrePosition();
+ Vector2 prePosition = GetPropertyPrePosition();
+ position.GetVectorXY() -= prePosition;
- ScrollTo(Vector3(position.x - size.width * 0.5f, position.y - size.height * 0.5f, 0.0f), duration);
+ ScrollTo(Vector2(position.x - size.width * 0.5f, position.y - size.height * 0.5f), duration);
}
Actor ScrollView::FindClosestActor()
float angle = atan2(velocity.y, velocity.x);
float speed2 = velocity.LengthSquared();
AlphaFunction alphaFunction = mSnapAlphaFunction;
- Vector3 positionDuration = Vector3::ONE * mSnapDuration;
+ Vector2 positionDuration = Vector2::ONE * mSnapDuration;
float biasX = 0.5f;
float biasY = 0.5f;
FindDirection horizontal = None;
const float orthoAngleRange = FLICK_ORTHO_ANGLE_RANGE * M_PI / 180.0f;
const float flickSpeedThreshold2 = mFlickSpeedThreshold * mFlickSpeedThreshold;
- Vector3 positionSnap = mScrollPrePosition;
+ Vector2 positionSnap = mScrollPrePosition;
// Flick logic X Axis
if(isFlick || isFreeFlick)
{
- positionDuration = Vector3::ONE * mFlickDuration;
+ positionDuration = Vector2::ONE * mFlickDuration;
alphaFunction = mFlickAlphaFunction;
}
if(child)
{
- Vector3 position = Self().GetProperty<Vector3>(Toolkit::ScrollView::Property::SCROLL_POSITION);
+ Vector2 position = Self().GetProperty<Vector2>(Toolkit::ScrollView::Property::SCROLL_POSITION);
// Get center-point of the Actor.
Vector3 childPosition = GetPositionOfAnchor(child, AnchorPoint::CENTER);
}
}
- Vector3 startPosition = positionSnap;
+ Vector2 startPosition = positionSnap;
positionSnap.x = -mRulerX->Snap(-positionSnap.x, biasX); // NOTE: X & Y rulers think in -ve coordinate system.
positionSnap.y = -mRulerY->Snap(-positionSnap.y, biasY); // That is scrolling RIGHT (e.g. 100.0, 0.0) means moving LEFT.
- Vector3 clampDelta(Vector3::ZERO);
+ Vector2 clampDelta(Vector2::ZERO);
ClampPosition(positionSnap);
if( (mRulerX->GetType() == Ruler::Free || mRulerY->GetType() == Ruler::Free)
}
else
{
- clampDelta = Vector3::ZERO;
+ clampDelta = Vector2::ZERO;
}
// If Axis is Free and has velocity, then calculate time taken
}
}
- if(IsScrollComponentEnabled(Toolkit::Scrollable::OvershootIndicator))
+ if(IsOvershootEnabled())
{
// Scroll to the end of the overshoot only when overshoot is enabled.
positionSnap += clampDelta;
}
}
-bool ScrollView::AnimateTo(const Vector3& position, const Vector3& positionDuration,
+bool ScrollView::AnimateTo(const Vector2& position, const Vector2& positionDuration,
AlphaFunction alpha, bool findShortcuts,
DirectionBias horizontalBias, DirectionBias verticalBias,
SnapType snapType)
}
DALI_LOG_SCROLL_STATE("[0x%X] position-changed, mScrollTargetPosition[%.2f, %.2f], mScrollPrePosition[%.2f, %.2f], mScrollPostPosition[%.2f, %.2f]", this, mScrollTargetPosition.x, mScrollTargetPosition.y, mScrollPrePosition.x, mScrollPrePosition.y, mScrollPostPosition.x, mScrollPostPosition.y );
- DALI_LOG_SCROLL_STATE("[0x%X] SCROLL_PRE_POSITION[%.2f, %.2f], SCROLL_POSITION[%.2f, %.2f]", this, self.GetProperty( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get<Vector3>().x, self.GetProperty( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get<Vector3>().y, self.GetProperty( Toolkit::ScrollView::Property::SCROLL_POSITION ).Get<Vector3>().x, self.GetProperty( Toolkit::ScrollView::Property::SCROLL_POSITION ).Get<Vector3>().y );
+ DALI_LOG_SCROLL_STATE("[0x%X] SCROLL_PRE_POSITION[%.2f, %.2f], SCROLL_POSITION[%.2f, %.2f]", this, self.GetProperty( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get<Vector2>().x, self.GetProperty( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get<Vector2>().y, self.GetProperty( Toolkit::ScrollView::Property::SCROLL_POSITION ).Get<Vector2>().x, self.GetProperty( Toolkit::ScrollView::Property::SCROLL_POSITION ).Get<Vector2>().y );
}
SetScrollUpdateNotification(true);
return (mScrollStateFlags & SCROLL_ANIMATION_FLAGS) != 0;
}
-void ScrollView::SetOvershootEnabled(bool enabled)
+void ScrollView::EnableScrollOvershoot(bool enable)
{
- if(enabled && !mOvershootIndicator)
+ if(enable && !mOvershootIndicator)
{
mOvershootIndicator = ScrollOvershootIndicator::New();
}
- if( enabled )
+ if( enable )
{
mOvershootIndicator->AttachToScrollable(*this);
}
UnbindActor(child);
}
-Vector3 ScrollView::GetPropertyPrePosition() const
+Vector2 ScrollView::GetPropertyPrePosition() const
{
- Vector3 position = Self().GetProperty<Vector3>(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION);
+ Vector2 position = Self().GetProperty<Vector2>(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION);
WrapPosition(position);
return position;
}
-Vector3 ScrollView::GetPropertyPosition() const
+Vector2 ScrollView::GetPropertyPosition() const
{
- Vector3 position = Self().GetProperty<Vector3>(Toolkit::ScrollView::Property::SCROLL_POSITION);
+ Vector2 position = Self().GetProperty<Vector2>(Toolkit::ScrollView::Property::SCROLL_POSITION);
WrapPosition(position);
return position;
Actor self = Self();
self.SetProperty(Toolkit::ScrollView::Property::SCROLLING, false);
- Vector3 deltaPosition(mScrollPrePosition);
+ Vector2 deltaPosition(mScrollPrePosition);
UpdateLocalScrollProperties();
WrapPosition(mScrollPrePosition);
DALI_LOG_SCROLL_STATE("[0x%X] Setting SCROLL_PRE_POSITION To[%.2f, %.2f]", this, mScrollPrePosition.x, mScrollPrePosition.y );
self.SetProperty(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION, mScrollPrePosition);
- Vector3 currentScrollPosition = GetCurrentScrollPosition();
+ Vector2 currentScrollPosition = GetCurrentScrollPosition();
DALI_LOG_SCROLL_STATE("[0x%X] mScrollCompletedSignal 3 current[%.2f, %.2f], mScrollTargetPosition[%.2f, %.2f]", this, currentScrollPosition.x, currentScrollPosition.y, -mScrollTargetPosition.x, -mScrollTargetPosition.y );
mScrollCompletedSignal.Emit( currentScrollPosition );
// Guard against destruction during signal emission
Toolkit::ScrollView handle( GetOwner() );
- Vector3 currentScrollPosition = GetCurrentScrollPosition();
+ Vector2 currentScrollPosition = GetCurrentScrollPosition();
mScrollUpdatedSignal.Emit( currentScrollPosition );
}
{
mUserMaxOvershoot.x = size.x * 0.5f;
mUserMaxOvershoot.y = size.y * 0.5f;
- if( !IsScrollComponentEnabled(Toolkit::Scrollable::OvershootIndicator) )
+ if( !IsOvershootEnabled() )
{
mMaxOvershoot = mUserMaxOvershoot;
}
}
UpdatePropertyDomain(size);
UpdateMainInternalConstraint();
- if( IsScrollComponentEnabled(Toolkit::Scrollable::OvershootIndicator) )
+ if( IsOvershootEnabled() )
{
mOvershootIndicator->Reset();
}
void ScrollView::OnChildAdd(Actor& child)
{
- if(mAlterChild)
+ Dali::Toolkit::ScrollBar scrollBar = Dali::Toolkit::ScrollBar::DownCast(child);
+ if(scrollBar)
+ {
+ mInternalActor.Add(scrollBar);
+ if(scrollBar.GetScrollDirection() == Toolkit::ScrollBar::Horizontal)
+ {
+ scrollBar.SetScrollPropertySource(Self(),
+ Toolkit::ScrollView::Property::SCROLL_PRE_POSITION_X,
+ Toolkit::Scrollable::Property::SCROLL_POSITION_MIN_X,
+ Toolkit::ScrollView::Property::SCROLL_PRE_POSITION_MAX_X,
+ Toolkit::ScrollView::Property::SCROLL_DOMAIN_SIZE_X);
+ }
+ else
+ {
+ scrollBar.SetScrollPropertySource(Self(),
+ Toolkit::ScrollView::Property::SCROLL_PRE_POSITION_Y,
+ Toolkit::Scrollable::Property::SCROLL_POSITION_MIN_Y,
+ Toolkit::ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y,
+ Toolkit::ScrollView::Property::SCROLL_DOMAIN_SIZE_Y);
+ }
+ }
+ else if(mAlterChild)
{
BindActor(child);
}
mScrollInterrupted = true;
// reset domain offset as scrolling from original plane.
- mDomainOffset = Vector3::ZERO;
- Self().SetProperty(Toolkit::ScrollView::Property::SCROLL_DOMAIN_OFFSET, Vector3::ZERO);
+ mDomainOffset = Vector2::ZERO;
+ Self().SetProperty(Toolkit::ScrollView::Property::SCROLL_DOMAIN_OFFSET, Vector2::ZERO);
UpdateLocalScrollProperties();
- Vector3 currentScrollPosition = GetCurrentScrollPosition();
+ Vector2 currentScrollPosition = GetCurrentScrollPosition();
DALI_LOG_SCROLL_STATE("[0x%X] mScrollCompletedSignal 4 [%.2f, %.2f]", this, currentScrollPosition.x, currentScrollPosition.y);
mScrollCompletedSignal.Emit( currentScrollPosition );
}
return false;
}
- Vector3 targetScrollPosition = GetPropertyPosition();
+ Vector2 targetScrollPosition = GetPropertyPosition();
if(mRulerX->IsEnabled() && !mRulerY->IsEnabled())
{
Actor self = Self();
- Vector3 deltaPosition(mScrollPostPosition);
+ Vector2 deltaPosition(mScrollPostPosition);
WrapPosition(mScrollPostPosition);
mDomainOffset += deltaPosition - mScrollPostPosition;
Self().SetProperty(Toolkit::ScrollView::Property::SCROLL_DOMAIN_OFFSET, mDomainOffset);
if( duration > Math::MACHINE_EPSILON_10 )
{
Actor self = Self();
- DALI_LOG_SCROLL_STATE("[0x%X], Animating from[%.2f] to[%.2f]", this, self.GetProperty(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector3>().x, position );
+ DALI_LOG_SCROLL_STATE("[0x%X], Animating from[%.2f] to[%.2f]", this, self.GetProperty(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>().x, position );
mInternalXAnimation = Animation::New(duration);
DALI_LOG_SCROLL_STATE("[0x%X], mInternalXAnimation[0x%X]", this, mInternalXAnimation.GetObjectPtr() );
mInternalXAnimation.FinishedSignal().Connect(this, &ScrollView::OnScrollAnimationFinished);
if( duration > Math::MACHINE_EPSILON_10 )
{
Actor self = Self();
- DALI_LOG_SCROLL_STATE("[0x%X], Animating from[%.2f] to[%.2f]", this, self.GetProperty(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector3>().y, position );
+ DALI_LOG_SCROLL_STATE("[0x%X], Animating from[%.2f] to[%.2f]", this, self.GetProperty(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>().y, position );
mInternalYAnimation = Animation::New(duration);
DALI_LOG_SCROLL_STATE("[0x%X], mInternalYAnimation[0x%X]", this, mInternalYAnimation.GetObjectPtr() );
mInternalYAnimation.FinishedSignal().Connect(this, &ScrollView::OnScrollAnimationFinished);
if( source == mInternalXAnimation )
{
- DALI_LOG_SCROLL_STATE("[0x%X] mInternalXAnimation[0x%X], expected[%.2f], actual[%.2f], post[%.2f]", this, mInternalXAnimation.GetObjectPtr(), mScrollTargetPosition.x, Self().GetProperty(SCROLL_PRE_POSITION).Get<Vector3>().x, mScrollPostPosition.x );
+ DALI_LOG_SCROLL_STATE("[0x%X] mInternalXAnimation[0x%X], expected[%.2f], actual[%.2f], post[%.2f]", this, mInternalXAnimation.GetObjectPtr(), mScrollTargetPosition.x, Self().GetProperty(SCROLL_PRE_POSITION).Get<Vector2>().x, mScrollPostPosition.x );
if( !(mScrollStateFlags & AnimatingInternalY) )
{
if( source == mInternalYAnimation )
{
- DALI_LOG_SCROLL_STATE("[0x%X] mInternalYAnimation[0x%X], expected[%.2f], actual[%.2f], post[%.2f]", this, mInternalYAnimation.GetObjectPtr(), mScrollTargetPosition.y, Self().GetProperty(SCROLL_PRE_POSITION).Get<Vector3>().y, mScrollPostPosition.y );
+ DALI_LOG_SCROLL_STATE("[0x%X] mInternalYAnimation[0x%X], expected[%.2f], actual[%.2f], post[%.2f]", this, mInternalYAnimation.GetObjectPtr(), mScrollTargetPosition.y, Self().GetProperty(SCROLL_PRE_POSITION).Get<Vector2>().y, mScrollPostPosition.y );
if( !(mScrollStateFlags & AnimatingInternalX) )
{
Actor self = Self();
StopTouchDownTimer();
StopAnimation();
- mPanDelta = Vector3::ZERO;
- mLastVelocity = Vector2(0.0f, 0.0f);
+ mPanDelta = Vector2::ZERO;
+ mLastVelocity = Vector2::ZERO;
if( !mScrolling )
{
mLockAxis = LockPossible;
// appears mostly horizontal or mostly vertical respectively.
if(mAxisAutoLock)
{
- mLockAxis = GetLockAxis(mPanDelta.GetVectorXY(), mLockAxis, mAxisAutoLockGradient);
+ mLockAxis = GetLockAxis(mPanDelta, mLockAxis, mAxisAutoLockGradient);
} // end if mAxisAutoLock
}
if(state == Gesture::Started)
{
- Vector3 currentScrollPosition = GetCurrentScrollPosition();
+ Vector2 currentScrollPosition = GetCurrentScrollPosition();
Self().SetProperty(Toolkit::ScrollView::Property::SCROLLING, true);
mScrolling = true;
DALI_LOG_SCROLL_STATE("[0x%X] mScrollStartedSignal 2 [%.2f, %.2f]", this, currentScrollPosition.x, currentScrollPosition.y);
{
SnapInternalYTo(mScrollTargetPosition.y);
}
- Vector3 currentScrollPosition = GetCurrentScrollPosition();
+ Vector2 currentScrollPosition = GetCurrentScrollPosition();
DALI_LOG_SCROLL_STATE("[0x%X] mScrollCompletedSignal 6 [%.2f, %.2f]", this, currentScrollPosition.x, currentScrollPosition.y);
mScrollCompletedSignal.Emit( currentScrollPosition );
}
}
-Vector3 ScrollView::GetOvershoot(Vector3& position) const
+Vector2 ScrollView::GetOvershoot(Vector2& position) const
{
Vector3 size = Self().GetCurrentSize();
- Vector3 overshoot;
+ Vector2 overshoot;
const RulerDomain rulerDomainX = mRulerX->GetDomain();
const RulerDomain rulerDomainY = mRulerY->GetDomain();
return true;
}
-void ScrollView::ClampPosition(Vector3& position) const
+void ScrollView::ClampPosition(Vector2& position) const
{
- ClampState3D clamped;
+ ClampState2D clamped;
ClampPosition(position, clamped);
}
-void ScrollView::ClampPosition(Vector3& position, ClampState3D &clamped) const
+void ScrollView::ClampPosition(Vector2& position, ClampState2D &clamped) const
{
Vector3 size = Self().GetCurrentSize();
position.x = -mRulerX->Clamp(-position.x, size.width, 1.0f, clamped.x); // NOTE: X & Y rulers think in -ve coordinate system.
position.y = -mRulerY->Clamp(-position.y, size.height, 1.0f, clamped.y); // That is scrolling RIGHT (e.g. 100.0, 0.0) means moving LEFT.
-
- clamped.z = NotClamped;
}
-void ScrollView::WrapPosition(Vector3& position) const
+void ScrollView::WrapPosition(Vector2& position) const
{
if(mWrapMode)
{
mScrollMainInternalDeltaConstraint.Remove();
mScrollMainInternalFinalConstraint.Remove();
mScrollMainInternalRelativeConstraint.Remove();
+ mScrollMainInternalDomainConstraint.Remove();
+ mScrollMainInternalPrePositionMaxConstraint.Remove();
}
if( mScrollMainInternalPrePositionConstraint )
{
if( mPanning )
{
- mScrollMainInternalPrePositionConstraint = Constraint::New<Vector3>( self,
+ mScrollMainInternalPrePositionConstraint = Constraint::New<Vector2>( self,
Toolkit::ScrollView::Property::SCROLL_PRE_POSITION,
InternalPrePositionConstraint( mPanStartPosition,
initialPanMask,
}
// 2. Second calculate the clamped position (actual position)
- mScrollMainInternalPositionConstraint = Constraint::New<Vector3>( self,
+ mScrollMainInternalPositionConstraint = Constraint::New<Vector2>( self,
Toolkit::ScrollView::Property::SCROLL_POSITION,
InternalPositionConstraint( mRulerX->GetDomain(),
mRulerY->GetDomain(),
mScrollMainInternalPositionConstraint.AddSource( Source( self, Actor::Property::SIZE ) );
mScrollMainInternalPositionConstraint.Apply();
- mScrollMainInternalDeltaConstraint = Constraint::New<Vector3>( self, Toolkit::ScrollView::Property::SCROLL_POSITION_DELTA, InternalPositionDeltaConstraint );
+ mScrollMainInternalDeltaConstraint = Constraint::New<Vector2>( self, Toolkit::ScrollView::Property::SCROLL_POSITION_DELTA, InternalPositionDeltaConstraint );
mScrollMainInternalDeltaConstraint.AddSource( LocalSource( Toolkit::ScrollView::Property::SCROLL_POSITION ) );
mScrollMainInternalDeltaConstraint.AddSource( LocalSource( Toolkit::ScrollView::Property::SCROLL_DOMAIN_OFFSET ) );
mScrollMainInternalDeltaConstraint.Apply();
- mScrollMainInternalFinalConstraint = Constraint::New<Vector3>( self, Toolkit::ScrollView::Property::SCROLL_FINAL,
+ mScrollMainInternalFinalConstraint = Constraint::New<Vector2>( self, Toolkit::ScrollView::Property::SCROLL_FINAL,
InternalFinalConstraint( FinalDefaultAlphaFunction,
FinalDefaultAlphaFunction ) );
- mScrollMainInternalFinalConstraint .AddSource( LocalSource( Toolkit::ScrollView::Property::SCROLL_POSITION ) );
- mScrollMainInternalFinalConstraint .AddSource( LocalSource( Toolkit::ScrollView::Property::OVERSHOOT_X ) );
- mScrollMainInternalFinalConstraint .AddSource( LocalSource( Toolkit::ScrollView::Property::OVERSHOOT_Y ) );
+ mScrollMainInternalFinalConstraint.AddSource( LocalSource( Toolkit::ScrollView::Property::SCROLL_POSITION ) );
+ mScrollMainInternalFinalConstraint.AddSource( LocalSource( Toolkit::ScrollView::Property::OVERSHOOT_X ) );
+ mScrollMainInternalFinalConstraint.AddSource( LocalSource( Toolkit::ScrollView::Property::OVERSHOOT_Y ) );
mScrollMainInternalFinalConstraint.Apply();
- mScrollMainInternalRelativeConstraint = Constraint::New<Vector3>( self, Toolkit::Scrollable::Property::SCROLL_RELATIVE_POSITION, InternalRelativePositionConstraint );
+ mScrollMainInternalRelativeConstraint = Constraint::New<Vector2>( self, Toolkit::Scrollable::Property::SCROLL_RELATIVE_POSITION, InternalRelativePositionConstraint );
mScrollMainInternalRelativeConstraint.AddSource( LocalSource( Toolkit::ScrollView::Property::SCROLL_POSITION ) );
mScrollMainInternalRelativeConstraint.AddSource( LocalSource( Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
mScrollMainInternalRelativeConstraint.AddSource( LocalSource( Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
mScrollMainInternalRelativeConstraint.AddSource( LocalSource( Actor::Property::SIZE ) );
mScrollMainInternalRelativeConstraint.Apply();
+ mScrollMainInternalDomainConstraint = Constraint::New<Vector2>( self, Toolkit::ScrollView::Property::SCROLL_DOMAIN_SIZE, InternalScrollDomainConstraint );
+ mScrollMainInternalDomainConstraint.AddSource( LocalSource( Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+ mScrollMainInternalDomainConstraint.AddSource( LocalSource( Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ mScrollMainInternalDomainConstraint.AddSource( LocalSource( Actor::Property::SIZE ) );
+ mScrollMainInternalDomainConstraint.Apply();
+
+ mScrollMainInternalPrePositionMaxConstraint = Constraint::New<Vector2>( self, Toolkit::ScrollView::Property::SCROLL_PRE_POSITION_MAX, InternalPrePositionMaxConstraint );
+ mScrollMainInternalPrePositionMaxConstraint.AddSource( LocalSource( Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ mScrollMainInternalPrePositionMaxConstraint.AddSource( LocalSource( Actor::Property::SIZE ) );
+ mScrollMainInternalPrePositionMaxConstraint.Apply();
+
// When panning we want to make sure overshoot values are affected by pre position and post position
SetOvershootConstraintsEnabled(!mWrapMode);
}
/**
* @copydoc Toolkit::ScrollView::GetCurrentScrollPosition
*/
- Vector3 GetCurrentScrollPosition() const;
+ Vector2 GetCurrentScrollPosition() const;
/**
* @copydoc Toolkit::ScrollView::SetScrollPosition
*/
- void SetScrollPosition(const Vector3& position);
+ void SetScrollPosition(const Vector2& position);
/**
* @copydoc Toolkit::Scrollable::GetDomainSize
*/
- Vector3 GetDomainSize() const;
+ Vector2 GetDomainSize() const;
/**
- * @copydoc ScrollTo(const Vector3&)
+ * @copydoc ScrollTo(const Vector2&)
*/
- void TransformTo(const Vector3& position,
+ void TransformTo(const Vector2& position,
DirectionBias horizontalBias = DirectionBiasNone, DirectionBias verticalBias = DirectionBiasNone);
/**
- * @copydoc ScrollTo(const Vector3&, float, AlhpaFunction, DirectionBias, DirectionBias)
+ * @copydoc ScrollTo(const Vector2&, float, AlhpaFunction, DirectionBias, DirectionBias)
*/
- void TransformTo(const Vector3& position, float duration, AlphaFunction alpha,
+ void TransformTo(const Vector2& position, float duration, AlphaFunction alpha,
DirectionBias horizontalBias = DirectionBiasNone, DirectionBias verticalBias = DirectionBiasNone);
/**
- * @copydoc Toolkit::ScrollView::ScrollTo(const Vector3 &position)
+ * @copydoc Toolkit::ScrollView::ScrollTo(const Vector2 &position)
*/
- void ScrollTo(const Vector3 &position);
+ void ScrollTo(const Vector2 &position);
/**
- * @copydoc Toolkit::Scrollable::ScrollTo(const Vector3& position, float duration)
+ * @copydoc Toolkit::Scrollable::ScrollTo(const Vector2& position, float duration)
*/
- void ScrollTo(const Vector3& position, float duration);
+ void ScrollTo(const Vector2& position, float duration);
/**
- * @copydoc Toolkit::Scrollable::ScrollTo(const Vector3& position, float duration, AlphaFunction alpha)
+ * @copydoc Toolkit::Scrollable::ScrollTo(const Vector2& position, float duration, AlphaFunction alpha)
*/
- void ScrollTo(const Vector3& position, float duration, AlphaFunction alpha);
+ void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha);
/**
- * @copydoc Toolkit::ScrollView::ScrollTo(const Vector3 &position, float duration, DirectionBias horizontalBias, DirectionBias verticalBias)
+ * @copydoc Toolkit::ScrollView::ScrollTo(const Vector2 &position, float duration, DirectionBias horizontalBias, DirectionBias verticalBias)
*/
- void ScrollTo(const Vector3& position, float duration,
+ void ScrollTo(const Vector2& position, float duration,
DirectionBias horizontalBias, DirectionBias verticalBias);
/**
- * @copydoc Toolkit::ScrollView::ScrollTo(const Vector3 &position, float duration, AlphaFunction alpha, DirectionBias horizontalBias, DirectionBias verticalBias)
+ * @copydoc Toolkit::ScrollView::ScrollTo(const Vector2 &position, float duration, AlphaFunction alpha, DirectionBias horizontalBias, DirectionBias verticalBias)
*/
- void ScrollTo(const Vector3& position, float duration, AlphaFunction alpha,
+ void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha,
DirectionBias horizontalBias, DirectionBias verticalBias);
/**
* @param[in] verticalBias (optional) Whether to bias animation to top or bottom (or no biasing)
* @return True if animation necessary and taking place to reach desired transform.
*/
- bool AnimateTo(const Vector3& position, const Vector3& positionDuration,
+ bool AnimateTo(const Vector2& position, const Vector2& positionDuration,
AlphaFunction alpha, bool findShortcuts = true,
DirectionBias horizontalBias = DirectionBiasNone, DirectionBias verticalBias = DirectionBiasNone,
SnapType snapType = Snap);
virtual bool OnAccessibilityPan(PanGesture gesture);
/**
- * @copydoc Toolkit::Scrollable::SetOvershootEnabled()
+ * @copydoc Toolkit::Scrollable::EnableScrollOvershoot()
*/
- virtual void SetOvershootEnabled(bool enable);
+ virtual void EnableScrollOvershoot(bool enable);
private:
*
* @param[in] position The position for which you wish to obtain overshoot vector
*/
- Vector3 GetOvershoot(Vector3& position) const;
+ Vector2 GetOvershoot(Vector2& position) const;
/**
* Clamps position within the domain set up by X/Y Rulers
*
* @param[in,out] position The position you wish to clamp
*/
- void ClampPosition(Vector3& position) const;
+ void ClampPosition(Vector2& position) const;
/**
* Clamps position within the domain set up by X/Y Rulers
* @param[in,out] position The position you wish to clamp
* @param[out] clamped The results of the clamping.
*/
- void ClampPosition(Vector3& position, ClampState3D &clamped) const;
+ void ClampPosition(Vector2& position, ClampState2D &clamped) const;
/**
* Wraps position within the domain set up by X/Y Rulers
*
* @param[in,out] position The position you wish to wrap
*/
- void WrapPosition(Vector3& position) const;
+ void WrapPosition(Vector2& position) const;
/**
* Updates the main internal scroll constraints with new ruler and domain
*
* @return The current position
*/
- Vector3 GetPropertyPrePosition() const;
+ Vector2 GetPropertyPrePosition() const;
/**
* Gets position property.
*
* @return The current position
*/
- Vector3 GetPropertyPosition() const;
+ Vector2 GetPropertyPosition() const;
/**
* Handles a Stopped animation. Its position properties need to be saved, and the animation flag
int mGestureStackDepth; ///< How many gestures are currently occuring.
Vector2 mPanStartPosition; ///< Where the pan gesture's touch down occured
- Vector3 mPanDelta; ///< Amount currently panned.
+ Vector2 mPanDelta; ///< Amount currently panned.
unsigned int mScrollStateFlags; ///< flags indicating current state of scrolling
// Scroll delegate pre and post position properties...
- Vector3 mScrollPrePosition; ///< Wrapped scroll position, but not clamped
- Vector3 mScrollPostPosition; ///< Wrapped and clamped, this is the final scroll position used
- Vector3 mScrollTargetPosition; ///< Final target position for an animated scroll
- Vector3 mDomainOffset; ///< Domain offset (this keeps track of the domain boundaries that scroll positions traverses)
+ Vector2 mScrollPrePosition; ///< Wrapped scroll position, but not clamped
+ Vector2 mScrollPostPosition; ///< Wrapped and clamped, this is the final scroll position used
+ Vector2 mScrollTargetPosition; ///< Final target position for an animated scroll
+ Vector2 mDomainOffset; ///< Domain offset (this keeps track of the domain boundaries that scroll positions traverses)
// Rulers for each axes...
RulerPtr mRulerX;
RulerPtr mRulerY;
// Last property values set to ScrollView
- Vector3 mMinScroll;
- Vector3 mMaxScroll;
+ Vector2 mMinScroll;
+ Vector2 mMaxScroll;
Animation mInternalXAnimation; ///< Animates mPropertyX to a snap position or application requested scroll position
Animation mInternalYAnimation; ///< Animates mPropertyY to a snap position or application requested scroll position
Vector2 mMaxOvershoot; ///< Number of scrollable pixels that will take overshoot from 0.0f to 1.0f
Vector2 mUserMaxOvershoot; ///< Set by user, allows overriding of default max overshoot for the scroll indicator
- float mSnapOvershootDuration; ///< Duration for overshoot snapping back to Vector3::ZERO
+ float mSnapOvershootDuration; ///< Duration for overshoot snapping back to Vector2::ZERO
AlphaFunction mSnapOvershootAlphaFunction; ///< AlphaFunction to be used for this overshoot.
float mSnapDuration; ///< Time for the snap animation to take (in seconds).
Constraint mScrollMainInternalDeltaConstraint;
Constraint mScrollMainInternalFinalConstraint;
Constraint mScrollMainInternalRelativeConstraint;
+ Constraint mScrollMainInternalDomainConstraint;
+ Constraint mScrollMainInternalPrePositionMaxConstraint;
ScrollOvershootIndicatorPtr mOvershootIndicator;
* @param[in,out] wobbleEffect Reference to wobbleEffect instance
*/
ScrollViewWobbleEffectConstraint(ScrollViewWobbleEffect& wobbleEffect)
- : mChase(Vector3::ZERO),
- mVelocity(Vector3::ZERO),
+ : mChase(Vector2::ZERO),
+ mVelocity(Vector2::ZERO),
mTime(0.0f),
mStabilityTimeCounter(0),
mStabilized(true),
else
{
// not stable (i.e. wobbling)
- Vector3 offset(inputs[2]->GetFloat(), inputs[3]->GetFloat(), 0.0f);
- const Vector3& position = inputs[1]->GetVector3() - offset;
+ Vector2 offset(inputs[2]->GetFloat(), inputs[3]->GetFloat());
+ const Vector2& position = inputs[1]->GetVector2() - offset;
const float time = inputs[0]->GetFloat();
const float timePassed = time - mTime;
if(timePassed>0)
{
- const Vector3 delta = position - mChase;
+ const Vector2 delta = position - mChase;
// Check to see if wobble has stabilized.
if( (fabsf(delta.x) < STABILITY_DELTA_THRESHOLD) &&
} // end else
}
- Vector3 mChase; ///< Chaser position
- Vector3 mVelocity; ///< Velocity of Chaser
+ Vector2 mChase; ///< Chaser position
+ Vector2 mVelocity; ///< Velocity of Chaser
float mTime; ///< Current time.
float mStabilityTimeCounter; ///< Time in seconds that stable for.
bool mStabilized; ///< Stabilized flag.
}
-void ScrollViewWobbleEffect::OnScrollStart( const Vector3& position )
+void ScrollViewWobbleEffect::OnScrollStart( const Vector2& position )
{
// When animation starts, all constraints all unstable,
// and we change the animation cycle id.
ContinueAnimation(WOBBLEEFFECT_ANIMATION_MAX_TIME);
}
-void ScrollViewWobbleEffect::OnScrollUpdate( const Vector3& position )
+void ScrollViewWobbleEffect::OnScrollUpdate( const Vector2& position )
{
// nothing to do
}
-void ScrollViewWobbleEffect::OnScrollComplete( const Vector3& position )
+void ScrollViewWobbleEffect::OnScrollComplete( const Vector2& position )
{
// nothing to do
}
*
* @param[in] position The current scroll position
*/
- void OnScrollStart( const Vector3& position );
+ void OnScrollStart( const Vector2& position );
/**
* Signal handler, called when the ScrollView is moving
*
* @param[in] position The current scroll position
*/
- void OnScrollUpdate( const Vector3& position );
+ void OnScrollUpdate( const Vector2& position );
/**
* Signal handler, called when the ScrollView has completed movement
*
* @param[in] position The current scroll position
*/
- void OnScrollComplete( const Vector3& position );
+ void OnScrollComplete( const Vector2& position );
/**
* Signal handler, called when the Wobble Effect animation has completed.
// INTERNAL INCLUDES
#include <dali-toolkit/internal/controls/scrollable/scrollable-impl.h>
-#include <dali-toolkit/internal/controls/scroll-component/scroll-bar-internal-impl.h>
using namespace Dali;
DALI_PROPERTY_REGISTRATION( Toolkit, Scrollable, "overshoot-effect-color", VECTOR4, OVERSHOOT_EFFECT_COLOR )
DALI_PROPERTY_REGISTRATION( Toolkit, Scrollable, "overshoot-animation-speed", FLOAT, OVERSHOOT_ANIMATION_SPEED )
-DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "scroll-relative-position", VECTOR3, SCROLL_RELATIVE_POSITION )
-DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "scroll-position-min", VECTOR3, SCROLL_POSITION_MIN )
-DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "scroll-position-max", VECTOR3, SCROLL_POSITION_MAX )
-DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "scroll-direction", VECTOR3, SCROLL_DIRECTION )
-DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "can-scroll-vertical", BOOLEAN, CAN_SCROLL_VERTICAL )
-DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "can-scroll-horizontal", BOOLEAN, CAN_SCROLL_HORIZONTAL )
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "scroll-relative-position", VECTOR2, SCROLL_RELATIVE_POSITION)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "scroll-position-min", VECTOR2, SCROLL_POSITION_MIN)
+DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, Scrollable, "scroll-position-min-x", SCROLL_POSITION_MIN_X, SCROLL_POSITION_MIN, 0)
+DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, Scrollable, "scroll-position-min-y", SCROLL_POSITION_MIN_Y, SCROLL_POSITION_MIN, 1)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "scroll-position-max", VECTOR2, SCROLL_POSITION_MAX)
+DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, Scrollable, "scroll-position-max-x", SCROLL_POSITION_MAX_X, SCROLL_POSITION_MAX, 0)
+DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, Scrollable, "scroll-position-max-y", SCROLL_POSITION_MAX_Y, SCROLL_POSITION_MAX, 1)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "can-scroll-vertical", BOOLEAN, CAN_SCROLL_VERTICAL)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "can-scroll-horizontal", BOOLEAN, CAN_SCROLL_HORIZONTAL)
DALI_SIGNAL_REGISTRATION( Toolkit, Scrollable, "scroll-started", SIGNAL_SCROLL_STARTED )
DALI_SIGNAL_REGISTRATION( Toolkit, Scrollable, "scroll-completed", SIGNAL_SCROLL_COMPLETED )
Scrollable::~Scrollable()
{
- // Clear scroll components, forces their destruction before Scrollable is destroyed.
- mComponents.clear();
}
-bool Scrollable::IsScrollComponentEnabled(Toolkit::Scrollable::ScrollComponentType type) const
+bool Scrollable::IsOvershootEnabled() const
{
- if(type == Toolkit::Scrollable::OvershootIndicator)
- {
- return mOvershootEnabled;
- }
- return (mComponents.find(type) != mComponents.end());
+ return mOvershootEnabled;
}
-void Scrollable::EnableScrollComponent(Toolkit::Scrollable::ScrollComponentType type)
+void Scrollable::SetOvershootEnabled(bool enable)
{
- if(type == Toolkit::Scrollable::OvershootIndicator)
- {
- if( !mOvershootEnabled )
- {
- SetOvershootEnabled(true);
- mOvershootEnabled = true;
- }
- return;
- }
- if( mComponents.find(type) == mComponents.end() )
- {
- // Create ScrollComponent
- Toolkit::Scrollable scrollable = Toolkit::Scrollable::DownCast(Self());
- Toolkit::ScrollComponent scrollComponent = NewScrollComponent(scrollable, type);
- Toolkit::ScrollComponentImpl& component = static_cast<Toolkit::ScrollComponentImpl&>(scrollComponent.GetImplementation());
- ScrollComponentPtr componentPtr(&component);
-
- mComponents[type] = componentPtr;
- }
-}
-
-void Scrollable::DisableScrollComponent(Toolkit::Scrollable::ScrollComponentType type)
-{
- if(type == Toolkit::Scrollable::OvershootIndicator)
- {
- if( mOvershootEnabled )
- {
- SetOvershootEnabled(false);
- mOvershootEnabled = false;
- }
- return;
- }
- ComponentIter pair = mComponents.find( type );
-
- if( mComponents.end() != pair )
- {
- ScrollComponentPtr component = pair->second;
-
- // Disconnect the scroll component first.
- component->OnDisconnect();
-
- // Destroy ScrollComponent.
- mComponents.erase( type );
- }
+ EnableScrollOvershoot(enable);
+ mOvershootEnabled = enable;
}
Vector4 Scrollable::GetOvershootEffectColor() const
return value;
}
-Toolkit::ScrollComponent Scrollable::NewScrollComponent(Toolkit::Scrollable& scrollable, Toolkit::Scrollable::ScrollComponentType type)
-{
- Toolkit::ScrollComponent instance;
-
- switch(type)
- {
- case Toolkit::Scrollable::VerticalScrollBar:
- {
- instance = static_cast<Toolkit::ScrollComponent>(Toolkit::ScrollBarInternal::New(scrollable, true));
- break;
- }
- case Toolkit::Scrollable::HorizontalScrollBar:
- {
- instance = static_cast<Toolkit::ScrollComponent>(Toolkit::ScrollBarInternal::New(scrollable, false));
- break;
- }
- case Toolkit::Scrollable::OvershootIndicator:
- {
- DALI_ASSERT_ALWAYS(!"Unrecognized component type");
- break;
- }
- }
-
- return instance;
-}
-
} // namespace Internal
} // namespace Toolkit
*
*/
-// EXTERNAL INCLUDES
-#include <dali/public-api/common/map-wrapper.h>
-
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/public-api/controls/scrollable/scrollable.h>
-#include <dali-toolkit/public-api/controls/scrollable/scroll-component-impl.h>
namespace Dali
{
public:
/**
- * @copydoc Dali::Toolkit::Scrollable::IsScrollComponentEnabled(Scrollable::ScrollComponentType type)
+ * @copydoc Dali::Toolkit::Scrollable::IsOvershootEnabled
*/
- bool IsScrollComponentEnabled(Toolkit::Scrollable::ScrollComponentType type) const;
+ bool IsOvershootEnabled() const;
/**
- * @copydoc Dali::Toolkit::Scrollable::EnableScrollComponent(Scrollable::ScrollComponentType type)
+ * @copydoc Dali::Toolkit::Scrollable::SetOvershootEnabled
*/
- void EnableScrollComponent(Toolkit::Scrollable::ScrollComponentType type);
-
- /**
- * @copydoc Dali::Toolkit::Scrollable::DisableScrollComponent(Scrollable::ScrollComponentType type)
- */
- void DisableScrollComponent(Toolkit::Scrollable::ScrollComponentType type);
+ void SetOvershootEnabled(bool enable);
/**
* Gets the size of the domain (minimum/maximum extents for each axis to scroll to)
* @return the domain size
*/
- virtual Vector3 GetDomainSize() const = 0;
+ virtual Vector2 GetDomainSize() const = 0;
/**
* Adds actor as an Overlay to Scrollable
* Retrieves current scroll position.
* @returns The current scroll position.
*/
- virtual Vector3 GetCurrentScrollPosition() const = 0;
+ virtual Vector2 GetCurrentScrollPosition() const = 0;
/**
* Scrolls Scrollable to position specified (contents will scroll to this position)
* @param[in] position The position to scroll to.
* @param[in] duration The duration of the animation in seconds
*/
- virtual void ScrollTo(const Vector3 &position, float duration) = 0;
+ virtual void ScrollTo(const Vector2 &position, float duration) = 0;
/**
* Set the color of the overshoot effect.
private:
/**
- * Temporary function to override EnableScrollComponent functionality for overshoot
+ * Temporary function to override EnableScrollOvershoot functionality for overshoot
* Only ScrollView needs to override this as HQ has not requested disable functionality in ItemView
* @param[in] enable true to enable, false to disable overshoot indicator
*/
- virtual void SetOvershootEnabled(bool enable) {}
+ virtual void EnableScrollOvershoot(bool enable) {}
public: //Signals
*
* @return The current position
*/
- Vector3 GetPropertyPosition() const;
+ Vector2 GetPropertyPosition() const;
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:
Vector4 mOvershootEffectColor; ///<The color of the overshoot bouncing effect
float mOvershootAnimationSpeed; ///<The speed of the overshoot animation (pixels per second)
- std::map<Toolkit::Scrollable::ScrollComponentType, ScrollComponentPtr> mComponent; ///< ScrollComponent (such as a scrollbar/page indicator/status)
-
Toolkit::Scrollable::ScrollStartedSignalType mScrollStartedSignal;
Toolkit::Scrollable::ScrollUpdatedSignalType mScrollUpdatedSignal;
Toolkit::Scrollable::ScrollCompletedSignalType mScrollCompletedSignal;
private:
- typedef std::map<Toolkit::Scrollable::ScrollComponentType, ScrollComponentPtr> ComponentContainer;
- typedef ComponentContainer::iterator ComponentIter;
-
- ComponentContainer mComponents; ///< ScrollComponent (such as a scrollbar/page indicator/status)
bool mOvershootEnabled:1;
};
$(toolkit_src_dir)/controls/page-turn-view/page-turn-landscape-view-impl.cpp \
$(toolkit_src_dir)/controls/page-turn-view/page-turn-view-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-bar-internal.cpp \
$(toolkit_src_dir)/controls/scrollable/bouncing-effect-actor.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-effect-impl.cpp \
}
ScrollBar::ScrollBar(Internal::ScrollBar& implementation)
-: ScrollComponent( implementation )
+: Control( implementation )
{
}
ScrollBar::ScrollBar( Dali::Internal::CustomActor* internal )
-: ScrollComponent( internal )
+: Control( internal )
{
VerifyCustomActorPointer<Internal::ScrollBar>(internal);
}
-ScrollBar::ScrollBar( const ScrollBar& scrollBar )
-: ScrollComponent( scrollBar )
+ScrollBar::ScrollBar( const ScrollBar& handle )
+: Control( handle )
{
}
return *this;
}
-ScrollBar ScrollBar::New()
+ScrollBar ScrollBar::New(ScrollBar::Direction direction)
{
- return Internal::ScrollBar::New();
+ return Internal::ScrollBar::New(direction);
}
ScrollBar ScrollBar::DownCast( BaseHandle handle )
{
}
-void ScrollBar::SetIndicatorImage( Image image )
+void ScrollBar::SetScrollPropertySource( Handle handle, Dali::Property::Index propertyScrollPosition, Dali::Property::Index propertyMinScrollPosition, Dali::Property::Index propertyMaxScrollPosition, Dali::Property::Index propertyScrollContentSize )
{
- GetImpl(*this).SetIndicatorImage(image);
+ GetImpl(*this).SetScrollPropertySource(handle, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
+}
+
+void ScrollBar::SetScrollIndicator( Actor indicator )
+{
+ GetImpl(*this).SetScrollIndicator(indicator);
}
Actor ScrollBar::GetScrollIndicator()
return GetImpl(*this).GetScrollIndicator();
}
-void ScrollBar::SetPositionNotifications( const Dali::Vector<float>& positions )
+void ScrollBar::SetScrollPositionIntervals( const Dali::Vector<float>& positions )
+{
+ GetImpl(*this).SetScrollPositionIntervals(positions);
+}
+
+Dali::Vector<float> ScrollBar::GetScrollPositionIntervals() const
{
- GetImpl(*this).SetPositionNotifications(positions);
+ return GetImpl(*this).GetScrollPositionIntervals();
+}
+
+void ScrollBar::SetScrollDirection( ScrollBar::Direction direction )
+{
+ GetImpl(*this).SetScrollDirection(direction);
+}
+
+ScrollBar::Direction ScrollBar::GetScrollDirection() const
+{
+ return GetImpl(*this).GetScrollDirection();
}
void ScrollBar::SetIndicatorHeightPolicy( ScrollBar::IndicatorHeightPolicy policy )
GetImpl(*this).SetIndicatorHeightPolicy(policy);
}
-ScrollBar::IndicatorHeightPolicy ScrollBar::GetIndicatorHeightPolicy()
+ScrollBar::IndicatorHeightPolicy ScrollBar::GetIndicatorHeightPolicy() const
{
return GetImpl(*this).GetIndicatorHeightPolicy();
}
GetImpl(*this).SetIndicatorFixedHeight(height);
}
-float ScrollBar::GetIndicatorFixedHeight()
+float ScrollBar::GetIndicatorFixedHeight() const
{
return GetImpl(*this).GetIndicatorFixedHeight();
}
GetImpl(*this).SetIndicatorShowDuration(durationSeconds);
}
-float ScrollBar::GetIndicatorShowDuration()
+float ScrollBar::GetIndicatorShowDuration() const
{
return GetImpl(*this).GetIndicatorShowDuration();
}
GetImpl(*this).SetIndicatorHideDuration(durationSeconds);
}
-float ScrollBar::GetIndicatorHideDuration()
+float ScrollBar::GetIndicatorHideDuration() const
{
return GetImpl(*this).GetIndicatorHideDuration();
}
-void ScrollBar::Show()
+void ScrollBar::ShowIndicator()
+{
+ GetImpl(*this).ShowIndicator();
+}
+
+void ScrollBar::HideIndicator()
{
- GetImpl(*this).Show();
+ GetImpl(*this).HideIndicator();
}
-void ScrollBar::Hide()
+ScrollBar::PanFinishedSignalType& ScrollBar::PanFinishedSignal()
{
- GetImpl(*this).Hide();
+ return GetImpl(*this).PanFinishedSignal();
}
-ScrollBar::ScrollPositionNotifiedSignalType& ScrollBar::ScrollPositionNotifiedSignal()
+ScrollBar::ScrollPositionIntervalReachedSignalType& ScrollBar::ScrollPositionIntervalReachedSignal()
{
- return GetImpl(*this).ScrollPositionNotifiedSignal();
+ return GetImpl(*this).ScrollPositionIntervalReachedSignal();
}
} // namespace Toolkit
*
*/
-// EXTERNAL INCLUDES
-#include <dali/public-api/common/dali-vector.h>
-
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/scrollable/scroll-component.h>
+#include <dali-toolkit/public-api/controls/control.h>
namespace Dali
{
namespace Toolkit
{
-// Forward declarations
-class ScrollConnector;
-
namespace Internal DALI_INTERNAL
{
// Forward declarations
}
/**
- * 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 |
- * |--------------------------|-------------------------------------|
- * | scroll-position-notified | @ref ScrollPositionNotifiedSignal() |
+ * | %Signal Name | Method |
+ * |----------------------------------|--------------------------------------------|
+ * | pan-finished | @ref PanFinishedSignal() |
+ * | scroll-position-interval-reached | @ref ScrollPositionIntervalReachedSignal() |
*/
-class DALI_IMPORT_API ScrollBar : public ScrollComponent
+class DALI_IMPORT_API ScrollBar : public Control
{
public:
+ // Properties
+
/**
* @brief The start and end property ranges for this control.
*/
{
enum
{
- INDICATOR_HEIGHT_POLICY = PROPERTY_START_INDEX, ///< name "indicator-height-policy", @see SetIndicatorHeightPolicy(), type std::string
+ SCROLL_DIRECTION = PROPERTY_START_INDEX, ///< name "scroll-direction", @see SetScrollDirection(), type std::string
+ INDICATOR_HEIGHT_POLICY, ///< name "indicator-height-policy", @see SetIndicatorHeightPolicy(), type std::string
INDICATOR_FIXED_HEIGHT, ///< name "indicator-fixed-height", @see SetIndicatorFixedHeight(), type float
INDICATOR_SHOW_DURATION, ///< name "indicator-show-duration", @see SetIndicatorShowDuration(), type float
INDICATOR_HIDE_DURATION, ///< name "indicator-hide-duration", @see SetIndicatorHideDuration(), type float
+ SCROLL_POSITION_INTERVALS ///< name "scroll-position-intervals", type float
};
};
// Signals
- typedef Signal< 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
/**
* @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();
/**
* @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
static ScrollBar DownCast( BaseHandle handle );
/**
- * @brief Sets the image for the indicator of scroll bar.
+ * @brief Set the source of the scroll position properties.
*
- * @pre The scroll bar actor has been initialised.
+ * * @pre The handle to the object owing the scroll properties has been initialised and the property index must be vaild.
*
- * 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.
+ * @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.
*
- * @param[in] image The image of indicator that moves to indicate the current scroll position.
+ * @pre The scroll bar actor has been initialised.
+ *
+ * @param[in] indicator The indicator that moves to indicate the current scroll position.
*/
- void SetIndicatorImage( Image image );
+ void SetScrollIndicator( Actor indicator );
/**
* @brief Gets the indicator of scroll bar.
Actor GetScrollIndicator();
/**
- * @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 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] positions List of values to receive notifications for when the current scroll position crosses them
*/
- void SetPositionNotifications( const Dali::Vector<float>& positions );
+ void SetScrollPositionIntervals( const Dali::Vector<float>& positions );
+
+ /**
+ * @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.
+ *
+ * @return The list of values to receive notifications for when the current scroll position crosses them
+ */
+ Dali::Vector<float> 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] direction The direction of scroll bar (either vertically or horizontally).
+ */
+ void SetScrollDirection( Direction direction );
+
+ /**
+ * @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.
*
* @return The height policy of scroll indicator
*/
- IndicatorHeightPolicy GetIndicatorHeightPolicy();
+ IndicatorHeightPolicy GetIndicatorHeightPolicy() const;
/**
* @brief Sets the fixed height of scroll indicator.
* @brief Gets the fix height of scroll indicator.
* @return The fixed height of the scroll indicator
*/
- float GetIndicatorFixedHeight();
+ 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.
+ * @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
*/
* @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();
+ 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.
+ * @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
*/
* @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
*/
- float GetIndicatorHideDuration();
+ 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 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 SetPositionNotifications.
+ * @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
* @pre The Object has been initialized.
* @return The signal to connect to.
*/
- ScrollBar::ScrollPositionNotifiedSignalType& ScrollPositionNotifiedSignal();
+ ScrollBar::ScrollPositionIntervalReachedSignalType& ScrollPositionIntervalReachedSignal();
public: // Not intended for application developers
return GetScrollSpeedFactor();
}
-void ItemLayout::ApplyConstraints( Actor& actor, const int itemId, const float durationSeconds, Handle scrollPositionObject, const Actor& itemViewActor )
+void ItemLayout::ApplyConstraints( Actor& actor, const int itemId, const float durationSeconds, const Actor& itemViewActor )
{
// This just implements the default behaviour of constraint application.
// Custom layouts can override this function to apply their custom constraints.
- Dali::Toolkit::ItemView itemView = Dali::Toolkit::ItemView::DownCast( itemViewActor );
- if(itemView && scrollPositionObject)
+ Toolkit::ItemView itemView = Toolkit::ItemView::DownCast( itemViewActor );
+ if(itemView)
{
- Property::Index scrollSpeedProperty = itemView.GetPropertyIndex("item-view-scroll-speed");
- Property::Index scrollPositionProperty = scrollPositionObject.GetPropertyIndex("scroll-position");
-
// We want to animate the layout in so use a weight object to do this
if ( !mWeightObject )
{
{
WrappedVector3Constraint wrapped(positionConstraint, itemId);
Constraint constraint = Constraint::New<Vector3>( actor, Actor::Property::POSITION, wrapped );
- constraint.AddSource( Source( scrollPositionObject, scrollPositionProperty ) );
- constraint.AddSource( ParentSource( scrollSpeedProperty ) );
+ constraint.AddSource( ParentSource( Toolkit::ItemView::Property::LAYOUT_POSITION ) );
+ constraint.AddSource( ParentSource( Toolkit::ItemView::Property::SCROLL_SPEED ) );
constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
constraint.AddSource( Source( mWeightObject, WeightObject::WEIGHT ) );
constraint.Apply();
WrappedQuaternionConstraint wrapped(rotationConstraint, itemId);
Constraint constraint = Constraint::New<Quaternion>( actor, Actor::Property::ORIENTATION, wrapped );
- constraint.AddSource( Source( scrollPositionObject, scrollPositionProperty ) );
- constraint.AddSource( ParentSource( scrollSpeedProperty ) );
+ constraint.AddSource( ParentSource( Toolkit::ItemView::Property::LAYOUT_POSITION ) );
+ constraint.AddSource( ParentSource( Toolkit::ItemView::Property::SCROLL_SPEED ) );
constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
constraint.AddSource( Source( mWeightObject, WeightObject::WEIGHT ) );
constraint.Apply();
WrappedVector3Constraint wrapped(scaleConstraint, itemId);
Constraint constraint = Constraint::New<Vector3>( actor, Actor::Property::SCALE, wrapped );
- constraint.AddSource( Source( scrollPositionObject, scrollPositionProperty ) );
- constraint.AddSource( ParentSource( scrollSpeedProperty ) );
+ constraint.AddSource( ParentSource( Toolkit::ItemView::Property::LAYOUT_POSITION ) );
+ constraint.AddSource( ParentSource( Toolkit::ItemView::Property::SCROLL_SPEED ) );
constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
constraint.AddSource( Source( mWeightObject, WeightObject::WEIGHT ) );
constraint.Apply();
WrappedVector4Constraint wrapped(colorConstraint, itemId);
Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, wrapped );
- constraint.AddSource( Source( scrollPositionObject, scrollPositionProperty ) );
- constraint.AddSource( ParentSource( scrollSpeedProperty ) );
+ constraint.AddSource( ParentSource( Toolkit::ItemView::Property::LAYOUT_POSITION ) );
+ constraint.AddSource( ParentSource( Toolkit::ItemView::Property::SCROLL_SPEED ) );
constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
constraint.AddSource( Source( mWeightObject, WeightObject::WEIGHT ) );
constraint.SetRemoveAction(Dali::Constraint::Discard);
WrappedBoolConstraint wrapped(visibilityConstraint, itemId);
Constraint constraint = Constraint::New<bool>( actor, Actor::Property::VISIBLE, wrapped );
- constraint.AddSource( Source( scrollPositionObject, scrollPositionProperty ) );
- constraint.AddSource( ParentSource( scrollSpeedProperty ) );
+ constraint.AddSource( ParentSource( Toolkit::ItemView::Property::LAYOUT_POSITION ) );
+ constraint.AddSource( ParentSource( Toolkit::ItemView::Property::SCROLL_SPEED ) );
constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
constraint.AddSource( Source( mWeightObject, WeightObject::WEIGHT ) );
* @param[in] actor The actor to constrain.
* @param[in] itemId The ID of the item represented by the actor.
* @param[in] durationSeconds The time taken to fully constrain the actors.
- * @param[in] scrollPositionObject The object which provides the layout position property.
* @param[in] itemViewActor The item view instance which requests the application of constraints.
*/
- DALI_IMPORT_API virtual void ApplyConstraints( Actor& actor, const int itemId, const float durationSeconds, Handle scrollPositionObject, const Actor& itemViewActor );
+ DALI_IMPORT_API virtual void ApplyConstraints( Actor& actor, const int itemId, const float durationSeconds, const Actor& itemViewActor );
/**
* @brief Gets the position of a given item
return Control::DownCast<ItemView, Internal::ItemView>(handle);
}
-ScrollConnector ItemView::GetScrollConnector() const
-{
- return GetImpl(*this).GetScrollConnector();
-}
-
ItemView::~ItemView()
{
}
class ItemView;
}
-class ScrollConnector;
class ItemFactory;
class ItemLayout;
struct ItemRange;
{
public:
+ enum PropertyRange
+ {
+ ANIMATABLE_PROPERTY_START_INDEX = Toolkit::Scrollable::ANIMATABLE_PROPERTY_END_INDEX + 1,
+ ANIMATABLE_PROPERTY_END_INDEX = ANIMATABLE_PROPERTY_START_INDEX + 1000 ///< Reserve animatable property indices
+ };
+
+ /**
+ * @brief An enumeration of properties belonging to the ScrollView class.
+ */
+ struct Property
+ {
+ enum
+ {
+ LAYOUT_POSITION = ANIMATABLE_PROPERTY_START_INDEX, ///< Property, name "layout-position", type float
+ SCROLL_SPEED, ///< Property, name "scroll-speed", type float
+ OVERSHOOT, ///< Property, name "overshoot", type float
+ SCROLL_DIRECTION, ///< Property, name "scroll-direction", type Vector2
+ LAYOUT_ORIENTATION, ///< Property, name "layout-orientation", type integer
+ SCROLL_CONTENT_SIZE ///< Property, name "scroll-content-size", type float
+ };
+ };
+
+public:
+
/**
* @brief Create an uninitialized ItemView; this can be initialized with ItemView::New().
*
static ItemView DownCast( BaseHandle handle );
/**
- * @brief Retrieve a scroll-connector; this can be used to connect scroll components e.g. scroll bars.
- *
- * @return The connector.
- */
- ScrollConnector GetScrollConnector() const;
-
- /**
* @brief Query the number of layouts.
*
* @return The number of layouts.
+++ /dev/null
-/*
- * 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.
- *
- */
-
-// CLASS HEADER
-#include <dali-toolkit/public-api/controls/scrollable/scroll-component-impl.h>
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
-
-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()
-: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) )
-{
-}
-
-ScrollComponentImpl::~ScrollComponentImpl()
-{
-}
-
-void ScrollComponentImpl::OnScrollConnectorSet( Toolkit::ScrollConnector connector )
-{
- // Do nothing (override in derived classes)
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_TOOLKIT_SCROLL_COMPONENT_IMPL_H__
-#define __DALI_TOOLKIT_SCROLL_COMPONENT_IMPL_H__
-
-/*
- * 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 <dali-toolkit/public-api/controls/scrollable/scroll-component.h>
-
-#include <dali-toolkit/public-api/controls/control-impl.h>
-#include <dali-toolkit/public-api/controls/scrollable/scrollable.h>
-#include <dali-toolkit/public-api/controls/scrollable/scroll-connector.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-class ScrollComponentImpl;
-typedef IntrusivePtr<ScrollComponentImpl> ScrollComponentPtr;
-
-/**
- * Base class for scroll component implementations.
- * Scroll-components such as scroll bars, indicators etc. are connected to scrollable containers via ScrollConnector.
- */
-class DALI_IMPORT_API ScrollComponentImpl : public Internal::Control
-{
-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;
-
- /**
- * Called when the scroll component is disconnected from a scrollable container.
- */
- virtual void OnDisconnect() {}
-
-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
- DALI_INTERNAL ScrollComponentImpl(const ScrollComponentImpl&);
-
- // Undefined
- DALI_INTERNAL 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<Toolkit::ScrollComponentImpl&>(handle);
-}
-
-inline const Toolkit::ScrollComponentImpl& GetImpl(const Toolkit::ScrollComponent& scrollComponent)
-{
- DALI_ASSERT_ALWAYS(scrollComponent);
-
- const Dali::RefObject& handle = scrollComponent.GetImplementation();
-
- return static_cast<const Toolkit::ScrollComponentImpl&>(handle);
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_SCROLL_COMPONENT_IMPL_H__
+++ /dev/null
-/*
- * 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.
- *
- */
-
-// CLASS HEADER
-#include <dali-toolkit/public-api/controls/scrollable/scroll-component.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/scrollable/scroll-component-impl.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-ScrollComponent::ScrollComponent()
-{
-}
-
-ScrollComponent::ScrollComponent( ScrollComponentImpl& implementation )
-: Control( implementation )
-{
-}
-
-ScrollComponent::ScrollComponent( Dali::Internal::CustomActor* actor )
-: Control( actor )
-{
- VerifyCustomActorPointer<ScrollComponentImpl>( actor );
-}
-
-ScrollComponent::ScrollComponent( const ScrollComponent& scrollComponent )
-: Control( scrollComponent )
-{
-}
-
-ScrollComponent& ScrollComponent::operator=( const ScrollComponent& scrollComponent )
-{
- if( &scrollComponent != this )
- {
- Control::operator=( scrollComponent );
- }
- return *this;
-}
-
-ScrollComponent ScrollComponent::DownCast( BaseHandle handle )
-{
- return Control::DownCast<ScrollComponent, ScrollComponentImpl>(handle);
-}
-
-ScrollComponent::~ScrollComponent()
-{
-}
-
-void ScrollComponent::SetScrollConnector( ScrollConnector connector )
-{
- GetImpl(*this).SetScrollConnector(connector);
-}
-
-ScrollConnector ScrollComponent::GetScrollConnector() const
-{
- return GetImpl(*this).GetScrollConnector();
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_TOOLKIT_SCROLL_COMPONENT_H__
-#define __DALI_TOOLKIT_SCROLL_COMPONENT_H__
-
-/*
- * 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 <dali-toolkit/public-api/controls/control.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-class ScrollComponentImpl;
-class ScrollConnector;
-
-/**
- * Base class for scroll component handles.
- * Scroll-components such as scroll bars, indicators etc. are connected to scrollable containers via ScrollConnector.
- */
-class DALI_IMPORT_API ScrollComponent : public Control
-{
-
-public:
- /**
- * Create an uninitialized ScrollComponent; this can be initialized with ScrollComponent::New()
- * Calling member functions with an uninitialized Dali::Object is not allowed.
- */
- ScrollComponent();
-
- /**
- * Copy constructor.
- */
- ScrollComponent( const ScrollComponent& scrollComponent );
-
- /**
- * Assignment operator.
- */
- ScrollComponent& operator=( const ScrollComponent& scrollComponent );
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~ScrollComponent();
-
- /**
- * Downcast an Object handle to ScrollComponent. If handle points to a ScrollComponent the
- * downcast produces valid handle. If not the returned handle is left uninitialized.
- * @param[in] handle Handle to an object
- * @return handle to a ScrollComponent or an uninitialized handle
- */
- 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 implementation.
- * @param[in] implementation The Control implementation.
- */
- DALI_INTERNAL ScrollComponent( ScrollComponentImpl& implementation );
-
- /**
- * Allows the creation of this Control from an Internal::CustomActor pointer.
- * @param[in] internal A pointer to the internal CustomActor.
- */
- explicit DALI_INTERNAL ScrollComponent( Dali::Internal::CustomActor* internal );
-};
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_SCROLL_COMPONENT_H__
+++ /dev/null
-/*
- * 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.
- *
- */
-
-#include <dali-toolkit/public-api/controls/scrollable/scroll-connector.h>
-#include <dali-toolkit/internal/controls/scrollable/scroll-connector-impl.h>
-
-using namespace Dali;
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-const char* const ScrollConnector::SCROLL_POSITION_PROPERTY_NAME = "scroll-position";
-const char* const ScrollConnector::OVERSHOOT_PROPERTY_NAME = "overshoot";
-
-const Property::Index ScrollConnector::SCROLL_POSITION = Internal::ScrollConnector::SCROLL_POSITION;
-const Property::Index ScrollConnector::OVERSHOOT = Internal::ScrollConnector::OVERSHOOT;
-
-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<Internal::ScrollConnector*>(handle.GetObjectPtr()) );
-}
-
-void ScrollConnector::SetScrollDomain( float min, float max, float length )
-{
- GetImpl(*this).SetScrollDomain( min, max, length );
-}
-
-float ScrollConnector::GetMinLimit() const
-{
- return GetImpl(*this).GetMinLimit();
-}
-
-float ScrollConnector::GetMaxLimit() const
-{
- return GetImpl(*this).GetMaxLimit();
-}
-
-float ScrollConnector::GetContentLength() const
-{
- return GetImpl(*this).GetContentLength();
-}
-
-Handle ScrollConnector::GetScrollPositionObject() const
-{
- return GetImpl(*this).GetScrollPositionObject();
-}
-
-void ScrollConnector::SetScrollPosition( float position )
-{
- GetImpl(*this).SetScrollPosition( position );
-}
-
-float ScrollConnector::GetScrollPosition() const
-{
- return GetImpl(*this).GetScrollPosition();
-}
-
-ScrollConnector::ScrollPositionChangedSignalType& ScrollConnector::ScrollPositionChangedSignal()
-{
- return GetImpl(*this).ScrollPositionChangedSignal();
-}
-
-ScrollConnector::DomainChangedSignalType& ScrollConnector::DomainChangedSignal()
-{
- return GetImpl(*this).DomainChangedSignal();
-}
-
-ScrollConnector::ScrollConnector( Internal::ScrollConnector* impl )
-: BaseHandle( impl )
-{
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_TOOLKIT_SCROLL_CONNECTOR_H__
-#define __DALI_TOOLKIT_SCROLL_CONNECTOR_H__
-
-/*
- * 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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/handle.h>
-
-namespace Dali
-{
-
-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.
- * - An "overshoot" property which shows any attempts to exceed the start & end points.
- * - The scrollable content size, which corresponds to the length of the scrollable content in the scrollable container in actor coordinates.
- *
- * The provider of the scrollable content is responsible for calling SetScrollDomain(). Scroll-bar components are then expected to
- * receive these values via the DOMAIN_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.
- *
- * The overshoot property is intended for implementing 'end of list' style indicators. This property is expected to be in the range
- * -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.
- * Zero indicates normal scrolling i.e. when overshoot indicators should be hidden.
- *
- * Signals
- * | %Signal Name | Method |
- * |-------------------------|------------------------------------|
- * | domain-changed | @ref DomainChangedSignal() |
- * | scroll-position-changed | @ref ScrollPositionChangedSignal() |
- */
-class DALI_IMPORT_API ScrollConnector : public BaseHandle
-{
-public:
-
- static const char* const SCROLL_POSITION_PROPERTY_NAME; ///< This float "scroll-position" property is available via GetScrollPositionObject()
- static const char* const OVERSHOOT_PROPERTY_NAME; ///< This float "overshoot" property is available via GetScrollPositionObject()
-
- static const Property::Index SCROLL_POSITION; ///< The index of the "scroll-position" property
- static const Property::Index OVERSHOOT; ///< The index of the "overshoot" property
-
- // Signals
- typedef Signal< void ( float min, float max, float size ) > DomainChangedSignalType;
- typedef Signal< void ( float position ) > ScrollPositionChangedSignalType;
-
- /**
- * 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=;
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~ScrollConnector();
-
- /**
- * @brief Downcast a BaseHandle to ScrollConnector handle.
- * @return A handle to a ScrollConnector or an empty handle.
- */
- static ScrollConnector DownCast( BaseHandle handle );
-
- /**
- * @brief Set the scroll domain, corresponding to the start & end position, and size of the scrollable content in actor coordinates.
- * @param[in] min The minimum scroll position limit.
- * @param[in] max The maximum scroll position limit.
- * @param[in] length The length of the scrollable content in actor coordinates.
- */
- void SetScrollDomain( float min, float max, float length );
-
- /**
- * @brief Retrieve the min limit.
- * @return The minimum value.
- */
- float GetMinLimit() const;
-
- /**
- * @brief Retrieve the max limit.
- * @return The maximum value.
- */
- float GetMaxLimit() const;
-
- /**
- * @brief Retrieve the length of the scrollable content in actor coordinates.
- * @return The length of the scrollable content.
- */
- float GetContentLength() const;
-
- /**
- * @brief Set the scroll position.
- *
- * This will set the "scroll-position" property and emit the ScrollPositionChanged signal.
- *
- * @param[in] position The scroll position.
- */
- void SetScrollPosition( float position );
-
- /**
- * @brief Retrieve the scroll position.
- * @return The scroll position.
- */
- float GetScrollPosition() const;
-
- /**
- * @brief Signal emitted after the SetScrollPosition() method has been called.
- */
- ScrollConnector::ScrollPositionChangedSignalType& ScrollPositionChangedSignal();
-
- /**
- * @brief Signal emitted after the SetScrollDomain() method has been called.
- */
- ScrollConnector::DomainChangedSignalType& DomainChangedSignal();
-
- /**
- * @brief Retrieve the object which provides the "scroll-position" property.
- * @return The scroll-position object.
- */
- Handle GetScrollPositionObject() const;
-
-public: // Not intended for application developers
-
- /**
- * Creates a handle using the Toolkit::Internal implementation.
- * @param[in] impl The Control implementation.
- */
- explicit DALI_INTERNAL ScrollConnector( Internal::ScrollConnector* impl );
-};
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_SCROLL_CONNECTOR_H__
void MoveActorConstraint( Vector3& current, const PropertyInputContainer& inputs )
{
- current += inputs[0]->GetVector3();
+ current += Vector3(inputs[0]->GetVector2());
}
void WrapActorConstraint( Vector3& position, const PropertyInputContainer& inputs )
if(wrap)
{
- const Vector3& min = inputs[3]->GetVector3();
- const Vector3& max = inputs[4]->GetVector3();
+ const Vector2& min = inputs[3]->GetVector2();
+ const Vector2& max = inputs[4]->GetVector2();
const Vector3& anchor = inputs[1]->GetVector3();
const Vector3 scale = inputs[0]->GetVector3();
// ScrollView
///////////////////////////////////////////////////////////////////////////////////////////////////
-const float ScrollView::DEFAULT_SLOW_SNAP_ANIMATION_DURATION(0.5f);
-const float ScrollView::DEFAULT_FAST_SNAP_ANIMATION_DURATION(0.25f);
-const float ScrollView::DEFAULT_SNAP_OVERSHOOT_DURATION(0.5f);
-const float ScrollView::DEFAULT_MAX_OVERSHOOT(100.0f); // 100 pixels
-
-const float ScrollView::DEFAULT_AXIS_AUTO_LOCK_GRADIENT(0.36f);
-const float ScrollView::DEFAULT_FRICTION_COEFFICIENT(1.0f);
-const float ScrollView::DEFAULT_FLICK_SPEED_COEFFICIENT(1.0f);
-const float ScrollView::DEFAULT_MAX_FLICK_SPEED(3.0f);
-
ScrollView::ScrollView()
{
}
GetImpl(*this).SetMouseWheelScrollDistanceStep(step);
}
-Vector3 ScrollView::GetCurrentScrollPosition() const
+Vector2 ScrollView::GetCurrentScrollPosition() const
{
return GetImpl(*this).GetCurrentScrollPosition();
}
-void ScrollView::SetScrollPosition(const Vector3& position)
+void ScrollView::SetScrollPosition(const Vector2& position)
{
GetImpl(*this).SetScrollPosition(position);
}
return GetImpl(*this).GetCurrentPage();
}
-void ScrollView::ScrollTo(const Vector3 &position)
+void ScrollView::ScrollTo(const Vector2 &position)
{
GetImpl(*this).ScrollTo(position);
}
-void ScrollView::ScrollTo(const Vector3 &position, float duration)
+void ScrollView::ScrollTo(const Vector2 &position, float duration)
{
GetImpl(*this).ScrollTo(position, duration);
}
-void ScrollView::ScrollTo(const Vector3 &position, float duration, AlphaFunction alpha)
+void ScrollView::ScrollTo(const Vector2 &position, float duration, AlphaFunction alpha)
{
GetImpl(*this).ScrollTo(position, duration, alpha);
}
-void ScrollView::ScrollTo(const Vector3 &position, float duration,
+void ScrollView::ScrollTo(const Vector2 &position, float duration,
DirectionBias horizontalBias, DirectionBias verticalBias)
{
GetImpl(*this).ScrollTo(position, duration, horizontalBias, verticalBias);
}
-void ScrollView::ScrollTo(const Vector3 &position, float duration, AlphaFunction alpha,
+void ScrollView::ScrollTo(const Vector2 &position, float duration, AlphaFunction alpha,
DirectionBias horizontalBias, DirectionBias verticalBias)
{
GetImpl(*this).ScrollTo(position, duration, alpha, horizontalBias, verticalBias);
};
/**
- * @brief A 3 dimensional clamp
+ * @brief A 2 dimensional clamp
*/
-struct ClampState3D
+struct ClampState2D
{
ClampState x; ///< The clamp state of the x axis
ClampState y; ///< The clamp state of the y axis
- ClampState z; ///< The clamp state of the z axis
};
/**
};
+// Forward declare future extension interface
+class RulerExtension;
+
/**
* @brief Abstract class to define scroll axes.
*
*/
virtual unsigned int GetTotalPages() const = 0;
+ /**
+ * @brief Gets the extension interface of the Ruler.
+ *
+ * @return The extension interface of the Ruler
+ */
+ virtual RulerExtension* GetExtension() { return NULL; }
+
public:
/**
*/
class DALI_IMPORT_API ScrollView : public Scrollable
{
-public:
-
- // Default settings
-
- static const float DEFAULT_SLOW_SNAP_ANIMATION_DURATION; ///< Default Drag-Release animation time.
- static const float DEFAULT_FAST_SNAP_ANIMATION_DURATION; ///< Default Drag-Flick animation time.
- static const float DEFAULT_SNAP_OVERSHOOT_DURATION; ///< Default Overshoot snapping animation time.
- static const float DEFAULT_MAX_OVERSHOOT; ///< Default maximum allowed overshoot
-
- static const float DEFAULT_AXIS_AUTO_LOCK_GRADIENT; ///< Default Axis-AutoLock gradient threshold. default is 0.36:1 (20 degrees)
- static const float DEFAULT_FRICTION_COEFFICIENT; ///< Default Friction Co-efficient. (in stage diagonals per second)
- static const float DEFAULT_FLICK_SPEED_COEFFICIENT; ///< Default Flick speed coefficient (multiples input touch velocity)
- static const float DEFAULT_MAX_FLICK_SPEED; ///< Default Maximum flick speed. (in stage diagonals per second)
public:
*/
struct ClampEvent
{
- ClampState3D scale; ///< Clamp information for scale axes
- ClampState3D position; ///< Clamp information for position axes
+ ClampState2D scale; ///< Clamp information for scale axes
+ ClampState2D position; ///< Clamp information for position axes
ClampState rotation; ///< Clamp information for rotation
};
struct SnapEvent
{
SnapType type; ///< Current snap commencing
- Vector3 position; ///< Target snap position
+ Vector2 position; ///< Target snap position
float duration; ///< Duration of snap animation.
};
{
enum
{
- SCROLL_POSITION = ANIMATABLE_PROPERTY_START_INDEX, ///< Property, name "scroll-position", type Vector3
- SCROLL_PRE_POSITION, ///< Property, name "scroll-pre-position", type Vector3
- OVERSHOOT_X, ///< Property, name "overshoot-x", type float
- OVERSHOOT_Y, ///< Property, name "overshoot-y", type float
- SCROLL_FINAL, ///< Property, name "scroll-final", type Vector3
- SCROLL_FINAL_X,
- SCROLL_FINAL_Y,
- WRAP, ///< Property, name "wrap", type bool
- PANNING, ///< Property, name "panning", type bool
- SCROLLING, ///< Property, name "scrolling", type bool
- SCROLL_DOMAIN_OFFSET, ///< Property, name "scroll-domain-offset" type Vector3
- SCROLL_POSITION_DELTA, ///< Property, name "scroll-position-delta" type Vector3
- START_PAGE_POSITION ///< Property, name "start-page-position" type Vector3
+ SCROLL_POSITION = ANIMATABLE_PROPERTY_START_INDEX, ///< Property, name "scroll-position", type Vector2
+ SCROLL_PRE_POSITION, ///< Property, name "scroll-pre-position", type Vector2
+ SCROLL_PRE_POSITION_X, ///< Property, name "scroll-pre-position-x", type float
+ SCROLL_PRE_POSITION_Y, ///< Property, name "scroll-pre-position-y", type float
+ SCROLL_PRE_POSITION_MAX, ///< Property, name "scroll-pre-position-max", type Vector2
+ SCROLL_PRE_POSITION_MAX_X, ///< Property, name "scroll-pre-position-max-x", type float
+ SCROLL_PRE_POSITION_MAX_Y, ///< Property, name "scroll-pre-position-max-y", type float
+ OVERSHOOT_X, ///< Property, name "overshoot-x", type float
+ OVERSHOOT_Y, ///< Property, name "overshoot-y", type float
+ SCROLL_FINAL, ///< Property, name "scroll-final", type Vector2
+ SCROLL_FINAL_X, ///< Property, name "scroll-final-x", type float
+ SCROLL_FINAL_Y, ///< Property, name "scroll-final-y", type float
+ WRAP, ///< Property, name "wrap", type bool
+ PANNING, ///< Property, name "panning", type bool
+ SCROLLING, ///< Property, name "scrolling", type bool
+ SCROLL_DOMAIN_SIZE, ///< Property, name "scroll-domain-size" type Vector2
+ SCROLL_DOMAIN_SIZE_X, ///< Property, name "scroll-domain-size-x" type float
+ SCROLL_DOMAIN_SIZE_Y, ///< Property, name "scroll-domain-size-y" type float
+ SCROLL_DOMAIN_OFFSET, ///< Property, name "scroll-domain-offset" type Vector2
+ SCROLL_POSITION_DELTA, ///< Property, name "scroll-position-delta" type Vector2
+ START_PAGE_POSITION ///< Property, name "start-page-position" type Vector3
};
};
- typedef Signal< void ( const SnapEvent& ) > SnapStartedSignalType; ///< SnapStarted signal type
+ // Typedefs
- /**
- * @brief Signal emitted when the ScrollView has started to snap or flick (it tells the target
- * position, scale, rotation for the snap or flick)
- */
- SnapStartedSignalType& SnapStartedSignal();
+ typedef Signal< void ( const SnapEvent& ) > SnapStartedSignalType; ///< SnapStarted signal type
public:
*
* @returns The current scroll position.
*/
- Vector3 GetCurrentScrollPosition() const;
+ Vector2 GetCurrentScrollPosition() const;
/**
* @brief Sets the current scroll position, overriding current scroll animations. If panning is currently taking place
*
* @param[in] position The new scroll position to set.
*/
- void SetScrollPosition(const Vector3& position);
+ void SetScrollPosition(const Vector2& position);
/**
* @brief Retrieves current scroll page based on ScrollView
*
* @param[in] position The position to scroll to.
*/
- void ScrollTo(const Vector3 &position);
+ void ScrollTo(const Vector2& position);
/**
* @brief Scrolls View to position specified (contents will scroll to this position).
* @param[in] position The position to scroll to.
* @param[in] duration The duration of the animation in seconds
*/
- void ScrollTo(const Vector3 &position, float duration);
+ void ScrollTo(const Vector2& position, float duration);
/**
* @brief Scrolls View to position specified (contents will scroll to this position)
* @param[in] duration The duration of the animation in seconds
* @param[in] alpha The alpha function to use
*/
- void ScrollTo(const Vector3 &position, float duration, AlphaFunction alpha);
+ void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha);
/**
* @brief Scrolls View to position specified (contents will scroll to this position).
* @param[in] horizontalBias Whether to bias scrolling to left or right.
* @param[in] verticalBias Whether to bias scrolling to top or bottom.
*/
- void ScrollTo(const Vector3 &position, float duration,
+ void ScrollTo(const Vector2& position, float duration,
DirectionBias horizontalBias, DirectionBias verticalBias);
/**
* @param[in] verticalBias Whether to bias scrolling to top or bottom.
* @param[in] alpha Alpha function to use
*/
- void ScrollTo(const Vector3 &position, float duration, AlphaFunction alpha,
+ void ScrollTo(const Vector2& position, float duration, AlphaFunction alpha,
DirectionBias horizontalBias, DirectionBias verticalBias);
/**
*/
void RemoveScrollingDirection( Radian direction );
+public: // Signals
+
+ /**
+ * @brief Signal emitted when the ScrollView has started to snap or flick (it tells the target
+ * position, scale, rotation for the snap or flick)
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName(const SnapEvent& event);
+ * @endcode
+ * @pre The Object has been initialized.
+ * @return The signal to connect to.
+ */
+ SnapStartedSignalType& SnapStartedSignal();
+
public: // Not intended for application developers
/**
return GetImpl(*this).ScrollCompletedSignal();
}
-bool Scrollable::IsScrollComponentEnabled(Scrollable::ScrollComponentType indicator) const
+bool Scrollable::IsOvershootEnabled() const
{
- return GetImpl(*this).IsScrollComponentEnabled(indicator);
+ return GetImpl(*this).IsOvershootEnabled();
}
-void Scrollable::EnableScrollComponent(Scrollable::ScrollComponentType indicator)
+void Scrollable::SetOvershootEnabled(bool enable)
{
- GetImpl(*this).EnableScrollComponent(indicator);
-}
-
-void Scrollable::DisableScrollComponent(Scrollable::ScrollComponentType indicator)
-{
- GetImpl(*this).DisableScrollComponent(indicator);
+ GetImpl(*this).SetOvershootEnabled(enable);
}
void Scrollable::SetOvershootEffectColor( const Vector4& color )
public:
/**
- * @brief Scroll component types
- */
- enum ScrollComponentType
- {
- HorizontalScrollBar,
- VerticalScrollBar,
- OvershootIndicator,
- };
-
- /**
* @brief The start and end property ranges for this control.
*/
enum PropertyRange
OVERSHOOT_ANIMATION_SPEED, ///< Property, name "overshoot-animation-speed", @see SetOvershootAnimationSpeed(), type float
// Animatable properties
- SCROLL_RELATIVE_POSITION = ANIMATABLE_PROPERTY_START_INDEX, ///< Property, name "scroll-relative-position", type Vector3
- SCROLL_POSITION_MIN, ///< Property, name "scroll-position-min", type Vector3
- SCROLL_POSITION_MAX, ///< Property, name "scroll-position-max", type Vector3
- SCROLL_DIRECTION, ///< Property, name "scroll-direction", type Vector2
+ SCROLL_RELATIVE_POSITION = ANIMATABLE_PROPERTY_START_INDEX, ///< Property, name "scroll-relative-position", type Vector2
+ SCROLL_POSITION_MIN, ///< Property, name "scroll-position-min", type Vector2
+ SCROLL_POSITION_MIN_X, ///< Property, name "scroll-position-min-x", type float
+ SCROLL_POSITION_MIN_Y, ///< Property, name "scroll-position-min-y", type float
+ SCROLL_POSITION_MAX, ///< Property, name "scroll-position-max", type Vector2
+ SCROLL_POSITION_MAX_X, ///< Property, name "scroll-position-max-x", type float
+ SCROLL_POSITION_MAX_Y, ///< Property, name "scroll-position-max-y", type float
CAN_SCROLL_VERTICAL, ///< Property, name "can-scroll-vertical", type bool
CAN_SCROLL_HORIZONTAL ///< Property, name "can-scroll-horizontal", type bool
};
};
-public:
-
- typedef Signal< void ( const Vector3& ) > ScrollStartedSignalType; ///< ScrollStarted signal type
- typedef Signal< void ( const Vector3& ) > ScrollCompletedSignalType; ///< ScrollCompleted signal type
- typedef Signal< void ( const Vector3& ) > ScrollUpdatedSignalType; ///< Scroll updated signal type
-
- /**
- * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
- */
- ScrollStartedSignalType& ScrollStartedSignal();
-
- /**
- * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
- */
- ScrollUpdatedSignalType& ScrollUpdatedSignal();
+ // Typedefs
- /**
- * @brief Signal emitted when the Scrollable has completed movement (whether by touch or animation).
- */
- ScrollCompletedSignalType& ScrollCompletedSignal();
+ typedef Signal< void ( const Vector2& ) > ScrollStartedSignalType; ///< ScrollStarted signal type
+ typedef Signal< void ( const Vector2& ) > ScrollCompletedSignalType; ///< ScrollCompleted signal type
+ typedef Signal< void ( const Vector2& ) > ScrollUpdatedSignalType; ///< Scroll updated signal type
public:
static Scrollable DownCast( BaseHandle handle );
/**
- * @brief Checks if a ScrollComponent has been enabled or not.
- *
- * @param[in] type The Scroll Component Type to check
- * @return True (if Enabled)
- */
- bool IsScrollComponentEnabled(Scrollable::ScrollComponentType type) const;
-
- /**
- * @brief Enables a ScrollComponent.
+ * @brief Checks if scroll overshoot has been enabled or not.
*
- * @param[in] type The Scroll Component Type to enable
+ * @return Whether the scroll obvershoot is enabled
*/
- void EnableScrollComponent(Scrollable::ScrollComponentType type);
+ bool IsOvershootEnabled() const;
/**
- * @brief Disables a ScrollComponent.
+ * @brief Sets whether to enables or disable scroll overshoot.
*
- * @param[in] type The Scroll Component Type to disable
+ * @param[in] enable Whether to enable the scroll obvershoot or not
*/
- void DisableScrollComponent(Scrollable::ScrollComponentType type);
+ void SetOvershootEnabled(bool enable);
/**
* @brief Set the color of the overshoot effect.
*/
float GetOvershootAnimationSpeed() const;
+public: // Signals
+
+ /**
+ * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName(const Vector2& currentScrollPosition);
+ * @endcode
+ * @pre The Object has been initialized.
+ * @return The signal to connect to.
+ */
+ ScrollStartedSignalType& ScrollStartedSignal();
+
+ /**
+ * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName(const Vector2& currentScrollPosition);
+ * @endcode
+ * @pre The Object has been initialized.
+ * @return The signal to connect to.
+ */
+ ScrollUpdatedSignalType& ScrollUpdatedSignal();
+
+ /**
+ * @brief Signal emitted when the Scrollable has completed movement (whether by touch or animation).
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName(const Vector2& currentScrollPosition);
+ * @endcode
+ * @pre The Object has been initialized.
+ * @return The signal to connect to.
+ */
+ ScrollCompletedSignalType& ScrollCompletedSignal();
+
public: // Not intended for application developers
/**
$(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-page-path-effect.cpp \
$(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-wobble-effect.cpp \
$(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view.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/scrollable.cpp \
$(public_api_src_dir)/controls/shadow-view/shadow-view.cpp \
$(public_api_src_dir)/controls/slider/slider.cpp \
$(public_api_src_dir)/controls/popup/popup.h
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_src_dir)/controls/scrollable/scroll-connector.h \
$(public_api_src_dir)/controls/scrollable/scrollable.h
public_api_scroll_bar_header_files = \