[3.0] Text's selection popup mirroring. 01/109801/5
authorVictor Cebollada <v.cebollada@samsung.com>
Wed, 11 Jan 2017 16:17:08 +0000 (16:17 +0000)
committerPaul Wisbey <p.wisbey@samsung.com>
Mon, 16 Jan 2017 10:31:07 +0000 (02:31 -0800)
* 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 <v.cebollada@samsung.com>
dali-toolkit/devel-api/controls/text-controls/text-selection-toolbar.cpp
dali-toolkit/devel-api/controls/text-controls/text-selection-toolbar.h
dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp
dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.cpp
dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.h
dali-toolkit/po/ar.po
dali-toolkit/po/fa.po
dali-toolkit/po/ur.po

index 46c32c8..84bd8db 100644 (file)
@@ -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<TextSelectionToolbar, Internal::TextSelectionToolbar>(handle);
index 0a3b941..bf4c303 100644 (file)
@@ -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.
index e82d82d..4e07ba8 100644 (file)
@@ -20,6 +20,7 @@
 
 // EXTERNAL INCLUDES
 #include <libintl.h>
+#include <string.h>
 #include <cfloat>
 #include <dali/public-api/animation/animation.h>
 #include <dali/devel-api/images/nine-patch-image.h>
@@ -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 )
index 00c74f4..ab20e8a 100644 (file)
@@ -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.
index 46e633b..e5b96ae 100644 (file)
@@ -84,6 +84,11 @@ public:
    */
   void RaiseAbove( Layer target );
 
+  /**
+   * @copydoc Toolkit::TextSelectionToolbar::ScrollTo()
+   */
+  void ScrollTo( const Vector2& position );
+
 private: // From Control
 
   /**
index a31e003..414fb07 100755 (executable)
@@ -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 "اختيار الكل"
 
index 4996205..5e8369b 100644 (file)
@@ -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 "انتخاب همه"
 
index 7872070..b4bf3be 100644 (file)
@@ -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 "تمام منتخب کریں"