const float DEFAULT_INDICATOR_MINIMUM_HEIGHT(0.0f);
const float DEFAULT_INDICATOR_START_PADDING(0.0f);
const float DEFAULT_INDICATOR_END_PADDING(0.0f);
+const float DEFAULT_INDICATOR_TRANSIENT_DURATION(1.0f);
+
+// The following properties are not in the public-api yet.
+enum
+{
+ /**
+ * @brief The duration that transient indicators will remain fully visible.
+ * @details name "indicatorTransientDuration", type float.
+ */
+ INDICATOR_TRANSIENT_DURATION = Toolkit::ScrollBar::Property::INDICATOR_END_PADDING + 1
+};
/**
* Indicator size constraint
// Setup properties, signals and actions using the type-registry.
DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ScrollBar, Toolkit::Control, Create );
-DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "scrollDirection", STRING, SCROLL_DIRECTION )
-DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorHeightPolicy", STRING, INDICATOR_HEIGHT_POLICY )
-DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorFixedHeight", FLOAT, INDICATOR_FIXED_HEIGHT )
-DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorShowDuration", FLOAT, INDICATOR_SHOW_DURATION )
-DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorHideDuration", FLOAT, INDICATOR_HIDE_DURATION )
-DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "scrollPositionIntervals", ARRAY, SCROLL_POSITION_INTERVALS )
-DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorMinimumHeight", FLOAT, INDICATOR_MINIMUM_HEIGHT )
-DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorStartPadding", FLOAT, INDICATOR_START_PADDING )
-DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorEndPadding", FLOAT, INDICATOR_END_PADDING )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "scrollDirection", STRING, SCROLL_DIRECTION )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorHeightPolicy", STRING, INDICATOR_HEIGHT_POLICY )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorFixedHeight", FLOAT, INDICATOR_FIXED_HEIGHT )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorShowDuration", FLOAT, INDICATOR_SHOW_DURATION )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorHideDuration", FLOAT, INDICATOR_HIDE_DURATION )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "scrollPositionIntervals", ARRAY, SCROLL_POSITION_INTERVALS )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorMinimumHeight", FLOAT, INDICATOR_MINIMUM_HEIGHT )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorStartPadding", FLOAT, INDICATOR_START_PADDING )
+DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicatorEndPadding", FLOAT, INDICATOR_END_PADDING )
+
+Dali::PropertyRegistration manualProperty1( typeRegistration, "indicatorTransientDuration", INDICATOR_TRANSIENT_DURATION,
+ Property::FLOAT, Dali::Toolkit::Internal::ScrollBar::SetProperty, Dali::Toolkit::Internal::ScrollBar::GetProperty );
DALI_SIGNAL_REGISTRATION( Toolkit, ScrollBar, "panFinished", PAN_FINISHED_SIGNAL )
DALI_SIGNAL_REGISTRATION( Toolkit, ScrollBar, "scrollPositionIntervalReached", SCROLL_POSITION_INTERVAL_REACHED_SIGNAL )
}
ScrollBar::ScrollBar(Toolkit::ScrollBar::Direction direction)
-: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
+: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
mIndicatorShowAlpha(1.0f),
mDirection(direction),
mScrollableObject(WeakHandleBase()),
mPropertyScrollContentSize(Property::INVALID_INDEX),
mIndicatorShowDuration(DEFAULT_INDICATOR_SHOW_DURATION),
mIndicatorHideDuration(DEFAULT_INDICATOR_HIDE_DURATION),
+ mTransientIndicatorDuration(DEFAULT_INDICATOR_TRANSIENT_DURATION),
mScrollStart(0.0f),
mCurrentScrollPosition(0.0f),
mIndicatorHeightPolicy(Toolkit::ScrollBar::Variable),
{
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 )
Toolkit::ImageView indicator = Toolkit::ImageView::New( DEFAULT_INDICATOR_IMAGE_PATH );
indicator.SetParentOrigin( ParentOrigin::TOP_LEFT );
indicator.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-
+ indicator.SetStyleName( "ScrollBarIndicator" );
+ indicator.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
SetScrollIndicator(indicator);
}
}
}
+void ScrollBar::ShowTransientIndicator()
+{
+ // Cancel any animation
+ if(mAnimation)
+ {
+ mAnimation.Clear();
+ mAnimation.Reset();
+ }
+
+ mAnimation = Animation::New( mIndicatorShowDuration + mTransientIndicatorDuration + mIndicatorHideDuration );
+ if(mIndicatorShowDuration > 0.0f)
+ {
+ mAnimation.AnimateTo( Property( mIndicator, Actor::Property::COLOR_ALPHA ),
+ mIndicatorShowAlpha, AlphaFunction::EASE_IN, TimePeriod(0, mIndicatorShowDuration) );
+ }
+ else
+ {
+ mIndicator.SetOpacity(mIndicatorShowAlpha);
+ }
+ mAnimation.AnimateTo( Property( mIndicator, Actor::Property::COLOR_ALPHA ),
+ 0.0f, AlphaFunction::EASE_IN, TimePeriod((mIndicatorShowDuration + mTransientIndicatorDuration), mIndicatorHideDuration) );
+ mAnimation.Play();
+}
+
bool ScrollBar::OnPanGestureProcessTick()
{
// Update the scroll position property.
}
}
+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
scrollBarImpl.ApplyConstraints();
break;
}
+ case INDICATOR_TRANSIENT_DURATION:
+ {
+ scrollBarImpl.mTransientIndicatorDuration = value.Get<float>();
+ break;
+ }
}
}
}
value = scrollBarImpl.mIndicatorEndPadding;
break;
}
+ case INDICATOR_TRANSIENT_DURATION:
+ {
+ value = scrollBarImpl.mTransientIndicatorDuration;
+ break;
+ }
}
}
return value;