)
ADD_SUBDIRECTORY(src)
+
+#Internationalization
+SET(PO_DIR ${CMAKE_SOURCE_DIR}/resources/po)
+MESSAGE("po dir: ${PO_DIR}")
+FILE(GLOB PO_FILES RELATIVE "${PO_DIR}" "${PO_DIR}/*.po")
+
+SET(MSGFMT "/usr/bin/msgfmt")
+SET(MO_FILES_DIR /tmp/locale/en/LC_MESSAGES)
+FILE(MAKE_DIRECTORY ${MO_FILES_DIR})
+MESSAGE("mo dir: ${MO_FILES_DIR}")
+
+FOREACH(PO_FILE ${PO_FILES})
+ SET(PO_FILE ${PO_DIR}/${PO_FILE})
+ MESSAGE("PO: ${PO_FILE}")
+ GET_FILENAME_COMPONENT(ABS_PO_FILE ${PO_FILE} ABSOLUTE)
+ MESSAGE("ABS_PO_FILE : ${ABS_PO_FILE}")
+ GET_FILENAME_COMPONENT(lang ${ABS_PO_FILE} NAME_WE)
+ MESSAGE("lang : ${lang}")
+ SET(MO_FILE ${MO_FILES_DIR}/dali-toolkit.mo.${lang})
+ MESSAGE("MO_FILE : ${MO_FILE}")
+ ADD_CUSTOM_COMMAND(OUTPUT ${MO_FILE}
+ COMMAND ${MSGFMT} -o ${MO_FILE} ${ABS_PO_FILE}
+ DEPENDS ${ABS_PO_FILE})
+ SET(MO_FILES ${MO_FILES} ${MO_FILE})
+ENDFOREACH(PO_FILE)
+
+MESSAGE(".mo files: ${MO_FILES}")
+ADD_CUSTOM_TARGET(po ALL DEPENDS ${MO_FILES})
--- /dev/null
+#: Used to know if the language is using a right to left script
+msgid "IDS_LTR"
+msgstr "RTL"
--- /dev/null
+#: Used to know if the language is using a right to left script
+msgid "IDS_LTR"
+msgstr "LTR"
utc-Dali-TextField.cpp
utc-Dali-TextLabel.cpp
utc-Dali-TextSelectionPopup.cpp
+ utc-Dali-TextSelectionPopupMirroringLTR.cpp
+ utc-Dali-TextSelectionPopupMirroringRTL.cpp
utc-Dali-ToolBar.cpp
utc-Dali-Tooltip.cpp
utc-Dali-TransitionData.cpp
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+#include <fstream>
+#include <stdlib.h>
+#include <locale.h>
+#include <libintl.h>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
+
+using namespace Dali;
+using namespace Toolkit;
+
+namespace
+{
+
+const char* DEFAULT_LOCALE_DIR = "/tmp/locale/";
+const std::string DEFAULT_EN_LOCALE_DIR = "/tmp/locale/en/LC_MESSAGES/";
+
+}
+
+void dali_textselectionpopupmirroringltr_startup(void)
+{
+ // Cheat! Copy the .mo file
+ std::ifstream src( std::string( DEFAULT_EN_LOCALE_DIR + "dali-toolkit.mo.en" ).c_str(), std::ifstream::binary );
+ std::ofstream dst( std::string( DEFAULT_EN_LOCALE_DIR + "dali-toolkit.mo" ).c_str(), std::ofstream::binary );
+ dst << src.rdbuf();
+
+ test_return_value = TET_UNDEF;
+}
+
+void dali_textselectionpopupmirroringltr_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+int UtcDaliToolkitTextSelectionPopupMirroringLTR(void)
+{
+ // Test the popup mirroring.
+ const std::string CUT( "optionCut" );
+ const std::string COPY( "optionCopy" );
+ const std::string PASTE( "optionPaste" );
+
+ ToolkitTestApplication application;
+
+ setlocale( LC_ALL, "en_GB.UTF-8" );
+ textdomain("dali-toolkit");
+ bindtextdomain("dali-toolkit", DEFAULT_LOCALE_DIR );
+
+ TextSelectionPopup textSelectionPopup = TextSelectionPopup::New( NULL );
+
+ // Enable some buttons.
+ TextSelectionPopup::Buttons buttons = static_cast<TextSelectionPopup::Buttons>( TextSelectionPopup::COPY | TextSelectionPopup::CUT | TextSelectionPopup::PASTE );
+ textSelectionPopup.EnableButtons( buttons );
+
+ // Show the popup.
+ textSelectionPopup.ShowPopup();
+
+ Actor cutActor = textSelectionPopup.FindChildByName( CUT );
+ if( !cutActor )
+ {
+ tet_result(TET_FAIL);
+ }
+
+ Actor tableOfButtons = cutActor.GetParent();
+ if( !tableOfButtons )
+ {
+ tet_result(TET_FAIL);
+ }
+
+ // The order should be COPY, CUT, PASTE
+ DALI_TEST_EQUALS( COPY, tableOfButtons.GetChildAt( 0 ).GetName(), TEST_LOCATION );
+ DALI_TEST_EQUALS( CUT, tableOfButtons.GetChildAt( 2 ).GetName(), TEST_LOCATION );
+ DALI_TEST_EQUALS( PASTE, tableOfButtons.GetChildAt( 4 ).GetName(), TEST_LOCATION );
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+#include <fstream>
+#include <stdlib.h>
+#include <locale.h>
+#include <libintl.h>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
+
+using namespace Dali;
+using namespace Toolkit;
+
+namespace
+{
+
+const char* DEFAULT_LOCALE_DIR = "/tmp/locale/";
+const std::string DEFAULT_EN_LOCALE_DIR = "/tmp/locale/en/LC_MESSAGES/";
+
+}
+
+void dali_textselectionpopupmirroringrtl_startup(void)
+{
+ // Cheat! Copy the .mo file
+ std::ifstream src( std::string( DEFAULT_EN_LOCALE_DIR + "dali-toolkit.mo.ar" ).c_str(), std::ifstream::binary );
+ std::ofstream dst( std::string( DEFAULT_EN_LOCALE_DIR + "dali-toolkit.mo" ).c_str(), std::ofstream::binary );
+ dst << src.rdbuf();
+
+ test_return_value = TET_UNDEF;
+}
+
+void dali_textselectionpopupmirroringrtl_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+int UtcDaliToolkitTextSelectionPopupMirroringRTL(void)
+{
+ // Test the popup mirroring.
+ const std::string CUT( "optionCut" );
+ const std::string COPY( "optionCopy" );
+ const std::string PASTE( "optionPaste" );
+
+ ToolkitTestApplication application;
+
+ setlocale( LC_ALL, "en_GB.UTF-8" );
+ textdomain("dali-toolkit");
+ bindtextdomain("dali-toolkit", DEFAULT_LOCALE_DIR );
+
+ TextSelectionPopup textSelectionPopup = TextSelectionPopup::New( NULL );
+
+ // Enable some buttons.
+ TextSelectionPopup::Buttons buttons = static_cast<TextSelectionPopup::Buttons>( TextSelectionPopup::COPY | TextSelectionPopup::CUT | TextSelectionPopup::PASTE );
+ textSelectionPopup.EnableButtons( buttons );
+
+ // Show the popup.
+ textSelectionPopup.ShowPopup();
+
+ Actor cutActor = textSelectionPopup.FindChildByName( CUT );
+ if( !cutActor )
+ {
+ tet_result(TET_FAIL);
+ }
+
+ Actor tableOfButtons = cutActor.GetParent();
+ if( !tableOfButtons )
+ {
+ tet_result(TET_FAIL);
+ }
+
+ // The order should be PASTE, CUT, COPY
+ DALI_TEST_EQUALS( PASTE, tableOfButtons.GetChildAt( 0 ).GetName(), TEST_LOCATION );
+ DALI_TEST_EQUALS( CUT, tableOfButtons.GetChildAt( 2 ).GetName(), TEST_LOCATION );
+ DALI_TEST_EQUALS( COPY, tableOfButtons.GetChildAt( 4 ).GetName(), TEST_LOCATION );
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
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);
*/
void RaiseAbove( Layer target );
+ /**
+ * @copydoc Toolkit::ScrollView::ScrollTo(const Vector2&)
+ */
+ void ScrollTo( const Vector2& position );
+
/**
* @brief Downcast a handle to TextSelectionToolbar.
*
// 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>
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 );
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;
AddOption( button, ( numberOfOptionsAdded < numberOfOptionsRequired ) , showIcons, showCaptions );
}
}
+
+ if( mirror )
+ {
+ mToolbar.ScrollTo( Vector2( mPopupMaxSize.x, 0.f ) );
+ }
}
void TextSelectionPopup::CreateBackgroundBorder( Property::Map& propertyMap )
void TextSelectionToolbar::OnScrollStarted( const Vector2& position )
{
+ if( mFirstScrollEnd )
+ {
+ mScrollView.SetOvershootEnabled( true );
+ }
mTableOfButtons.SetSensitive( false );
}
void TextSelectionToolbar::OnScrollCompleted( const Vector2& position )
{
+ mFirstScrollEnd = true;
mTableOfButtons.SetSensitive( true );
}
RelayoutRequest();
}
+void TextSelectionToolbar::ScrollTo( const Vector2& position )
+{
+ mFirstScrollEnd = false;
+ mScrollView.SetOvershootEnabled( false );
+ 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.
mMaxSize (),
mScrollBarPadding( DEFAULT_SCROLL_BAR_PADDING ),
mIndexInTable( 0 ),
- mDividerIndexes()
+ mDividerIndexes(),
+ mFirstScrollEnd( false )
{
}
*/
const Vector2& GetScrollBarPadding() const;
+ /**
+ * @copydoc Toolkit::TextSelectionToolbar::ScrollTo()
+ */
+ void ScrollTo( const Vector2& position );
+
private: // From Control
/**
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.
+ bool mFirstScrollEnd; ///< Used for RTL mirroring. Avoids the overshoot to be shown the first time the popup is shown.
};
} // namespace Internal
+#: 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 "اختيار الكل"
+#: 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 "انتخاب همه"
+#: 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 "تمام منتخب کریں"