{
MAX_SIZE = PROPERTY_START_INDEX, ///< name "maxSize", The maximum size the Popup can be, type VECTOR2
ENABLE_OVERSHOOT, ///< name "enableOvershoot", Whether the overshoot image is enabled, type BOOLEAN
+ ENABLE_SCROLL_BAR, ///< name "enableScrollBar", Whether the scroll-bar is enabled, type BOOLEAN
+ SCROLL_BAR_PADDING, ///< name "scrollBarPadding", The padding used to position the scroll bar, type VECTOR2
SCROLL_VIEW, ///< name "scrollView", Properties to set on scroll view type Property::Map
};
};
indicator.SetParentOrigin( ParentOrigin::TOP_LEFT );
indicator.SetAnchorPoint( AnchorPoint::TOP_LEFT );
indicator.SetStyleName( "ScrollBarIndicator" );
+ indicator.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
SetScrollIndicator(indicator);
}
mAlterChild(false),
mDefaultMaxOvershoot(true),
mCanScrollHorizontal(true),
- mCanScrollVertical(true)
+ mCanScrollVertical(true),
+ mTransientScrollBar(true)
{
}
ScrollBase::OnChildAdd( child );
Dali::Toolkit::ScrollBar scrollBar = Dali::Toolkit::ScrollBar::DownCast(child);
- if(scrollBar)
+ if( scrollBar )
{
- mInternalActor.Add(scrollBar);
- if(scrollBar.GetScrollDirection() == Toolkit::ScrollBar::Horizontal)
+ mScrollBar = scrollBar;
+ scrollBar.SetName("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);
+ 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);
+ 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 );
+ }
+
+ if( mTransientScrollBar )
+ {
+ scrollBar.SetVisible( false );
+ scrollBar.HideIndicator();
}
}
else if(mAlterChild)
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();
+ }
+ }
break;
}
{
mScrollMainInternalPrePositionConstraint.Remove();
}
+
+ Toolkit::ScrollBar scrollBar = mScrollBar.GetHandle();
+ if( scrollBar && mTransientScrollBar )
+ {
+ scrollBar.HideIndicator();
+ }
}
else
{
#include <dali/public-api/adaptor-framework/timer.h>
#include <dali/public-api/animation/animation.h>
#include <dali/public-api/object/property-notification.h>
+#include <dali/devel-api/object/weak-handle.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control-impl.h>
+#include <dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h>
#include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-base-impl.h>
#include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
#include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-effect.h>
Constraint mScrollMainInternalPrePositionMaxConstraint;
ScrollOvershootIndicatorPtr mOvershootIndicator;
+ WeakHandle<Toolkit::ScrollBar> mScrollBar;
Toolkit::ScrollView::SnapStartedSignalType mSnapStartedSignal;
bool mDefaultMaxOvershoot:1; ///< Whether to use default max overshoot or application defined one
bool mCanScrollHorizontal:1; ///< Local value of our property to check against
bool mCanScrollVertical:1; ///< Local value of our property to check against
+ bool mTransientScrollBar:1; ///< True if scroll-bar should be automatically show/hidden during/after panning
};
} // namespace Internal
namespace
{
+const Dali::Vector2 DEFAULT_SCROLL_BAR_PADDING( 8.0f, 6.0f );
+
BaseHandle Create()
{
return Toolkit::TextSelectionToolbar::New();
DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionToolbar, "maxSize", VECTOR2, MAX_SIZE )
DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionToolbar, "enableOvershoot", BOOLEAN, ENABLE_OVERSHOOT )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionToolbar, "enableScrollBar", BOOLEAN, ENABLE_SCROLL_BAR )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionToolbar, "scrollBarPadding", VECTOR2, SCROLL_BAR_PADDING )
DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionToolbar, "scrollView", MAP, SCROLL_VIEW )
DALI_TYPE_REGISTRATION_END()
impl.mScrollView.SetOvershootEnabled( value.Get< bool >() );
break;
}
+ case Toolkit::TextSelectionToolbar::Property::ENABLE_SCROLL_BAR:
+ {
+ impl.SetUpScrollBar( value.Get< bool >() );
+ break;
+ }
+ case Toolkit::TextSelectionToolbar::Property::SCROLL_BAR_PADDING:
+ {
+ impl.SetScrollBarPadding( value.Get< Vector2 >() );
+ break;
+ }
case Toolkit::TextSelectionToolbar::Property::SCROLL_VIEW:
{
// Get a Property::Map from the property if possible.
value = impl.mScrollView.IsOvershootEnabled();
break;
}
+ case Toolkit::TextSelectionToolbar::Property::ENABLE_SCROLL_BAR:
+ {
+ value = impl.mScrollBar ? true : false;
+ break;
+ }
+ case Toolkit::TextSelectionToolbar::Property::SCROLL_BAR_PADDING:
+ {
+ value = impl.GetScrollBarPadding();
+ break;
+ }
} // switch
}
return value;
float width = std::max ( mTableOfButtons.GetNaturalSize().width, size.width );
mRulerX->SetDomain( RulerDomain( 0.0, width, true ) );
mScrollView.SetRulerX( mRulerX );
+
+ if( mScrollBar )
+ {
+ float barWidth = std::min( mTableOfButtons.GetNaturalSize().width, size.width ) - 2.f * mScrollBarPadding.x;
+ mScrollBar.SetSize( Vector2( 0.0f, barWidth ) );
+ }
}
void TextSelectionToolbar::SetPopupMaxSize( const Size& maxSize )
self.Add( mToolbarLayer );
}
+void TextSelectionToolbar::SetUpScrollBar( bool enable )
+{
+ if( enable )
+ {
+ if( ! mScrollBar )
+ {
+ mScrollBar = Toolkit::ScrollBar::New( Toolkit::ScrollBar::Horizontal );
+ mScrollBar.SetName( "Text popup scroll bar" );
+ mScrollBar.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
+ mScrollBar.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ mScrollBar.SetPosition( mScrollBarPadding.x, -mScrollBarPadding.y );
+ mScrollBar.SetResizePolicy( Dali::ResizePolicy::FIT_TO_CHILDREN, Dali::Dimension::WIDTH );
+ mScrollBar.SetOrientation( Quaternion( Radian( 1.5f * Math::PI ), Vector3::ZAXIS ) );
+ mScrollBar.GetPanGestureDetector().DetachAll();
+ mScrollView.Add( mScrollBar );
+ }
+ }
+ else
+ {
+ UnparentAndReset( mScrollBar );
+ }
+}
+
void TextSelectionToolbar::OnScrollStarted( const Vector2& position )
{
mTableOfButtons.SetSensitive( false );
mToolbarLayer.RaiseAbove( target );
}
+void TextSelectionToolbar::SetScrollBarPadding( const Vector2& padding )
+{
+ mScrollBarPadding = padding;
+ if( mScrollBar )
+ {
+ mScrollBar.SetPosition( mScrollBarPadding.x, -mScrollBarPadding.y );
+ }
+
+ RelayoutRequest();
+}
+
void TextSelectionToolbar::ConfigureScrollview( const Property::Map& properties )
{
// Set any properties specified for the label by iterating through all property key-value pairs.
RelayoutRequest();
}
+const Vector2& TextSelectionToolbar::GetScrollBarPadding() const
+{
+ return mScrollBarPadding;
+}
TextSelectionToolbar::TextSelectionToolbar()
: Control( ControlBehaviour( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ) ),
mMaxSize (),
+ mScrollBarPadding( DEFAULT_SCROLL_BAR_PADDING ),
mIndexInTable( 0 ),
mDividerIndexes()
{
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
+#include <dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h>
#include <dali-toolkit/public-api/controls/table-view/table-view.h>
#include <dali-toolkit/devel-api/controls/text-controls/text-selection-toolbar.h>
*/
void RaiseAbove( Layer target );
+ /**
+ * Sets the scroll bar padding.
+ *
+ * @param[in] padding The padding value.
+ */
+ void SetScrollBarPadding( const Vector2& padding );
+
+ /**
+ * @return The padding value.
+ */
+ const Vector2& GetScrollBarPadding() const;
+
private: // From Control
/**
void SetUp();
/**
+ * @brief Enable or disable the scroll-bar
+ *
+ * @param[in] enable True if the scroll-bar is required
+ */
+ void SetUpScrollBar( bool enable );
+
+ /**
* Toolbar has started to scroll
* @param[in] position current scroll view position
*/
Layer mToolbarLayer; ///< The layer used to house the toolbar.
Toolkit::TableView mTableOfButtons; ///< Actor which holds all the buttons, sensitivity can be set on buttons via this actor
Toolkit::ScrollView mScrollView; ///< Provides scrolling of Toolbar when content does not fit.
+ Toolkit::ScrollBar mScrollBar; ///< An horizontal scroll bar for the text's popup options.
RulerPtr mRulerX; ///< Ruler to clamp horizontal scrolling. Updates on Relayout
Size mMaxSize; ///< Max size of the Toolbar
+ Vector2 mScrollBarPadding; ///< The padding used to position the scroll indicator.
unsigned int mIndexInTable; ///< Index in table to add option
Dali::Vector< unsigned int > mDividerIndexes; ///< Vector of indexes in the Toolbar that contain dividers.
-
};
} // namespace Internal
"TextSelectionToolbar":
{
"enableOvershoot":true,
+ "enableScrollBar":true,
"scrollView":
{
"overshootAnimationSpeed":360.0,
"overshootAnimationSpeed":960.0,
"overshootSize":[1920.0,130.0]
},
+ "ScrollBar":
+ {
+ "indicatorShowDuration":0.25,
+ "indicatorHideDuration":0.25,
+ "color":[0.0,0.72,0.9,0.7]
+ },
"TextEditor":
{
"pointSize":120,
"TextSelectionToolbar":
{
"enableOvershoot":true,
+ "enableScrollBar":true,
"scrollView":
{
"overshootAnimationSpeed":120.0,
"overshootAnimationSpeed":120.0,
"overshootSize":[480.0,42.0]
},
+ "ScrollBar":
+ {
+ "indicatorShowDuration":0.25,
+ "indicatorHideDuration":0.25,
+ "color":[0.0,0.72,0.9,0.7]
+ },
"TextEditor":
{
"pointSize":18,
"TextSelectionToolbar":
{
"enableOvershoot":true,
+ "enableScrollBar":true,
"scrollView":
{
"overshootAnimationSpeed":360.0,
"overshootAnimationSpeed":360.0,
"overshootSize":[720.0,130.0]
},
+ "ScrollBar":
+ {
+ "indicatorShowDuration":0.25,
+ "indicatorHideDuration":0.25,
+ "color":[0.0,0.72,0.9,0.7]
+ },
"TextEditor":
{
"pointSize":18,