[3.0] Initially show scroll indicator for a brief period 68/116868/3
authorPaul Wisbey <p.wisbey@samsung.com>
Tue, 28 Feb 2017 19:24:19 +0000 (19:24 +0000)
committerPaul Wisbey <p.wisbey@samsung.com>
Thu, 2 Mar 2017 15:05:16 +0000 (15:05 +0000)
Change-Id: Ib19586c964d7f62aa78b89c791f7ff0067c729d0

dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp
dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h
dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp
dali-toolkit/styles/1920x1080/dali-toolkit-default-theme.json
dali-toolkit/styles/480x800/dali-toolkit-default-theme.json
dali-toolkit/styles/720x1280/dali-toolkit-default-theme.json

index 8f69a6e..5a4beea 100755 (executable)
@@ -46,6 +46,17 @@ const float DEFAULT_INDICATOR_FIXED_HEIGHT(80.0f);
 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
@@ -154,15 +165,18 @@ BaseHandle Create()
 // 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 )
@@ -185,6 +199,7 @@ ScrollBar::ScrollBar(Toolkit::ScrollBar::Direction direction)
   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),
@@ -403,6 +418,30 @@ void ScrollBar::HideIndicator()
   }
 }
 
+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.
@@ -685,6 +724,11 @@ void ScrollBar::SetProperty( BaseObject* object, Property::Index index, const Pr
         scrollBarImpl.ApplyConstraints();
         break;
       }
+      case INDICATOR_TRANSIENT_DURATION:
+      {
+        scrollBarImpl.mTransientIndicatorDuration = value.Get<float>();
+        break;
+      }
     }
   }
 }
@@ -756,6 +800,11 @@ Property::Value ScrollBar::GetProperty( BaseObject* object, Property::Index inde
         value = scrollBarImpl.mIndicatorEndPadding;
         break;
       }
+      case INDICATOR_TRANSIENT_DURATION:
+      {
+        value = scrollBarImpl.mTransientIndicatorDuration;
+        break;
+      }
     }
   }
   return value;
index 0826ef3..da398b6 100755 (executable)
@@ -146,7 +146,12 @@ public:
   /**
    * @copydoc Toolkit::ScrollBar::HideIndicator()
    */
- void HideIndicator();
+  void HideIndicator();
+
+  /**
+   * @brief Shows indicator until the transient duration has expired
+   */
+  void ShowTransientIndicator();
 
  /**
   * @copydoc Toolkit::ScrollBar::PanFinishedSignal()
@@ -278,6 +283,7 @@ private:
 
   float mIndicatorShowDuration;                                      ///< The duration of scroll indicator show animation
   float mIndicatorHideDuration;                                      ///< The duration of scroll indicator hide animation
+  float mTransientIndicatorDuration;                                 ///< The duration before hiding transient indicator
 
   float mScrollStart;                                                ///< Scroll Start position (start of drag)
   Vector3 mGestureDisplacement;                                      ///< Gesture Displacement.
index 6ab13c2..622a934 100644 (file)
@@ -34,6 +34,7 @@
 #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>
 #include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-effect-impl.h>
+#include <dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h>
 
 //#define ENABLED_SCROLL_STATE_LOGGING
 
@@ -1983,8 +1984,8 @@ void ScrollView::OnChildAdd(Actor& child)
 
     if( mTransientScrollBar )
     {
-      scrollBar.SetVisible( false );
-      scrollBar.HideIndicator();
+      // Show the scroll-indicator for a brief period
+      GetImpl(scrollBar).ShowTransientIndicator();
     }
   }
   else if(mAlterChild)
@@ -2492,7 +2493,6 @@ void ScrollView::OnPan( const PanGesture& gesture )
 
         if( ( rulerDomainX.max > size.width ) || ( rulerDomainY.max > size.height ) )
         {
-          scrollBar.SetVisible( true );
           scrollBar.ShowIndicator();
         }
       }
index 1274cf0..05e101d 100644 (file)
     "TextSelectionScrollBar":
     {
       "indicatorShowDuration":0.25,
-      "indicatorHideDuration":0.25
+      "indicatorHideDuration":0.25,
+      "indicatorTransientDuration":1.0
     },
     "TextSelectionScrollIndicator":
     {
index 2548843..0100130 100644 (file)
     "TextSelectionScrollBar":
     {
       "indicatorShowDuration":0.25,
-      "indicatorHideDuration":0.25
+      "indicatorHideDuration":0.25,
+      "indicatorTransientDuration":1.0
     },
     "TextSelectionScrollIndicator":
     {
index 0958f29..d9c6c02 100644 (file)
     "TextSelectionScrollBar":
     {
       "indicatorShowDuration":0.25,
-      "indicatorHideDuration":0.25
+      "indicatorHideDuration":0.25,
+      "indicatorTransientDuration":1.0
     },
     "TextSelectionScrollIndicator":
     {