From 310438cc8e309f07e3c470bc02b81c7e1ab49492 Mon Sep 17 00:00:00 2001 From: Paul Wisbey Date: Fri, 3 Mar 2017 17:39:48 +0000 Subject: [PATCH] Fix for TextSelectionToolbar overshootEffectColor styling Change-Id: I9ee4b4182964cccdf0b1540e1495fc5d325227f8 --- .../dali-toolkit/utc-Dali-TextSelectionPopup.cpp | 33 ++++++++++++++++++++++ .../text-controls/text-selection-toolbar-impl.cpp | 20 +++++++++++-- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextSelectionPopup.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextSelectionPopup.cpp index 9b7c6fc..dc7fcc7 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextSelectionPopup.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextSelectionPopup.cpp @@ -197,3 +197,36 @@ int UtcDaliToolkitTextSelectionToolBarScrollBarP(void) DALI_TEST_CHECK( toolbar ); END_TEST; } + +int UtcDaliToolkitTextSelectionToolBarScrollView(void) +{ + // Configures the ScrollView within the TextSelectionToolbar + ToolkitTestApplication application; + + TextSelectionToolbar toolbar = TextSelectionToolbar::New(); + DALI_TEST_CHECK( toolbar ); + Stage::GetCurrent().Add( toolbar ); + + Property::Map map; + map["overshootEffectColor"] = Color::RED; + map["overshootSize"] = Vector2(50.0f, 50.f); + toolbar.SetProperty( Toolkit::TextSelectionToolbar::Property::SCROLL_VIEW, map ); + + application.SendNotification(); + application.Render(); + + Actor actor = toolbar.FindChildByName("TextSelectionScrollView"); + DALI_TEST_CHECK( actor ); + + ScrollView scrollView = ScrollView::DownCast( actor ); + DALI_TEST_CHECK( scrollView ); + + Vector4 color = scrollView.GetProperty( Toolkit::Scrollable::Property::OVERSHOOT_EFFECT_COLOR ); + DALI_TEST_EQUALS( color, Color::RED, TEST_LOCATION ); + + Vector2 size = scrollView.GetProperty( Toolkit::Scrollable::Property::OVERSHOOT_SIZE ); + DALI_TEST_EQUALS( size, Vector2(50.0f, 50.f), TEST_LOCATION ); + + END_TEST; +} + diff --git a/dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.cpp index 0cb62af..957e152 100644 --- a/dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.cpp @@ -29,6 +29,7 @@ // INTERNAL INCLUDES #include #include +#include namespace Dali { @@ -198,6 +199,7 @@ const Dali::Vector2& TextSelectionToolbar::GetPopupMaxSize() const void TextSelectionToolbar::SetUpScrollView() { + mScrollView.SetName("TextSelectionScrollView"); mScrollView.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS ); mScrollView.SetParentOrigin( ParentOrigin::CENTER_LEFT ); mScrollView.SetAnchorPoint( AnchorPoint::CENTER_LEFT ); @@ -336,9 +338,21 @@ void TextSelectionToolbar::ConfigureScrollview( const Property::Map& properties Property::Index setPropertyIndex = mScrollView.GetPropertyIndex( propertyPair.first ); if( setPropertyIndex != Property::INVALID_INDEX ) { - // If the conversion worked, we have a valid property index, - // Set the property to the new value. - mScrollView.SetProperty( setPropertyIndex, propertyPair.second ); + // Convert the string representation of a color into a Vector4 + if( setPropertyIndex == Toolkit::Scrollable::Property::OVERSHOOT_EFFECT_COLOR ) + { + Vector4 color; + if( ConvertPropertyToColor( propertyPair.second, color ) ) + { + mScrollView.SetOvershootEffectColor( color ); + } + } + else + { + // If the conversion worked, we have a valid property index, + // Set the property to the new value. + mScrollView.SetProperty( setPropertyIndex, propertyPair.second ); + } } } -- 2.7.4