{
CreateDefaultIndicatorActor();
Self().SetDrawMode(DrawMode::OVERLAY_2D);
+ SetScrollDirection(mDirection);
}
void ScrollBar::SetScrollPropertySource( Handle handle, Property::Index propertyScrollPosition, Property::Index propertyMinScrollPosition, Property::Index propertyMaxScrollPosition, Property::Index propertyScrollContentSize )
}
}
+void ScrollBar::OnStageConnection( int depth )
+{
+ Actor parent = Self().GetParent();
+ if (parent && mDirection == Toolkit::ScrollBar::Horizontal)
+ {
+ parent.OnRelayoutSignal().Connect( this, &ScrollBar::OnParentRelayout );
+ }
+
+ Control::OnStageConnection( depth );
+}
+
+void ScrollBar::OnStageDisconnection()
+{
+ Actor parent = Self().GetParent();
+ if (parent && mDirection == Toolkit::ScrollBar::Horizontal)
+ {
+ parent.OnRelayoutSignal().Disconnect( this, &ScrollBar::OnParentRelayout );
+ }
+
+ Control::OnStageDisconnection();
+}
+
+void ScrollBar::OnParentRelayout(Actor actor)
+{
+ // Make the height of the horizontal scroll bar to be the same as the width of its parent.
+ // The parent size only set during relayout.
+ Self().SetSize(Vector2(0.0f, actor.GetRelayoutSize( Dimension::WIDTH) ));
+}
+
void ScrollBar::SetScrollDirection( Toolkit::ScrollBar::Direction direction )
{
mDirection = direction;
+
+ Actor self = Self();
+
+ if(mDirection == Toolkit::ScrollBar::Horizontal)
+ {
+ // Rotate the scroll bar and align it to the bottom of its parent
+ self.SetParentOrigin(ParentOrigin::BOTTOM_LEFT);
+ self.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ self.SetResizePolicy(Dali::ResizePolicy::FIT_TO_CHILDREN, Dali::Dimension::WIDTH);
+ self.SetOrientation(Quaternion(Radian( 1.5f * Math::PI ), Vector3::ZAXIS));
+
+ Actor parent = self.GetParent();
+ if (parent && mDirection == Toolkit::ScrollBar::Horizontal)
+ {
+ parent.OnRelayoutSignal().Connect( this, &ScrollBar::OnParentRelayout );
+ }
+ }
+ else
+ {
+ // Align the scroll bar to the right of its parent
+ self.SetParentOrigin(ParentOrigin::TOP_RIGHT);
+ self.SetAnchorPoint(AnchorPoint::TOP_RIGHT);
+ self.SetResizePolicy(Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::HEIGHT);
+ self.SetResizePolicy(Dali::ResizePolicy::FIT_TO_CHILDREN, Dali::Dimension::WIDTH);
+ }
}
Toolkit::ScrollBar::Direction ScrollBar::GetScrollDirection() const
{
mTransientScrollBar = transient;
- Toolkit::ScrollBar scrollBar = mScrollBar.GetHandle();
- if( mTransientScrollBar && scrollBar )
+ if( mTransientScrollBar )
{
- // Show the scroll-indicator for a brief period
- scrollBar.SetVisible( true );
- GetImpl(scrollBar).ShowTransientIndicator();
+ ShowScrollIndicator(true);
}
}
}
DALI_LOG_SCROLL_STATE("[0x%X] mSnapStartedSignal [%.2f, %.2f]", this, snapEvent.position.x, snapEvent.position.y);
mSnapStartedSignal.Emit( snapEvent );
+ // Make indicator visible during scrolling
+ ShowScrollIndicator(false);
+
return (mScrollStateFlags & SCROLL_ANIMATION_FLAGS) != 0;
}
mDomainOffset += deltaPosition - mScrollPostPosition;
self.SetProperty(Toolkit::ScrollView::Property::SCROLL_DOMAIN_OFFSET, mDomainOffset);
HandleStoppedAnimation();
+
+ if( mTransientScrollBar )
+ {
+ HideScrollIndicator();
+ }
}
void ScrollView::SetScrollUpdateNotification( bool enabled )
Dali::Toolkit::ScrollBar scrollBar = Dali::Toolkit::ScrollBar::DownCast(child);
if( scrollBar )
{
- mScrollBar = scrollBar;
scrollBar.SetName("ScrollBar");
mInternalActor.Add( scrollBar );
if( scrollBar.GetScrollDirection() == Toolkit::ScrollBar::Horizontal )
{
+ mHorizontalScrollBar = scrollBar;
scrollBar.SetScrollPropertySource( Self(),
Toolkit::ScrollView::Property::SCROLL_PRE_POSITION_X,
Toolkit::Scrollable::Property::SCROLL_POSITION_MIN_X,
}
else
{
+ mVerticalScrollBar = scrollBar;
scrollBar.SetScrollPropertySource( Self(),
Toolkit::ScrollView::Property::SCROLL_PRE_POSITION_Y,
Toolkit::Scrollable::Property::SCROLL_POSITION_MIN_Y,
}
else
{
- scrollBar.SetVisible( false );
+ scrollBar.SetVisible(false);
scrollBar.HideIndicator();
}
}
self.SetProperty( Toolkit::ScrollView::Property::START_PAGE_POSITION, Vector3(gesture.position.x, gesture.position.y, 0.0f) );
UpdateMainInternalConstraint();
- Toolkit::ScrollBar scrollBar = mScrollBar.GetHandle();
- if( scrollBar && mTransientScrollBar )
- {
- Vector3 size = Self().GetCurrentSize();
- const Toolkit::RulerDomain& rulerDomainX = mRulerX->GetDomain();
- const Toolkit::RulerDomain& rulerDomainY = mRulerY->GetDomain();
- if( ( rulerDomainX.max > size.width ) || ( rulerDomainY.max > size.height ) )
- {
- scrollBar.SetVisible( true );
- scrollBar.ShowIndicator();
- }
- }
+ // Make scroll indicator visible as soon as the panning starts
+ ShowScrollIndicator(false);
+
break;
}
{
mScrollMainInternalPrePositionConstraint.Remove();
}
-
- Toolkit::ScrollBar scrollBar = mScrollBar.GetHandle();
- if( scrollBar && mTransientScrollBar )
- {
- scrollBar.HideIndicator();
- }
}
else
{
return panningOrScrolling;
}
+void ScrollView::ShowScrollIndicator(bool transient)
+{
+ Vector3 scrollViewSize = Self().GetCurrentSize();
+
+ Toolkit::ScrollBar scrollBar = mHorizontalScrollBar.GetHandle();
+ if( scrollBar)
+ {
+ const Toolkit::RulerDomain& rulerDomainX = mRulerX->GetDomain();
+
+ if( rulerDomainX.max > scrollViewSize.width )
+ {
+ scrollBar.SetVisible(true);
+ if( transient )
+ {
+ GetImpl(scrollBar).ShowTransientIndicator();
+ }
+ else
+ {
+ scrollBar.ShowIndicator();
+ }
+ }
+ }
+
+ scrollBar = mVerticalScrollBar.GetHandle();
+ if( scrollBar)
+ {
+ const Toolkit::RulerDomain& rulerDomainY = mRulerY->GetDomain();
+
+ if( rulerDomainY.max > scrollViewSize.height )
+ {
+ scrollBar.SetVisible(true);
+ if( transient )
+ {
+ GetImpl(scrollBar).ShowTransientIndicator();
+ }
+ else
+ {
+ scrollBar.ShowIndicator();
+ }
+ }
+ }
+}
+
+void ScrollView::HideScrollIndicator()
+{
+ Toolkit::ScrollBar scrollBar = mHorizontalScrollBar.GetHandle();
+ if( scrollBar )
+ {
+ scrollBar.HideIndicator();
+ }
+
+ scrollBar = mVerticalScrollBar.GetHandle();
+ if( scrollBar )
+ {
+ scrollBar.HideIndicator();
+ }
+}
+
void ScrollView::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
{
Toolkit::ScrollView scrollView = Toolkit::ScrollView::DownCast( Dali::BaseHandle( object ) );