From: Victor Cebollada Date: Wed, 11 Jan 2017 16:17:08 +0000 (+0000) Subject: [3.0] Text's selection popup mirroring. X-Git-Tag: accepted/tizen/3.0/common/20170123.132219~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=d86dc4637c192f72f68cee348b7bc4b8398ff048 [3.0] Text's selection popup mirroring. * Reverses the order of the text's selection popup toolbar when the platform's language is right to left. * Scrolls to the first reversed button (that's the end of the toolbar). Change-Id: I58c5bbc5402810e0bd94510cc3f12143b572e395 Signed-off-by: Victor Cebollada --- diff --git a/dali-toolkit/devel-api/controls/text-controls/text-selection-toolbar.cpp b/dali-toolkit/devel-api/controls/text-controls/text-selection-toolbar.cpp index 46c32c8..84bd8db 100644 --- a/dali-toolkit/devel-api/controls/text-controls/text-selection-toolbar.cpp +++ b/dali-toolkit/devel-api/controls/text-controls/text-selection-toolbar.cpp @@ -76,6 +76,11 @@ void TextSelectionToolbar::RaiseAbove( Layer target ) GetImpl(*this).RaiseAbove( target ); } +void TextSelectionToolbar::ScrollTo( const Vector2& position ) +{ + GetImpl(*this).ScrollTo( position ); +} + TextSelectionToolbar TextSelectionToolbar::DownCast( BaseHandle handle ) { return Control::DownCast(handle); diff --git a/dali-toolkit/devel-api/controls/text-controls/text-selection-toolbar.h b/dali-toolkit/devel-api/controls/text-controls/text-selection-toolbar.h index 0a3b941..bf4c303 100644 --- a/dali-toolkit/devel-api/controls/text-controls/text-selection-toolbar.h +++ b/dali-toolkit/devel-api/controls/text-controls/text-selection-toolbar.h @@ -128,6 +128,11 @@ public: void RaiseAbove( Layer target ); /** + * @copydoc Toolkit::ScrollView::ScrollTo(const Vector2&) + */ + void ScrollTo( const Vector2& position ); + + /** * @brief Downcast a handle to TextSelectionToolbar. * * If the BaseHandle points is a TextSelectionToolbar the downcast returns a valid handle. diff --git a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp index e82d82d..4e07ba8 100644 --- a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp @@ -20,6 +20,7 @@ // EXTERNAL INCLUDES #include +#include #include #include #include @@ -83,6 +84,9 @@ const char* const OPTION_COPY("optionCopy"); const char* const OPTION_PASTE("optionPaste"); // "Paste" popup option. const char* const OPTION_CLIPBOARD("optionClipboard"); // "Clipboard" popup option. +const std::string IDS_LTR( "IDS_LTR" ); +const std::string RTL_DIRECTION( "RTL" ); + BaseHandle Create() { return Toolkit::TextSelectionPopup::New( NULL ); @@ -789,6 +793,19 @@ std::string TextSelectionPopup::GetPressedImage() const self.Add( mToolbar ); } + // Whether to mirror the list of buttons (for right to left languages) + bool mirror = false; + char* idsLtr = GET_LOCALE_TEXT( IDS_LTR.c_str() ); + if( NULL != idsLtr ) + { + mirror = ( 0 == strcmp( idsLtr, RTL_DIRECTION.c_str() ) ); + + if( mirror ) + { + std::reverse( mOrderListOfButtons.begin(), mOrderListOfButtons.end() ); + } + } + // Iterate list of buttons and add active ones to Toolbar std::size_t numberOfOptionsRequired = GetNumberOfEnabledOptions(); std::size_t numberOfOptionsAdded = 0u; @@ -801,6 +818,11 @@ std::string TextSelectionPopup::GetPressedImage() const AddOption( button, ( numberOfOptionsAdded < numberOfOptionsRequired ) , showIcons, showCaptions ); } } + + if( mirror ) + { + mToolbar.ScrollTo( Vector2( mPopupMaxSize.x, 0.f ) ); + } } TextSelectionPopup::TextSelectionPopup( TextSelectionPopupCallbackInterface* callbackInterface ) 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 00c74f4..ab20e8a 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 @@ -263,6 +263,11 @@ void TextSelectionToolbar::RaiseAbove( Layer target ) mToolbarLayer.RaiseAbove( target ); } +void TextSelectionToolbar::ScrollTo( const Vector2& position ) +{ + mScrollView.ScrollTo( position, 0.f ); +} + void TextSelectionToolbar::ConfigureScrollview( const Property::Map& properties ) { // Set any properties specified for the label by iterating through all property key-value pairs. diff --git a/dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.h b/dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.h index 46e633b..e5b96ae 100644 --- a/dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.h @@ -84,6 +84,11 @@ public: */ void RaiseAbove( Layer target ); + /** + * @copydoc Toolkit::TextSelectionToolbar::ScrollTo() + */ + void ScrollTo( const Vector2& position ); + private: // From Control /** diff --git a/dali-toolkit/po/ar.po b/dali-toolkit/po/ar.po index a31e003..414fb07 100755 --- a/dali-toolkit/po/ar.po +++ b/dali-toolkit/po/ar.po @@ -1,3 +1,7 @@ +#: Used to know if the language is using a right to left script +msgid "IDS_LTR" +msgstr "RTL" + msgid "IDS_COM_BODY_SELECT_ALL" msgstr "اختيار الكل" diff --git a/dali-toolkit/po/fa.po b/dali-toolkit/po/fa.po index 4996205..5e8369b 100644 --- a/dali-toolkit/po/fa.po +++ b/dali-toolkit/po/fa.po @@ -1,3 +1,7 @@ +#: Used to know if the language is using a right to left script +msgid "IDS_LTR" +msgstr "RTL" + msgid "IDS_COM_BODY_SELECT_ALL" msgstr "انتخاب همه" diff --git a/dali-toolkit/po/ur.po b/dali-toolkit/po/ur.po index 7872070..b4bf3be 100644 --- a/dali-toolkit/po/ur.po +++ b/dali-toolkit/po/ur.po @@ -1,3 +1,7 @@ +#: Used to know if the language is using a right to left script +msgid "IDS_LTR" +msgstr "RTL" + msgid "IDS_COM_BODY_SELECT_ALL" msgstr "تمام منتخب کریں"