From: Paul Wisbey
Date: Fri, 19 Dec 2014 09:45:05 +0000 (+0000)
Subject: Initial removal of Text features
X-Git-Tag: new_text_0.1~65
X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=93fb6a1d3dc8872275bde30ef6a05407a67d694c
Initial removal of Text features
Change-Id: I900965567d917695882fead0b5a14e8dc2f64da2
---
diff --git a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt
index 227f4af..d63dc57 100644
--- a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt
+++ b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt
@@ -8,11 +8,6 @@ SET(CAPI_LIB "dali-toolkit-internal")
# List of test case sources (Only these get parsed for test cases)
SET(TC_SOURCES
utc-Dali-PushButton.cpp
- utc-Dali-TextView-HelperAndDebug.cpp
- utc-Dali-TextView-Processor-Types.cpp
- utc-Dali-TextView-Processor.cpp
- utc-Dali-TextView-Relayout-Utilities.cpp
- utc-Dali-TextView.cpp
)
# Append list of test harness files (Won't get parsed for test cases)
diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView-HelperAndDebug.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView-HelperAndDebug.cpp
deleted file mode 100644
index f5e39e6..0000000
--- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView-HelperAndDebug.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright (c) 2014 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
-
-#include
-#include
-#include
-
-// Internal headers are allowed here
-#include
-#include
-#include
-#include
-#include
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-using namespace Dali::Toolkit::Internal;
-
-void dali_text_view_helper_and_debug_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void dali_text_view_helper_and_debug_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-namespace
-{
-// Data structures used to create an 'experiment' in TET cases
-
-const Toolkit::Internal::TextView::LayoutParameters DEFAULT_LAYOUT_PARAMETERS;
-const Toolkit::Internal::TextView::VisualParameters DEFAULT_VISUAL_PARAMETERS;
-
-struct GetIndicesFromGlobalCharacterIndexTest
-{
- std::string description;
- std::string input;
- std::size_t position;
- std::size_t paragraphIndex;
- std::size_t wordIndex;
- std::size_t characterIndex;
-};
-
-/**
- * Gets the paragraph, word, and character indices for a given text and a given position and checks the results with the given indices.
- *
- * If the test fails it prints a short description and the line where this function was called.
- *
- * @param description Short description of the experiment.
- * @param input The input text.
- * @param position Global position of the character. i.e in a text with with 1000 characters, position could be any value from 0 to 1000.
- * @param resultParagraphIndex Index to the paragraph where the character is located.
- * @param resultWordIndex Index to the word within the paragraph where the character is located.
- * @param resultCharacterIndex Index to the character within the word where the character is located.
- * @param location Where this function has been called.
- *
- * @return \e true if the experiment is successful. Otherwise returns \e false.
- */
-bool TestGetIndicesFromGlobalCharacterIndex( const std::string& description,
- const std::string& input,
- const std::size_t position,
- const std::size_t resultParagraphIndex,
- const std::size_t resultWordIndex,
- const std::size_t resultCharacterIndex,
- const char* location )
-{
- tet_printf( "%s", description.c_str() );
-
- // Create natural size, layout and text-actor info for the input word.
- Toolkit::Internal::TextView::RelayoutData relayoutData;
- TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( input, inputStyledText, true );
-
- TextViewProcessor::CreateTextInfo( inputStyledText,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData );
-
- TextViewProcessor::TextInfoIndices indices;
- TextViewProcessor::GetIndicesFromGlobalCharacterIndex( position,
- inputLayout,
- indices );
-
- if( indices.mParagraphIndex != resultParagraphIndex )
- {
- tet_printf( "Fail. different paragraph index. %s", location );
- return false;
- }
- if( indices.mWordIndex != resultWordIndex )
- {
- tet_printf( "Fail. different word index. %s", location );
- return false;
- }
- if( indices.mCharacterIndex != resultCharacterIndex )
- {
- tet_printf( "Fail. different character index. %s", location );
- return false;
- }
-
- return true;
-}
-
-//////////////////////////////////////////////////////////////////
-} // namespace
-
-
-int UtcDaliTextViewGetIndicesFromGlobalCharacterIndex(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewGetIndicesFromGlobalCharacterIndex : ");
- struct GetIndicesFromGlobalCharacterIndexTest getIndicesFromGlobalCharacterIndexTests[] =
- {
- {
- std::string( "Test position 0" ),
- std::string( "text text text text text\n"
- "text text ××§×¡× ××§×¡× text\n"
- "text text text text text\n"
- "\n" ),
- 0,
- 0,
- 0,
- 0
- },
- {
- std::string( "Test position 76. (just after the last \\n)" ),
- std::string( "text text text text text\n"
- "text text ××§×¡× ××§×¡× text\n"
- "text text text text text\n"
- "\n" ),
- 76,
- 4,
- 0,
- 0
- },
- {
- std::string( "Test position 73. (the last \\n)" ),
- std::string( "text text text text text\n"
- "text text ××§×¡× ××§×¡× text\n"
- "text text text text text\n"
- "\n" ),
- 75,
- 3,
- 0,
- 0
- },
- {
- std::string( "Test position 35. (first hebrew character)" ),
- std::string( "text text text text text\n"
- "text text ××§×¡× ××§×¡× text\n"
- "text text text text text\n"
- "\n" ),
- 35,
- 1,
- 4,
- 0
- },
- {
- std::string( "Test position 3. (end of the first word)" ),
- std::string( "text text text text text\n"
- "text text ××§×¡× ××§×¡× text\n"
- "text text text text text\n"
- "\n" ),
- 3,
- 0,
- 0,
- 3
- },
- {
- std::string( "Test position 33. (end of the second word of the second paragraph)" ),
- std::string( "text text text text text\n"
- "text text ××§×¡× ××§×¡× text\n"
- "text text text text text\n"
- "\n" ),
- 33,
- 1,
- 2,
- 3
- },
- {
- std::string( "Test position 43. (last hebrew character)" ),
- std::string( "text text text text text\n"
- "text text ××§×¡× ××§×¡× text\n"
- "text text text text text\n"
- "\n" ),
- 43,
- 1,
- 6,
- 3
- },
- };
- const std::size_t numberOfTests( 7 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const GetIndicesFromGlobalCharacterIndexTest& test = getIndicesFromGlobalCharacterIndexTests[index];
-
- if( !TestGetIndicesFromGlobalCharacterIndex( test.description, test.input, test.position, test.paragraphIndex, test.wordIndex, test.characterIndex, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewDebugCouts(void)
-{
- /////////////////////////////////////////////////////
- // Text debug functions to not to penalize coverage
- /////////////////////////////////////////////////////
-
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewDebugCouts : ");
-
- Toolkit::Internal::TextView::RelayoutData relayoutData;
-
- MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( std::string( "Hello world\nhello world" ), inputStyledText, true );
-
- TextViewProcessor::CreateTextInfo( inputStyledText,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData );
-
- Actor dummy = Actor::New();
- Toolkit::Internal::SplitByNewLineChar::Relayout( dummy,
- Toolkit::Internal::TextView::RELAYOUT_ALL,
- DEFAULT_LAYOUT_PARAMETERS,
- DEFAULT_VISUAL_PARAMETERS,
- relayoutData );
-
- TextViewProcessor::dbgPrint( relayoutData.mTextLayoutInfo );
-
- TextStyle textStyle;
- TextViewProcessor::dbgPrint( textStyle );
-
- TextViewProcessor::TextInfoIndices indices;
- TextViewProcessor::dbgPrint( indices );
-
- TextViewProcessor::dbgPrint( inputStyledText );
-
- tet_result( TET_PASS );
- END_TEST;
-}
diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView-Processor-Types.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView-Processor-Types.cpp
deleted file mode 100644
index 44e25c0..0000000
--- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView-Processor-Types.cpp
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * Copyright (c) 2014 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
-#include
-#include
-#include
-
-
-// Internal headers are allowed here
-#include
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-using namespace Dali::Toolkit::Internal;
-
-void dali_text_view_processor_types_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void dali_text_view_processor_types_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-namespace
-{
-// Data structures used to create an 'experiment' in TET cases
-
-//////////////////////////////////////////////////////////////////
-} // namespace
-
-
-int UtcDaliTextViewDefaultConstructorDestructor_PT(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewDefaultConstructorDestructor : ");
-
- TextViewProcessor::TextInfoIndices indices;
- DALI_TEST_EQUALS( indices.mParagraphIndex, 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( indices.mWordIndex, 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( indices.mCharacterIndex, 0u, TEST_LOCATION );
-
- TextViewProcessor::CharacterLayoutInfo characterLayoutInfo;
- DALI_TEST_EQUALS( characterLayoutInfo.mSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mBearing, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mPosition, Vector3::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mOffset, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mUnderlineThickness, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mUnderlinePosition, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_CHECK( !characterLayoutInfo.mGlyphActor );
- DALI_TEST_EQUALS( characterLayoutInfo.mColorAlpha, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_CHECK( NULL == characterLayoutInfo.mGradientInfo );
- DALI_TEST_CHECK( characterLayoutInfo.mIsVisible );
- DALI_TEST_CHECK( !characterLayoutInfo.mSetText );
- DALI_TEST_CHECK( !characterLayoutInfo.mSetStyle );
-
- TextViewProcessor::WordLayoutInfo wordLayoutInfo;
- DALI_TEST_EQUALS( wordLayoutInfo.mSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( wordLayoutInfo.mAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( wordLayoutInfo.mType, TextViewProcessor::NoSeparator, TEST_LOCATION );
- DALI_TEST_EQUALS( wordLayoutInfo.mCharactersLayoutInfo.size(), 0u, TEST_LOCATION );
-
- TextViewProcessor::ParagraphLayoutInfo paragraphLayoutInfo;
- DALI_TEST_EQUALS( paragraphLayoutInfo.mSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( paragraphLayoutInfo.mAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( paragraphLayoutInfo.mLineHeightOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( paragraphLayoutInfo.mWordsLayoutInfo.size(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( paragraphLayoutInfo.mNumberOfCharacters, 0u, TEST_LOCATION );
-
- TextViewProcessor::TextLayoutInfo textLayoutInfo;
- DALI_TEST_EQUALS( textLayoutInfo.mWholeTextSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mMaxWordWidth, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mParagraphsLayoutInfo.size(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mNumberOfCharacters, 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mMaxItalicsOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mEllipsizeLayoutInfo.mSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mEllipsizeLayoutInfo.mAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mEllipsizeLayoutInfo.mType, TextViewProcessor::NoSeparator, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mEllipsizeLayoutInfo.mCharactersLayoutInfo.size(), 0u, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliTextViewCopyConstructorOperator(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewCopyConstructorOperator : ");
-
- TextViewProcessor::CharacterLayoutInfo characterLayoutInfo;
- characterLayoutInfo.mSize = Vector2( 1.f, 1.f );
- characterLayoutInfo.mBearing = 1.f;
- characterLayoutInfo.mPosition = Vector3( 1.f, 1.f, 1.f );
- characterLayoutInfo.mOffset = Vector2( 1.f, 1.f );
- characterLayoutInfo.mAscender = 1.f;
- characterLayoutInfo.mUnderlineThickness = 1.f;
- characterLayoutInfo.mUnderlinePosition = 1.f;
-
- characterLayoutInfo.mGlyphActor = TextActor::New( "Hello" );
-
- TextViewProcessor::GradientInfo* info = new TextViewProcessor::GradientInfo();
- info->mGradientColor = Vector4( 1.f, 1.f, 1.f, 1.f );
- info->mStartPoint = Vector2( 1.f, 1.f );
- info->mEndPoint = Vector2( 1.f, 1.f );
-
- characterLayoutInfo.mColorAlpha = 0.f;
- characterLayoutInfo.mGradientInfo = info;
-
- characterLayoutInfo.mIsVisible = false;
- characterLayoutInfo.mSetText = false;
- characterLayoutInfo.mSetStyle = false;
-
- TextViewProcessor::CharacterLayoutInfo characterLayoutInfo1;
- characterLayoutInfo1 = characterLayoutInfo;
-
- DALI_TEST_EQUALS( characterLayoutInfo1.mBearing, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mPosition, Vector3( 1.f, 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mOffset, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mAscender, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mUnderlineThickness, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mUnderlinePosition, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_CHECK( characterLayoutInfo1.mGlyphActor );
- DALI_TEST_EQUALS( characterLayoutInfo1.mColorAlpha, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mGradientInfo->mGradientColor, Vector4( 1.f, 1.f, 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mGradientInfo->mStartPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mGradientInfo->mEndPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_CHECK( !characterLayoutInfo1.mIsVisible );
- DALI_TEST_CHECK( !characterLayoutInfo1.mSetText );
- DALI_TEST_CHECK( !characterLayoutInfo1.mSetStyle );
-
- TextViewProcessor::CharacterLayoutInfo characterLayoutInfo2( characterLayoutInfo );
- DALI_TEST_EQUALS( characterLayoutInfo2.mBearing, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mPosition, Vector3( 1.f, 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mOffset, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mAscender, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mUnderlineThickness, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mUnderlinePosition, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_CHECK( characterLayoutInfo2.mGlyphActor );
- DALI_TEST_EQUALS( characterLayoutInfo2.mColorAlpha, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mGradientInfo->mGradientColor, Vector4( 1.f, 1.f, 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mGradientInfo->mStartPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mGradientInfo->mEndPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_CHECK( !characterLayoutInfo2.mIsVisible );
- DALI_TEST_CHECK( !characterLayoutInfo2.mSetText );
- DALI_TEST_CHECK( !characterLayoutInfo2.mSetStyle );
-
- // Increases coverage.
- characterLayoutInfo2.mGlyphActor.Reset();
- characterLayoutInfo1 = characterLayoutInfo2;
- DALI_TEST_CHECK( !characterLayoutInfo1.mGlyphActor );
-
- TextViewProcessor::WordLayoutInfo wordLayoutInfo;
- wordLayoutInfo.mSize = Vector2( 1.f, 1.f );
- wordLayoutInfo.mAscender = 1.f;
- wordLayoutInfo.mType = TextViewProcessor::ParagraphSeparator;
-
- TextViewProcessor::WordLayoutInfo wordLayoutInfo1;
- wordLayoutInfo1 = wordLayoutInfo;
-
- DALI_TEST_EQUALS( wordLayoutInfo1.mSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( wordLayoutInfo1.mAscender, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( wordLayoutInfo1.mType, TextViewProcessor::ParagraphSeparator, TEST_LOCATION );
-
- TextViewProcessor::WordLayoutInfo wordLayoutInfo2( wordLayoutInfo );
-
- DALI_TEST_EQUALS( wordLayoutInfo2.mSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( wordLayoutInfo2.mAscender, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( wordLayoutInfo2.mType, TextViewProcessor::ParagraphSeparator, TEST_LOCATION );
-
- TextViewProcessor::ParagraphLayoutInfo paragraphLayoutInfo;
- paragraphLayoutInfo.mSize = Vector2( 1.f, 1.f );
- paragraphLayoutInfo.mAscender = 1.f;
- paragraphLayoutInfo.mLineHeightOffset = 1.f;
- paragraphLayoutInfo.mNumberOfCharacters = 1u;
-
- TextViewProcessor::ParagraphLayoutInfo paragraphLayoutInfo1;
- paragraphLayoutInfo1 = paragraphLayoutInfo;
-
- DALI_TEST_EQUALS( paragraphLayoutInfo1.mSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( paragraphLayoutInfo1.mAscender, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( paragraphLayoutInfo1.mLineHeightOffset, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( paragraphLayoutInfo1.mNumberOfCharacters, 1u, TEST_LOCATION );
-
- TextViewProcessor::ParagraphLayoutInfo paragraphLayoutInfo2( paragraphLayoutInfo );
-
- DALI_TEST_EQUALS( paragraphLayoutInfo2.mSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( paragraphLayoutInfo2.mAscender, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( paragraphLayoutInfo2.mLineHeightOffset, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( paragraphLayoutInfo2.mNumberOfCharacters, 1u, TEST_LOCATION );
-
- TextViewProcessor::TextLayoutInfo textLayoutInfo;
- textLayoutInfo.mWholeTextSize = Vector2( 1.f, 1.f );
- textLayoutInfo.mMaxWordWidth = 1.f;
- textLayoutInfo.mNumberOfCharacters = 1u;
- textLayoutInfo.mMaxItalicsOffset = 1.f;
-
- TextViewProcessor::TextLayoutInfo textLayoutInfo1;
- textLayoutInfo1 = textLayoutInfo;
-
- DALI_TEST_EQUALS( textLayoutInfo1.mWholeTextSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo1.mMaxWordWidth, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo1.mNumberOfCharacters, 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo1.mMaxItalicsOffset, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-
- TextViewProcessor::TextLayoutInfo textLayoutInfo2( textLayoutInfo );
-
- DALI_TEST_EQUALS( textLayoutInfo2.mWholeTextSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo2.mMaxWordWidth, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo2.mNumberOfCharacters, 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo2.mMaxItalicsOffset, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliTextViewEqualityOperator(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewEqualityOperator : ");
-
- TextViewProcessor::TextInfoIndices indices;
- TextViewProcessor::TextInfoIndices indices1( 1u, 1u, 1u );
-
- DALI_TEST_CHECK( !( indices == indices1 ) );
-
- indices = indices1;
-
- DALI_TEST_CHECK( indices == indices1 );
- END_TEST;
-}
diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView-Processor.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView-Processor.cpp
deleted file mode 100644
index 8fef857..0000000
--- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView-Processor.cpp
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- * Copyright (c) 2014 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
-#include
-#include
-#include
-
-// Internal headers are allowed here
-#include
-#include
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-using namespace Dali::Toolkit::Internal;
-
-void dali_text_view_processor_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void dali_text_view_processor_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-namespace
-{
-// Data structures used to create an 'experiment' in TET cases
-
-//////////////////////////////////////////////////////////////////
-
-struct BeginsRightToLeftCharacterTest
-{
- std::string description;
- std::string input;
- bool result;
-};
-
-bool TestBeginsRightToLeftCharacter( const std::string& description, const std::string& input, const bool result, const char* location )
-{
- // Creates a text with the string.
- Text text( input );
-
- const bool ret = ( result == TextProcessor::BeginsRightToLeftCharacter( text ) );
-
- if( !ret )
- {
- tet_printf( "Fail. %s", location );
- tet_printf( "Input : %s", input.c_str() );
- }
-
- return ret;
-}
-
-//////////////////////////////////////////////////////////////////
-
-struct ContainsRightToLeftCharacterTest
-{
- std::string description;
- std::string input;
- bool result;
-};
-
-bool TestContainsRightToLeftCharacter( const std::string& description, const std::string& input, const bool result, const char* location )
-{
- // Creates a text with the string.
- Text text( input );
-
- const bool ret = ( result == TextProcessor::ContainsRightToLeftCharacter( text ) );
-
- if( !ret )
- {
- tet_printf( "Fail. %s", location );
- tet_printf( "Input : %s", input.c_str() );
- }
-
- return ret;
-}
-
-//////////////////////////////////////////////////////////////////
-
-struct FindNearestWordTest
-{
- std::string description;
- std::string input;
- std::size_t offset;
- std::size_t start;
- std::size_t end;
-};
-
-bool TestFindNearestWord( const std::string& description, const std::string& input, const std::size_t offset, const std::size_t startResult, const std::size_t endResult, const char* location )
-{
- // Creates a styled text with the markup or plain string.
- MarkupProcessor::StyledTextArray styledText;
- MarkupProcessor::GetStyledTextArray( input, styledText, true );
-
- std::size_t start;
- std::size_t end;
- TextProcessor::FindNearestWord( styledText, offset, start, end );
-
- const bool ret = ( start == startResult ) && ( end == endResult );
-
- if( !ret )
- {
- tet_printf( "Fail. %s", location );
- tet_printf( "Input : %s, offset %d, start %d, end %d", input.c_str(), offset, start, end );
- }
-
- return ret;
-}
-
-//////////////////////////////////////////////////////////////////
-
-struct SplitInParagraphsTest
-{
- std::string inputText;
-
- std::size_t resultNumberOfParagraphs;
-};
-
-bool TestSplitInParagraphs( const SplitInParagraphsTest& test, const char* location )
-{
- // Creates a styled text with the markup or plain string.
- MarkupProcessor::StyledTextArray styledText;
- MarkupProcessor::GetStyledTextArray( test.inputText, styledText, true );
-
- std::vector paragraphs;
- std::vector< Vector > styles;
-
- TextProcessor::SplitInParagraphs( styledText,
- paragraphs,
- styles );
-
- if( paragraphs.size() != test.resultNumberOfParagraphs )
- {
- tet_printf( "Fail. %s", location );
- tet_printf( "Different number of paragraphs, result %d, expected result %d", paragraphs.size(), test.resultNumberOfParagraphs );
-
- return false;
- }
-
- return true;
-}
-
-//////////////////////////////////////////////////////////////////
-
-struct SplitInWordsTest
-{
- std::string inputText;
-
- std::size_t resultNumberOfSeparators;
-};
-
-bool TestSplitInWords( const SplitInWordsTest& test, const char* location )
-{
- // Creates a text with the string.
- Text text( test.inputText );
-
- Vector positions;
-
- TextProcessor::SplitInWords( text,
- positions );
-
- if( positions.Count() != test.resultNumberOfSeparators )
- {
- tet_printf( "Fail. %s", location );
- tet_printf( "Different number of separators, result %d, expected result %d", positions.Count(), test.resultNumberOfSeparators );
-
- return false;
- }
-
- return true;
-}
-
-//////////////////////////////////////////////////////////////////
-
-} // namespace
-
-
-int UtcDaliTextViewSplitInParagraphs(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewSplitInParagraphs : ");
-
- struct SplitInParagraphsTest splitInParagraphsTest[] =
- {
- {
- std::string( "Hello world\nhello world." ),
- 2
- },
- {
- std::string( "Hello world\nhello world.\n\n" ),
- 4
- }
- };
- const std::size_t numberOfTests( 2 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const SplitInParagraphsTest& test = splitInParagraphsTest[index];
-
- if( !TestSplitInParagraphs( test, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewSplitInWords(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewSplitInWords : ");
-
- struct SplitInWordsTest splitInWordsTest[] =
- {
- {
- std::string( "Hello world, hello word!" ),
- 3u
- },
- {
- std::string( "Hello world\n" ),
- 2u
- }
- };
- const std::size_t numberOfTests( 2u );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const SplitInWordsTest& test = splitInWordsTest[index];
-
- if( !TestSplitInWords( test, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewBeginsRightToLeftCharacter(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewBeginsRightToLeftCharacter : ");
-
- struct BeginsRightToLeftCharacterTest beginsRightToLeftCharacterTest[] =
- {
- {
- std::string( "Test if it begins with a right to left character. Should return false." ),
- std::string( "Hello world Ù
رØبا اÙعاÙÙ
." ),
- false
- },
- {
- std::string( "Test if it begins with a right to left character. Should return true." ),
- std::string( "Ù
رØبا اÙعاÙÙ
Hola mundo." ),
- true
- }
- };
- const std::size_t numberOfTests( 2 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const BeginsRightToLeftCharacterTest& test = beginsRightToLeftCharacterTest[index];
-
- if( !TestBeginsRightToLeftCharacter( test.description, test.input, test.result, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewContainsRightToLeftCharacter(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewContainsRightToLeftCharacter : ");
-
- struct ContainsRightToLeftCharacterTest containsRightToLeftCharacterTest[] =
- {
- {
- std::string( "Test if it contains a right to left character. Should return true." ),
- std::string( "Hello world Ù
رØبا اÙعاÙÙ
." ),
- true
- },
- {
- std::string( "Test if it contains a right to left character. Should return true." ),
- std::string( "Ù
رØبا اÙعاÙÙ
Hola mundo." ),
- true
- },
- {
- std::string( "Test if it contains a right to left character. Should return false." ),
- std::string( "Hello world." ),
- false
- },
- {
- std::string( "Test if it contains a right to left character. Should return true." ),
- std::string( "Ù
رØبا اÙعاÙÙ
." ),
- true
- }
- };
- const std::size_t numberOfTests( 4 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const ContainsRightToLeftCharacterTest& test = containsRightToLeftCharacterTest[index];
-
- if( !TestContainsRightToLeftCharacter( test.description, test.input, test.result, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewFindNearestWord(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewFindNearestWord : ");
-
- struct FindNearestWordTest findNearestWordTest[] =
- {
- {
- std::string( "" ),
- std::string( "Hello world, hola mundo" ),
- 0u,
- 0u,
- 5u
- },
- {
- std::string( "" ),
- std::string( "Hello world, hola mundo" ),
- 7u,
- 6u,
- 12u
- },
- {
- std::string( "" ),
- std::string( "Hello world, hola mundo" ),
- 11u,
- 6u,
- 12u
- },
- {
- std::string( "" ),
- std::string( "Hello world, hola mundo" ),
- 23u,
- 18u,
- 23u
- },
- {
- std::string( "" ),
- std::string( "Hello world, hola mundo" ),
- 5u,
- 0u,
- 5u
- },
- {
- std::string( "" ),
- std::string( "Hello world, hola mundo Ù
رØبا اÙعاÙÙ
" ),
- 24u,
- 25u,
- 30u
- }
- };
-
- const std::size_t numberOfTests( 6 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const FindNearestWordTest& test = findNearestWordTest[index];
-
- if( !TestFindNearestWord( test.description, test.input, test.offset, test.start, test.end, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView-Relayout-Utilities.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView-Relayout-Utilities.cpp
deleted file mode 100644
index c556e08..0000000
--- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView-Relayout-Utilities.cpp
+++ /dev/null
@@ -1,833 +0,0 @@
-/*
- * Copyright (c) 2014 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
-
-#include
-#include
-#include
-
-// Internal headers are allowed here
-#include
-#include
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-using namespace Dali::Toolkit::Internal;
-
-void dali_text_view_relayout_utils_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void dali_text_view_relayout_utils_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-namespace
-{
-
-const Toolkit::Internal::TextView::LayoutParameters DEFAULT_LAYOUT_PARAMETERS;
-
-// Data structures used to create an 'experiment' in TET cases
-
-
-bool TestEqual( float x, float y )
-{
- return ( fabsf( x - y ) < Math::MACHINE_EPSILON_1000 );
-}
-
-//////////////////////////////////////////////////////////////////
-
-struct CalculateLineLayoutTest
-{
- std::string description;
- std::string inputParagraph;
- float parentWidth;
- std::size_t wordIndex;
- std::size_t characterIndex;
- std::size_t characterParagraphIndex;
- TextViewRelayout::HorizontalWrapType splitPolicy;
- float shrinkFactor;
-
- float resultLineLength;
- float resultMaxCharHeight;
- float resultMaxAscender;
-};
-
-bool TestCalculateLineLayout( const CalculateLineLayoutTest& test, const char* location )
-{
- tet_printf( "%s", test.description.c_str() );
-
- // Create styled text.
- MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( test.inputParagraph, inputStyledText, true );
-
- // Create styled text layout info.
- Toolkit::Internal::TextView::RelayoutData relayoutData;
- TextViewProcessor::CreateTextInfo( inputStyledText,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData );
-
- // Prepare input parameters and the result structure and call the function to be tested.
-
- // Creaqte indices.
- TextViewProcessor::TextInfoIndices indices( 0u, test.wordIndex, test.characterIndex );
- indices.mCharacterParagraphIndex = test.characterParagraphIndex;
-
- // Get the input paragraph.
- TextViewProcessor::ParagraphLayoutInfo inputParagraphLayout;
-
- if( !relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.empty() )
- {
- inputParagraphLayout = *relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin();
- }
-
- // Result struct.
- TextViewRelayout::LineLayoutInfo resultLayoutInfo;
-
- CalculateLineLayout( test.parentWidth,
- indices,
- inputParagraphLayout,
- test.splitPolicy,
- test.shrinkFactor,
- resultLayoutInfo );
-
- // Check results.
- if( !TestEqual( test.resultLineLength, resultLayoutInfo.mLineLength ) )
- {
- tet_printf( "Fail. different line length %f == %f. %s", test.resultLineLength, resultLayoutInfo.mLineLength, location );
- return false;
- }
-
- if( !TestEqual( test.resultMaxCharHeight, resultLayoutInfo.mMaxCharHeight ) )
- {
- tet_printf( "Fail. different max character height %f == %f. %s", test.resultMaxCharHeight, resultLayoutInfo.mMaxCharHeight, location );
- return false;
- }
-
- if( !TestEqual( test.resultMaxAscender, resultLayoutInfo.mMaxAscender ) )
- {
- tet_printf( "Fail. different max ascender %f == %f. %s", test.resultMaxAscender, resultLayoutInfo.mMaxAscender, location );
- return false;
- }
-
- return true;
-}
-
-//////////////////////////////////////////////////////////////////
-
-struct AlignmentOffsetTest
-{
- Toolkit::Alignment::Type alignment;
- float parentSize;
- float wholeTextSize;
-
- float resultOffset;
-};
-
-bool TestAlignmentOffset( const AlignmentOffsetTest& test, const char* location )
-{
- float offset = 0.f;
-
- switch( test.alignment )
- {
- case Toolkit::Alignment::HorizontalLeft:
- case Toolkit::Alignment::HorizontalCenter:
- case Toolkit::Alignment::HorizontalRight:
- {
- offset = TextViewRelayout::CalculateXoffset( test.alignment, test.parentSize, test.wholeTextSize );
- break;
- }
- case Toolkit::Alignment::VerticalTop:
- case Toolkit::Alignment::VerticalCenter:
- case Toolkit::Alignment::VerticalBottom:
- {
- offset = TextViewRelayout::CalculateYoffset( test.alignment, test.parentSize, test.wholeTextSize );
- break;
- }
- }
-
- // Check results.
- if( !TestEqual( test.resultOffset, offset ) )
- {
- tet_printf( "Fail. different offset %f == %f. %s", test.resultOffset, offset, location );
- return false;
- }
-
- return true;
-}
-
-//////////////////////////////////////////////////////////////////
-
-struct JustificationOffsetTest
-{
- Toolkit::TextView::LineJustification justification;
- float wholeTextWidth;
- float lineLength;
-
- float resultOffset;
-};
-
-bool TestJustificationOffset( const JustificationOffsetTest& test, const char* location )
-{
- float offset = TextViewRelayout::CalculateJustificationOffset( test.justification, test.wholeTextWidth, test.lineLength );
-
- // Check results.
- if( !TestEqual( test.resultOffset, offset ) )
- {
- tet_printf( "Fail. different offset %f == %f. %s", test.resultOffset, offset, location );
- return false;
- }
-
- return true;
-}
-
-//////////////////////////////////////////////////////////////////
-
-struct CalculateVisibilityTest
-{
- Vector3 position;
- Size size;
- Size parentSize;
- TextViewRelayout::VisibilityTestType type;
-
- bool resultVisible;
-};
-
-bool TestCalculateVisibility( const CalculateVisibilityTest& test, const char* location )
-{
- if( test.resultVisible != TextViewRelayout::IsVisible( test.position, test.size, test.parentSize, test.type ) )
- {
- tet_printf( "Fail. different visibility. Type %d, %s", test.type, location );
- return false;
- }
-
- return true;
-}
-
-//////////////////////////////////////////////////////////////////
-
-} // namespace
-
-
-int UtcDaliTextViewDefaultConstructorDestructor_RU(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewDefaultConstructorDestructor : ");
-
- // Test RelayoutParameters defaults.
- TextViewRelayout::RelayoutParameters relayoutParameters;
-
- DALI_TEST_EQUALS( relayoutParameters.mPositionOffset, Vector3::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( relayoutParameters.mParagraphSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( relayoutParameters.mWordSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( relayoutParameters.mCharacterSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( relayoutParameters.mIndices.mParagraphIndex, 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( relayoutParameters.mIndices.mWordIndex, 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( relayoutParameters.mIndices.mCharacterIndex, 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( relayoutParameters.mCharacterGlobalIndex, 0u, TEST_LOCATION );
- DALI_TEST_CHECK( !relayoutParameters.mIsFirstCharacter );
- DALI_TEST_CHECK( !relayoutParameters.mIsFirstCharacterOfWord );
- DALI_TEST_CHECK( !relayoutParameters.mIsNewLine );
- DALI_TEST_CHECK( !relayoutParameters.mIsNewParagraphCharacter );
- DALI_TEST_CHECK( !relayoutParameters.mIsWhiteSpace );
- DALI_TEST_CHECK( !relayoutParameters.mIsVisible );
-
- // Test FadeParameter defaults
- TextViewRelayout::FadeParameters fadeParameters;
-
- DALI_TEST_EQUALS( fadeParameters.mRightFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mRightFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mRightFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mRightFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mRightAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mLeftFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mLeftFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mLeftFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mLeftFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mLeftAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mTopFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mTopFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mTopFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mTopFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mTopAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mBottomFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mBottomFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mBottomFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mBottomFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mBottomAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_CHECK( !fadeParameters.mIsPartiallyVisible );
-
- // Test EllipsizeParameters defaults
- TextViewRelayout::EllipsizeParameters ellipsizeParameters;
-
- DALI_TEST_EQUALS( ellipsizeParameters.mPosition, Vector3::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( ellipsizeParameters.mLineDescender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( ellipsizeParameters.mLineWidth, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( ellipsizeParameters.mEllipsizeBoundary, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( ellipsizeParameters.mFirstIndex, 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( ellipsizeParameters.mLastIndex, 0u, TEST_LOCATION );
- DALI_TEST_CHECK( !ellipsizeParameters.mEllipsizeLine );
- DALI_TEST_CHECK( !ellipsizeParameters.mIsLineWidthFullyVisible );
- DALI_TEST_CHECK( !ellipsizeParameters.mIsLineHeightFullyVisible );
- DALI_TEST_CHECK( !ellipsizeParameters.mIsNextLineFullyVisibleHeight );
- DALI_TEST_CHECK( !ellipsizeParameters.mCreateEllipsizedTextActors );
- DALI_TEST_CHECK( !ellipsizeParameters.mLineFits );
- DALI_TEST_CHECK( !ellipsizeParameters.mWordFits );
-
- // Test UnderlineInfo defaults
- TextViewRelayout::UnderlineInfo underlineInfo;
-
- DALI_TEST_EQUALS( underlineInfo.mMaxHeight, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( underlineInfo.mMaxThickness, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( underlineInfo.mPosition, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-
- // Test TextUnderlineStatus defaults
- TextViewRelayout::TextUnderlineStatus textUnderlineStatus;
-
- DALI_TEST_CHECK( textUnderlineStatus.mUnderlineInfo.empty() );
- DALI_TEST_EQUALS( textUnderlineStatus.mCharacterGlobalIndex, 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( textUnderlineStatus.mLineGlobalIndex, 0u, TEST_LOCATION );
- DALI_TEST_CHECK( !textUnderlineStatus.mCurrentUnderlineStatus );
-
- // Test LineLayoutInfo defaults
- TextViewRelayout::LineLayoutInfo lineLayoutInfo;
-
- DALI_TEST_EQUALS( lineLayoutInfo.mLineLength, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo.mMaxCharHeight, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo.mMaxAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliTextViewCalculateLineLayout(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewCalculateLineLayout : ");
-
- struct CalculateLineLayoutTest calculateLineLayoutTest[] =
- {
- //WrapByCharacter
- {
- "The paragraph is wraped by character. All characters have the same size.",
- "Hello world", // input paragraph
- 100.f, // parent width
- 0, // indices
- 0,
- 0,
- TextViewRelayout::WrapByCharacter, // split policy
- 1.f,
- // results
- 91.041672f, // line length. (only fits 8 characters 8x11.38)
- 11.380209f, // max character height
- 10.242188f // max ascender
- },
- {
- "The paragraph is wraped by character. There are characters with different sizes.",
- "Hello world", // input paragraph
- 100.f, // parent width
- 0, // indices
- 0,
- 0,
- TextViewRelayout::WrapByCharacter, // split policy
- 1.f,
- // results
- 94.835075f, // line length. (only fits 8 characters 6x11.38 + 2x13.27)
- 13.276911f, // max character height
- 11.949220f // max ascender
- },
- {
- "The paragraph is wraped by character. There are characters with different sizes. It calculates the layout for the second line.",
- "Hello world hello world", // input paragraph
- 100.f, // parent width
- 2, // indices. The third character of the third word starts in a new line.
- 2,
- 8,
- TextViewRelayout::WrapByCharacter, // split policy
- 1.f,
- // results
- 91.041672f, // line length. (only fits 8 characters 8x11.38)
- 11.380209f, // max character height
- 10.242188f // max ascender
- },
- {
- "The paragraph is wraped by character. There are characters with different sizes. It calculates the layout for the third line.",
- "Hello world hello world", // input paragraph
- 100.f, // parent width
- 4, // indices. The fifth character of the fifth word starts in a new line.
- 4,
- 16,
- TextViewRelayout::WrapByCharacter, // split policy
- 1.f,
- // results
- 92.938377f, // line length. (only fits 8 characters 8x11.38)
- 13.276911f, // max character height
- 11.949220f // max ascender
- },
-
- //WrapByWord
- {
- "The paragraph is wraped by word. All characters have the same size.",
- "Hello world", // input paragraph
- 100.f, // parent width
- 0, // indices. It shouldn't use the index character so 9999999 shouldn't make it crash.
- 9999999,
- 9999999,
- TextViewRelayout::WrapByWord, // split policy
- 1.f,
- // results
- 56.901047f, // line length. (only fits 5 characters 5x11.38, white space is not counted)
- 11.380209f, // max character height
- 10.242188f // max ascender
- },
- {
- "The paragraph is wraped by word. There are characters with different sizes.",
- "Hello world", // input paragraph
- 100.f, // parent width
- 0, // indices.
- 0,
- 0,
- TextViewRelayout::WrapByWord, // split policy
- 1.f,
- // results
- 58.797747f, // line length. (only fits 5 characters 4x11.38 + 13.276911, white space is not counted)
- 13.276911f, // max character height
- 11.949220f // max ascender
- },
- {
- "The paragraph is wraped by word. There are characters with different sizes. It calculates the layout for the second line.",
- "Hello world hello world", // input paragraph
- 100.f, // parent width
- 2, // indices. The third word starts in a new line.
- 0,
- 6,
- TextViewRelayout::WrapByWord, // split policy
- 1.f,
- // results
- 60.694449f, // line length. (only fits 5 characters 2x13.276911 + 3x11.38)
- 13.276911f, // max character height
- 11.949220f // max ascender
- },
- {
- "The paragraph is wraped by word. The word doen't fit.",
- "Hello world", // input paragraph
- 40.f, // parent width
- 0, // indices. The third word starts in a new line.
- 0,
- 0,
- TextViewRelayout::WrapByWord, // split policy
- 1.f,
- // results
- 0.f, // line length. (The word doesn't fit)
- 11.380209f, // max character height
- 10.242188f // max ascender
- },
-
- //WrapByWordAndSplit
- {
- "The paragraph is wraped by word and by character. All characters have the same size. There is not a long word.",
- "Hello world hello world", // input paragraph
- 100.f, // parent width
- 0, // indices.
- 0,
- 0,
- TextViewRelayout::WrapByWordAndSplit, // split policy
- 1.f,
- // results
- 56.901047f, // line length. (only fits 5 characters 5x11.38, white space is not counted)
- 11.380209f, // max character height
- 10.242188f // max ascender
- },
- {
- "The paragraph is wraped by word and by character. All characters have the same size. There is a long word.",
- "Helloooooooo world", // input paragraph
- 100.f, // parent width
- 0, // indices.
- 0,
- 0,
- TextViewRelayout::WrapByWordAndSplit, // split policy
- 1.f,
- // results
- 91.041672f, // line length. (only fits 8 characters 8x11.38)
- 11.380209f, // max character height
- 10.242188f // max ascender
- },
- {
- "The paragraph is wraped by word and by character. There are characters with different sizes. There is a long word. It calculates the layout for the second line.",
- "Helloooooooo world", // input paragraph
- 100.f, // parent width
- 0, // indices.
- 8,
- 8,
- TextViewRelayout::WrapByWordAndSplit, // split policy
- 1.f,
- // results
- 45.520836f, // line length. (only fits 8 characters 8x11.38)
- 11.380209f, // max character height
- 10.242188f // max ascender
- },
- {
- "The paragraph is wraped by word and by character. There are characters with different sizes. There is a shrink factor.",
- "Helloooooooo world", // input paragraph
- 100.f, // parent width
- 0, // indices.
- 8,
- 8,
- TextViewRelayout::WrapByWordAndSplit, // split policy
- 0.7f,
- // results
- 95.593755f, // line length. (only fits 12 characters 8x11.38)
- 7.9661463f, // max character height
- 7.169531f // max ascender
- },
-
- //WrapByParagraphCharacterAndSplit
- {
- "The paragraph is wraped by end of paragraph and by character. All characters have the same size.",
- "Hello world", // input paragraph
- 100.f, // parent width
- 0, // indices
- 0,
- 0,
- TextViewRelayout::WrapByParagraphCharacterAndSplit, // split policy
- 1.f,
- // results
- 91.041672f, // line length. (only fits 8 characters 8x11.38)
- 11.380209f, // max character height
- 10.242188f // max ascender
- },
- {
- "The paragraph fits in the width.",
- "Hello", // input paragraph
- 100.f, // parent width
- 0, // indices
- 0,
- 0,
- TextViewRelayout::WrapByParagraphCharacterAndSplit, // split policy
- 1.f,
- // results
- 56.901047f, // line length. (only fits 5 characters 5x11.38)
- 11.380209f, // max character height
- 10.242188f // max ascender
- },
- {
- "The paragraph is wraped by end of paragraph and by character. All characters have the same size. It calculates the layout for the second line.",
- "Hello world, hello world", // input paragraph
- 100.f, // parent width
- 2, // indices
- 2,
- 8,
- TextViewRelayout::WrapByParagraphCharacterAndSplit, // split policy
- 1.f,
- // results
- 91.041672f, // line length. (only fits 8 characters 8x11.38)
- 11.380209f, // max character height
- 10.242188f // max ascender
- },
- };
- const std::size_t numberOfTests( 15 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const CalculateLineLayoutTest& test = calculateLineLayoutTest[index];
-
- if( !TestCalculateLineLayout( test, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewCalculateAlignmentOffsets(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewCalculateAlignmentOffsets : ");
-
- struct AlignmentOffsetTest alignmentOffsetTest[] =
- {
- {
- Toolkit::Alignment::HorizontalLeft,
- 100.f,
- 75.f,
- 0.f
- },
- {
- Toolkit::Alignment::HorizontalCenter,
- 100.f,
- 75.f,
- 12.5f
- },
- {
- Toolkit::Alignment::HorizontalRight,
- 100.f,
- 75.f,
- 25.f
- },
- {
- Toolkit::Alignment::VerticalTop,
- 100.f,
- 75.f,
- 0.f
- },
- {
- Toolkit::Alignment::VerticalCenter,
- 100.f,
- 75.f,
- 12.5f
- },
- {
- Toolkit::Alignment::VerticalBottom,
- 100.f,
- 75.f,
- 25.f
- }
- };
- const std::size_t numberOfTests( 6 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const AlignmentOffsetTest& test = alignmentOffsetTest[index];
-
- if( !TestAlignmentOffset( test, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewCalculateJustificationOffsets(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewCalculateJustificationOffsets : ");
-
- struct JustificationOffsetTest justificationOffsetTest[] =
- {
- {
- Toolkit::TextView::Left,
- 100.f,
- 75.f,
- 0.f
- },
- {
- Toolkit::TextView::Justified,
- 100.f,
- 75.f,
- 0.f
- },
- {
- Toolkit::TextView::Center,
- 100.f,
- 150.f,
- -25.f
- },
- {
- Toolkit::TextView::Right,
- 100.f,
- 75.f,
- 25.f
- },
- };
- const std::size_t numberOfTests( 4 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const JustificationOffsetTest& test = justificationOffsetTest[index];
-
- if( !TestJustificationOffset( test, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-
-int UtcDaliTextViewCalculateVisibility(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewCalculateVisibility : ");
-
- struct CalculateVisibilityTest calculateVisibilityTest[] =
- {
- {
- Vector3( 0.f, 10.f, 0.f ),
- Size( 10.f, 10.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::FULLY_VISIBLE,
- true
- },
- {
- Vector3( 10.f, 10.f, 0.f ),
- Size( 10.f, 10.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::FULLY_VISIBLE,
- true
- },
- {
- Vector3( 0.f, 10.f, 0.f ),
- Size( 150.f, 10.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::FULLY_VISIBLE,
- false
- },
- {
- Vector3( 0.f, 10.f, 0.f ),
- Size( 10.f, 10.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::FULLY_VISIBLE_WIDTH,
- true
- },
- {
- Vector3( 95.f, 10.f, 0.f ),
- Size( 10.f, 10.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::FULLY_VISIBLE_WIDTH,
- false
- },
- {
- Vector3( 0.f, 10.f, 0.f ),
- Size( 10.f, 10.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::FULLY_VISIBLE_HEIGHT,
- true
- },
- {
- Vector3( 0.f, 0.f, 0.f ),
- Size( 10.f, 10.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::FULLY_VISIBLE_HEIGHT,
- false
- },
- {
- Vector3( -10.f, 10.f, 0.f ),
- Size( 150.f, 150.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::PARTIALLY_VISIBLE,
- true
- },
- {
- Vector3( -100.f, -100.f, 0.f ),
- Size( 10.f, 10.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::PARTIALLY_VISIBLE,
- false
- },
- {
- Vector3( -10.f, 10.f, 0.f ),
- Size( 50.f, 10.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::PARTIALLY_VISIBLE_WIDTH,
- true
- },
- {
- Vector3( 110.f, 10.f, 0.f ),
- Size( 10.f, 10.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::PARTIALLY_VISIBLE_WIDTH,
- false
- },
- {
- Vector3( 0.f, 20.f, 0.f ),
- Size( 10.f, 50.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::PARTIALLY_VISIBLE_HEIGHT,
- true
- },
- {
- Vector3( 0.f, -10.f, 0.f ),
- Size( 10.f, 10.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::PARTIALLY_VISIBLE_HEIGHT,
- false
- },
- };
- const std::size_t numberOfTests( 13 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const CalculateVisibilityTest& test = calculateVisibilityTest[index];
-
- if( !TestCalculateVisibility( test, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewMiscelaneousAsserts(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewMiscelaneousAsserts : ");
-
- float offset = 0.f;
-
- bool assert1 = false;
- bool assert2 = false;
- try
- {
- offset = Toolkit::Internal::TextViewRelayout::CalculateXoffset( Toolkit::Alignment::VerticalTop, 100.f, 50.f );
- }
- catch( Dali::DaliException& e )
- {
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewRelayout::CalculateXoffset: Wrong horizontal text alignment. Did you set a vertical one?\"", TEST_LOCATION );
- assert1 = true;
- }
- catch( ... )
- {
- tet_result( TET_FAIL );
- }
- DALI_TEST_EQUALS( offset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-
- try
- {
- offset = Toolkit::Internal::TextViewRelayout::CalculateYoffset( Toolkit::Alignment::HorizontalRight, 100.f, 50.f );
- }
- catch( Dali::DaliException& e )
- {
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewRelayout::CalculateXoffset: Wrong vertical text alignment. Did you set an horizontal one?\"", TEST_LOCATION );
- assert2 = true;
- }
- catch( ... )
- {
- tet_result( TET_FAIL );
- }
- DALI_TEST_EQUALS( offset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-
- DALI_TEST_CHECK( assert1 && assert2 );
-
- END_TEST;
-}
diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView.cpp
deleted file mode 100644
index dc2a363..0000000
--- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextView.cpp
+++ /dev/null
@@ -1,2168 +0,0 @@
-/*
- * Copyright (c) 2014 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
-#include
-#include
-#include
-
-
-// Internal headers are allowed here
-#include
-#include
-#include
-#include
-#include
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-using namespace Dali::Toolkit::Internal;
-
-void dali_text_view_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void dali_text_view_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-namespace
-{
-
-const Toolkit::Internal::TextView::LayoutParameters DEFAULT_LAYOUT_PARAMETERS;
-const Toolkit::Internal::TextView::VisualParameters DEFAULT_VISUAL_PARAMETERS;
-
-// Data structures used to create an 'experiment' in TET cases
-
-struct SplitWordTest
-{
- std::string description;
- std::string input;
- std::size_t position;
- std::string firstResult;
- std::string lastResult;
-};
-
-struct SplitParagraphTest
-{
- std::string description;
- std::string input;
- std::size_t wordIndex;
- std::size_t characterIndex;
- std::size_t characterParagraphIndex;
- float lineHeightOffset;
- std::string firstResult;
- std::string lastResult;
-};
-
-struct MergeWordsTest
-{
- std::string description;
- std::string inputFirst;
- std::string inputLast;
- std::string result;
-};
-
-struct MergeParagraphsTest
-{
- std::string description;
- std::string inputFirst;
- std::string inputLast;
- float lineHeightOffset;
- std::string result;
-};
-
-struct RemoveCharactersFromWordTest
-{
- std::string description;
- std::string input;
- std::size_t position;
- std::size_t numberOfCharacters;
- std::string result;
-};
-
-struct RemoveWordsFromParagraphTest
-{
- std::string description;
- std::string input;
- std::size_t wordIndex;
- std::size_t numberOfWords;
- float lineHeightOffset;
- std::string result;
-};
-
-enum UpdateTextInfoOperation
-{
- Insert,
- Remove,
- Replace
-};
-
-struct UpdateTextInfoTest
-{
- std::string description;
- UpdateTextInfoOperation operation;
- std::string input;
- std::size_t position;
- std::size_t numberOfCharacters;
- std::string inputText;
- float lineHeightOffset;
- std::string result;
-};
-
-// Useful Print functions when something goes wrong.
-
-void Print( const TextViewProcessor::CharacterLayoutInfo& character )
-{
- std::cout << " height : " << character.mSize.height << std::endl;
- std::cout << " advance : " << character.mSize.width << std::endl;
- std::cout << " bearing : " << character.mBearing << std::endl;
- std::cout << " ascender : " << character.mAscender << std::endl;
- std::cout << " position : " << character.mPosition << std::endl;
-
- TextActor textActor = TextActor::DownCast( character.mGlyphActor );
- if( textActor )
- {
- std::cout << "[" << textActor.GetText() << "]";
- }
-}
-
-void Print( const TextViewProcessor::WordLayoutInfo& word )
-{
- std::cout << "[";
- std::cout << " mSize : " << word.mSize << std::endl;
- std::cout << " mAscender : " << word.mAscender << std::endl;
- std::cout << " mType : " << word.mType << std::endl;
- std::cout << "mNumberOfCharacters : " << word.mCharactersLayoutInfo.size() << std::endl;
- std::cout << "[";
- for( TextViewProcessor::CharacterLayoutInfoContainer::const_iterator it = word.mCharactersLayoutInfo.begin(), endIt = word.mCharactersLayoutInfo.end(); it != endIt; ++it )
- {
- Print( *it );
- }
- std::cout << "]"; std::cout << std::endl;
- std::cout << "]"; std::cout << std::endl;
-}
-
-void Print( const TextViewProcessor::ParagraphLayoutInfo& paragraph )
-{
- std::cout << "<";
- std::cout << " mSize : " << paragraph.mSize << std::endl;
- std::cout << " mAscender : " << paragraph.mAscender << std::endl;
- std::cout << "mNumberOfCharacters : " << paragraph.mNumberOfCharacters << std::endl;
- for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it = paragraph.mWordsLayoutInfo.begin(), endIt = paragraph.mWordsLayoutInfo.end(); it != endIt; ++it )
- {
- Print( *it );
- }
- std::cout << ">" << std::endl;
-}
-
-void Print( const TextViewProcessor::TextLayoutInfo& text )
-{
- std::cout << "||";
- for( TextViewProcessor::ParagraphLayoutInfoContainer::const_iterator it = text.mParagraphsLayoutInfo.begin(), endIt = text.mParagraphsLayoutInfo.end(); it != endIt; ++it )
- {
- Print( *it );
- }
- std::cout << "||" << std::endl;
-}
-
-std::string GetText( const TextViewProcessor::WordLayoutInfo& word, const Text& paragraphText )
-{
- Text text;
-
- paragraphText.GetSubText( word.mFirstCharacter, word.mFirstCharacter + word.mCharactersLayoutInfo.size() - 1u, text );
-
- return text.GetText();
-}
-
-std::string GetText( const TextViewProcessor::ParagraphLayoutInfo& paragraph )
-{
- std::string text;
-
- for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it = paragraph.mWordsLayoutInfo.begin(), endIt = paragraph.mWordsLayoutInfo.end(); it != endIt; ++it )
- {
- text += GetText( *it, paragraph.mText );
- }
-
- return text;
-}
-
-// Test functions used to check if two data structures are equal.
-
-bool TestEqual( float x, float y )
-{
- return ( fabsf( x - y ) < 0.001f );
-}
-
-bool TestEqual( const TextViewProcessor::CharacterLayoutInfo& character1,
- const TextViewProcessor::CharacterLayoutInfo& character2 )
-{
- if( !TestEqual( character1.mSize.height, character2.mSize.height ) )
- {
- return false;
- }
- if( !TestEqual( character1.mSize.width, character2.mSize.width ) )
- {
- return false;
- }
- if( !TestEqual( character1.mBearing, character2.mBearing ) )
- {
- return false;
- }
-
- if( !TestEqual( character1.mPosition.x, character2.mPosition.x ) )
- {
- return false;
- }
- if( !TestEqual( character1.mPosition.y, character2.mPosition.y ) )
- {
- return false;
- }
-
- if( !TestEqual( character1.mAscender, character2.mAscender ) )
- {
- return false;
- }
-
- if( character1.mGlyphActor && !character2.mGlyphActor )
- {
- return false;
- }
-
- if( !character1.mGlyphActor && character2.mGlyphActor )
- {
- return false;
- }
-
- std::string text1;
- std::string text2;
- TextStyle style1;
- TextStyle style2;
-
- TextActor textActor1 = TextActor::DownCast( character1.mGlyphActor );
- TextActor textActor2 = TextActor::DownCast( character2.mGlyphActor );
- if( textActor1 )
- {
- text1 = textActor1.GetText();
- style1 = textActor1.GetTextStyle();
-
- text2 = textActor2.GetText();
- style2 = textActor2.GetTextStyle();
- }
-
- if( text1 != text2 )
- {
- return false;
- }
-
- if( style1 != style2 )
- {
- return false;
- }
-
- return true;
-}
-
-bool TestEqual( const TextViewProcessor::WordLayoutInfo& word1,
- const TextViewProcessor::WordLayoutInfo& word2 )
-{
- if( !TestEqual( word1.mSize.x, word2.mSize.x ) )
- {
- return false;
- }
- if( !TestEqual( word1.mSize.y, word2.mSize.y ) )
- {
- return false;
- }
-
- if( !TestEqual( word1.mAscender, word2.mAscender ) )
- {
- return false;
- }
-
- if( word1.mType != word2.mType )
- {
- return false;
- }
-
- if( word1.mCharactersLayoutInfo.size() != word2.mCharactersLayoutInfo.size() )
- {
- return false;
- }
-
- for( TextViewProcessor::CharacterLayoutInfoContainer::const_iterator it1 = word1.mCharactersLayoutInfo.begin(), endIt1 = word1.mCharactersLayoutInfo.end(),
- it2 = word2.mCharactersLayoutInfo.begin(), endIt2 = word2.mCharactersLayoutInfo.end();
- ( it1 != endIt1 ) && ( it2 != endIt2 );
- ++it1, ++it2 )
- {
- if( !TestEqual( *it1, *it2 ) )
- {
- return false;
- }
- }
-
- return true;
-}
-
-bool TestEqual( const TextViewProcessor::ParagraphLayoutInfo& paragraph1,
- const TextViewProcessor::ParagraphLayoutInfo& paragraph2 )
-{
- if( !TestEqual( paragraph1.mSize.x, paragraph2.mSize.x ) )
- {
- return false;
- }
- if( !TestEqual( paragraph1.mSize.y, paragraph2.mSize.y ) )
- {
- return false;
- }
-
- if( !TestEqual( paragraph1.mAscender, paragraph2.mAscender ) )
- {
- return false;
- }
-
- if( paragraph1.mNumberOfCharacters != paragraph2.mNumberOfCharacters )
- {
- return false;
- }
-
- if( paragraph1.mWordsLayoutInfo.size() != paragraph2.mWordsLayoutInfo.size() )
- {
- return false;
- }
-
- for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it1 = paragraph1.mWordsLayoutInfo.begin(), endIt1 = paragraph1.mWordsLayoutInfo.end(),
- it2 = paragraph2.mWordsLayoutInfo.begin(), endIt2 = paragraph2.mWordsLayoutInfo.end();
- ( it1 != endIt1 ) && ( it2 != endIt2 );
- ++it1, ++it2 )
- {
- if( !TestEqual( *it1, *it2 ) )
- {
- return false;
- }
- }
-
- return true;
-}
-
-bool TestEqual( const TextViewProcessor::TextLayoutInfo& text1,
- const TextViewProcessor::TextLayoutInfo& text2 )
-{
- if( !TestEqual( text1.mWholeTextSize.x, text2.mWholeTextSize.x ) )
- {
- return false;
- }
- if( !TestEqual( text1.mWholeTextSize.y, text2.mWholeTextSize.y ) )
- {
- return false;
- }
-
- if( !TestEqual( text1.mMaxWordWidth, text2.mMaxWordWidth ) )
- {
- return false;
- }
-
- if( text1.mNumberOfCharacters != text2.mNumberOfCharacters )
- {
- return false;
- }
-
- if( text1.mParagraphsLayoutInfo.size() != text2.mParagraphsLayoutInfo.size() )
- {
- return false;
- }
-
- for( TextViewProcessor::ParagraphLayoutInfoContainer::const_iterator it1 = text1.mParagraphsLayoutInfo.begin(), endIt1 = text1.mParagraphsLayoutInfo.end(),
- it2 = text2.mParagraphsLayoutInfo.begin(), endIt2 = text2.mParagraphsLayoutInfo.end();
- ( it1 != endIt1 ) && ( it2 != endIt2 );
- ++it1, ++it2 )
- {
- if( !TestEqual( *it1, *it2 ) )
- {
- return false;
- }
- }
-
- return true;
-}
-
-/**
- * Splits the \e input word in two by the given \e position and checks the results with \e firstResult and \e lastResult.
- *
- * If the test fails it prints a short description and the line where this function was called.
- *
- * @param description Short description of the experiment. i.e. "Split the word from the beginning. (position 0)".
- * @param input The input word.
- * @param position Where to split the word.
- * @param firstResult First part of the split word.
- * @param lastResult Last part of the split word.
- * @param location Where this function has been called.
- *
- * @return \e true if the experiment is successful. Otherwise returns \e false.
- */
-bool TestSplitWord( const std::string& description, const std::string& input, const size_t position, const std::string& firstResult, const std::string& lastResult, const char* location )
-{
- tet_printf( "%s\n", description.c_str() );
-
- // Create layout info for the input word.
- Toolkit::Internal::TextView::RelayoutData relayoutData;
- TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( input, inputStyledText, true );
-
- TextViewProcessor::CreateTextInfo( inputStyledText,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData );
-
- // Get the input word
- TextViewProcessor::WordLayoutInfo inputWordLayout;
-
- if( !inputLayout.mParagraphsLayoutInfo.empty() )
- {
- const TextViewProcessor::ParagraphLayoutInfo& paragraph( *inputLayout.mParagraphsLayoutInfo.begin() );
- if( !paragraph.mWordsLayoutInfo.empty() )
- {
- inputWordLayout = *( *inputLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
- }
- }
-
- // Create layout info for the first part of the result (after split the word)
-
- Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
- TextViewProcessor::TextLayoutInfo& firstResultLayout( firstRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray firstResultStyledText;
- MarkupProcessor::GetStyledTextArray( firstResult, firstResultStyledText, true );
-
- TextViewProcessor::CreateTextInfo( firstResultStyledText,
- DEFAULT_LAYOUT_PARAMETERS,
- firstRelayoutData );
-
- // Get the first result word
- TextViewProcessor::WordLayoutInfo firstResultWordLayout;
-
- if( !firstResultLayout.mParagraphsLayoutInfo.empty() )
- {
- const TextViewProcessor::ParagraphLayoutInfo& paragraph( *firstResultLayout.mParagraphsLayoutInfo.begin() );
- if( !paragraph.mWordsLayoutInfo.empty() )
- {
- firstResultWordLayout = *( *firstResultLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
- }
- }
-
- // Create layout info for the last part of the result (after split the word)
-
- Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
- TextViewProcessor::TextLayoutInfo& lastResultLayout( lastRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray lastResultStyledText;
- MarkupProcessor::GetStyledTextArray( lastResult, lastResultStyledText, true );
-
- TextViewProcessor::CreateTextInfo( lastResultStyledText,
- DEFAULT_LAYOUT_PARAMETERS,
- lastRelayoutData );
-
- // Get the last result word
- TextViewProcessor::WordLayoutInfo lastResultWordLayout;
-
- if( !lastResultLayout.mParagraphsLayoutInfo.empty() )
- {
- const TextViewProcessor::ParagraphLayoutInfo& paragraph( *lastResultLayout.mParagraphsLayoutInfo.begin() );
- if( !paragraph.mWordsLayoutInfo.empty() )
- {
- lastResultWordLayout = *( *lastResultLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
- }
- }
-
- // Split the word.
-
- TextViewProcessor::WordLayoutInfo lastWordLayoutInfo;
-
- SplitWord( position,
- inputWordLayout,
- lastWordLayoutInfo );
-
- // Test results
- if( !TestEqual( inputWordLayout, firstResultWordLayout ) )
- {
- tet_printf( "Fail. different layout info. %s\n", location );
- return false;
- }
-
- if( !TestEqual( lastWordLayoutInfo, lastResultWordLayout ) )
- {
- tet_printf( "Fail. different layout info. %s\n", location );
- return false;
- }
-
- return true;
-}
-
-/**
- * Splits the \e input paragraph in two by the given \e wordIndex and \e characterIndex and checks the results with \e firstResult and \e lastResult.
- *
- * If the test fails it prints a short description and the line where this function was called.
- *
- * @param description Short description of the experiment. i.e. "Split the paragraph from the beginning. (wordIndex 0 and characterIndex 0)".
- * @param input The input word.
- * @param wordIndex Index to the word within the paragraph where to split it.
- * @param characterIndex Where to split the word.
- * @param characterIndex Character index within the paragraph.
- * @param lineHeightOffset Offset between lines.
- * @param firstResult First part of the split paragraph.
- * @param lastResult Last part of the split paragraph.
- * @param location Where this function has been called.
- *
- * @return \e true if the experiment is successful. Otherwise returns \e false.
- */
-bool TestSplitParagraph( const std::string& description,
- const std::string& input,
- size_t wordIndex,
- size_t characterIndex,
- size_t characterParagraphIndex,
- float lineHeightOffset,
- const std::string& firstResult,
- const std::string& lastResult,
- const char* location )
-{
- tet_printf( "%s\n", description.c_str() );
-
- // Create layout info for the input paragraph.
- Toolkit::Internal::TextView::RelayoutData relayoutData;
- TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( input, inputStyledText, true );
-
- TextViewProcessor::CreateTextInfo( inputStyledText,
- Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
- Toolkit::TextView::Original,
- Toolkit::TextView::Original,
- static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
- Toolkit::TextView::Center,
- PointSize( lineHeightOffset ),
- true ),
- relayoutData );
-
- // Get the input paragraph
- TextViewProcessor::ParagraphLayoutInfo inputParagraphLayout;
-
- if( !inputLayout.mParagraphsLayoutInfo.empty() )
- {
- inputParagraphLayout = *inputLayout.mParagraphsLayoutInfo.begin();
- }
-
- // Create layout info for the first part of the result (after split the paragraph)
-
- Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
- TextViewProcessor::TextLayoutInfo& firstResultLayout( firstRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray firstResultStyledText;
- MarkupProcessor::GetStyledTextArray( firstResult, firstResultStyledText, true );
-
- TextViewProcessor::CreateTextInfo( firstResultStyledText,
- Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
- Toolkit::TextView::Original,
- Toolkit::TextView::Original,
- static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
- Toolkit::TextView::Center,
- PointSize( lineHeightOffset ),
- true ),
- firstRelayoutData );
-
- // Get the first result paragraph
- TextViewProcessor::ParagraphLayoutInfo firstResultParagraphLayout;
-
- if( !firstResultLayout.mParagraphsLayoutInfo.empty() )
- {
- firstResultParagraphLayout = *firstResultLayout.mParagraphsLayoutInfo.begin();
- }
-
- // Create layout info for the last part of the result (after split the paragraph)
-
- Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
- TextViewProcessor::TextLayoutInfo& lastResultLayout( lastRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray lastResultStyledText;
- MarkupProcessor::GetStyledTextArray( lastResult, lastResultStyledText, true );
-
- TextViewProcessor::CreateTextInfo( lastResultStyledText,
- Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
- Toolkit::TextView::Original,
- Toolkit::TextView::Original,
- static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
- Toolkit::TextView::Center,
- PointSize( lineHeightOffset ),
- true ),
- lastRelayoutData );
-
- // Get the last result paragraph
- TextViewProcessor::ParagraphLayoutInfo lastResultParagraphLayout;
-
- if( !lastResultLayout.mParagraphsLayoutInfo.empty() )
- {
- lastResultParagraphLayout = *lastResultLayout.mParagraphsLayoutInfo.begin();
- }
-
- // Split the paragraph.
-
- TextViewProcessor::ParagraphLayoutInfo lastParagraphLayoutInfo;
-
- TextViewProcessor::TextInfoIndices indices( 0, wordIndex, characterIndex );
- indices.mCharacterParagraphIndex = characterParagraphIndex;
-
- SplitParagraph( indices,
- PointSize( lineHeightOffset ),
- inputParagraphLayout,
- lastParagraphLayoutInfo );
-
- // Test results
- if( !TestEqual( inputParagraphLayout, firstResultParagraphLayout ) )
- {
- tet_printf( "Fail. different first layout info. %s\n", location );
- return false;
- }
-
- if( !TestEqual( lastParagraphLayoutInfo, lastResultParagraphLayout ) )
- {
- tet_printf( "Fail. different last layout info. %s\n", location );
- return false;
- }
-
- return true;
-}
-
-/**
- * Merges the \e inputFirst word and the \e inputLast word, and checks the results with \e result.
- *
- * If the test fails it prints a short description and the line where this function was called.
- *
- * @param description Short description of the experiment. i.e. "Merge two words with same style".
- * @param inputFirst The first part of the word.
- * @param inputLast The last part of the word.
- * @param result The merged word.
- * @param location Where this function has been called.
- *
- * @return \e true if the experiment is successful. Otherwise returns \e false.
- */
-bool TestMergeWords( const std::string& description, const std::string& inputFirst, const std::string& inputLast, const std::string& result, const char* location )
-{
- tet_printf( "%s\n", description.c_str() );
-
- // Create layout info for the inputFirst word.
- Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
- TextViewProcessor::TextLayoutInfo& inputFirstLayout( firstRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray inputFirstStyledText;
- MarkupProcessor::GetStyledTextArray( inputFirst, inputFirstStyledText, true );
-
- TextViewProcessor::CreateTextInfo( inputFirstStyledText,
- DEFAULT_LAYOUT_PARAMETERS,
- firstRelayoutData );
-
- // Get the input word
- TextViewProcessor::WordLayoutInfo inputFirstWordLayout;
-
- if( !inputFirstLayout.mParagraphsLayoutInfo.empty() )
- {
- const TextViewProcessor::ParagraphLayoutInfo& paragraph( *inputFirstLayout.mParagraphsLayoutInfo.begin() );
- if( !paragraph.mWordsLayoutInfo.empty() )
- {
- inputFirstWordLayout = *( *inputFirstLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
- }
- }
-
- // Create layout info for the inputLast word.
- Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
- TextViewProcessor::TextLayoutInfo& inputLastLayout( lastRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray inputLastStyledText;
- MarkupProcessor::GetStyledTextArray( inputLast, inputLastStyledText, true );
-
- TextViewProcessor::CreateTextInfo( inputLastStyledText,
- DEFAULT_LAYOUT_PARAMETERS,
- lastRelayoutData );
-
- // Get the input word
- TextViewProcessor::WordLayoutInfo inputLastWordLayout;
-
- if( !inputLastLayout.mParagraphsLayoutInfo.empty() )
- {
- const TextViewProcessor::ParagraphLayoutInfo& paragraph( *inputLastLayout.mParagraphsLayoutInfo.begin() );
- if( !paragraph.mWordsLayoutInfo.empty() )
- {
- inputLastWordLayout = *( *inputLastLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
- }
- }
-
- // Create layout info for the result word.
- Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
- TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray resultStyledText;
- MarkupProcessor::GetStyledTextArray( result, resultStyledText, true );
-
- TextViewProcessor::CreateTextInfo( resultStyledText,
- DEFAULT_LAYOUT_PARAMETERS,
- resultRelayoutData );
-
- // Get the result word
- TextViewProcessor::WordLayoutInfo resultWordLayout;
-
- if( !resultLayout.mParagraphsLayoutInfo.empty() )
- {
- const TextViewProcessor::ParagraphLayoutInfo& paragraph( *resultLayout.mParagraphsLayoutInfo.begin() );
- if( !paragraph.mWordsLayoutInfo.empty() )
- {
- resultWordLayout = *( *resultLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
- }
- }
-
- MergeWord( inputFirstWordLayout,
- inputLastWordLayout );
-
- if( !TestEqual( inputFirstWordLayout, resultWordLayout ) )
- {
- tet_printf( "Fail. different layout info. %s\n", location );
- return false;
- }
-
- return true;
-}
-
-/**
- * Merges the \e inputFirst paragraph and the \e inputLast paragraph, and checks the results with \e result.
- *
- * If the test fails it prints a short description and the line where this function was called.
- *
- * @param description Short description of the experiment.
- * @param inputFirst The first part of the paragraph.
- * @param inputLast The last part of the paragraph.
- * @param lineHeightOffset Offset between lines.
- * @param result The merged paragraph.
- * @param location Where this function has been called.
- *
- * @return \e true if the experiment is successful. Otherwise returns \e false.
- */
-bool TestMergeParagraphs( const std::string& description, const std::string& inputFirst, const std::string& inputLast, const float lineHeightOffset, const std::string& result, const char* location )
-{
- tet_printf( "%s\n", description.c_str() );
-
- // Create layout info for the inputFirst paragraph.
- Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
- TextViewProcessor::TextLayoutInfo& inputFirstLayout( firstRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray inputFirstStyledText;
- MarkupProcessor::GetStyledTextArray( inputFirst, inputFirstStyledText, true );
-
- TextViewProcessor::CreateTextInfo( inputFirstStyledText,
- Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
- Toolkit::TextView::Original,
- Toolkit::TextView::Original,
- static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
- Toolkit::TextView::Center,
- PointSize( lineHeightOffset ),
- true ),
- firstRelayoutData );
-
- // Get the input word
- TextViewProcessor::ParagraphLayoutInfo inputFirstParagraphLayout;
-
- if( !inputFirstLayout.mParagraphsLayoutInfo.empty() )
- {
- inputFirstParagraphLayout = *inputFirstLayout.mParagraphsLayoutInfo.begin();
- }
-
- // Create layout info for the inputLast paragraph.
- Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
- TextViewProcessor::TextLayoutInfo& inputLastLayout( lastRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray inputLastStyledText;
- MarkupProcessor::GetStyledTextArray( inputLast, inputLastStyledText, true );
-
- TextViewProcessor::CreateTextInfo( inputLastStyledText,
- Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
- Toolkit::TextView::Original,
- Toolkit::TextView::Original,
- static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
- Toolkit::TextView::Center,
- PointSize( lineHeightOffset ),
- true ),
- lastRelayoutData );
-
- // Get the input word
- TextViewProcessor::ParagraphLayoutInfo inputLastParagraphLayout;
-
- if( !inputLastLayout.mParagraphsLayoutInfo.empty() )
- {
- inputLastParagraphLayout = *inputLastLayout.mParagraphsLayoutInfo.begin();
- }
-
- // Create layout info for the result word.
- Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
- TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray resultStyledText;
- MarkupProcessor::GetStyledTextArray( result, resultStyledText, true );
-
- TextViewProcessor::CreateTextInfo( resultStyledText,
- Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
- Toolkit::TextView::Original,
- Toolkit::TextView::Original,
- static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
- Toolkit::TextView::Center,
- PointSize( lineHeightOffset ),
- true ),
- resultRelayoutData );
-
- // Get the result word
- TextViewProcessor::ParagraphLayoutInfo resultParagraphLayout;
-
- if( !resultLayout.mParagraphsLayoutInfo.empty() )
- {
- resultParagraphLayout = *resultLayout.mParagraphsLayoutInfo.begin();
- }
-
- MergeParagraph( inputFirstParagraphLayout,
- inputLastParagraphLayout );
-
- if( !TestEqual( inputFirstParagraphLayout, resultParagraphLayout ) )
- {
- tet_printf( "Fail. different layout info. %s\n", location );
- return false;
- }
-
- return true;
-}
-
-/**
- * Removes from the \e input word the \e numberOfCharacters characters starting from the given \e position and checks the results with \e result.
- *
- * If the test fails it prints a short description and the line where this function was called.
- *
- * @param description Short description of the experiment. i.e. "Remove a whole word. Merge".
- * @param input The input word.
- * @param position Where to start to remove characters
- * @param numberOfCharacters The number of characters to remove.
- * @param result The word without the removed characters.
- * @param location Where this function has been called.
- *
- * @return \e true if the experiment is successful. Otherwise returns \e false.
- */
-bool TestRemoveCharactersFromWord( const std::string& description, const std::string& input, const std::size_t position, const std::size_t numberOfCharacters, const std::string& result, const char* location )
-{
- tet_printf( "%s\n", description.c_str() );
-
- // Create layout info for the input word.
- Toolkit::Internal::TextView::RelayoutData relayoutData;
- TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( input, inputStyledText, true );
-
- TextViewProcessor::CreateTextInfo( inputStyledText,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData );
-
- // Get the input word
- TextViewProcessor::WordLayoutInfo inputWordLayout;
-
- if( !inputLayout.mParagraphsLayoutInfo.empty() )
- {
- const TextViewProcessor::ParagraphLayoutInfo& paragraph( *inputLayout.mParagraphsLayoutInfo.begin() );
- if( !paragraph.mWordsLayoutInfo.empty() )
- {
- inputWordLayout = *( *inputLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
- }
- }
-
- // Create layout info for the result word.
- Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
- TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray resultStyledText;
- MarkupProcessor::GetStyledTextArray( result, resultStyledText, true );
-
- TextViewProcessor::CreateTextInfo( resultStyledText,
- DEFAULT_LAYOUT_PARAMETERS,
- resultRelayoutData );
-
- // Get the result word
- TextViewProcessor::WordLayoutInfo resultWordLayout;
-
- if( !resultLayout.mParagraphsLayoutInfo.empty() )
- {
- const TextViewProcessor::ParagraphLayoutInfo& paragraph( *resultLayout.mParagraphsLayoutInfo.begin() );
- if( !paragraph.mWordsLayoutInfo.empty() )
- {
- resultWordLayout = *( *resultLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
- }
- }
-
- RemoveCharactersFromWord( position,
- numberOfCharacters,
- inputWordLayout );
-
- if( !TestEqual( inputWordLayout, resultWordLayout ) )
- {
- tet_printf( "Fail. different layout info. %s\n", location );
- return false;
- }
-
- return true;
-}
-
-/**
- * Removes from the \e input paragraph the \e numberOfWords words starting from the given \e wordIndex and checks the results with \e result.
- *
- * If the test fails it prints a short description and the line where this function was called.
- *
- * @param description Short description of the experiment.
- * @param input The input paragraph.
- * @param wordIndex Index within the paragraph where to start to remove words.
- * @param numberOfWords The number of words to remove.
- * @param lineHeightOffset Offset between lines.
- * @param result The paragraph without the removed words.
- * @param location Where this function has been called.
- *
- * @return \e true if the experiment is successful. Otherwise returns \e false.
- */
-bool TestRemoveWordsFromParagraph( const std::string& description, const std::string& input, const std::size_t wordIndex, const std::size_t numberOfWords, const float lineHeightOffset, const std::string& result, const char* location )
-{
- tet_printf( "%s\n", description.c_str() );
-
- // Create layout info for the input paragraph.
- Toolkit::Internal::TextView::RelayoutData relayoutData;
- TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( input, inputStyledText, true );
-
- TextViewProcessor::CreateTextInfo( inputStyledText,
- Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
- Toolkit::TextView::Original,
- Toolkit::TextView::Original,
- static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
- Toolkit::TextView::Center,
- PointSize( lineHeightOffset ),
- true ),
- relayoutData );
-
- // Get the input paragraph
- TextViewProcessor::ParagraphLayoutInfo inputParagraphLayout;
-
- if( !inputLayout.mParagraphsLayoutInfo.empty() )
- {
- inputParagraphLayout = *inputLayout.mParagraphsLayoutInfo.begin();
- }
-
- // Create layout info for the result paragraph.
- Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
- TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray resultStyledText;
- MarkupProcessor::GetStyledTextArray( result, resultStyledText, true );
-
- TextViewProcessor::CreateTextInfo( resultStyledText,
- Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
- Toolkit::TextView::Original,
- Toolkit::TextView::Original,
- static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
- Toolkit::TextView::Center,
- PointSize( lineHeightOffset ),
- true ),
- resultRelayoutData );
-
- // Get the result paragraph
- TextViewProcessor::ParagraphLayoutInfo resultParagraphLayout;
-
- if( !resultLayout.mParagraphsLayoutInfo.empty() )
- {
- resultParagraphLayout = *resultLayout.mParagraphsLayoutInfo.begin();
- }
-
- RemoveWordsFromParagraph( wordIndex,
- numberOfWords,
- lineHeightOffset,
- inputParagraphLayout );
-
- if( !TestEqual( inputParagraphLayout, resultParagraphLayout ) )
- {
- tet_printf( "Fail. different layout info. %s\n", location );
- tet_printf( " input : [%s]\n", input.c_str() );
- tet_printf( " result : [%s]\n", GetText( resultParagraphLayout ).c_str() );
- tet_printf( " expected result : [%s]\n\n", result.c_str() );
-
- Print(inputParagraphLayout); std::cout << std::endl << std::endl;
- Print(resultParagraphLayout); std::cout << std::endl;
- return false;
- }
-
- return true;
-}
-
-/**
- * Tests inserts, removes and updates operation in the given \e input text and checks with the given \e result.
- *
- * If the test fails it prints a short description and the line where this function was called.
- *
- * @param description Short description of the experiment.
- * @param operation Type of update operation (insert, remove, replace)
- * @param input The input text.
- * @param position Where to insert, remove or replace text.
- * @param numberOfCharacters Number of characters to remove or replace.
- * @param inputText Inserted or updated text.
- * @param lineHeightOffset Offset between lines.
- * @param result Expected result.
- * @param location Where this function has been called.
- *
- * @return \e true if the experiment is successful. Otherwise returns \e false.
- */
-bool TestUpdateTextInfo( const std::string& description,
- UpdateTextInfoOperation operation,
- const std::string& input,
- std::size_t position,
- std::size_t numberOfCharacters,
- const std::string& inputText,
- float lineHeightOffset,
- const std::string& result,
- const char* location )
-{
- tet_printf( "%s\n", description.c_str() );
-
- // Create layout info for the input.
- Toolkit::Internal::TextView::RelayoutData relayoutData;
- TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( input, inputStyledText, true );
-
- TextViewProcessor::CreateTextInfo( inputStyledText,
- Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
- Toolkit::TextView::Original,
- Toolkit::TextView::Original,
- static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
- Toolkit::TextView::Center,
- PointSize( lineHeightOffset ),
- true ),
- relayoutData );
-
- // Create layout info for the result.
- Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
- TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray resultStyledText;
- MarkupProcessor::GetStyledTextArray( result, resultStyledText, true );
-
- TextViewProcessor::CreateTextInfo( resultStyledText,
- Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
- Toolkit::TextView::Original,
- Toolkit::TextView::Original,
- static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
- Toolkit::TextView::Center,
- PointSize( lineHeightOffset ),
- true ),
- resultRelayoutData );
-
- // Choose operation and call appropiate UpdateTextInfo() method.
- const Toolkit::Internal::TextView::LayoutParameters layoutParameters( Toolkit::TextView::SplitByNewLineChar,
- Toolkit::TextView::Original,
- Toolkit::TextView::Original,
- static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
- Toolkit::TextView::Center,
- PointSize( lineHeightOffset ),
- true );
-
- switch( operation )
- {
- case Insert:
- {
- MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( inputText, inputStyledText, true );
-
- TextViewProcessor::UpdateTextInfo( position,
- inputStyledText,
- layoutParameters,
- relayoutData );
- break;
- }
- case Remove:
- {
- TextViewProcessor::UpdateTextInfo( position,
- numberOfCharacters,
- layoutParameters,
- relayoutData,
- TextViewProcessor::CLEAR_TEXT );
- break;
- }
- case Replace:
- {
- MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( inputText, inputStyledText, true );
-
- TextViewProcessor::UpdateTextInfo( position,
- numberOfCharacters,
- inputStyledText,
- layoutParameters,
- relayoutData );
- break;
- }
- default:
- {
- tet_printf( "TestUpdateTextInfo: unknown update operation. %s\n", location );
- return false;
- }
- }
-
- if( !TestEqual( inputLayout, resultLayout ) )
- {
- tet_printf( "Fail. different layout info. %s\n", location );
-
- // std::cout << " result : "; Print( inputLayout );
- // std::cout << " expected result : "; Print( resultLayout );
- return false;
- }
-
- return true;
-}
-
-} // namespace
-
-
-int UtcDaliTextViewCreateTextInfo(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewCreateTextInfo : ");
-
- // Metrics for characters
-
- // Font size = 10
- // size : [9.48351, 9.48351]
- // advance : 9.48351
- // bearing : 8.53516
- // ascender : 8.53516
-
- // Font size = 12
- // size : [11.3802, 11.3802]
- // advance : 11.3802
- // bearing : 10.2422
- // ascender : 10.2422
-
- // Font size = 14
- // size : [13.2769, 13.2769]
- // advance : 13.2769
- // bearing : 11.9492
- // ascender : 11.9492
-
- const float HEIGHT_10( 9.48351f );
- const float ADVANCE_10( 9.48351f );
- const float BEARING_10( 8.53516f );
- const float ASCENDER_10( 8.53516f );
-
- const float HEIGHT_12( 11.3802f );
- const float ADVANCE_12( 11.3802f );
- const float BEARING_12( 10.2422f );
- const float ASCENDER_12( 10.2422f );
-
-
- // Generate a text.
- Toolkit::Internal::TextView::RelayoutData relayoutData;
- TextViewProcessor::TextLayoutInfo& textLayoutInfo( relayoutData.mTextLayoutInfo );
-
- std::string text( "Hello world!\n"
- "\n" );
-
- MarkupProcessor::StyledTextArray styledText;
- MarkupProcessor::GetStyledTextArray( text, styledText, true );
-
- TextViewProcessor::CreateTextInfo( styledText,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData );
-
-
- // Build the text info with metric values.
-
- // Characters
-
- TextViewProcessor::CharacterLayoutInfo layoutInfo10; // ( [lo wo])
- layoutInfo10.mSize.height = HEIGHT_10;
- layoutInfo10.mSize.width = ADVANCE_10;
- layoutInfo10.mBearing = BEARING_10;
- layoutInfo10.mAscender = ASCENDER_10;
- TextViewProcessor::CharacterLayoutInfo layoutInfo12; // ( [Hel], [rld!] and [CR])
- layoutInfo12.mSize.height = HEIGHT_12;
- layoutInfo12.mSize.width = ADVANCE_12;
- layoutInfo12.mBearing = BEARING_12;
- layoutInfo12.mAscender = ASCENDER_12;
-
- // Words
-
- TextViewProcessor::WordLayoutInfo wordLayout1, wordLayout2, wordLayout3, wordLayout4;
-
- // Hello
- wordLayout1.mSize = Size( 3.f * ADVANCE_12 + 2.f * ADVANCE_10, HEIGHT_12 );
- wordLayout1.mAscender = ASCENDER_12;
- wordLayout1.mType = TextViewProcessor::NoSeparator;
-
- wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // H
- wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // e
- wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // l
- wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo10 ); // l
- wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo10 ); // o
-
- // (white space)
- wordLayout2.mSize = Size( ADVANCE_10, HEIGHT_10 );
- wordLayout2.mAscender = ASCENDER_10;
- wordLayout2.mType = TextViewProcessor::WordSeparator;
- wordLayout2.mCharactersLayoutInfo.push_back( layoutInfo10 ); // (white space)
-
- // world!
- wordLayout3.mSize = Size( 2.f * ADVANCE_10 + 4.f * ADVANCE_12, HEIGHT_12 );
- wordLayout3.mAscender = ASCENDER_12;
- wordLayout3.mType = TextViewProcessor::NoSeparator;
- wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo10 ); // w
- wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo10 ); // o
- wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // r
- wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // l
- wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // d
- wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // !
-
- // (new paragraph character)
- wordLayout4.mSize = Size( 0.f, HEIGHT_12 );
- wordLayout4.mAscender = ASCENDER_12;
- wordLayout4.mType = TextViewProcessor::ParagraphSeparator;
- layoutInfo12.mSize.width = 0.f;
- wordLayout4.mCharactersLayoutInfo.push_back( layoutInfo12 ); // (new paragraph char)
-
- // Paragraphs
-
- TextViewProcessor::ParagraphLayoutInfo paragraphLayout1, paragraphLayout2, paragraphLayout3;
-
- paragraphLayout1.mSize = Size( 5.f * ADVANCE_10 + 7.f * ADVANCE_12, HEIGHT_12 );
- paragraphLayout1.mAscender = ASCENDER_12;
- paragraphLayout1.mNumberOfCharacters = 13;
- paragraphLayout1.mWordsLayoutInfo.push_back( wordLayout1 );
- paragraphLayout1.mWordsLayoutInfo.push_back( wordLayout2 );
- paragraphLayout1.mWordsLayoutInfo.push_back( wordLayout3 );
- paragraphLayout1.mWordsLayoutInfo.push_back( wordLayout4 );
-
- paragraphLayout2.mSize = Size( 0.f, HEIGHT_12 );
- paragraphLayout2.mAscender = ASCENDER_12;
- paragraphLayout2.mNumberOfCharacters = 1;
- paragraphLayout2.mWordsLayoutInfo.push_back( wordLayout4 );
-
- paragraphLayout3.mSize = Size( 0.f, HEIGHT_12 );
-
- // Text (layout)
- TextViewProcessor::TextLayoutInfo textLayout;
-
- textLayout.mWholeTextSize = Size( 5.f * ADVANCE_10 + 7.f * ADVANCE_12, 3.f * HEIGHT_12 );
- textLayout.mMaxWordWidth = 2.f * ADVANCE_10 + 4.f * ADVANCE_12;
- textLayout.mNumberOfCharacters = 14;
- textLayout.mParagraphsLayoutInfo.push_back( paragraphLayout1 );
- textLayout.mParagraphsLayoutInfo.push_back( paragraphLayout2 );
- textLayout.mParagraphsLayoutInfo.push_back( paragraphLayout3 );
-
- if(!TestEqual( textLayout, textLayoutInfo ))
- {
- std::cout << "Layout fails" << std::endl;
- Print(textLayout); std::cout << std::endl;
- Print(textLayoutInfo); std::cout << std::endl;
- }
-
- DALI_TEST_CHECK( TestEqual( textLayout, textLayoutInfo ) );
- END_TEST;
-}
-
-int UtcDaliTextViewSplitWord(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewSplitWord : ");
-
- struct SplitWordTest splitWordTests[] =
- {
- {
- std::string( "Split word, position 0." ),
- std::string( "Helloooo" ),
- 0,
- std::string( "" ),
- std::string( "Helloooo" ),
- },
- {
- std::string( "Split word, position 8." ),
- std::string( "Helloooo" ),
- 8,
- std::string( "Helloooo" ),
- std::string( "" ),
- },
- {
- std::string( "Split word, position 2." ),
- std::string( "Helloooo" ),
- 2,
- std::string( "He" ),
- std::string( "lloooo" ),
- },
- {
- std::string( "Split word, position 3." ),
- std::string( "Helloooo" ),
- 3,
- std::string( "Hel" ),
- std::string( "loooo" ),
- },
- {
- std::string( "Split word, position 4." ),
- std::string( "Helloooo" ),
- 4,
- std::string( "Hell" ),
- std::string( "oooo" ),
- },
- };
- const std::size_t numberOfTests( 5u );
-
- for( std::size_t index = 0u; index < numberOfTests; ++index )
- {
- const SplitWordTest& test = splitWordTests[index];
-
- if( !TestSplitWord( test.description, test.input, test.position, test.firstResult, test.lastResult, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewUpdateTextInfo(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewUpdateTextInfo : ");
-
- struct UpdateTextInfoTest updateTextInfoTest[] =
- {
- // Remove operations
-
- {
- std::string( "Remove from new paragraph character to first character next paragraph." ),
- Remove,
- std::string("Hello world\nhello world."),
- 11,
- 2,
- std::string(""),
- 0.f,
- std::string("Hello worldello world."),
- },
- {
- std::string( "Replace style from new paragraph character to first character next paragraph." ),
- Replace,
- std::string("Hello world\nhello world."),
- 11,
- 2,
- std::string("\nh"),
- 0.f,
- std::string("Hello world\nhello world."),
- },
- {
- std::string( "Remove from the beginning to the middle of last word." ),
- Remove,
- std::string("Hello world, hello world."),
- 0,
- 22,
- std::string(), // Not used.
- 0.f,
- std::string("ld."),
- },
- {
- std::string( "Remove from the beginning to the middle of the text." ),
- Remove,
- std::string("Hello world hello world."),
- 0,
- 12,
- std::string(), // Not used.
- 0.f,
- std::string("hello world."),
- },
- // Remove within the same word:
- // * within the same group of characters with same style.
- {
- std::string( "Remove within the same word, within the same group of characters with same style" ),
- Remove,
- std::string("Hello world\nhello world"),
- 7,
- 3,
- std::string(), // Not used.
- 0.f,
- std::string( "Hello wd\nhello world" )
- },
- // * whole group of characters (merge adjacent group of characters)
- {
- std::string( "Remove within the same word, whole group of characters (merge adjacent group of characters)" ),
- Remove,
- std::string("Hello world\nhello world"),
- 7,
- 3,
- std::string(), // Not used.
- 0.f,
- std::string( "Hello wd\nhello world" )
- },
- // * whole group of characters (don't merge adjacent gtoup of characters)
- {
- std::string( "Remove within the same word, whole group of characters (don't merge adjacent gtoup of characters)" ),
- Remove,
- std::string("Hello world\nhello world"),
- 7,
- 3,
- std::string(), // Not used.
- 0.f,
- std::string( "Hello wd\nhello world" )
- },
- // * Remove whole word (merge words)
- {
- std::string( "Remove within the same word, whole word (merge words)" ),
- Remove,
- std::string("Hello world\nhello world"),
- 5,
- 1,
- std::string(), // Not used.
- 0.f,
- std::string( "Helloworld\nhello world" )
- },
- // * Remove whole word (don't merge words)
- {
- std::string( "Remove within the same word, whole word (don't merge words)" ),
- Remove,
- std::string("Hello world\nhello world"),
- 6,
- 5,
- std::string(), // Not used.
- 0.f,
- std::string( "Hello \nhello world" )
- },
- // * Remove whole word (merge paragraphs)
- {
- std::string( "Remove within the same word, whole word (merge paragraphs)" ),
- Remove,
- std::string("Hello world\nhello world"),
- 11,
- 1,
- std::string(), // Not used.
- 0.f,
- std::string( "Hello worldhello world" )
- },
- // * Remove RTL text within LTR
- {
- std::string( "Remove within the same paragraph, RTL text within LTR." ),
- Remove,
- std::string("Hello world, ש××× ×¢×××, hello world"),
- 10,
- 15,
- std::string(), // Not used.
- 0.f,
- std::string( "Hello worlello world" )
- },
- // * Remove whole paragraph
- {
- std::string( "Remove whole paragraph" ),
- Remove,
- std::string("Hello world, hello world\n"
- "Hello world, hello world\n"
- "Hello world, hello world\n"
- "Hello world, hello world\n"),
- 25,
- 25,
- std::string(), // Not used.
- 0.f,
- std::string("Hello world, hello world\n"
- "Hello world, hello world\n"
- "Hello world, hello world\n"),
- },
- {
- std::string( "Remove whole paragraph" ),
- Remove,
- std::string("Hello world, hello world\n"
- "H"),
- 25,
- 1,
- std::string(), // Not used.
- 0.f,
- std::string("Hello world, hello world\n"),
- },
-
-
- // Insert operations
- {
- std::string( "insert some text" ),
- Insert,
- std::string("inpuext"),
- 4,
- 0, // Not used
- std::string( "t t" ),
- 0.f,
- std::string( "input text" )
- },
- {
- std::string( "Insert text at the end" ),
- Insert,
- std::string("touch "),
- 6,
- 0,
- std::string("me\nhello"),
- 0.f,
- std::string("touch me\nhello")
- },
-
- // Replace operations.
- {
- std::string( "Replace style from the beginning to some point in the middle of the text." ),
- Replace,
- std::string( "Hello world" ),
- 0,
- 7,
- std::string( "Hello w" ),
- 0.f,
- std::string( "Hello world" )
- },
- {
- std::string( "Replace style from the middle of the text to the end." ),
- Replace,
- std::string( "Touch me\nhello" ),
- 6,
- 8,
- std::string( "me\nhello" ),
- 0.f,
- std::string( "Touch me\nhello" )
- },
- {
- std::string( "Remove characters from text. Previous next test:Replace style from the middle of the text 1." ),
- Remove,
- std::string( "Touch me\nhello\nworld" ),
- 6,
- 8,
- std::string( "" ),
- 0.f,
- std::string( "Touch \nworld" )
- },
- {
- std::string( "Insert styled text in the middle of a text. Previous: Replace style from the middle of the text 1." ),
- Insert,
- std::string( "Touch \nworld" ),
- 6,
- 0,
- std::string( "me\nhello" ),
- 0.f,
- std::string( "Touch me\nhello\nworld" )
- },
- {
- std::string( "Replace style from the middle of the text 1." ),
- Replace,
- std::string( "Touch me\nhello\nworld" ),
- 6,
- 8,
- std::string( "me\nhello" ),
- 0.f,
- std::string( "Touch me\nhello\nworld" )
- },
- {
- std::string( "Remove characters from text. Previous next test:Replace style from the middle of the text 2." ),
- Remove,
- std::string( "Touch me\nhello\nworld" ),
- 6,
- 9,
- std::string( "" ),
- 0.f,
- std::string( "Touch world" )
- },
- {
- std::string( "Replace style from the middle of the text 2." ),
- Replace,
- std::string( "Touch me\nhello\nworld" ),
- 6,
- 9,
- std::string( "me\nhello\n" ),
- 0.f,
- std::string( "Touch me\nhello\nworld" )
- },
- };
- const std::size_t numberOfTests( 22u );
-
- for( std::size_t index = 0u; index < numberOfTests; ++index )
- {
- const UpdateTextInfoTest& test = updateTextInfoTest[index];
-
- if( !TestUpdateTextInfo( test.description, test.operation, test.input, test.position, test.numberOfCharacters, test.inputText, test.lineHeightOffset, test.result, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewSplitParagraph(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewSplitParagraph : ");
-
- struct SplitParagraphTest splitParagraphTests[] =
- {
- {
- std::string( "Split paragraph, wordPosition 0, position 0." ),
- std::string( "Helloooo wooorld ש××× ×¢××× text text" ),
- 0,
- 0,
- 0,
- 3.f,
- std::string( "" ),
- std::string( "Helloooo wooorld ש××× ×¢××× text text" ),
- },
- {
- std::string( "Split paragraph, wordPosition 10, position 4." ),
- std::string( "Helloooo wooorld ש××× ×¢××× text text" ),
- 10,
- 4,
- 36,
- 0.f,
- std::string( "Helloooo wooorld ש××× ×¢××× text text" ),
- std::string( "" ),
- },
- {
- std::string( "Split paragraph, wordPosition 2, position 4." ),
- std::string("Hello world, hello world"),
- 2,
- 4,
- 10,
- 0.f,
- std::string("Hello worl"),
- std::string("d, hello world")
- },
- {
- std::string( "Split paragraph, wordPosition 6, position 0." ),
- std::string( "Helloooo wooorld ש××× ×¢××× text text" ),
- 6,
- 0,
- 21,
- 0.f,
- std::string( "Helloooo wooorld ש××× " ),
- std::string( "×¢××× text text" ),
- },
- {
- std::string( "Split paragraph, wordPosition 4, position 0." ),
- std::string( "Helloooo wooorld ש××× ×¢××× text text" ),
- 4,
- 0,
- 17,
- 0.f,
- std::string( "Helloooo wooorld " ),
- std::string( "ש××× ×¢××× text text" ),
- },
- {
- std::string( "Split paragraph2, wordPosition 8, position 0." ),
- std::string( "Helloooo wooorld ש××× ×¢××× text text" ),
- 8,
- 0,
- 27,
- 6.f,
- std::string( "Helloooo wooorld ש××× ×¢××× " ),
- std::string( "text text" ),
- },
- };
- const std::size_t numberOfTests( 6u );
-
- for( std::size_t index = 0u; index < numberOfTests; ++index )
- {
- const SplitParagraphTest& test = splitParagraphTests[index];
-
- if( !TestSplitParagraph( test.description,
- test.input,
- test.wordIndex,
- test.characterIndex,
- test.characterParagraphIndex,
- test.lineHeightOffset,
- test.firstResult,
- test.lastResult,
- TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewMergeWord01(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewMergeWord01 : ");
-
- struct MergeWordsTest mergeWordsTests[] =
- {
- {
- std::string( "Merge words with same style." ),
- std::string( "Hel" ),
- std::string( "lo" ),
- std::string( "Hello" ),
- },
- {
- std::string( "Merge words with different styles." ),
- std::string( "lo" ),
- std::string( "Hello" )
- },
- };
- const std::size_t numberOfTests( 2u );
-
- for( std::size_t index = 0u; index < numberOfTests; ++index )
- {
- const MergeWordsTest& test = mergeWordsTests[index];
-
- if( !TestMergeWords( test.description, test.inputFirst, test.inputLast, test.result, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewMergeWord02(void)
-{
- // Negative test.
- // It test white spaces and new paragraph characters can't be merged to other words.
-
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewMergeWord02 : ");
-
- // Generate three words
-
- Toolkit::Internal::TextView::RelayoutData relayoutData01;
- Toolkit::Internal::TextView::RelayoutData relayoutData02;
- Toolkit::Internal::TextView::RelayoutData relayoutData03;
- TextViewProcessor::TextLayoutInfo& textLayoutInfo01( relayoutData01.mTextLayoutInfo );
- TextViewProcessor::TextLayoutInfo& textLayoutInfo02( relayoutData02.mTextLayoutInfo );
- TextViewProcessor::TextLayoutInfo& textLayoutInfo03( relayoutData03.mTextLayoutInfo );
-
- std::string text01( " " );
- std::string text02( "\n" );
- std::string text03( "a" );
- MarkupProcessor::StyledTextArray styledText01;
- MarkupProcessor::StyledTextArray styledText02;
- MarkupProcessor::StyledTextArray styledText03;
- MarkupProcessor::GetStyledTextArray( text01, styledText01, true );
- MarkupProcessor::GetStyledTextArray( text02, styledText02, true );
- MarkupProcessor::GetStyledTextArray( text03, styledText03, true );
-
- TextViewProcessor::CreateTextInfo( styledText01,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData01 );
-
- TextViewProcessor::WordLayoutInfo wordLayoutInfo01;
-
- wordLayoutInfo01 = *( *textLayoutInfo01.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
-
- TextViewProcessor::CreateTextInfo( styledText02,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData02 );
-
- TextViewProcessor::WordLayoutInfo wordLayoutInfo02;
-
- wordLayoutInfo02 = *( *textLayoutInfo02.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
-
- TextViewProcessor::CreateTextInfo( styledText03,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData03 );
-
- TextViewProcessor::WordLayoutInfo wordLayoutInfo03;
-
- wordLayoutInfo03 = *( *textLayoutInfo03.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
-
- // Test MergeWord() asserts if white spaces or new paragraph chars are merged.
- bool assert1 = false;
- bool assert2 = false;
- bool assert3 = false;
- bool assert4 = false;
- bool assert5 = false;
- bool assert6 = false;
-
- try
- {
- MergeWord( wordLayoutInfo01,
- wordLayoutInfo02 );
- }
- catch( Dali::DaliException& e )
- {
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
- assert1 = true;
- }
- try
- {
- MergeWord( wordLayoutInfo01,
- wordLayoutInfo03 );
- }
- catch( Dali::DaliException& e )
- {
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
- assert2 = true;
- }
- try
- {
- MergeWord( wordLayoutInfo02,
- wordLayoutInfo01 );
- }
- catch( Dali::DaliException& e )
- {
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
- assert3 = true;
- }
- try
- {
- MergeWord( wordLayoutInfo02,
- wordLayoutInfo03 );
- }
- catch( Dali::DaliException& e )
- {
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
- assert4 = true;
- }
- try
- {
- MergeWord( wordLayoutInfo03,
- wordLayoutInfo01 );
- }
- catch( Dali::DaliException& e )
- {
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
- assert5 = true;
- }
- try
- {
- MergeWord( wordLayoutInfo03,
- wordLayoutInfo02 );
- }
- catch( Dali::DaliException& e )
- {
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
- assert6 = true;
- }
-
- if( assert1 && assert2 && assert3 && assert4 && assert5 && assert6 )
- {
- tet_result( TET_PASS );
- }
- else
- {
- tet_result( TET_FAIL );
- }
- END_TEST;
-}
-
-int UtcDaliTextViewMergeParagraph01(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewMergeParagraph01 : ");
-
- struct MergeParagraphsTest mergeParagraphsTests[] =
- {
- {
- std::string( "Merge a void first paragraph." ),
- std::string( "" ),
- std::string( "Hello world, this is a whole paragraph" ),
- 2.f,
- std::string( "Hello world, this is a whole paragraph" )
- },
- {
- std::string( "Merge a void last paragraph." ),
- std::string( "Hello world, this is a whole paragraph" ),
- std::string( "" ),
- 0.f,
- std::string( "Hello world, this is a whole paragraph" )
- },
- {
- std::string( "Merge paragraphs: last starting with RTL text and first ending with RTL" ),
- std::string( "Hello world, ש×××" ),
- std::string( " ×¢×××, hello world." ),
- 6.f,
- std::string( "Hello world, ש××× ×¢×××, hello world." )
- },
- {
- std::string( "Merge paragraphs and don't merge last and first words." ),
- std::string( "Hello world, " ),
- std::string( "ש××× ×¢×××, hello world." ),
- 3.f,
- std::string( "Hello world, ש××× ×¢×××, hello world." )
- },
- {
- std::string( "Merge paragraphs. Don't merge words" ),
- std::string( "Hello world," ),
- std::string( " this is a whole paragraph" ),
- 0.f,
- std::string( "Hello world, this is a whole paragraph" )
- },
- {
- std::string( "Merge paragraphs. Merge words" ),
- std::string( "Hello world, th" ),
- std::string( "is is a whole paragraph" ),
- 0.f,
- std::string( "Hello world, this is a whole paragraph" )
- },
- };
- const std::size_t numberOfTests( 6u );
-
- for( std::size_t index = 0u; index < numberOfTests; ++index )
- {
- const MergeParagraphsTest& test = mergeParagraphsTests[index];
-
- if( !TestMergeParagraphs( test.description, test.inputFirst, test.inputLast, test.lineHeightOffset, test.result, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewMergeParagraph02(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewMergeParagraph02 : ");
-
- Toolkit::Internal::TextView::RelayoutData relayoutData01;
- Toolkit::Internal::TextView::RelayoutData relayoutData02;
- TextViewProcessor::TextLayoutInfo& textLayoutInfo01( relayoutData01.mTextLayoutInfo );
- TextViewProcessor::TextLayoutInfo& textLayoutInfo02( relayoutData02.mTextLayoutInfo );
-
- std::string text01( "Hello world\n" );
- std::string text02( "hello world" );
- MarkupProcessor::StyledTextArray styledText01;
- MarkupProcessor::StyledTextArray styledText02;
- MarkupProcessor::GetStyledTextArray( text01, styledText01, true );
- MarkupProcessor::GetStyledTextArray( text02, styledText02, true );
-
- TextViewProcessor::CreateTextInfo( styledText01,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData01 );
-
- TextViewProcessor::ParagraphLayoutInfo paragraphLayoutInfo01;
-
- paragraphLayoutInfo01 = *textLayoutInfo01.mParagraphsLayoutInfo.begin();
-
- TextViewProcessor::CreateTextInfo( styledText02,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData02 );
-
- TextViewProcessor::ParagraphLayoutInfo paragraphLayoutInfo02;
-
- paragraphLayoutInfo02 = *textLayoutInfo02.mParagraphsLayoutInfo.begin();
-
- bool assert1 = false;
-
- try
- {
- MergeParagraph( paragraphLayoutInfo01,
- paragraphLayoutInfo02 );
- }
- catch( Dali::DaliException& e )
- {
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeParagraph(). ERROR: A paragraph can't be merged to another paragraph which finishes with a new paragraph character.\"", TEST_LOCATION );
- assert1 = true;
- }
-
- if( assert1 )
- {
- tet_result( TET_PASS );
- }
- else
- {
- tet_result( TET_FAIL );
- }
- END_TEST;
-}
-
-int UtcDaliTextViewRemoveCharactersFromWord(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewMergeWord02 : ");
-
- struct RemoveCharactersFromWordTest removeCharactersFromWordTests[] =
- {
- {
- std::string( "Delete 0 characters." ),
- std::string( "Hello" ),
- 3,
- 0,
- std::string( "Hello" ),
- },
- {
- std::string( "Delete within the same group of characters. Starting from the beginning" ),
- std::string( "Hello" ),
- 0,
- 3,
- std::string( "lo" ),
- },
- {
- std::string( "Delete within the same group of characters. Somewhere in the middle" ),
- std::string( "Hello" ),
- 2,
- 2,
- std::string( "Heo" ),
- },
- {
- std::string( "Delete within the same group of characters. Starting somewhere in the middle to the end" ),
- std::string( "Hello" ),
- 3,
- 2,
- std::string( "Hel" ),
- },
- {
- std::string( "Delete within the same group of characters. Finish just before a new one." ),
- std::string( "HelloWorld" ),
- 1,
- 2,
- std::string( "HloWorld" ),
- },
- {
- std::string( "Delete starting in one group of characters and finishing in a different one. No merge of groups." ),
- std::string( "HelloWorld" ),
- 2,
- 3,
- std::string( "HeWorld" ),
- },
- {
- std::string( "Delete within the same group of characters. Starting just after a different one." ),
- std::string( "HelloWorld" ),
- 7,
- 2,
- std::string( "HelloWod" ),
- },
- {
- std::string( "Delete whole group of characters. No merge" ),
- std::string( "HelloWorld" ),
- 3,
- 4,
- std::string( "Helrld" ),
- },
- {
- std::string( "Delete whole group of characters and part of the adjacent ones. No merge" ),
- std::string( "HelloWorld" ),
- 2,
- 6,
- std::string( "Held" ),
- },
- {
- std::string( "Delete whole group of characters. Merge" ),
- std::string( "HelloWorld" ),
- 3,
- 4,
- std::string( "Helrld" ),
- },
- {
- std::string( "Delete whole group of characters and part of the adjacent ones. Merge" ),
- std::string( "HelloWorld" ),
- 2,
- 6,
- std::string( "Held" ),
- },
- };
- const std::size_t numberOfTests( 11u );
-
- for( std::size_t index = 0u; index < numberOfTests; ++index )
- {
- const RemoveCharactersFromWordTest& test = removeCharactersFromWordTests[index];
-
- if( !TestRemoveCharactersFromWord( test.description, test.input, test.position, test.numberOfCharacters, test.result, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewRemoveWordsFromParagraph(void)
-{
- // Note: Currently RemoveWordsFromParagraph() function is only used to remove a number of words from the beginning, or
- // from a given index to the end.
-
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewRemoveWordsFromParagraph : ");
- struct RemoveWordsFromParagraphTest removeWordsFromParagraphTest[] =
- {
- {
- std::string( "Delete 0 words." ),
- std::string( "Hello hello, ש××× ×¢××× hello hello" ),
- 0,
- 0,
- 2.f,
- std::string( "Hello hello, ש××× ×¢××× hello hello" ),
- },
- {
- std::string( "Delete from the middle to the end." ),
- std::string( "Hello hello, ש××× ×¢××× hello hello" ),
- 4,
- 7,
- 0.f,
- std::string( "Hello hello, " ),
- },
- {
- std::string( "Delete from the beginning to the middle." ),
- std::string( "Hello hello, ש××× ×¢××× hello hello" ),
- 0,
- 8,
- 6.f,
- std::string( "hello hello" ),
- },
- };
- const std::size_t numberOfTests( 3u );
-
- for( std::size_t index = 0u; index < numberOfTests; ++index )
- {
- const RemoveWordsFromParagraphTest& test = removeWordsFromParagraphTest[index];
-
- if( !TestRemoveWordsFromParagraph( test.description, test.input, test.wordIndex, test.numberOfWords, test.lineHeightOffset, test.result, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
diff --git a/automated-tests/src/dali-toolkit-unmanaged/CMakeLists.txt b/automated-tests/src/dali-toolkit-unmanaged/CMakeLists.txt
index f62490f..5dce36d 100644
--- a/automated-tests/src/dali-toolkit-unmanaged/CMakeLists.txt
+++ b/automated-tests/src/dali-toolkit-unmanaged/CMakeLists.txt
@@ -46,7 +46,6 @@ SET(TC_SOURCES
utc-Dali-ItemView.cpp
utc-Dali-KeyboardFocusManager.cpp
utc-Dali-ScrollViewEffect.cpp
- utc-Dali-TextInput.cpp
utc-Dali-StyleManager.cpp
utc-Dali-RadioButton.cpp
)
diff --git a/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-Builder.cpp b/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-Builder.cpp
index f95bbe7..cc03bb1 100644
--- a/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-Builder.cpp
+++ b/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-Builder.cpp
@@ -26,131 +26,6 @@ using namespace Toolkit;
namespace
{
-//
-// Note: To avoid escaping double quotes single quotes are used and then replaced
-// before parsing. JSON uses double quotes
-//
-
- std::string JSON_TEXT_ACTOR("\
-{ \
- 'templates': \
- { \
- 'basic-text': \
- { \
- 'type':'TextActor', \
- 'text':'Template Hello', \
- 'size': [150,170,1], \
- 'position':[-10,10,0] \
- } \
- }, \
- 'styles': \
- { \
- 'basic-text': \
- { \
- 'text':'Hello', \
- 'font':'', \
- 'parent-origin':[0.0,0.0,0], \
- 'anchor-point' :[0.5,0.5,0], \
- 'size': [150,170,1], \
- 'position':[-10,10,0] \
- } \
- }, \
- 'animations': \
- { \
- 'rotate': \
- { \
- 'duration': 10, \
- 'properties': \
- [ \
- { \
- 'actor':'text', \
- 'property':'rotation', \
- 'value':[0, 3, 0, 0], \
- 'alpha-function': 'EASE_IN_OUT', \
- 'time-period': {'delay': 0, 'duration': 3 } \
- } \
- ] \
- } \
- }, \
- 'stage': \
- [ \
- { \
- 'name':'text', \
- 'type':'basic-text', \
- 'text':'Hello' \
- }, \
- { \
- 'name':'text2', \
- 'type':'basic-text', \
- 'text':'Hello', \
- 'signals': \
- [ \
- { 'name': 'on-stage', 'action':'set', 'actor':'text2', 'property':'text', 'value':'Jaylo' } \
- ] \
- } \
- ], \
- 'other': \
- [ \
- { \
- 'name':'other-text', \
- 'type':'basic-text', \
- 'text':'Hello' \
- } \
- ] \
-} \
-");
-
-
- std::string JSON_CORE_ACTOR_TREE("\
-{ \
- 'templates': \
- { \
- 'my-camera': { \
- 'type':'CameraActor', \
- 'camera-type':'FreeLook', \
- 'field-of-view': 0.125, \
- 'aspect-ratio':5.0, \
- 'near-plane-distance': 100, \
- 'far-plane-distance': 200 \
- }, \
- 'basic-text': { \
- 'type':'TextActor', \
- 'text':'Hello', \
- 'font':'Freesans', \
- 'smooth-edge':0.2, \
- 'position': [-10.0, 10.0, -1000.0], \
- 'size': [300.0, 250.0, 0.0] \
- } \
- }, \
- 'styles': \
- { \
- 'theme2-text': { \
- 'type':'TextActor', \
- 'text':'Hello', \
- 'font':'Freesans', \
- 'smooth-edge':0.8 \
- } \
- }, \
- 'stage': \
- [ \
- {'name':'txt1', \
- 'type':'TextActor', \
- 'text':'Hello World', \
- 'font':'freesans', \
- 'parent-origin':'CENTER', \
- 'actors': \
- [ \
- { 'type':'basic-text', 'text':'Hello', 'position-y':50 }, \
- { 'type':'basic-text', 'text':'Hello', 'position-y':100 }, \
- { 'type':'basic-text', 'text':'Hello', 'position-y':150 }, \
- { 'type':'basic-text', 'text':'Hello', 'position-y':200 }, \
- { 'type':'basic-text', 'text':'Hello', 'position-y':250 } \
- ] \
- } \
- ] \
-} \
-");
-
std::string ReplaceQuotes(const std::string &in_s)
{
@@ -189,263 +64,6 @@ void builder_cleanup(void)
test_return_value = TET_PASS;
}
-int UtcDaliBuilderTextActorCreate(void)
-{
- ToolkitTestApplication application;
- Stage stage = Stage::GetCurrent();
-
- tet_infoline(" UtcDaliBuilderTextActorCreate");
-
- Builder builder = Builder::New();
-
- builder.LoadFromString(ReplaceQuotes(JSON_TEXT_ACTOR));
-
- TextActor actor( TextActor::DownCast( builder.Create("basic-text") ) );
-
- DALI_TEST_CHECK( actor );
-
- stage.GetRootLayer().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- Vector3 v;
-
- v = actor.GetCurrentPosition();
- DALI_TEST_CHECK(v.x == -10.0);
- DALI_TEST_CHECK(v.y == 10.0);
- DALI_TEST_CHECK(v.z == 0.0);
-
- v = actor.GetCurrentSize();
- DALI_TEST_CHECK(v.x == 150.0);
- DALI_TEST_CHECK(v.y == 170.0);
- DALI_TEST_CHECK(v.z == 1.0);
-
- DALI_TEST_CHECK(actor.GetText() == "Template Hello");
-
- actor = TextActor::DownCast( builder.Create("*(&^") );
- DALI_TEST_CHECK(!actor);
-
- END_TEST;
-}
-
-int UtcDaliBuilderTextActorCreateAnimation(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliBuilderTextActorCreateAnimation");
-
- Builder builder = Builder::New();
-
- builder.LoadFromString(ReplaceQuotes(JSON_TEXT_ACTOR));
-
- builder.AddActors( Stage::GetCurrent().GetRootLayer() );
-
- Animation anim = builder.CreateAnimation("rotate");
- DALI_TEST_CHECK( anim );
-
- DALI_TEST_CHECK( 10.0f == anim.GetDuration() );
-
- END_TEST;
-}
-
-int UtcDaliBuilderTextActorApplyFromStyle(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliBuilderTextActorApplyFromStyle");
-
- Builder builder = Builder::New();
-
- builder.LoadFromString(ReplaceQuotes(JSON_TEXT_ACTOR));
-
- TextActor actor = TextActor::New("a");
-
- builder.ApplyStyle("basic-text", actor);
-
- DALI_TEST_CHECK( actor );
-
- Stage::GetCurrent().GetRootLayer().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- Vector3 v;
-
- v = actor.GetCurrentPosition();
- DALI_TEST_CHECK(v.x == -10.0);
- DALI_TEST_CHECK(v.y == 10.0);
- DALI_TEST_CHECK(v.z == 0.0);
-
- v = actor.GetCurrentSize();
- DALI_TEST_CHECK(v.x == 150.0);
- DALI_TEST_CHECK(v.y == 170.0);
- DALI_TEST_CHECK(v.z == 1.0);
-
- DALI_TEST_CHECK(actor.GetText() == "Hello");
-
- END_TEST;
-}
-
-int UtcDaliBuilderAddActors(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliBuilderAddActors");
-
- Builder builder = Builder::New();
-
- builder.LoadFromString(ReplaceQuotes(JSON_TEXT_ACTOR));
-
- builder.AddActors( Stage::GetCurrent().GetRootLayer() );
-
- application.SendNotification();
- application.Render();
-
- TextActor actor = TextActor::DownCast( Stage::GetCurrent().GetRootLayer().FindChildByName("text") );
-
- DALI_TEST_CHECK( actor );
- DALI_TEST_CHECK(actor.GetText() == "Hello");
-
- END_TEST;
-}
-
-int UtcDaliBuilderAddActorsOther(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliBuilderAddActorsOther");
-
- Actor rootActor = Stage::GetCurrent().GetRootLayer();
-
- Builder builder = Builder::New();
-
- builder.LoadFromString(ReplaceQuotes(JSON_TEXT_ACTOR));
-
- builder.AddActors( "other", rootActor );
-
- application.SendNotification();
- application.Render();
-
- TextActor actor = TextActor::DownCast( Stage::GetCurrent().GetRootLayer().FindChildByName("other-text") );
-
- DALI_TEST_CHECK( actor );
- DALI_TEST_CHECK(actor.GetText() == "Hello");
-
- END_TEST;
-}
-
-
-int UtcDaliBuilderStyles(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliBuilderStyles");
-
- Builder builder = Builder::New();
-
- builder.LoadFromString(ReplaceQuotes(JSON_CORE_ACTOR_TREE));
-
- BaseHandle handle = builder.Create("my-camera");
- CameraActor camera = CameraActor::DownCast(handle);
-
- DALI_TEST_CHECK(camera);
-
- Property::Value v;
-
- v = camera.GetProperty( camera.GetPropertyIndex("field-of-view") );
- DALI_TEST_CHECK( 0.125f == v.Get() );
-
- v = camera.GetProperty( camera.GetPropertyIndex("aspect-ratio") );
- DALI_TEST_CHECK( 5.0f == v.Get() );
-
- handle = builder.Create("basic-text");
- TextActor textActor = TextActor::DownCast(handle);
-
- v = textActor.GetProperty( textActor.GetPropertyIndex("smooth-edge") );
-
- DALI_TEST_CHECK( 0.2f == v.Get() );
-
- // test ApplyStyle another
- builder.ApplyStyle("theme2-text", textActor);
-
- v = textActor.GetProperty( textActor.GetPropertyIndex("smooth-edge") );
- DALI_TEST_CHECK( 0.8f == v.Get() );
-
- END_TEST;
-}
-
-int UtcDaliBuilderSetProperty(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliBuilderSetProperty");
-
- Builder builder = Builder::New();
-
- builder.LoadFromString(ReplaceQuotes(JSON_TEXT_ACTOR));
-
- builder.AddActors( Stage::GetCurrent().GetRootLayer() );
-
- application.SendNotification();
- application.Render();
-
- TextActor actor = TextActor::DownCast( Stage::GetCurrent().GetRootLayer().FindChildByName("text2") );
-
- DALI_TEST_CHECK( actor );
- DALI_TEST_CHECK( actor.GetText() == "Jaylo" );
-
- END_TEST;
-}
-
-int UtcDaliBuilderCreateFromJson(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliBuilderCreateFromJson");
-
- Builder builder = Builder::New();
-
- TextActor actor = TextActor::DownCast( builder.CreateFromJson("foobar") );
-
- DALI_TEST_CHECK( !actor );
-
- actor = TextActor::DownCast(
- builder.CreateFromJson(
- ReplaceQuotes("{'type':'TextActor','text':'Hi'}") ) );
-
- DALI_TEST_CHECK( actor );
-
- DALI_TEST_CHECK( actor.GetText() == "Hi" );
-
- END_TEST;
-}
-
-int UtcDaliBuilderApplyFromJson(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliBuilderApplyFromJson");
-
- Builder builder = Builder::New();
-
- TextActor actor = TextActor::DownCast(
- builder.CreateFromJson(
- ReplaceQuotes("{'type':'TextActor','text':'Hi'}") ) );
-
- DALI_TEST_CHECK( actor );
-
- DALI_TEST_CHECK( actor.GetText() == "Hi" );
-
- DALI_TEST_CHECK( !builder.ApplyFromJson(actor, ReplaceQuotes("foobar") ) );
-
- builder.ApplyFromJson(actor, ReplaceQuotes("{'text':'low'}") );
-
- DALI_TEST_CHECK( actor.GetText() == "low" );
-
- END_TEST;
-}
-
int UtcDaliBuilderQuitSignal(void)
{
ToolkitTestApplication application;
diff --git a/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-NavigationControl.cpp b/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-NavigationControl.cpp
index e3ea205..459f990 100644
--- a/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-NavigationControl.cpp
+++ b/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-NavigationControl.cpp
@@ -327,15 +327,11 @@ int UtcDaliNavigationControlCreateNavigationTitleBar(void)
tet_infoline( "UtcDaliNavigationControlCreateNavigationTitleBar" );
ImageActor background = CreateSolidColorActor( Color::RED );
- TextStyle textStyle;
Stage stage = Stage::GetCurrent();
NavigationControl naviControl = NavigationControl::New();
stage.Add( naviControl );
- Toolkit::NaviTitleBarStyle titleBarStyle( background, textStyle, textStyle, 720, 111, 68, 48, 34, 16, 11, 45, 63, 26, 14, 22 );
- naviControl.CreateNavigationTitleBar( titleBarStyle, titleBarStyle );
-
Page naviItem = Page::New();
PushButton firstControl = PushButton::New();
diff --git a/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-RadioButton.cpp b/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-RadioButton.cpp
index f39ce42..f3ff7b4 100644
--- a/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-RadioButton.cpp
+++ b/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-RadioButton.cpp
@@ -103,17 +103,7 @@ int UtcDaliRadioButtonDownCast(void)
int UtcDaliRadioButtonLabelActor(void)
{
- ToolkitTestApplication application;
-
- TextView actor1 = TextView::New( "test actor 1" );
-
- RadioButton radioButton = RadioButton::New( actor1 );
- DALI_TEST_CHECK( actor1 == radioButton.GetLabel() );
-
- TextView actor2 = TextView::New( "test actor 2" );
- radioButton.SetLabel( actor2 );
- DALI_TEST_CHECK( actor2 == radioButton.GetLabel() );
-
+ // TODO
END_TEST;
}
diff --git a/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-TextInput.cpp b/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-TextInput.cpp
deleted file mode 100644
index 52d91f4..0000000
--- a/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-TextInput.cpp
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright (c) 2014 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
-#include
-#include
-#include
-#include
-
-using namespace Dali;
-using namespace Toolkit;
-
-
-int UtcDaliTextInputSetActiveStyle(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing Setting of Style to newly added text");
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- Stage::GetCurrent().Add(textInput);
-
- const std::string styledString = "Test Stringab" ;
- const std::string plainString = "Test String";
- textInput.SetInitialText( plainString );
-
- application.SendNotification();
- application.Render();
-
- textInput.SetEditable(true);
-
- std::string retreivedMarkupString = textInput.GetMarkupText();
-
- tet_infoline("Confirm markup text is a plain string ");
- DALI_TEST_EQUALS( plainString,textInput.GetText(), TEST_LOCATION);
-
- TextStyle style;
- style.SetItalics( true );
-
- tet_infoline("Apply style to TextInput");
- textInput.SetActiveStyle( style );
-
- Integration::KeyEvent eventA("a", "a", 0, 0, 0, Integration::KeyEvent::Down );
- Integration::KeyEvent eventB("b", "b", 0, 0, 0, Integration::KeyEvent::Down );
-
- application.SendNotification();
- application.Render();
-
- application.ProcessEvent(eventA);
- application.SendNotification();
- application.Render();
-
- application.ProcessEvent(eventB);
- application.SendNotification();
- application.Render();
-
- retreivedMarkupString = textInput.GetMarkupText();
-
- DALI_TEST_EQUALS( styledString, retreivedMarkupString, TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputApplyStyleToSelectedText(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing application of style to selected text ");
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- Stage::GetCurrent().Add(textInput);
-
- const std::string styledString = "Test String to style";
- const std::string plainString = "Test String to style";
- textInput.SetInitialText( plainString );
-
- application.SendNotification();
- application.Render();
-
- textInput.SetEditable(true);
-
- std::string retreivedMarkupString = textInput.GetMarkupText();
-
- tet_infoline("Confirm markup text is a plain string ");
- DALI_TEST_EQUALS( plainString,textInput.GetText(), TEST_LOCATION);
-
- TextStyle style;
- style.SetItalics( true );
-
- textInput.SelectText( 5, 11 );
-
- tet_infoline("Apply style to selected text");
- textInput.ApplyStyle( style );
-
- application.Render();
-
- retreivedMarkupString = textInput.GetMarkupText();
-
- DALI_TEST_EQUALS( styledString, retreivedMarkupString, TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputApplyStyleToAll(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing application of style to all text ");
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- Stage::GetCurrent().Add(textInput);
-
- const std::string styledString = "Test String to style";
- const std::string plainString = "Test String to style";
- textInput.SetInitialText( plainString );
-
- application.SendNotification();
- application.Render();
-
- textInput.SetEditable(true);
-
- std::string retreivedMarkupString = textInput.GetMarkupText();
-
- tet_infoline("Confirm markup text is a plain string ");
- DALI_TEST_EQUALS( plainString,textInput.GetText(), TEST_LOCATION);
-
- TextStyle style;
- style.SetItalics( true );
-
- tet_infoline("Apply style to all text");
- textInput.ApplyStyleToAll( style );
-
- application.Render();
-
- retreivedMarkupString = textInput.GetMarkupText();
-
- DALI_TEST_EQUALS( styledString, retreivedMarkupString, TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputGetStyleAtCursor(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Test getting style at cursor");
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- Stage::GetCurrent().Add(textInput);
-
- const std::string styledString = "Test Stringab" ;
- const std::string plainString = "Test String";
- textInput.SetInitialText( plainString );
-
- application.SendNotification();
- application.Render();
-
- textInput.SetEditable(true);
-
- tet_infoline("Confirm style at cursor is default(plain)");
- TextStyle style;
- Integration::KeyEvent eventA("a", "a", 0, 0, 0, Integration::KeyEvent::Down );
- application.ProcessEvent(eventA);
- application.SendNotification();
- application.Render();
-
- TextStyle retreivedStyleAtCursor = textInput.GetStyleAtCursor();
-
- DALI_TEST_CHECK( style == retreivedStyleAtCursor );
- DALI_TEST_CHECK( !retreivedStyleAtCursor.IsItalicsEnabled() );
-
- tet_infoline("Set style before adding new character");
- style.SetItalics( true );
- textInput.SetActiveStyle( style );
-
- Integration::KeyEvent eventB("b", "b", 0, 0, 0, Integration::KeyEvent::Down );
- application.ProcessEvent(eventB);
- application.SendNotification();
- application.Render();
-
- tet_infoline("Confirm style at cursor is correct style");
- retreivedStyleAtCursor = textInput.GetStyleAtCursor();
-
- DALI_TEST_CHECK( retreivedStyleAtCursor.IsItalicsEnabled() );
-
- tet_infoline("Confirm style at cursor is not a style that was not set");
- DALI_TEST_CHECK( !retreivedStyleAtCursor.IsUnderlineEnabled() );
-
- tet_infoline("Confirm markup text is correct");
- DALI_TEST_EQUALS( styledString, textInput.GetMarkupText(), TEST_LOCATION);
-
-
-
- END_TEST;
-}
-
-int UtcDaliTextInputSetAndGetTextAlignment(void)
-{
- ToolkitTestApplication application;
-
- TextInput textInput = TextInput::New();
- textInput.SetTextAlignment(static_cast( Alignment::HorizontalCenter) );
-
- bool result = ( textInput.GetTextAlignment() & Alignment::HorizontalCenter ) ;
-
- DALI_TEST_CHECK( result );
-
- result = ( textInput.GetTextAlignment() & Alignment::HorizontalRight );
-
- DALI_TEST_CHECK( !result );
- END_TEST;
-}
-
-int UtcDaliTextInputSetAndGetMultilinePolicy(void)
-{
- ToolkitTestApplication application;
-
- const TextView::MultilinePolicy MULTILINE_POLICIES[] = { TextView::SplitByNewLineChar, TextView::SplitByWord, TextView::SplitByChar };
- const unsigned int NUM_MULTILINE_POLICIES = sizeof( MULTILINE_POLICIES ) / sizeof( unsigned int );
-
- TextInput textInput = TextInput::New();
- Stage::GetCurrent().Add(textInput);
- textInput.SetInitialText( "Hello world!" );
-
- for( unsigned int epIndex = 0; epIndex < NUM_MULTILINE_POLICIES; ++epIndex )
- {
- textInput.SetMultilinePolicy( MULTILINE_POLICIES[epIndex] );
-
- DALI_TEST_EQUALS( textInput.GetMultilinePolicy(), MULTILINE_POLICIES[epIndex], TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliTextInputSetAndGetExceedEnabled(void)
-{
- ToolkitTestApplication application;
-
- const TextView::ExceedPolicy EXCEED_POLICIES[] = { TextView::Original, TextView::Fade, TextView::Split, TextView::ShrinkToFit };
- const unsigned int NUM_EXCEED_POLICIES = sizeof( EXCEED_POLICIES ) / sizeof( unsigned int );
-
- TextInput textInput = TextInput::New();
- Stage::GetCurrent().Add(textInput);
- textInput.SetInitialText( "Hello world!" );
-
- for( unsigned int epIndex = 0; epIndex < NUM_EXCEED_POLICIES; ++epIndex )
- {
- textInput.SetWidthExceedPolicy( EXCEED_POLICIES[epIndex] );
-
- DALI_TEST_EQUALS( textInput.GetWidthExceedPolicy(), EXCEED_POLICIES[epIndex], TEST_LOCATION );
- }
- END_TEST;
-}
diff --git a/automated-tests/src/dali-toolkit/CMakeLists.txt b/automated-tests/src/dali-toolkit/CMakeLists.txt
index 0ebd611..47c8ec7 100644
--- a/automated-tests/src/dali-toolkit/CMakeLists.txt
+++ b/automated-tests/src/dali-toolkit/CMakeLists.txt
@@ -20,7 +20,6 @@ SET(TC_SOURCES
utc-Dali-ItemLayout.cpp
utc-Dali-ItemView.cpp
utc-Dali-KeyboardFocusManager.cpp
- utc-Dali-MarkupProcessor.cpp
utc-Dali-MaskEffect.cpp
utc-Dali-NinePatchMaskEffect.cpp
utc-Dali-Popup.cpp
@@ -30,8 +29,6 @@ SET(TC_SOURCES
utc-Dali-ScrollViewEffect.cpp
utc-Dali-SuperBlurView.cpp
utc-Dali-SwirlEffect.cpp
- utc-Dali-TextInput.cpp
- utc-Dali-TextView.cpp
)
# Append list of test harness files (Won't get parsed for test cases)
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h
index 571dde4..43034ac 100644
--- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h
+++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h
@@ -296,41 +296,6 @@ void DALI_TEST_EQUALS( const std::string &str1, const char* str2, const char* lo
void DALI_TEST_EQUALS( const char* str1, const std::string &str2, const char* location);
/**
- * Test whether two UTF32 strings are equal.
- * @param[in] str1 The first string
- * @param[in] str2 The second string
- * @param[in] location The TEST_LOCATION macro should be used here
- */
-template<>
-inline void DALI_TEST_EQUALS( const Integration::TextArray& str1, const Integration::TextArray& str2, const char* location)
-{
- if( !std::equal( str1.Begin(), str1.End(), str2.Begin() ) )
- {
- fprintf(stderr, "%s, checking '", location);
-
- for( unsigned int i = 0; i < str1.Count(); ++i )
- {
- fprintf(stderr, "%c", str1[i]);
- }
-
- fprintf(stderr, "' == '");
-
- for( unsigned int i = 0; i < str2.Count(); ++i )
- {
- fprintf(stderr, "%c", str2[i]);
- }
-
- fprintf(stderr, "'\n");
-
- tet_result(TET_FAIL);
- }
- else
- {
- tet_result(TET_PASS);
- }
-}
-
-/**
* Test whether one unsigned integer value is greater than another.
* Test succeeds if value1 > value2
* @param[in] value1 The first value
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.cpp
index aa1b5b2..a8a47e0 100644
--- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.cpp
+++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.cpp
@@ -80,23 +80,13 @@ void TestPlatformAbstraction::GetClosestImageSize( Integration::ResourcePointer
mTrace.PushCall("GetClosestImageSize", "");
}
-
/**
* @copydoc PlatformAbstraction::LoadResource()
*/
void TestPlatformAbstraction::LoadResource(const Integration::ResourceRequest& request)
{
std::ostringstream out;
- out << "Type:";
- if( request.GetType()->id == Integration::ResourceText )
- {
- out << "Text";
- }
- else
- {
- out << request.GetType()->id;
- }
- out << ", Path: " << request.GetPath() << std::endl ;
+ out << "Type:" << request.GetType()->id << ", Path: " << request.GetPath() << std::endl;
mTrace.PushCall("LoadResource", out.str());
if(mRequest != NULL)
@@ -170,148 +160,6 @@ bool TestPlatformAbstraction::IsLoading()
}
/**
- * @copydoc PlatformAbstraction::GetDefaultFontFamily()
- */
-const std::string& TestPlatformAbstraction::GetDefaultFontFamily() const
-{
- mTrace.PushCall("GetDefaultFontFamily", "");
- return mGetDefaultFontFamilyResult;
-}
-
-/**
- * @copydoc PlatformAbstraction::GetDefaultFontSize()
- */
-float TestPlatformAbstraction::GetDefaultFontSize() const
-{
- mTrace.PushCall("GetDefaultFontSize", "");
- return mGetDefaultFontSizeResult;
-}
-
-PixelSize TestPlatformAbstraction::GetFontLineHeightFromCapsHeight(const std::string& fontFamily, const std::string& fontStyle, CapsHeight capsHeight) const
-{
- mTrace.PushCall("GetFontLineHeightFromCapsHeight", "");
- // LineHeight will be bigger than CapsHeight, so return capsHeight + 1
- return PixelSize(capsHeight + 1);
-}
-
-/**
- * @copydoc PlatformAbstraction::GetGlyphData()
- */
-
-Integration::GlyphSet* TestPlatformAbstraction::GetGlyphData ( const Integration::TextResourceType& textRequest,
- const std::string& fontFamily,
- bool getBitmap) const
-{
- if( getBitmap )
- {
- mTrace.PushCall("GetGlyphData", "getBitmap:true");
- }
- else
- {
- mTrace.PushCall("GetGlyphData", "getBitmap:false");
- }
-
- // It creates fake metrics for the received characters.
-
- Integration::GlyphSet* set = new Dali::Integration::GlyphSet();
- Integration::BitmapPtr bitmapData;
-
- std::set characters;
-
- for( Integration::TextResourceType::CharacterList::const_iterator it = textRequest.mCharacterList.begin(), endIt = textRequest.mCharacterList.end(); it != endIt; ++it )
- {
- if( characters.find( it->character ) == characters.end() )
- {
- characters.insert( it->character );
- Integration::GlyphMetrics character = {it->character, Integration::GlyphMetrics::LOW_QUALITY, 10.0f, 10.0f, 9.0f, 1.0f, 10.0f, it->xPosition, it->yPosition };
-
- if( getBitmap )
- {
- bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD);
- bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, 64, 64);
- PixelBuffer* pixelBuffer = bitmapData->GetBuffer();
- memset( pixelBuffer, it->character, 64*64 );
- }
-
- set->AddCharacter(bitmapData, character);
- }
- }
-
- set->mLineHeight = 10.0f;
- set->mAscender = 9.0f;
- set->mUnitsPerEM = 2048.0f/64.0f;
- set->SetAtlasResourceId( textRequest.mTextureAtlasId );
- set->mFontHash = textRequest.mFontHash;
-
- return set;
-}
-
-/**
- * @copydoc PlatformAbstraction::GetCachedGlyphData()
- */
-
-Integration::GlyphSet* TestPlatformAbstraction::GetCachedGlyphData( const Integration::TextResourceType& textRequest,
- const std::string& fontFamily ) const
-{
- mTrace.PushCall("GetCachedGlyphData", "");
-
- // It creates fake metrics and bitmap for received numeric characters '0' through '9'.
- Integration::GlyphSet* set = new Dali::Integration::GlyphSet();
- Integration::BitmapPtr bitmapData;
-
- std::set characters;
-
- for( Integration::TextResourceType::CharacterList::const_iterator it = textRequest.mCharacterList.begin(), endIt = textRequest.mCharacterList.end(); it != endIt; ++it )
- {
- if( it->character >= '0' && it->character <= '9' && characters.find( it->character ) == characters.end() )
- {
- characters.insert( it->character );
- Integration::GlyphMetrics character = {it->character, Integration::GlyphMetrics::HIGH_QUALITY, 10.0f, 10.0f, 9.0f, 1.0f, 10.0f, it->xPosition, it->yPosition };
-
- bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD);
- bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, 64, 64);
- PixelBuffer* pixelBuffer = bitmapData->GetBuffer();
- memset( pixelBuffer, it->character, 64*64 );
- set->AddCharacter(bitmapData, character);
- }
- }
-
- set->mLineHeight = 10.0f;
- set->mAscender = 9.0f;
- set->mUnitsPerEM = 2048.0f/64.0f;
- set->SetAtlasResourceId( textRequest.mTextureAtlasId );
- set->mFontHash = textRequest.mFontHash;
-
- return set;
-}
-
-
-/**
- * @copydoc PlatformAbstraction::GetGlobalMetrics()
- */
-void TestPlatformAbstraction::GetGlobalMetrics( const std::string& fontFamily,
- const std::string& fontStyle,
- Integration::GlobalMetrics& globalMetrics ) const
-{
- globalMetrics.lineHeight = 10.0f;
- globalMetrics.ascender = 9.0f;
- globalMetrics.unitsPerEM = 2048.0f/64.0f;
- globalMetrics.underlineThickness = 2.f;
- globalMetrics.underlinePosition = 1.f;
-}
-
-/**
- * @copydoc PlatformAbstraction::GetFontPath()
- */
-std::string TestPlatformAbstraction::GetFontPath(const std::string& family, bool bold, bool italic) const
-{
- mTrace.PushCall("GetFontPath", "");
- return mGetFontPathResult;
-
- // Do nothing with arguments
-}
-
-/**
* @copydoc PlatformAbstraction::SetDpi()
*/
void TestPlatformAbstraction::SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical)
@@ -320,42 +168,6 @@ void TestPlatformAbstraction::SetDpi (unsigned int dpiHorizontal, unsigned int d
}
/**
- * @copydoc PlatformAbstraction::GetFontFamilyForChars()
- */
-const std::string& TestPlatformAbstraction::GetFontFamilyForChars(const Integration::TextArray& charsRequested) const
-{
- mTrace.PushCall("GetFontFamilyForChars", "");
- return mGetDefaultFontFamilyResult;
-}
-
-/**
- * @copydoc PlatformAbstraction::AllGlyphsSupported()
- */
-bool TestPlatformAbstraction::AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const Integration::TextArray& text) const
-{
- mTrace.PushCall("AllGlyphsSupported", "");
- return true;
-}
-
-/**
- * @copydoc PlatformAbstraction::ValidateFontFamilyName()
- */
-bool TestPlatformAbstraction::ValidateFontFamilyName(const std::string& fontFamily, const std::string& fontStyle, bool& isDefaultSystemFont, std::string& closestMatch, std::string& closestStyleMatch) const
-{
- mTrace.PushCall("ValidateFontFamilyName", "");
- return true;
-}
-
-/**
- * @copydoc PlatformAbstraction::GetFontList()
- */
-void TestPlatformAbstraction::GetFontList( PlatformAbstraction::FontListMode mode, std::vector& fonstList ) const
-{
- mFontListMode = mode;
- mTrace.PushCall("ValidateGetFontList", "");
-}
-
-/**
* @copydoc PlatformAbstraction::LoadFile()
*/
bool TestPlatformAbstraction::LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const
@@ -383,102 +195,21 @@ void TestPlatformAbstraction::JoinLoaderThreads()
mTrace.PushCall("JoinLoaderThreads", "");
}
-void TestPlatformAbstraction::UpdateDefaultsFromDevice()
-{
- mTrace.PushCall("UpdateDefaultsFromDevice", "");
- mGetDefaultFontFamilyResult+=1.0f;
-}
-
Integration::DynamicsFactory* TestPlatformAbstraction::GetDynamicsFactory()
{
mTrace.PushCall("GetDynamicsFactory", "");
return NULL;
}
-bool TestPlatformAbstraction::ReadGlobalMetricsFromCache( const std::string& fontFamily,
- const std::string& fontStyle,
- Integration::GlobalMetrics& globalMetrics )
-{
- mTrace.PushCall("ReadGlobalMetricsFromCacheFile", "");
- globalMetrics = mReadGlobalMetrics; // Want to copy contents...
- return mReadGlobalMetricsResult; // Default false (will be set to true on subsequent write)
-}
-
-void TestPlatformAbstraction::WriteGlobalMetricsToCache( const std::string& fontFamily,
- const std::string& fontStyle,
- const Integration::GlobalMetrics& globalMetrics )
-{
- // Copy so next read uses written values. TODO: Could add method
- // to turn this behaviour off for more extensive testing.
- mReadGlobalMetrics = globalMetrics;
- mReadGlobalMetricsResult = true;
-
- mTrace.PushCall("WriteGlobalMetricsToCacheFile", "");
-}
-
-bool TestPlatformAbstraction::ReadMetricsFromCache( const std::string& fontFamily,
- const std::string& fontStyle,
- std::vector& glyphMetricsContainer )
-{
- mTrace.PushCall("ReadMetricsFromCacheFile", "");
- glyphMetricsContainer = mReadMetrics;
- return mReadMetricsResult; // Default false (will be set to true on subsequent write)
-}
-
-void TestPlatformAbstraction::WriteMetricsToCache( const std::string& fontFamily,
- const std::string& fontStyle,
- const Integration::GlyphSet& glyphSet )
-{
- // Copy so next read uses written values. TODO: Could add method
- // to turn this behaviour off for more extensive testing.
- const Integration::GlyphSet::CharacterList& charList = glyphSet.GetCharacterList();
- mReadMetrics.clear();
- for(std::size_t i=0, end=charList.size(); i& fileNames )
-{
- fileNames.push_back( std::string( "u1f004.png" ) );
- fileNames.push_back( std::string( "u1f0cf.png" ) );
- fileNames.push_back( std::string( "u1f170.png" ) );
- fileNames.push_back( std::string( "u1f601.png" ) );
-}
-
-
-Integration::BitmapPtr TestPlatformAbstraction::GetGlyphImage( const std::string& fontFamily, const std::string& fontStyle, float fontSize, uint32_t character ) const
-{
- Integration::BitmapPtr image = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
- image->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 1, 1 );
-
- mTrace.PushCall("GetGlyphImage", "");
-
- return image;
-}
-
-
/** Call this every test */
void TestPlatformAbstraction::Initialize()
{
mTrace.Reset();
mTrace.Enable(true);
memset(&mResources, 0, sizeof(Resources));
- memset(&mReadGlobalMetrics, 0, sizeof(Integration::GlobalMetrics));
mSeconds=0;
mMicroSeconds=0;
mIsLoadingResult=false;
- mGetDefaultFontFamilyResult = "HelveticaNeue";
- mGetDefaultFontSizeResult=12.0f;
- mGetFontPathResult="helvetica-12";
- mReadMetricsResult=false;
- mReadGlobalMetricsResult=false;
if(mRequest)
{
@@ -502,24 +233,9 @@ bool TestPlatformAbstraction::WasCalled(TestFuncEnum func)
case CancelLoadFunc: return mTrace.FindMethod("CancelLoad");
case GetResourcesFunc: return mTrace.FindMethod("GetResources");
case IsLoadingFunc: return mTrace.FindMethod("IsLoading");
- case GetDefaultFontFamilyFunc: return mTrace.FindMethod("GetDefaultFontFamily");
- case GetDefaultFontSizeFunc: return mTrace.FindMethod("GetDefaultFontSize");
- case GetFontLineHeightFromCapsHeightFunc: return mTrace.FindMethod("GetFontLineHeightFromCapsHeight");
- case GetGlyphDataFunc: return mTrace.FindMethod("GetGlyphData");
- case GetCachedGlyphDataFunc: return mTrace.FindMethod("GetCachedGlyphData");
- case GetFontPathFunc: return mTrace.FindMethod("GetFontPath");
case SetDpiFunc: return mTrace.FindMethod("SetDpi");
case JoinLoaderThreadsFunc: return mTrace.FindMethod("JoinLoaderThreads");
- case GetFontFamilyForCharsFunc: return mTrace.FindMethod("GetFontFamilyForChars");
- case AllGlyphsSupportedFunc: return mTrace.FindMethod("AllGlyphsSupported");
- case ValidateFontFamilyNameFunc: return mTrace.FindMethod("ValidateFontFamilyName");
- case UpdateDefaultsFromDeviceFunc: return mTrace.FindMethod("UpdateDefaultsFromDevice");
case GetDynamicsFactoryFunc: return mTrace.FindMethod("GetDynamicsFactory");
- case ValidateGetFontListFunc: return mTrace.FindMethod("ValidateGetFontList");
- case ReadGlobalMetricsFromCacheFileFunc: return mTrace.FindMethod("ReadGlobalMetricsFromCacheFile");
- case WriteGlobalMetricsToCacheFileFunc: return mTrace.FindMethod("WriteGlobalMetricsToCacheFile");
- case ReadMetricsFromCacheFileFunc: return mTrace.FindMethod("ReadMetricsFromCacheFile");
- case WriteMetricsToCacheFileFunc: return mTrace.FindMethod("WriteMetricsToCacheFile");
}
return false;
}
@@ -544,21 +260,6 @@ void TestPlatformAbstraction::SetIsLoadingResult(bool result)
mIsLoadingResult = result;
}
-void TestPlatformAbstraction::SetGetDefaultFontFamilyResult(std::string result)
-{
- mGetDefaultFontFamilyResult = result;
-}
-
-void TestPlatformAbstraction::SetGetDefaultFontSizeResult(float result)
-{
- mGetDefaultFontSizeResult = result;
-}
-
-void TestPlatformAbstraction::SetGetFontPathResult(std::string& result)
-{
- mGetFontPathResult = result;
-}
-
void TestPlatformAbstraction::ClearReadyResources()
{
memset(&mResources, 0, sizeof(Resources));
@@ -628,21 +329,4 @@ void TestPlatformAbstraction::SetSaveFileResult( bool result )
mSaveFileResult = result;
}
-Integration::PlatformAbstraction::FontListMode TestPlatformAbstraction::GetLastFontListMode( )
-{
- return mFontListMode;
-}
-
-void TestPlatformAbstraction::SetReadGlobalMetricsResult( bool success, Integration::GlobalMetrics& globalMetrics )
-{
- mReadGlobalMetricsResult = success;
- mReadGlobalMetrics = globalMetrics;
-}
-
-void TestPlatformAbstraction::SetReadMetricsResult( bool success, std::vector& glyphMetricsContainer )
-{
- mReadMetricsResult = success;
- mReadMetrics = glyphMetricsContainer; // copy
-}
-
} // namespace Dali
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.h
index 2d4c38c..afb67bf 100644
--- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.h
+++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.h
@@ -26,7 +26,6 @@
#include
#include
-#include
#include "test-trace-call-stack.h"
@@ -137,71 +136,9 @@ public:
virtual bool IsLoading();
/**
- * @copydoc PlatformAbstraction::GetDefaultFontFamily()
- */
- virtual const std::string& GetDefaultFontFamily() const;
-
- /**
- * @copydoc PlatformAbstraction::GetDefaultFontSize()
- */
- virtual float GetDefaultFontSize() const;
-
- /**
- * @copydoc PlatformAbstraction::GetFontLineHeightFromCapsHeight()
- */
- virtual Dali::PixelSize GetFontLineHeightFromCapsHeight(const std::string& fontFamily, const std::string& fontStyle, CapsHeight capsHeight) const;
-
- /**
- * @copydoc PlatformAbstraction::GetGlyphData()
- */
- virtual Integration::GlyphSet* GetGlyphData ( const Integration::TextResourceType& textRequest,
- const std::string& fontFamily,
- bool getBitmap) const;
-
- /**
- * @copydoc PlatformAbstraction::GetCachedGlyphData()
- */
- virtual Integration::GlyphSet* GetCachedGlyphData( const Integration::TextResourceType& textRequest,
- const std::string& fontFamily ) const;
-
-
- /**
- * @copydoc PlatformAbstraction::GetGlobalMetrics()
- */
- virtual void GetGlobalMetrics( const std::string& fontFamily,
- const std::string& fontStyle,
- Integration::GlobalMetrics& globalMetrics ) const;
-
- /**
- * @copydoc PlatformAbstraction::GetFontPath()
- */
- virtual std::string GetFontPath(const std::string& family, bool bold, bool italic) const;
-
- /**
* @copydoc PlatformAbstraction::SetDpi()
*/
virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical);
-
- /**
- * @copydoc PlatformAbstraction::GetFontFamilyForChars()
- */
- virtual const std::string& GetFontFamilyForChars(const Integration::TextArray& charsRequested) const;
-
- /**
- * @copydoc PlatformAbstraction::AllGlyphsSupported()
- */
- virtual bool AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const Integration::TextArray& text) const;
-
- /**
- * @copydoc PlatformAbstraction::ValidateFontFamilyName()
- */
- virtual bool ValidateFontFamilyName(const std::string& fontFamily, const std::string& fontStyle, bool& isDefaultSystemFont, std::string& closestMatch, std::string& closestStyleMatch) const;
-
- /**
- * @copydoc PlatformAbstraction::GetFontList()
- */
- virtual void GetFontList( PlatformAbstraction::FontListMode mode, std::vector& fontList ) const;
-
/**
* @copydoc PlatformAbstraction::LoadFile()
*/
@@ -214,31 +151,8 @@ public:
virtual void JoinLoaderThreads();
- virtual void UpdateDefaultsFromDevice();
-
virtual Integration::DynamicsFactory* GetDynamicsFactory();
- virtual bool ReadGlobalMetricsFromCache( const std::string& fontFamily,
- const std::string& fontStyle,
- Integration::GlobalMetrics& globalMetrics );
-
- virtual void WriteGlobalMetricsToCache( const std::string& fontFamily,
- const std::string& fontStyle,
- const Integration::GlobalMetrics& globalMetrics );
-
- virtual bool ReadMetricsFromCache( const std::string& fontFamily,
- const std::string& fontStyle,
- std::vector& glyphMetricsContainer );
- virtual void WriteMetricsToCache( const std::string& fontFamily,
- const std::string& fontStyle,
- const Integration::GlyphSet& glyphSet );
-
-
- virtual void GetFileNamesFromDirectory( const std::string& directoryName,
- std::vector& fileNames );
-
- virtual Integration::BitmapPtr GetGlyphImage( const std::string& fontFamily, const std::string& fontStyle, float fontSize, uint32_t character ) const;
-
public: // TEST FUNCTIONS
// Enumeration of Platform Abstraction methods
@@ -254,24 +168,9 @@ public: // TEST FUNCTIONS
CancelLoadFunc,
GetResourcesFunc,
IsLoadingFunc,
- GetDefaultFontFamilyFunc,
- GetDefaultFontSizeFunc,
- GetFontLineHeightFromCapsHeightFunc,
- GetGlyphDataFunc,
- GetCachedGlyphDataFunc,
SetDpiFunc,
- GetFontPathFunc,
JoinLoaderThreadsFunc,
- GetFontFamilyForCharsFunc,
- AllGlyphsSupportedFunc,
- ValidateFontFamilyNameFunc,
- UpdateDefaultsFromDeviceFunc,
GetDynamicsFactoryFunc,
- ValidateGetFontListFunc,
- ReadGlobalMetricsFromCacheFileFunc,
- WriteGlobalMetricsToCacheFileFunc,
- ReadMetricsFromCacheFileFunc,
- WriteMetricsToCacheFileFunc,
} TestFuncEnum;
/** Call this every test */
@@ -320,33 +219,18 @@ public: // TEST FUNCTIONS
void SetSaveFileResult( bool result );
- PlatformAbstraction::FontListMode GetLastFontListMode( );
-
- void SetReadGlobalMetricsResult( bool success, Integration::GlobalMetrics& globalMetrics );
-
- void SetReadMetricsResult( bool success, std::vector& glyphMetricsContainer );
-
-
private:
mutable TraceCallStack mTrace;
size_t mSeconds;
size_t mMicroSeconds;
bool mIsLoadingResult;
- std::string mGetDefaultFontFamilyResult;
- float mGetDefaultFontSizeResult;
- std::string mGetFontPathResult;
Resources mResources;
Integration::ResourceRequest* mRequest;
Vector2 mSize;
Vector2 mClosestSize;
- bool mReadGlobalMetricsResult;
- bool mReadMetricsResult;
- Integration::GlobalMetrics mReadGlobalMetrics;
- std::vector mReadMetrics;
LoadFileResult mLoadFileResult;
bool mSaveFileResult;
- mutable FontListMode mFontListMode;
};
} // Dali
diff --git a/automated-tests/src/dali-toolkit/utc-Dali-MarkupProcessor.cpp b/automated-tests/src/dali-toolkit/utc-Dali-MarkupProcessor.cpp
deleted file mode 100644
index d2317a7..0000000
--- a/automated-tests/src/dali-toolkit/utc-Dali-MarkupProcessor.cpp
+++ /dev/null
@@ -1,398 +0,0 @@
-/*
- * Copyright (c) 2014 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
-#include
-
-// Need to override adaptor classes for toolkit test harness, so include
-// test harness headers before dali headers.
-#include
-
-#include
-#include
-
-using namespace Dali;
-
-void utc_dali_toolkit_markup_processor_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_toolkit_markup_processor_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-namespace
-{
-
-struct MarkupStringTest
-{
- std::string input;
- std::string expectedResult;
-};
-
-bool TestMarkupString( const std::string& input, const std::string& expectedResult, std::string& result )
-{
- Toolkit::MarkupProcessor::StyledTextArray styledTextArray;
-
- GetStyledTextArray( input, styledTextArray, true );
- GetMarkupString( styledTextArray, result );
-
- return expectedResult == result;
-}
-
-} // namespace
-
-
-// Positive test case for a method
-int UtcDaliMarkupProcessor(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliMarkupProcessor ");
-
- const std::string text1( "Text" );
- const std::string text2( "< font face ='FreeSerif' color= 'green' >t< / font >" );
- const std::string text3( "< font face = 'FreeSerif' size= '16' style = 'Bold' color='red'>< i>Styled< / u> Text< /i >< / font >< br / >" );
- const std::string text4( "Styled Text< br/>" );
- const std::string text5( "< shadow color = 'blue' paramx = '1' paramy = '0.75' >Shadow< / shadow>
" );
- const std::string text6( "< glow color = 'red' param = '0.1' >Glow< br />" );
- const std::string text7( "< outline color = 'red' paramx = '0.7' paramy = '0.7' >Outline< / outline >< /font >< br / >" );
- const std::string text8( "Smooth< br / >" );
- const std::string text9( "\\<" );
- const std::string text10( "\\>" );
-
- char crlf[2];
- crlf[0] = 0x0D;
- crlf[1] = 0x0A;
- const std::string text11( crlf, 2 );
-
- const std::string result1( text1 );
- const std::string result2( "t" );
- const std::string result3( "Styled Text
" );
- const std::string result4( "Styled Text
" );
- const std::string result5( "Shadow
" );
- const std::string result6( "Glow
" );
- const std::string result7( "Outline
" );
- const std::string result8( "Smooth
" );
- const std::string result9( text9 );
- const std::string result10( text10 );
- const std::string result11( "
" );
-
- std::string markupString;
- Toolkit::MarkupProcessor::StyledTextArray styledTextArray;
-
- GetStyledTextArray( text1, styledTextArray, true );
- GetMarkupString( styledTextArray, markupString );
- DALI_TEST_EQUALS( result1, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text2, styledTextArray, true );
- GetMarkupString( styledTextArray, markupString );
- DALI_TEST_EQUALS( result2, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text3, styledTextArray, true );
- GetMarkupString( styledTextArray, markupString );
- DALI_TEST_EQUALS( result3, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text4, styledTextArray, true );
- GetMarkupString( styledTextArray, markupString );
- DALI_TEST_EQUALS( result4, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text5, styledTextArray, true );
- GetMarkupString( styledTextArray, markupString );
- DALI_TEST_EQUALS( result5, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text6, styledTextArray, true );
- GetMarkupString( styledTextArray, markupString );
- DALI_TEST_EQUALS( result6, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text7, styledTextArray, true );
- GetMarkupString( styledTextArray, markupString );
- DALI_TEST_EQUALS( result7, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text8, styledTextArray, true );
- GetMarkupString( styledTextArray, markupString );
- DALI_TEST_EQUALS( result8, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text9, styledTextArray, true );
- GetMarkupString( styledTextArray, markupString );
- DALI_TEST_EQUALS( result9, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text10, styledTextArray, true );
- GetMarkupString( styledTextArray, markupString );
-
- DALI_TEST_EQUALS( result10, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text11, styledTextArray, true );
- GetMarkupString( styledTextArray, markupString );
-
- DALI_TEST_EQUALS( result11, markupString, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliMarkupProcessorSetTextStyle01(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliMarkupProcessorSetTextStyle01 ");
-
- const std::string text1( "Text with no defined style" );
- const std::string result1( "Text with no defined style" );
- const std::string result2( "Text with no defined style" );
-
- std::string markupString;
- Toolkit::MarkupProcessor::StyledTextArray styledTextArray;
-
- GetStyledTextArray( text1, styledTextArray, true );
-
- TextStyle style;
- style.SetItalics( true );
- style.SetTextColor( Color::GREEN );
-
- SetTextStyle( styledTextArray, style );
- GetMarkupString( styledTextArray, markupString );
-
- DALI_TEST_EQUALS( result1, markupString, TEST_LOCATION );
-
- styledTextArray.clear();
- SetTextStyle( text1, styledTextArray, style );
- GetMarkupString( styledTextArray, markupString );
-
- DALI_TEST_EQUALS( result1, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text1, styledTextArray, true );
- SetTextStyleToRange( styledTextArray, style, TextStyle::ALL, 0, text1.size() - 1 );
- GetMarkupString( styledTextArray, markupString );
-
- DALI_TEST_EQUALS( result1, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text1, styledTextArray, true );
- SetTextStyleToRange( styledTextArray, style, TextStyle::ALL, 10, 19 );
- GetMarkupString( styledTextArray, markupString );
-
- DALI_TEST_EQUALS( result2, markupString, TEST_LOCATION );
-
- std::string plainString;
- GetPlainString( styledTextArray, plainString );
-
- DALI_TEST_EQUALS( text1, plainString, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliMarkupProcessorSetTextStyle02(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliMarkupProcessorSetTextStyle02 ");
-
- Toolkit::MarkupProcessor::StyledTextArray styledTextArray;
-
- // Test style applied to and empty string doesn't crash
-
- TextStyle style;
- style.SetItalics( true );
- style.SetTextColor( Color::GREEN );
-
- bool fails = false;
- try
- {
- SetTextStyle( styledTextArray, style );
- }
- catch( ... )
- {
- fails = true;
- }
-
- DALI_TEST_CHECK( !fails );
- END_TEST;
-}
-
-int UtcDaliMarkupProcessorTestColors(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliMarkupProcessorTestColors ");
-
- struct MarkupStringTest colorTests[] =
- {
- {
- std::string( "black" ),
- std::string( "black" )
- },
- {
- std::string( "white" ),
- std::string( "white" )
- },
- {
- std::string( "red" ),
- std::string( "red" )
- },
- {
- std::string( "green" ),
- std::string( "green" )
- },
- {
- std::string( "blue" ),
- std::string( "blue" )
- },
- {
- std::string( "yellow" ),
- std::string( "yellow" )
- },
- {
- std::string( "magenta" ),
- std::string( "magenta" )
- },
- {
- std::string( "cyan" ),
- std::string( "cyan" )
- },
- {
- std::string( "transparent" ),
- std::string( "transparent" )
- },
- {
- std::string( "black" ),
- std::string( "black" )
- },
- {
- std::string( "white" ),
- std::string( "white" )
- },
- {
- std::string( "red" ),
- std::string( "red" )
- },
- {
- std::string( "green" ),
- std::string( "green" )
- },
- {
- std::string( "blue" ),
- std::string( "blue" )
- },
- {
- std::string( "yellow" ),
- std::string( "yellow" )
- },
- {
- std::string( "magenta" ),
- std::string( "magenta" )
- },
- {
- std::string( "cyan" ),
- std::string( "cyan" )
- },
- {
- std::string( "black" ),
- std::string( "black" )
- },
- {
- std::string( "white" ),
- std::string( "white" )
- },
- {
- std::string( "red" ),
- std::string( "red" )
- },
- {
- std::string( "green" ),
- std::string( "green" )
- },
- {
- std::string( "blue" ),
- std::string( "blue" )
- },
- {
- std::string( "yellow" ),
- std::string( "yellow" )
- },
- {
- std::string( "magenta" ),
- std::string( "magenta" )
- },
- {
- std::string( "cyan" ),
- std::string( "cyan" )
- },
- {
- std::string( "black" ),
- std::string( "black" )
- },
- {
- std::string( "black" ),
- std::string( "black" )
- },
- {
- std::string( "white" ),
- std::string( "white" )
- },
- {
- std::string( "red" ),
- std::string( "red" )
- },
- {
- std::string( "green" ),
- std::string( "green" )
- },
- {
- std::string( "blue" ),
- std::string( "blue" )
- },
- {
- std::string( "yellow" ),
- std::string( "yellow" )
- },
- {
- std::string( "magenta" ),
- std::string( "magenta" )
- },
- {
- std::string( "cyan" ),
- std::string( "cyan" )
- },
- {
- std::string( "transparent" ),
- std::string( "transparent" )
- },
- {
- std::string( "outline" ),
- std::string( "outline" )
- },
- };
-
- const std::size_t numberOfTests( 36 );
-
- bool fails = false;
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const MarkupStringTest& test = colorTests[index];
-
- std::string result;
- if( !TestMarkupString( test.input, test.expectedResult, result ) )
- {
- TestMarkupString( test.input, test.expectedResult, result );
- tet_printf( "%s\n input : %s\nexpected result : %s\n result : %s\n", TEST_LOCATION, test.input.c_str(), test.expectedResult.c_str(), result.c_str() );
-
- fails = true;
- }
- }
-
- DALI_TEST_CHECK( !fails );
- END_TEST;
-}
diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Popup.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Popup.cpp
index 4374bfa..29fca22 100644
--- a/automated-tests/src/dali-toolkit/utc-Dali-Popup.cpp
+++ b/automated-tests/src/dali-toolkit/utc-Dali-Popup.cpp
@@ -168,7 +168,7 @@ int UtcDaliPopoupSetProperty(void)
//Test properties
std::string testString = "Hello World";
popup.SetProperty(popup.GetPropertyIndex("title"), testString);
- DALI_TEST_EQUALS( testString, popup.GetTitle().GetText(), TEST_LOCATION );
+ DALI_TEST_EQUALS( testString, popup.GetTitle(), TEST_LOCATION );
END_TEST;
}
@@ -191,63 +191,7 @@ int UtcDaliPopupSetBackgroundImage(void)
int UtcDaliPopupSetTitle(void)
{
- ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
- tet_infoline(" UtcDaliPopupSetTitle");
-
- // Create the Popup actor
- Popup popup = Popup::New();
- Stage::GetCurrent().Add( popup );
- // Put in show state so it's layer is connected to popup (for ancestor check).
- popup.SetState(Popup::POPUP_SHOW, 0.0f);
-
- TextView titleActor = TextView::New();
- titleActor.SetText("title");
-
- DALI_TEST_CHECK( !popup.GetTitle() );
- popup.SetTitle(titleActor);
- DALI_TEST_CHECK( popup.GetTitle() == titleActor );
- DALI_TEST_CHECK( (popup.GetTitle()) && (popup.GetTitle().GetText() == "title") );
- // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
- DALI_TEST_CHECK( HasAncestor(titleActor, popup) );
-
- TextView titleActor2 = TextView::New();
- titleActor2.SetText("anothertitle");
- popup.SetTitle(titleActor2);
- DALI_TEST_CHECK( popup.GetTitle() != titleActor );
- DALI_TEST_CHECK( popup.GetTitle() == titleActor2 );
- DALI_TEST_CHECK( (popup.GetTitle()) && (popup.GetTitle().GetText() == "anothertitle") );
- // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
- DALI_TEST_CHECK( HasAncestor(titleActor2, popup) );
- END_TEST;
-}
-
-int UtcDaliPopupSetTitleText(void)
-{
- ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
- tet_infoline(" UtcDaliPopupSetTitleText");
-
- // Create the Popup actor
- Popup popup = Popup::New();
- Stage::GetCurrent().Add( popup );
- // Put in show state so it's layer is connected to popup (for ancestor check).
- popup.SetState(Popup::POPUP_SHOW, 0.0f);
-
- TextView titleActor = TextView::New();
- titleActor.SetText("title");
-
- DALI_TEST_CHECK( !popup.GetTitle() );
- popup.SetTitle(titleActor);
- DALI_TEST_CHECK( popup.GetTitle() == titleActor );
- DALI_TEST_CHECK( (popup.GetTitle()) && (popup.GetTitle().GetText() == "title") );
- // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
- DALI_TEST_CHECK( HasAncestor(titleActor, popup) );
-
- // this text should replace titleImage actor.
- popup.SetTitle("newtext");
- DALI_TEST_CHECK( popup.GetTitle() != titleActor );
- DALI_TEST_CHECK( (popup.GetTitle()) && (popup.GetTitle().GetText() == "newtext") );
- // verify titleActor is no longer inside popup. (been displaced by newtext actor)
- DALI_TEST_CHECK( !HasAncestor(titleActor, popup) );
+ // TODO
END_TEST;
}
diff --git a/automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp b/automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp
index 79c39d7..6e48d4d 100644
--- a/automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp
+++ b/automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp
@@ -420,18 +420,8 @@ int UtcDaliPushButtonSetLabelText(void)
application.SendNotification();
application.Render();
- TextView textView;
-
pushButton.SetLabelText( STR );
- textView = TextView::DownCast( pushButton.GetLabelText() );
- DALI_TEST_CHECK( STR == textView.GetText() );
-
- TextView text = TextView::New( STR );
- pushButton.SetLabelText( text );
-
- textView = TextView::DownCast( pushButton.GetLabelText() );
- DALI_TEST_CHECK( STR == textView.GetText() );
END_TEST;
}
diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextInput.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextInput.cpp
deleted file mode 100644
index 5b56cec..0000000
--- a/automated-tests/src/dali-toolkit/utc-Dali-TextInput.cpp
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- * Copyright (c) 2014 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
-
-#include
-#include
-#include
-#include
-#include
-
-using namespace Dali;
-using namespace Toolkit;
-
-void utc_dali_toolkit_text_input_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_toolkit_text_input_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-namespace
-{
-static bool gObjectCreatedCallBackCalled;
-
-static void TestCallback(BaseHandle handle)
-{
- Actor actor = Actor::DownCast(handle);
-
- if(actor)
- {
- TextInput handle = TextInput::DownCast(actor);
- if (handle)
- {
- gObjectCreatedCallBackCalled = true;
- }
- }
-}
-
-static bool gHasEndSignalBeenReceived;
-static bool gHasStartSignalBeenReceived;
-
-// Callback test function
-void OnStartInput(TextInput textInput)
-{
- gHasStartSignalBeenReceived = true;
-}
-
-// Callback test function
-void OnEndInput(TextInput textInput)
-{
- gHasEndSignalBeenReceived = true;
-}
-
-}
-
-// Positive test case for a method
-int UtcDaliTextInputConstruction(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing New constructor");
-
- TextInput textInput = TextInput::New();
- DALI_TEST_CHECK(textInput);
-
- //Additional check to ensure object is created by checking if it's registered
- ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
- DALI_TEST_CHECK( registry );
-
- gObjectCreatedCallBackCalled = false;
- registry.ObjectCreatedSignal().Connect(&TestCallback);
- {
- TextInput textInput = TextInput::New();
- }
- DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
- END_TEST;
-}
-
-
-static bool downCastToTextInput(Dali::Actor actor)
-{
- TextInput handle = TextInput::DownCast(actor);
- if (handle)
- {
- tet_infoline("Downcasted to TextInput");
- return true;
- }
- else
- {
- tet_infoline("Did not downcast to TextInput");
- return false;
- }
-}
-
-// Positive test case for a method
-int UtcDaliTextInputDownCast(void)
-{
- ToolkitTestApplication application;
-
- TextInput textInput = TextInput::New();
-
- tet_infoline("Testing Downcasting with a TextInput");
- DALI_TEST_EQUALS(true,downCastToTextInput(textInput), TEST_LOCATION); // downcast a TextInput
-
- Dali::TextActor badHandle = Dali::TextActor::New("test");
-
- tet_infoline("Testing Downcasting with the wrong actor");
- DALI_TEST_EQUALS(false, downCastToTextInput(badHandle), TEST_LOCATION); // downcast a TextActor to TextInput
- END_TEST;
-}
-
-// Positive test case for a method
-int UtcDaliTextInputGetText(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing GetText");
-
- const std::string teststring = "test";
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- DALI_TEST_EQUALS("",textInput.GetText(), TEST_LOCATION); // Get text which should be empty
-
- textInput.SetInitialText(teststring);
-
- DALI_TEST_EQUALS(teststring,textInput.GetText(), TEST_LOCATION); // Get text which should be test string
-
- END_TEST;
-}
-
-int UtcDaliTextInputGetMarkupText(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing retrieval of Markup text after style set");
-
- const std::string markup = "Text with italic style" ;
- const std::string teststring = "Text with italic style";
-
- TextInput textInput = TextInput::New();
-
- tet_infoline("Set initial text");
-
- textInput.SetInitialText( teststring );
-
- tet_infoline("Check initial text");
- DALI_TEST_EQUALS( teststring,textInput.GetText(), TEST_LOCATION); // Get text which should be empty
-
- TextStyle style;
- style.SetItalics( true );
-
- tet_infoline("Apply style to TextInput");
- textInput.ApplyStyleToAll( style );
-
- tet_infoline("Retreive Markup Text");
- const std::string retreivedMarkupString = textInput.GetMarkupText();
-
- tet_infoline("Test Retreived text and Markup text match");
- DALI_TEST_EQUALS( retreivedMarkupString , retreivedMarkupString, TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputSetMaxCharacterLength(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing Setting of max characters");
-
- const int maxChars = 4;
- const char* testChar = "v";
-
- TextInput textInput = TextInput::New(); // create empty TextInput
- Stage::GetCurrent().Add(textInput);
- application.SendNotification();
- application.Render();
-
- textInput.SetMaxCharacterLength(maxChars);
-
- Integration::KeyEvent event(testChar, testChar, 0, 0, 0, Integration::KeyEvent::Down );
-
- std::string testString = "";
-
- tet_infoline("Starting editmode");
- textInput.SetEditable( true );
-
- tet_infoline("Sending Key Events");
- // Send max number of characters
- for (int i=0; i < maxChars; i++)
- {
- application.ProcessEvent(event);
- testString.append(testChar);
- }
-
- tet_printf( "Get text result : %s\n", textInput.GetText().c_str());
-
- DALI_TEST_EQUALS(testString, textInput.GetText(), TEST_LOCATION);
-
- tet_infoline("Sending Key Event which exceeds max characters");
-
- application.ProcessEvent(event); // try to append additional character
-
- DALI_TEST_EQUALS(testString,textInput.GetText(), TEST_LOCATION);
-
- tet_infoline("Increase max characters limit");
-
- textInput.SetMaxCharacterLength(maxChars+1); // increment max characters by 1
-
- tet_infoline("Send character again which should now fit");
- application.ProcessEvent(event); // append additional character
- testString.append(testChar);
-
- DALI_TEST_EQUALS(testString,textInput.GetText(), TEST_LOCATION);
- END_TEST;
-}
-
-
-int UtcDaliTextInputSetAndGetNumberOfLines(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Ensuring API for setting and getting max number of lines is correct");
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- unsigned int numberOfLines = 1;
-
- textInput.SetNumberOfLinesLimit( numberOfLines );
-
- DALI_TEST_EQUALS(numberOfLines ,textInput.GetNumberOfLinesLimit(), TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputGetNumberOfCharacters(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing Getting number of characters");
-
- const std::string initialString = "initial text";
- const std::string newInitialString = "initial text new";
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- textInput.SetInitialText( initialString );
-
- tet_infoline("Testing TextInput contains correct number of characters ");
-
- DALI_TEST_EQUALS( initialString.size() , textInput.GetNumberOfCharacters(), TEST_LOCATION);
-
- tet_infoline("Testing TextInput contains correct number of characters second phase ");
-
- textInput.SetInitialText( newInitialString );
-
- DALI_TEST_EQUALS( newInitialString.size() , textInput.GetNumberOfCharacters(), TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputSetAndGetPlaceholderText(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing Setting of PlaceholderText");
-
- const std::string initialString = "initial text";
- const std::string placeholderString = "placeholder";
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- tet_infoline("Testing TextInput is empty at creation ");
-
- DALI_TEST_EQUALS("",textInput.GetText(), TEST_LOCATION);
-
- tet_infoline("Set placeholder text");
-
- textInput.SetPlaceholderText( placeholderString );
-
- tet_infoline("Testing TextInput contains placeholder text");
-
- DALI_TEST_EQUALS( placeholderString , textInput.GetPlaceholderText(), TEST_LOCATION);
-
- tet_infoline("Set initial text which should replace placeholder text");
-
- textInput.SetInitialText( initialString );
-
- tet_infoline("Testing TextInput contains initial text when placeholder text set");
-
- DALI_TEST_EQUALS( initialString,textInput.GetText(), TEST_LOCATION);
- END_TEST;
-}
-
-// Positive test case for a method
-int UtcDaliTextInputSetInitialText(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing Setting of Initial Text");
-
- const std::string teststring = "test";
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- tet_infoline("Testing TextInput is empty at creation ");
-
- DALI_TEST_EQUALS("",textInput.GetText(), TEST_LOCATION);
-
- tet_infoline("Set text to TextInput");
-
- textInput.SetInitialText(teststring);
-
- tet_infoline("Test TextInput contains set text");
-
- DALI_TEST_EQUALS(teststring,textInput.GetText(), TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputSetEditableAndIsEditable(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing SetEditable And IsEditable");
-
- const std::string initialString = "initial text";
-
- TextInput textInput = TextInput::New(); // create empty TextInput
- textInput.SetInitialText( initialString );
-
- Stage::GetCurrent().Add(textInput);
- application.SendNotification();
- application.Render();
-
- bool editableStateFalse ( false );
- bool editableStateTrue ( true );
-
- textInput.SetEditable ( editableStateFalse );
- application.SendNotification();
- application.Render();
- DALI_TEST_EQUALS( editableStateFalse, textInput.IsEditable() , TEST_LOCATION);
-
- textInput.SetEditable ( editableStateTrue );
- application.SendNotification();
- application.Render();
- DALI_TEST_EQUALS( editableStateTrue, textInput.IsEditable() , TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputSetEditOnTouch(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing SetEditOnTouch And IsEditOnTouch");
-
- TextInput textInput = TextInput::New();
-
- bool editableOnTouchOn ( true );
- bool editableOnTouchOff( false );
-
- tet_infoline("Testing SetEditOnTouch disabled");
- textInput.SetEditOnTouch ( editableOnTouchOff );
- DALI_TEST_EQUALS( editableOnTouchOff, textInput.IsEditOnTouch() , TEST_LOCATION);
-
- tet_infoline("Testing SetEditOnTouch enabled");
- textInput.SetEditOnTouch ( editableOnTouchOn );
- DALI_TEST_EQUALS( editableOnTouchOn, textInput.IsEditOnTouch() , TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputSetTextSelectable(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing SetTextSelectable and IsTextSelectable");
-
- const std::string initialString = "initial text";
-
- TextInput textInput = TextInput::New();
- textInput.SetInitialText( initialString );
-
- tet_infoline("Testing SetTextSelectable");
- textInput.SetTextSelectable();
- DALI_TEST_EQUALS( true, textInput.IsTextSelectable() , TEST_LOCATION);
- textInput.SetTextSelectable( false );
- DALI_TEST_EQUALS( false, textInput.IsTextSelectable() , TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputTextSelection(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing Text Selection");
-
- const std::string initialString = "initial text";
-
- TextInput textInput = TextInput::New();
- textInput.SetInitialText( initialString );
-
- Stage::GetCurrent().Add(textInput);
- application.SendNotification();
- application.Render();
-
- textInput.SetEditable( true );
-
- tet_infoline("Testing IsTextSelected negative");
- DALI_TEST_EQUALS( false, textInput.IsTextSelected(), TEST_LOCATION);
-
- textInput.SelectText(1,7);
- DALI_TEST_EQUALS( true, textInput.IsTextSelected(), TEST_LOCATION);
-
- textInput.DeSelectText();
- DALI_TEST_EQUALS( false, textInput.IsTextSelected(), TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputEnableGrabHandleAndIsGrabHandleEnabled(void)
-{
- ToolkitTestApplication application;
-
- TextInput textInput = TextInput::New();
-
- bool grabHandleState = false;
-
- textInput.EnableGrabHandle( grabHandleState );
-
- DALI_TEST_EQUALS( grabHandleState, textInput.IsGrabHandleEnabled(), TEST_LOCATION);
-
- grabHandleState = true;
- textInput.EnableGrabHandle( grabHandleState );
-
- DALI_TEST_EQUALS( grabHandleState, textInput.IsGrabHandleEnabled(), TEST_LOCATION);
-
- END_TEST;
-}
-
-int UtcDaliTextInputSetAndGetBoundingRectangle(void)
-{
- ToolkitTestApplication application;
-
- TextInput textInput = TextInput::New();
-
- Stage::GetCurrent().Add(textInput);
- Vector2 stageSize = Stage::GetCurrent().GetSize();
-
- const Rect boundingRectangle( 100.0f, 100.0f, stageSize.width, stageSize.height );
-
- textInput.SetBoundingRectangle( boundingRectangle );
-
- const Rect retreievedBoundingRectangle = textInput.GetBoundingRectangle();
-
- DALI_TEST_EQUALS( boundingRectangle.x, retreievedBoundingRectangle.x, TEST_LOCATION);
- DALI_TEST_EQUALS( boundingRectangle.y, retreievedBoundingRectangle.y, TEST_LOCATION);
- DALI_TEST_EQUALS( boundingRectangle.width, retreievedBoundingRectangle.width, TEST_LOCATION);
- DALI_TEST_EQUALS( boundingRectangle.height, retreievedBoundingRectangle.height, TEST_LOCATION);
- END_TEST;
-}
-
-
-int UtcDaliTextInputSetAndGetTextAlignment(void)
-{
- ToolkitTestApplication application;
-
- TextInput textInput = TextInput::New();
- Stage::GetCurrent().Add(textInput);
- application.SendNotification();
- application.Render();
-
- textInput.SetTextAlignment(static_cast( Alignment::HorizontalCenter) );
- application.SendNotification();
- application.Render();
-
- DALI_TEST_CHECK( static_cast( Alignment::HorizontalCenter) & textInput.GetTextAlignment()) ;
- END_TEST;
-}
-
-
-int UtcDaliTextInputSetSortModifier(void)
-{
- tet_infoline("Testing SetSortModifier does not cause TextInput failure");
-
- ToolkitTestApplication application;
-
- TextInput textInput = TextInput::New();
-
- const float offsetToUse = 1.5f;
-
- textInput.SetSortModifier( offsetToUse );
-
- DALI_TEST_CHECK( textInput );
- END_TEST;
-}
-
-int UtcDaliTextInputSetAndGetSnapshotModeEnabled(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing SetSnapshotModeEnabled and IsSnapshotModeEnabled");
-
- TextInput textInput = TextInput::New(); // create empty TextInput
- bool snapshotMode( true );
- textInput.SetSnapshotModeEnabled( snapshotMode );
-
- DALI_TEST_EQUALS( snapshotMode, textInput.IsSnapshotModeEnabled(), TEST_LOCATION);
-
- snapshotMode = false;
- textInput.SetSnapshotModeEnabled( snapshotMode );
-
- DALI_TEST_EQUALS( snapshotMode, textInput.IsSnapshotModeEnabled(), TEST_LOCATION);
- END_TEST;
-}
-
-
-int UtcDaliTextInputEndSignalEmit(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing Set editable false emits end signal");
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- Stage::GetCurrent().Add(textInput);
-
- textInput.InputFinishedSignal().Connect( &OnEndInput );
-
- textInput.SetEditable(true) ;
-
- gHasEndSignalBeenReceived = false;
-
- textInput.SetEditable(false) ;
-
- DALI_TEST_EQUALS(true, gHasEndSignalBeenReceived, TEST_LOCATION);
- END_TEST;
-}
-
-
-
-int UtcDaliTextInputStartSignalEmit(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing SetEditable emits start signal");
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- Stage::GetCurrent().Add(textInput);
-
- textInput.InputStartedSignal().Connect( &OnStartInput );
-
- gHasStartSignalBeenReceived = false;
-
- textInput.SetEditable(true); // Set editable first time
-
- DALI_TEST_EQUALS(true, gHasStartSignalBeenReceived, TEST_LOCATION);
-
- gHasStartSignalBeenReceived = false;
-
- textInput.SetEditable(true); // Set editable second time, signal should not be sent again.
-
- DALI_TEST_EQUALS(false, gHasStartSignalBeenReceived, TEST_LOCATION);
-
- textInput.SetEditable(false);
-
- gHasStartSignalBeenReceived = false;
-
- textInput.SetEditable(true); // Set editable again
-
- DALI_TEST_EQUALS(true, gHasStartSignalBeenReceived, TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputExceedMaxCharacters(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing Max characters is obeyed when inputting key events ");
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- Stage::GetCurrent().Add(textInput);
- textInput.SetMaxCharacterLength(4);
- textInput.SetInitialText("");
- textInput.SetEditable(true);
-
- application.SendNotification();
- application.Render();
-
- Integration::KeyEvent eventA("a", "a", 0, 0, 0, Integration::KeyEvent::Down );
- Integration::KeyEvent eventB("b", "b", 0, 0, 0, Integration::KeyEvent::Down );
-
- application.ProcessEvent(eventA);
- application.ProcessEvent(eventB);
- application.ProcessEvent(eventA);
- application.ProcessEvent(eventB);
-
- application.ProcessEvent(eventA);
- application.ProcessEvent(eventB);
-
- tet_printf( "Get text result : %s\n", textInput.GetText().c_str());
-
- DALI_TEST_EQUALS("abab",textInput.GetText(), TEST_LOCATION); // Get text which should be only 4 characters
- END_TEST;
-}
-
-
-
-int UtcDaliTextInputSetAndGetFadeBoundary(void)
-{
- tet_infoline("UtcDaliTextViewSetAndGetFadeBoundary: ");
-
- ToolkitTestApplication application;
-
- TextView::FadeBoundary fadeBoundary( PixelSize( 0 ), PixelSize( 20 ), PixelSize( 0 ), PixelSize( 10 ) );
-
- TextInput textInput = TextInput::New();
- textInput.SetInitialText( "Hello world!" );
-
- Stage::GetCurrent().Add(textInput);
- application.SendNotification();
- application.Render();
-
- textInput.SetFadeBoundary( fadeBoundary );
-
- TextView::FadeBoundary fadeBoundary2 = textInput.GetFadeBoundary();
-
- DALI_TEST_EQUALS( fadeBoundary.mLeft, fadeBoundary2.mLeft, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeBoundary.mRight, fadeBoundary2.mRight, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeBoundary.mTop, fadeBoundary2.mTop, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeBoundary.mBottom, fadeBoundary2.mBottom, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliTextInputSetAndGetWidthExceedPolicy(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextInputSetAndGetWidthExceedPolicy: ");
-
- const TextView::ExceedPolicy EXCEED_POLICIES[] = { TextView::Original, TextView::Fade, TextView::Split, TextView::ShrinkToFit };
- const unsigned int NUM_EXCEED_POLICIES = sizeof( EXCEED_POLICIES ) / sizeof( unsigned int );
-
- TextInput textInput = TextInput::New();
- textInput.SetInitialText( "Hello world!" );
-
- for( unsigned int epIndex = 0; epIndex < NUM_EXCEED_POLICIES; ++epIndex )
- {
- textInput.SetWidthExceedPolicy( EXCEED_POLICIES[epIndex] );
-
- DALI_TEST_EQUALS( textInput.GetWidthExceedPolicy(), EXCEED_POLICIES[epIndex], TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliTextInputSetAndGetHeightExceedPolicy(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextInputSetAndGetHeightExceedPolicy: ");
-
- const TextView::ExceedPolicy EXCEED_POLICIES[] = { TextView::Original, TextView::Fade, TextView::ShrinkToFit };
- const unsigned int NUM_EXCEED_POLICIES = sizeof( EXCEED_POLICIES ) / sizeof( unsigned int );
-
- TextInput textInput = TextInput::New();
- textInput.SetInitialText( "Hello world!" );
-
- for( unsigned int epIndex = 0; epIndex < NUM_EXCEED_POLICIES; ++epIndex )
- {
- textInput.SetHeightExceedPolicy( EXCEED_POLICIES[epIndex] );
-
- DALI_TEST_EQUALS( textInput.GetHeightExceedPolicy(), EXCEED_POLICIES[epIndex], TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliTextInputScroll(void)
-{
- tet_infoline("UtcDaliTextInputScroll: ");
- ToolkitTestApplication application;
-
- // Avoids the frame buffer texture to throw an exception.
- application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
-
- TextInput view = TextInput::New();
- view.SetMultilinePolicy( TextView::SplitByNewLineChar );
- view.SetWidthExceedPolicy( TextView::Original );
- view.SetHeightExceedPolicy( TextView::Original );
- view.SetTextAlignment( static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ) );
- view.SetInitialText( "Hello world! This is a scroll test." );
- view.SetSize( 100.f, 100.f );
- view.SetSnapshotModeEnabled( false );
-
- Stage::GetCurrent().Add( view );
-
- application.SendNotification();
- application.Render();
-
- DALI_TEST_CHECK( !view.IsScrollEnabled() ); // Scroll should be disabled by default.
-
- view.SetScrollEnabled( true );
-
- DALI_TEST_CHECK( view.IsScrollEnabled() );
- DALI_TEST_CHECK( view.IsSnapshotModeEnabled() ); // Scroll should enable snapshot mode.
-
- view.SetScrollPosition( Vector2( 400.f, 400.f ) );
-
- application.SendNotification();
- application.Render();
-
- const Vector2& scrollPosition = view.GetScrollPosition();
- DALI_TEST_EQUALS( scrollPosition, Vector2( 149.153656f, 0.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- END_TEST;
-}
diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextView.cpp
deleted file mode 100644
index 5569d96..0000000
--- a/automated-tests/src/dali-toolkit/utc-Dali-TextView.cpp
+++ /dev/null
@@ -1,823 +0,0 @@
-/*
- * Copyright (c) 2014 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
-#include
-
-// Need to override adaptor classes for toolkit test harness, so include
-// test harness headers before dali headers.
-#include
-
-#include
-#include
-
-using namespace Dali;
-using namespace Toolkit;
-
-void utc_dali_toolkit_text_view_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_toolkit_text_view_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-namespace
-{
-
-const char* const PROPERTY_TEXT = "text";
-const char* const PROPERTY_MULTILINE_POLICY = "multiline-policy";
-const char* const PROPERTY_WIDTH_EXCEED_POLICY = "width-exceed-policy";
-const char* const PROPERTY_HEIGHT_EXCEED_POLICY = "height-exceed-policy";
-const char* const PROPERTY_LINE_JUSTIFICATION = "line-justification";
-const char* const PROPERTY_FADE_BOUNDARY = "fade-boundary";
-const char* const PROPERTY_LINE_HEIGHT_OFFSET = "line-height-offset";
-const char* const PROPERTY_HORIZONTAL_ALIGNMENT = "horizontal-alignment";
-const char* const PROPERTY_VERTICAL_ALIGNMENT = "vertical-alignment";
-
-bool TestEqual( float x, float y )
-{
- return !( fabsf( x - y ) > Math::MACHINE_EPSILON_1000 );
-}
-
-static bool gObjectCreatedCallBackCalled;
-static unsigned int gNumberObjectCreated;
-
-static void TestCallback(BaseHandle handle)
-{
- gObjectCreatedCallBackCalled = true;
- ++gNumberObjectCreated;
-}
-
-static bool gTextScrolled;
-static Vector2 gScrollDelta;
-static void TestTextScrolled( TextView textView, Vector2 scrollDelta )
-{
- gTextScrolled = true;
- gScrollDelta = scrollDelta;
-}
-
-} // namespace
-
-
-int UtcDaliTextViewNew(void)
-{
- tet_infoline("UtcDaliTextViewNew: ");
- ToolkitTestApplication application;
-
- // Test default constructor.
- TextView view;
-
- DALI_TEST_CHECK( !view );
-
- // Test default initialization.
- view = TextView::New();
-
- DALI_TEST_CHECK( view );
-
- // Test copy constructor and asignment operator.
- TextView viewCopy1;
-
- viewCopy1 = view;
-
- DALI_TEST_CHECK( viewCopy1 );
-
- TextView viewCopy2( view );
-
- DALI_TEST_CHECK( viewCopy2 );
-
- // Test down cast.
- Actor actorView;
-
- actorView = view;
-
- TextView downCastView = TextView::DownCast( actorView );
-
- DALI_TEST_CHECK( downCastView );
-
- // Test constructor with a given text.
-
- const std::string text( "Hello world!" );
-
- const float DESCENDER = 8.0f;
-
- TextView view1 = TextView::New( text );
-
- DALI_TEST_EQUALS( view1.GetText(), text, TEST_LOCATION );
-
- MarkupProcessor::StyledTextArray styledText;
- MarkupProcessor::GetStyledTextArray( text, styledText, true );
-
- TextView view2 = TextView::New( styledText );
-
- DALI_TEST_EQUALS( view2.GetText(), text, TEST_LOCATION );
-
- // Check the default Toolkit::TextView::CharacterLayoutInfo::CharacterLayoutInfo() to increase coverage.
- TextView::CharacterLayoutInfo characterLayoutInfo;
-
- DALI_TEST_EQUALS( characterLayoutInfo.mSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mPosition, Vector3::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mIsNewLineChar, false, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mIsRightToLeftCharacter, false, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mIsVisible, true, TEST_LOCATION );
-
- TextView::CharacterLayoutInfo characterLayoutInfo2( Size( 2.f, 2.f ),
- Vector3( 3.f, 4.f, 5.f ),
- true,
- true,
- false,
- DESCENDER );
-
- characterLayoutInfo = characterLayoutInfo2;
-
- DALI_TEST_EQUALS( characterLayoutInfo.mSize, Size( 2.f, 2.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mPosition, Vector3( 3.f, 4.f, 5.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mIsNewLineChar, true, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mIsRightToLeftCharacter, true, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mIsVisible, false, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mDescender, DESCENDER , TEST_LOCATION );
-
-
- TextView::CharacterLayoutInfo characterLayoutInfo3( characterLayoutInfo );
-
- DALI_TEST_EQUALS( characterLayoutInfo3.mSize, Size( 2.f, 2.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo3.mPosition, Vector3( 3.f, 4.f, 5.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo3.mIsNewLineChar, true, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo3.mIsRightToLeftCharacter, true, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo3.mIsVisible, false, TEST_LOCATION );
-
- // Check the default Toolkit::TextView::TextLayoutInfo::TextLayoutInfo() to increase coverage.
-
- TextView::TextLayoutInfo textLayoutInfo;
- DALI_TEST_EQUALS( textLayoutInfo.mCharacterLayoutInfoTable.size(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mCharacterLogicalToVisualMap.size(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mCharacterVisualToLogicalMap.size(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mTextSize, Size::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mScrollOffset, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-
- textLayoutInfo.mCharacterLayoutInfoTable.push_back( characterLayoutInfo );
- textLayoutInfo.mCharacterLogicalToVisualMap.push_back( 1 );
- textLayoutInfo.mCharacterVisualToLogicalMap.push_back( 1 );
- textLayoutInfo.mTextSize = Size( 10.f, 10.f );
- textLayoutInfo.mScrollOffset = Vector2( 5.f, 5.f );
-
- TextView::TextLayoutInfo textLayoutInfo2( textLayoutInfo );
-
- DALI_TEST_EQUALS( textLayoutInfo2.mCharacterLayoutInfoTable.size(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo2.mCharacterLogicalToVisualMap.size(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo2.mCharacterVisualToLogicalMap.size(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo2.mTextSize, Size( 10.f, 10.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo2.mScrollOffset, Vector2( 5.f, 5.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-
- TextView::TextLayoutInfo textLayoutInfo3;
-
- textLayoutInfo3 = textLayoutInfo2;
-
- DALI_TEST_EQUALS( textLayoutInfo3.mCharacterLayoutInfoTable.size(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo3.mCharacterLogicalToVisualMap.size(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo3.mCharacterVisualToLogicalMap.size(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo3.mTextSize, Size( 10.f, 10.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo3.mScrollOffset, Vector2( 5.f, 5.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-
- //Additional check to ensure object is created by checking if it's registered
- ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
- DALI_TEST_CHECK( registry );
-
- gObjectCreatedCallBackCalled = false;
- registry.ObjectCreatedSignal().Connect(&TestCallback);
- {
- TextView view = TextView::New();
- }
- DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
- END_TEST;
-}
-
-int UtcDaliTextViewSetAndGetText(void)
-{
- tet_infoline("UtcDaliTextViewSetAndGetText: ");
- ToolkitTestApplication application;
-
- TextView view = TextView::New();
- view.SetSnapshotModeEnabled( false ); // Disables offscreen rendering.
-
- std::string str( "Text with differing aCeNdEr and dEcEnDeR" );
-
- view.SetText( str );
- DALI_TEST_EQUALS( view.GetText(), str, TEST_LOCATION );
-
- MarkupProcessor::StyledTextArray styledText;
- MarkupProcessor::GetStyledTextArray( str, styledText, true );
-
- view.SetText( styledText );
- DALI_TEST_EQUALS( view.GetText(), str, TEST_LOCATION );
-
- // Test the number of text actor created.
-
- ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
- DALI_TEST_CHECK( registry );
-
- gNumberObjectCreated = 0u;
- registry.ObjectCreatedSignal().Connect(&TestCallback);
-
- // Following string should create three text-actors ([Hel], [lo wo] and [rld]).
- std::string text( "Hello world!\n"
- "\n" );
-
- view.SetMarkupProcessingEnabled( true ); // Enables markup processing.
-
- Stage::GetCurrent().Add( view );
- view.SetText( text );
-
- application.SendNotification();
- application.Render();
-
- DALI_TEST_EQUALS( 3u, gNumberObjectCreated, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliTextViewSetStyleToCurrentText(void)
-{
- tet_infoline("UtcDaliTextViewSetStyleToCurrentText: ");
- ToolkitTestApplication application;
-
- TextStyle style;
- style.SetItalics( true );
-
- const std::string text( "ìì ëìíë¶ ì£¼ì´ì ê²ìê²ì¬ë³¸ë¶\n"
- "ë물방ìë¶ì¥ì ë¨ì¥ì¼ë¡ íë\n"
- "민ê´í©ëì¡°ì¬ë¨ì ì§ëë¬ 30ì¼ë¶í°\n"
- "12ì¼ê°ì íì§ ì¡°ì¬íëì ë§ì¹ê³ \n"
- "11ì¼ ìë²½ ê·êµíìµëë¤." );
- TextView view = TextView::New( text );
-
- bool fail = false;
- try
- {
- view.SetStyleToCurrentText( style );
- }
- catch( ... )
- {
- tet_printf( "Tet case fails\n" );
- fail = true;
- tet_result(TET_FAIL);
- }
-
- DALI_TEST_CHECK( !fail );
- END_TEST;
-}
-
-int UtcDaliTextViewSetAndGetLineHeight(void)
-{
- tet_infoline("UtcDaliTextViewSetAndGetLineHeight: ");
-
- ToolkitTestApplication application;
-
- const float lineHeightOffset( 9.f );
-
- TextView textView = TextView::New();
-
- textView.SetLineHeightOffset( PointSize( lineHeightOffset ) );
-
- DALI_TEST_EQUALS( float(textView.GetLineHeightOffset()), lineHeightOffset, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliTextViewSetAndGetFadeBoundary(void)
-{
- tet_infoline("UtcDaliTextViewSetAndGetFadeBoundary: ");
-
- ToolkitTestApplication application;
-
- TextView::FadeBoundary fadeBoundary( PixelSize( 0 ), PixelSize( 20 ), PixelSize( 0 ), PixelSize( 10 ) );
-
- TextView textView = TextView::New( "Hello world!" );
-
- textView.SetFadeBoundary( fadeBoundary );
-
- TextView::FadeBoundary fadeBoundary2 = textView.GetFadeBoundary();
-
- DALI_TEST_EQUALS( fadeBoundary.mLeft, fadeBoundary2.mLeft, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeBoundary.mRight, fadeBoundary2.mRight, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeBoundary.mTop, fadeBoundary2.mTop, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeBoundary.mBottom, fadeBoundary2.mBottom, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliTextViewSetAndGetEllipsizeText(void)
-{
- tet_infoline("UtcDaliTextViewSetAndGetEllipsizeText: ");
-
- ToolkitTestApplication application;
-
- TextView textView = TextView::New( "Hello world!" );
-
- textView.SetEllipsizeText( std::string( "..." ) );
-
- DALI_TEST_EQUALS( std::string( "..." ), textView.GetEllipsizeText(), TEST_LOCATION );
-
- Toolkit::MarkupProcessor::StyledTextArray styledTextArray;
-
- GetStyledTextArray( std::string( "..." ), styledTextArray, true );
-
- textView.SetEllipsizeText( styledTextArray );
-
- DALI_TEST_EQUALS( std::string( "..." ), textView.GetEllipsizeText(), TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliTextViewSetAndGetWidthExceedPolicy(void)
-{
- tet_infoline("UtcDaliTextViewSetAndGetWidthExceedPolicy: ");
-
- ToolkitTestApplication application;
-
- const TextView::ExceedPolicy EXCEED_POLICIES[] = { TextView::Original, TextView::Fade, TextView::Split, TextView::ShrinkToFit };
- const unsigned int NUM_EXCEED_POLICIES = sizeof( EXCEED_POLICIES ) / sizeof( unsigned int );
-
- TextView textView = TextView::New( "Hello world!" );
-
- for( unsigned int epIndex = 0; epIndex < NUM_EXCEED_POLICIES; ++epIndex )
- {
- textView.SetWidthExceedPolicy( EXCEED_POLICIES[epIndex] );
-
- DALI_TEST_EQUALS( textView.GetWidthExceedPolicy(), EXCEED_POLICIES[epIndex], TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliTextViewSetAndGetHeightExceedPolicy(void)
-{
- tet_infoline("UtcDaliTextViewSetAndGetHeightExceedPolicy: ");
-
- ToolkitTestApplication application;
-
- const TextView::ExceedPolicy EXCEED_POLICIES[] = { TextView::Original, TextView::Fade, TextView::ShrinkToFit };
- const unsigned int NUM_EXCEED_POLICIES = sizeof( EXCEED_POLICIES ) / sizeof( unsigned int );
-
- TextView textView = TextView::New( "Hello world!" );
-
- for( unsigned int epIndex = 0; epIndex < NUM_EXCEED_POLICIES; ++epIndex )
- {
- textView.SetHeightExceedPolicy( EXCEED_POLICIES[epIndex] );
-
- DALI_TEST_EQUALS( textView.GetHeightExceedPolicy(), EXCEED_POLICIES[epIndex], TEST_LOCATION );
- }
- END_TEST;
-}
-
-/*
-// Re-enable this test case when ALL layout options work in TextView, currently this breaks TCT
-// output because too many warnings/errors are printed out
-//int UtcDaliTextViewTestLayoutOptions01(void)
-{
- tet_infoline("UtcDaliTextViewTestLayoutOptions01: ");
-
- ToolkitTestApplication application;
-
- const std::string text( "ìì ëìíë¶ ì£¼ì´ì ê²ìê²ì¬ë³¸ë¶\n"
- "ë물방ìë¶ì¥ì ë¨ì¥ì¼ë¡ íë\n"
- "민ê´í©ëì¡°ì¬ë¨ì ì§ëë¬ 30ì¼ë¶í°\n"
- "12ì¼ê°ì íì§ ì¡°ì¬íëì ë§ì¹ê³ \n"
- "11ì¼ ìë²½ ê·êµíìµëë¤." );
-
- const TextView::MultilinePolicy MULTILINE_POLICIES[] = { TextView::SplitByNewLineChar, TextView::SplitByWord, TextView::SplitByChar };
- const TextView::ExceedPolicy EXCEED_WIDTH_POLICIES[] = { TextView::Original, TextView::Fade, TextView::Split, TextView::ShrinkToFit, TextView::EllipsizeEnd };
- const TextView::ExceedPolicy EXCEED_HEIGHT_POLICIES[] = { TextView::Original, TextView::Fade, TextView::ShrinkToFit };
- const Alignment::Type TEXT_ALIGNMENT[] = { static_cast( Alignment::HorizontalLeft | Alignment::VerticalTop ),
- static_cast( Alignment::HorizontalLeft | Alignment::VerticalCenter ),
- static_cast( Alignment::HorizontalLeft | Alignment::VerticalBottom ),
- static_cast( Alignment::HorizontalCenter | Alignment::VerticalTop ),
- static_cast( Alignment::HorizontalCenter | Alignment::VerticalCenter ),
- static_cast( Alignment::HorizontalCenter | Alignment::VerticalBottom ),
- static_cast( Alignment::HorizontalRight | Alignment::VerticalTop ),
- static_cast( Alignment::HorizontalRight | Alignment::VerticalCenter ),
- static_cast( Alignment::HorizontalRight | Alignment::VerticalBottom ) };
- const TextView::LineJustification LINE_JUSTIFICATION[] = { TextView::Left, TextView::Center, TextView::Right, TextView::Justified };
-
- const unsigned int NUM_MULTILINE_POLICIES = sizeof( MULTILINE_POLICIES ) / sizeof( unsigned int );
- const unsigned int NUM_WIDTH_EXCEED_POLICIES = sizeof( EXCEED_WIDTH_POLICIES ) / sizeof( unsigned int );
- const unsigned int NUM_HEIGHT_EXCEED_POLICIES = sizeof( EXCEED_HEIGHT_POLICIES ) / sizeof( unsigned int );
- const unsigned int NUM_TEXT_ALIGNMENT = sizeof( TEXT_ALIGNMENT ) / sizeof( unsigned int );
- const unsigned int NUM_LINE_JUSTIFICATION = sizeof( LINE_JUSTIFICATION ) / sizeof( unsigned int );
-
- TextView textView = TextView::New( text );
- textView.SetSnapshotModeEnabled( false ); // Disables offscreen rendering.
-
- Stage::GetCurrent().Add( textView );
-
- TextView::TextLayoutInfo textLayoutInfo;
-
- for( unsigned int mlpIndex = 0; mlpIndex < NUM_MULTILINE_POLICIES; ++mlpIndex )
- {
- textView.SetMultilinePolicy( MULTILINE_POLICIES[mlpIndex] );
- for( unsigned int ewpIndex = 0; ewpIndex < NUM_WIDTH_EXCEED_POLICIES; ++ewpIndex )
- {
- textView.SetWidthExceedPolicy( EXCEED_WIDTH_POLICIES[ewpIndex] );
- for( unsigned int ehpIndex = 0; ehpIndex < NUM_HEIGHT_EXCEED_POLICIES; ++ehpIndex )
- {
- textView.SetHeightExceedPolicy( EXCEED_HEIGHT_POLICIES[ehpIndex] );
- for( unsigned int taIndex = 0; taIndex < NUM_TEXT_ALIGNMENT; ++taIndex )
- {
- textView.SetTextAlignment( TEXT_ALIGNMENT[taIndex] );
- for( unsigned int ljIndex = 0; ljIndex < NUM_LINE_JUSTIFICATION; ++ljIndex )
- {
- textView.SetLineJustification( LINE_JUSTIFICATION[ljIndex] );
-
- try
- {
- textView.GetTextLayoutInfo( textLayoutInfo );
-
- application.SendNotification();
- application.Render();
- }
- catch( Dali::DaliException& e )
- {
- DALI_TEST_EQUALS( e.mCondition, "!\"TextView::CombineExceedPolicies() Invalid width and height exceed policies combination\"", TEST_LOCATION );
- }
- catch( ... )
- {
- tet_printf( "Tet case fails\n" );
- tet_printf( " MultilinePolicy : %d\n", MULTILINE_POLICIES[mlpIndex] );
- tet_printf( " Width ExceedPolicy : %d\n", EXCEED_WIDTH_POLICIES[ewpIndex] );
- tet_printf( " Height ExceedPolicy : %d\n", EXCEED_HEIGHT_POLICIES[ehpIndex] );
- tet_printf( " TextAlignment : %d\n", TEXT_ALIGNMENT[taIndex] );
- tet_printf( " LineJustification : %d\n", LINE_JUSTIFICATION[ljIndex] );
- tet_result(TET_FAIL);
- }
-
- DALI_TEST_CHECK( LINE_JUSTIFICATION[ljIndex] == textView.GetLineJustification() );
- }
- DALI_TEST_CHECK( TEXT_ALIGNMENT[taIndex] == textView.GetTextAlignment() );
- }
- DALI_TEST_CHECK( EXCEED_HEIGHT_POLICIES[ehpIndex] == textView.GetHeightExceedPolicy() );
- }
- DALI_TEST_CHECK( EXCEED_WIDTH_POLICIES[ewpIndex] == textView.GetWidthExceedPolicy() );
- }
- DALI_TEST_CHECK( MULTILINE_POLICIES[mlpIndex] == textView.GetMultilinePolicy() );
- }
- END_TEST;
-}
-*/
-
-int UtcDaliTextViewTestLayoutOptions02(void)
-{
- tet_infoline("UtcDaliTextViewTestLayoutOptions02: ");
- ToolkitTestApplication application;
-
- // Check some configurations.
-
- TextView textView = TextView::New();
- textView.SetSnapshotModeEnabled( false ); // Disables offscreen rendering.
- textView.SetMarkupProcessingEnabled( true ); // Enables markup processing.
-
- Stage::GetCurrent().Add( textView );
-
- // SplitByWord and ShrinkToFit.
- // Centered alignment.
- // Centered justification.
- // Don't create a text actor per character.
-
- textView.SetMultilinePolicy( TextView::SplitByWord );
- textView.SetWidthExceedPolicy( TextView::ShrinkToFit );
- textView.SetHeightExceedPolicy( TextView::ShrinkToFit );
- textView.SetTextAlignment( static_cast( Alignment::HorizontalCenter | Alignment::VerticalTop ) );
- textView.SetLineJustification( TextView::Center );
- textView.SetSize( 136.56252f, 100.f );
-
- textView.SetText( "Hello world!" );
-
- application.SendNotification();
- application.Render();
-
- std::vector sizes;
- sizes.push_back( Size( 34.14063f, 11.380210f ) ); //
- sizes.push_back( Size( 56.90105f, 11.380210f ) ); //
- sizes.push_back( Size( 45.52084f, 11.380210f ) ); // By default characters have width and height values of 11.380210.
- // The result should be a line with the text 'Hello world' as shown below.
- std::vector positions; // ____________
- positions.push_back( Vector3( 0.000008f, 11.380209f, 0.f ) ); // |Hello world!|
- positions.push_back( Vector3( 34.14063f, 11.380209f, 0.f ) ); // ------------
- positions.push_back( Vector3( 91.04168f, 11.380209f, 0.f ) ); //
-
- DALI_TEST_CHECK( positions.size() == textView.GetChildCount() ); // Check text has two text-actors.
-
- for( std::size_t index = 0, num = textView.GetChildCount(); index < num; ++index )
- {
- const Vector3& size = textView.GetChildAt(index).GetCurrentSize();
- const Vector3& position = textView.GetChildAt(index).GetCurrentPosition();
-
- DALI_TEST_EQUALS( size.width, sizes[index].width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, sizes[index].height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( position.width, positions[index].width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( position.height, positions[index].height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- }
-
- textView.SetSize( 50.f, 50.f );
- textView.SetTextAlignment( static_cast( Alignment::HorizontalCenter | Alignment::VerticalCenter ) );
- textView.SetSizePolicy( Toolkit::Control::Fixed, Toolkit::Control::Fixed );
- textView.SetLineJustification( Toolkit::TextView::Left );
-
- application.SendNotification();
- application.Render();
-
- sizes.clear();
- sizes.push_back( Size( 24.999999f, 8.333333f ) ); //
- sizes.push_back( Size( 24.999999f, 8.333333f ) ); //
- sizes.push_back( Size( 16.666666f, 8.333333f ) ); // Longest word is 'world!' (6 characters x 11.380210) which doesn't fit in the 50x50 box.
- sizes.push_back( Size( 33.333332f, 8.333333f ) ); // The scale factor is 0.732265339, so the character size is 8.333333.
- // Text should be split in two lines, centered in the vertical dimension and fitted in the horizontal one.
- positions.clear(); // As shown below, the text is two lines and centered in the vertical dimension and
- positions.push_back( Vector3( 0.000008f, 25.223114f, 0.f ) ); // it should start in middle height (~25).
- positions.push_back( Vector3( 24.999999f, 25.223114f, 0.f ) ); // ______
- positions.push_back( Vector3( 0.000006f, 33.556446f, 0.f ) ); // | |
- positions.push_back( Vector3( 16.666666f, 33.556446f, 0.f ) ); // |Hello |
- // |world!|
- // |______|
- //
-
- DALI_TEST_CHECK( positions.size() == textView.GetChildCount() ); // Check text has two text-actors.
-
- for( std::size_t index = 0, num = textView.GetChildCount(); index < num; ++index )
- {
- const Vector3& size = textView.GetChildAt(index).GetCurrentSize();
- const Vector3& position = textView.GetChildAt(index).GetCurrentPosition();
-
- DALI_TEST_EQUALS( size.width, sizes[index].width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, sizes[index].height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( position.width, positions[index].width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( position.height, positions[index].height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- }
-
- // TODO: Add more tests when TextView implementation is finished.
- END_TEST;
-}
-
-int UtcDaliTextViewInsertRemoveText(void)
-{
- tet_infoline("UtcDaliTextViewInsertRemoveText: ");
- ToolkitTestApplication application;
-
- std::string text("Hello ");
-
- MarkupProcessor::StyledTextArray styledText;
- MarkupProcessor::GetStyledTextArray( text, styledText, true );
-
- TextView view = TextView::New( "world!" );
-
- view.InsertTextAt( 0, styledText );
-
- DALI_TEST_EQUALS( view.GetText(), std::string("Hello world!"), TEST_LOCATION );
-
- view.RemoveTextFrom( 4, 5 );
-
- DALI_TEST_EQUALS( view.GetText(), std::string("Hellld!"), TEST_LOCATION );
-
- view.InsertTextAt( 0, "Hello " );
-
- DALI_TEST_EQUALS( view.GetText(), std::string("Hello Hellld!"), TEST_LOCATION );
-
-
- view.InsertTextAt( 0, "Hello " );
- view.InsertTextAt( 0, "Hello " );
- view.InsertTextAt( 0, "Hello " );
- view.InsertTextAt( 0, "Hello " );
- view.RemoveTextFrom( 4, 2 );
- view.RemoveTextFrom( 4, 2 );
- view.RemoveTextFrom( 4, 2 );
- view.RemoveTextFrom( 4, 2 );
- view.RemoveTextFrom( 4, 2 );
- view.SetText( "Hello world!" );
-
- DALI_TEST_EQUALS( view.GetText(), std::string("Hello world!"), TEST_LOCATION );
-
- view.ReplaceTextFromTo( 5, 1, "" );
-
- DALI_TEST_EQUALS( view.GetText(), std::string("Helloworld!"), TEST_LOCATION );
-
- view.ReplaceTextFromTo( 0, 11, styledText );
-
- DALI_TEST_EQUALS( view.GetText(), std::string("Hello "), TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliTextViewSnapshotEnable(void)
-{
- tet_infoline("UtcDaliTextViewSnapshotEnable: ");
- ToolkitTestApplication application;
-
- // Avoids the frame buffer texture to throw an exception.
- application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
-
- TextView view = TextView::New();
- view.SetMarkupProcessingEnabled( true ); // Enables markup processing.
- view.SetText( "Hello world! This is a snapshot test." );
-
- Stage::GetCurrent().Add( view );
-
- view.SetSnapshotModeEnabled( true ); // VCC. By default the snapshot mode should be enabled but it has been temporary disabled.
- // This line should be removed when text-view is set to use the snapshot mode by default.
-
- // Snapshot is enabled by default.
- DALI_TEST_CHECK( view.IsSnapshotModeEnabled() );
-
- application.SendNotification();
- application.Render();
-
- // TextView should have only two actors:
- // the root (Actor) and the image (ImageActor).
-
- DALI_TEST_EQUALS( view.GetChildCount(), 2u, TEST_LOCATION );
-
- view.SetSnapshotModeEnabled( false );
- DALI_TEST_CHECK( !view.IsSnapshotModeEnabled() );
-
- application.SendNotification();
- application.Render();
-
- // TextView should have one text-actor per word.
-
- DALI_TEST_EQUALS( view.GetChildCount(), 7u, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliTextViewScroll(void)
-{
- tet_infoline("UtcDaliTextViewScroll: ");
- ToolkitTestApplication application;
-
- // Avoids the frame buffer texture to throw an exception.
- application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
-
- TextView view = TextView::New( "Hello world! This is a scroll test." );
- view.SetSize( 100.f, 100.f );
- view.SetSnapshotModeEnabled( false );
-
- Stage::GetCurrent().Add( view );
-
- application.SendNotification();
- application.Render();
-
- DALI_TEST_CHECK( !view.IsScrollEnabled() ); // Scroll should be disabled by default.
-
- view.SetScrollEnabled( true );
- view.ScrolledSignal().Connect( &TestTextScrolled );
-
- DALI_TEST_CHECK( view.IsScrollEnabled() );
- DALI_TEST_CHECK( view.IsSnapshotModeEnabled() ); // Scroll should enable snapshot mode.
-
- gTextScrolled = false;
- gScrollDelta = Vector2::ZERO;
- view.SetScrollPosition( Vector2( 400.f, 400.f ) );
-
- application.SendNotification();
- application.Render();
-
- const Vector2& scrollPosition = view.GetScrollPosition();
- DALI_TEST_EQUALS( scrollPosition, Vector2( 149.153656f, 0.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-
- DALI_TEST_CHECK( gTextScrolled );
- DALI_TEST_EQUALS( gScrollDelta, Vector2( 149.153656f, 0.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-
- DALI_TEST_CHECK( view.IsScrollPositionTrimmed() );
- END_TEST;
-}
-
-int UtcDaliTextViewSetProperty(void)
-{
- tet_infoline("UtcDaliTextViewSetAndGetText: ");
- ToolkitTestApplication application;
-
- TextView view = TextView::New( "Hello world!" );
- Stage::GetCurrent().Add( view );
-
- //Test multiline policy property
- view.SetProperty(view.GetPropertyIndex(PROPERTY_MULTILINE_POLICY), "SplitByNewLineChar");
- DALI_TEST_CHECK( Toolkit::TextView::SplitByNewLineChar == view.GetMultilinePolicy() );
-
- view.SetProperty(view.GetPropertyIndex(PROPERTY_MULTILINE_POLICY), "SplitByWord");
- DALI_TEST_CHECK( Toolkit::TextView::SplitByWord == view.GetMultilinePolicy() );
-
- view.SetProperty(view.GetPropertyIndex(PROPERTY_MULTILINE_POLICY), "SplitByChar");
- DALI_TEST_CHECK( Toolkit::TextView::SplitByChar == view.GetMultilinePolicy() );
-
- //Test width exceed policy property
- view.SetProperty(view.GetPropertyIndex(PROPERTY_WIDTH_EXCEED_POLICY), "Original");
- view.SetProperty(view.GetPropertyIndex(PROPERTY_HEIGHT_EXCEED_POLICY), "Original");
- DALI_TEST_CHECK( Toolkit::TextView::Original == view.GetWidthExceedPolicy() );
- DALI_TEST_CHECK( Toolkit::TextView::Original == view.GetHeightExceedPolicy() );
-
- view.SetProperty(view.GetPropertyIndex(PROPERTY_WIDTH_EXCEED_POLICY), "Fade");
- view.SetProperty(view.GetPropertyIndex(PROPERTY_HEIGHT_EXCEED_POLICY), "Fade");
- DALI_TEST_CHECK( Toolkit::TextView::Fade == view.GetWidthExceedPolicy() );
- DALI_TEST_CHECK( Toolkit::TextView::Fade == view.GetHeightExceedPolicy() );
-
- view.SetProperty(view.GetPropertyIndex(PROPERTY_WIDTH_EXCEED_POLICY), "ShrinkToFit");
- view.SetProperty(view.GetPropertyIndex(PROPERTY_HEIGHT_EXCEED_POLICY), "ShrinkToFit");
- DALI_TEST_CHECK( Toolkit::TextView::ShrinkToFit == view.GetWidthExceedPolicy() );
- DALI_TEST_CHECK( Toolkit::TextView::ShrinkToFit == view.GetHeightExceedPolicy() );
-
- //Test line justification property
- view.SetProperty(view.GetPropertyIndex(PROPERTY_LINE_JUSTIFICATION), "Left");
- DALI_TEST_CHECK( Toolkit::TextView::Left == view.GetLineJustification() );
-
- view.SetProperty(view.GetPropertyIndex(PROPERTY_LINE_JUSTIFICATION), "Center");
- DALI_TEST_CHECK( Toolkit::TextView::Center == view.GetLineJustification() );
-
- view.SetProperty(view.GetPropertyIndex(PROPERTY_LINE_JUSTIFICATION), "Right");
- DALI_TEST_CHECK( Toolkit::TextView::Right == view.GetLineJustification() );
-
- view.SetProperty(view.GetPropertyIndex(PROPERTY_LINE_JUSTIFICATION), "Justified");
- DALI_TEST_CHECK( Toolkit::TextView::Justified == view.GetLineJustification() );
-
- //Test fade boundary property
- const Vector4 testValue( 23.f, 26.f, 2.f, 11.f );
-
- view.SetProperty(view.GetPropertyIndex(PROPERTY_FADE_BOUNDARY), testValue);
- DALI_TEST_CHECK( testValue.x == view.GetFadeBoundary().mLeft );
- DALI_TEST_CHECK( testValue.y == view.GetFadeBoundary().mRight );
- DALI_TEST_CHECK( testValue.z == view.GetFadeBoundary().mTop );
- DALI_TEST_CHECK( testValue.w == view.GetFadeBoundary().mBottom );
-
- //Test Line height offset property
- float testOffsetValue = 14.04f;
- view.SetProperty(view.GetPropertyIndex(PROPERTY_LINE_HEIGHT_OFFSET), testOffsetValue);
- DALI_TEST_CHECK( PointSize(testOffsetValue) == view.GetLineHeightOffset() );
-
- //Test alignment property
- view.SetProperty(view.GetPropertyIndex(PROPERTY_HORIZONTAL_ALIGNMENT), "HorizontalLeft");
- view.SetProperty(view.GetPropertyIndex(PROPERTY_VERTICAL_ALIGNMENT), "VerticalTop");
- DALI_TEST_CHECK( (Toolkit::Alignment::HorizontalLeft | Toolkit::Alignment::VerticalTop) == view.GetTextAlignment() );
- END_TEST;
-}
-
-int UtcDaliTextViewSetSortModifier(void)
-{
- tet_infoline("UtcDaliTextViewSetAndGetText: ");
- ToolkitTestApplication application;
-
- TextView view = TextView::New( "Hello world!" );
- Stage::GetCurrent().Add( view );
-
- view.SetSortModifier( 10.f );
- view.SetSnapshotModeEnabled( false );
-
- application.SendNotification();
- application.Render();
-
- DALI_TEST_EQUALS( RenderableActor::DownCast(view.GetChildAt(0)).GetSortModifier(), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliTextViewUnderlineText(void)
-{
- tet_infoline("UtcDaliTextViewUnderlineText: ");
- ToolkitTestApplication application;
-
- TextView textView = TextView::New();
- textView.SetSnapshotModeEnabled( false );
- textView.SetMarkupProcessingEnabled( true );
- textView.SetText( "gggggggggggggg" );
-
- textView.SetSize( 150.f, 100.f );
-
- Stage::GetCurrent().Add( textView );
-
- application.SendNotification();
- application.Render();
-
- std::vector positions;
- positions.push_back( 6.448784f );
- positions.push_back( 9.862847f );
- positions.push_back( 13.276909f );
- positions.push_back( 16.690973f );
- positions.push_back( 13.276909f );
- positions.push_back( 9.862847f );
- positions.push_back( 6.448784f );
-
- for( std::size_t index = 0, num = textView.GetChildCount(); index < num; ++index )
- {
- TextStyle style = TextActor::DownCast( textView.GetChildAt(index) ).GetTextStyle();
-
- DALI_TEST_EQUALS( 4.17274f, style.GetUnderlineThickness(), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( positions[index], style.GetUnderlinePosition(), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- }
- END_TEST;
-}
diff --git a/base/dali-toolkit/internal/controls/buttons/push-button-default-painter-impl.cpp b/base/dali-toolkit/internal/controls/buttons/push-button-default-painter-impl.cpp
index 96587b1..ba6f77d 100644
--- a/base/dali-toolkit/internal/controls/buttons/push-button-default-painter-impl.cpp
+++ b/base/dali-toolkit/internal/controls/buttons/push-button-default-painter-impl.cpp
@@ -26,7 +26,6 @@
// INTERNAL INCLUDES
#include
-#include
#include "push-button-impl.h"
namespace Dali
diff --git a/base/dali-toolkit/internal/controls/buttons/push-button-impl.cpp b/base/dali-toolkit/internal/controls/buttons/push-button-impl.cpp
index 9f8452c..ee89ab9 100644
--- a/base/dali-toolkit/internal/controls/buttons/push-button-impl.cpp
+++ b/base/dali-toolkit/internal/controls/buttons/push-button-impl.cpp
@@ -27,7 +27,6 @@
// INTERNAL INCLUDES
#include "push-button-default-painter-impl.h"
-#include
#include
namespace Dali
@@ -324,9 +323,7 @@ Actor PushButton::GetDimmedImage() const
void PushButton::SetLabelText( const std::string& text )
{
- Toolkit::TextView textView ( Toolkit::TextView::New( text ) );
- textView.SetWidthExceedPolicy( Toolkit::TextView::ShrinkToFit ); // Make sure our text always fits inside the button
- SetLabelText( textView );
+ // TODO
}
void PushButton::SetLabelText( Actor text )
@@ -758,23 +755,6 @@ Vector3 PushButton::GetNaturalSize()
size.height = std::max( size.height, imageSize.height );
}
}
-
- // If label, test against it's size
- Toolkit::TextView textView = Toolkit::TextView::DownCast( mLabel );
- if( textView )
- {
- Vector3 textViewSize = textView.GetNaturalSize();
-
- if( widthIsZero )
- {
- size.width = std::max( size.width, textViewSize.width + TEXT_PADDING * 2.0f );
- }
-
- if( heightIsZero )
- {
- size.height = std::max( size.height, textViewSize.height + TEXT_PADDING * 2.0f );
- }
- }
}
return size;
diff --git a/base/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp b/base/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp
index 94d4ff4..b2254df 100644
--- a/base/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp
+++ b/base/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp
@@ -20,7 +20,6 @@
#include "radio-button-impl.h"
// EXTERNAL INCLUDES
-#include
#include
#include
@@ -85,16 +84,7 @@ RadioButton::~RadioButton()
void RadioButton::SetLabel(const std::string& label)
{
- TextActor textActor = TextActor::DownCast( mLabel );
- if( textActor )
- {
- textActor.SetText( label );
- }
- else
- {
- Toolkit::TextView newTextView = Toolkit::TextView::New( label );
- SetLabel( newTextView );
- }
+ // TODO
RelayoutRequest();
}
diff --git a/base/dali-toolkit/internal/controls/buttons/radio-button-impl.h b/base/dali-toolkit/internal/controls/buttons/radio-button-impl.h
index 26b4364..7685c43 100644
--- a/base/dali-toolkit/internal/controls/buttons/radio-button-impl.h
+++ b/base/dali-toolkit/internal/controls/buttons/radio-button-impl.h
@@ -23,7 +23,6 @@
#include
// INTERNAL INCLUDES
-#include
#include
#include "button-impl.h"
diff --git a/base/dali-toolkit/internal/controls/popup/popup-impl.cpp b/base/dali-toolkit/internal/controls/popup/popup-impl.cpp
index f5179d7..71eadd7 100755
--- a/base/dali-toolkit/internal/controls/popup/popup-impl.cpp
+++ b/base/dali-toolkit/internal/controls/popup/popup-impl.cpp
@@ -297,33 +297,12 @@ void Popup::SetButtonAreaImage( Actor image )
void Popup::SetTitle( const std::string& text )
{
- Toolkit::TextView titleActor = Toolkit::TextView::New();
- titleActor.SetText( text );
- titleActor.SetColor( Color::BLACK );
- titleActor.SetMultilinePolicy( Toolkit::TextView::SplitByWord );
- titleActor.SetWidthExceedPolicy( Toolkit::TextView::Split );
- titleActor.SetLineJustification( Toolkit::TextView::Center );
-
- SetTitle( titleActor );
}
-void Popup::SetTitle( Toolkit::TextView titleActor )
+const std::string& Popup::GetTitle() const
{
- // Replaces the current title actor.
- if( mTitle && mPopupBg )
- {
- mPopupBg.Remove( mTitle );
- }
- mTitle = titleActor;
-
- mPopupBg.Add( mTitle );
-
- RelayoutRequest();
-}
-
-Toolkit::TextView Popup::GetTitle() const
-{
- return mTitle;
+ static std::string temp("");
+ return temp;
}
void Popup::AddButton( Toolkit::Button button )
@@ -721,24 +700,7 @@ void Popup::OnRelaidOut( Vector2 size, ActorSizeContainer& container )
// Relayout title
Vector3 positionOffset( 0.0f, mPopupStyle->margin + POPUP_OUT_MARGIN_WIDTH, CONTENT_DEPTH );
- if( mTitle )
- {
- Vector2 titleSize;
- titleSize.width = popupSize.width;
- titleSize.height = mTitle.GetHeightForWidth( titleSize.width );
-
- // As the default size policy for text-view is Fixed & Fixed, a size needs to be set.
- // Otherwise size-negotiation algorithm uses the GetNaturalSize() with doesn't take
- // into account the multiline and exceed policies, giving as result a wrong size.
- mTitle.SetSize( titleSize );
- Relayout( mTitle, titleSize, container );
-
- mTitle.SetAnchorPoint( AnchorPoint::TOP_CENTER );
- mTitle.SetParentOrigin( ParentOrigin::TOP_CENTER );
- mTitle.SetPosition( positionOffset );
-
- positionOffset.y += titleSize.height + mPopupStyle->margin;
- }
+ // TODO
// Relayout content
if( mContent )
@@ -833,33 +795,9 @@ bool Popup::OnKeyEvent(const KeyEvent& event)
Vector3 Popup::GetNaturalSize()
{
float margin = 2.0f * ( POPUP_OUT_MARGIN_WIDTH + mPopupStyle->margin );
- const float maxWidth = Stage::GetCurrent().GetSize().width - margin;
Vector3 naturalSize( 0.0f, 0.0f, 0.0f );
- if ( mTitle )
- {
- Vector3 titleNaturalSize = mTitle.GetImplementation().GetNaturalSize();
- // Buffer to avoid errors. The width of the popup could potentially be the width of the title text.
- // It was observed in this case that text wrapping was then inconsistent when seen on device
- const float titleBuffer = 0.5f;
- titleNaturalSize.width += titleBuffer;
-
- // As TextView GetNaturalSize does not take wrapping into account, limit the width
- // to that of the stage
- if( titleNaturalSize.width >= maxWidth)
- {
- naturalSize.width = maxWidth;
- naturalSize.height = mTitle.GetImplementation().GetHeightForWidth( naturalSize.width );
- }
- else
- {
- naturalSize += titleNaturalSize;
- }
-
- naturalSize.height += mPopupStyle->margin;
- }
-
if( mContent )
{
Vector3 contentSize = RelayoutHelper::GetNaturalSize( mContent );
@@ -885,12 +823,6 @@ float Popup::GetHeightForWidth( float width )
float height( 0.0f );
float popupWidth( width - 2.f * ( POPUP_OUT_MARGIN_WIDTH + mPopupStyle->margin ) );
- if ( mTitle )
- {
- height += mTitle.GetImplementation().GetHeightForWidth( popupWidth );
- height += mPopupStyle->margin;
- }
-
if( mContent )
{
height += RelayoutHelper::GetHeightForWidth( mContent, popupWidth ) + mPopupStyle->margin;
diff --git a/base/dali-toolkit/internal/controls/popup/popup-impl.h b/base/dali-toolkit/internal/controls/popup/popup-impl.h
index 5adbb43..970ab19 100755
--- a/base/dali-toolkit/internal/controls/popup/popup-impl.h
+++ b/base/dali-toolkit/internal/controls/popup/popup-impl.h
@@ -83,14 +83,9 @@ public:
void SetTitle( const std::string& text );
/**
- * @copydoc Toolkit::Popup::SetTitle( TextView titleActor )
- */
- void SetTitle( Toolkit::TextView titleActor );
-
- /**
* @copydoc Toolkit::Popup::GetTitle
*/
- Toolkit::TextView GetTitle() const;
+ const std::string& GetTitle() const;
/**
* @copydoc Toolkit::Popup::AddButton
@@ -310,7 +305,6 @@ private:
Actor mBackgroundImage; ///< Stores the background image.
Actor mButtonAreaImage; ///< Stores the button background image.
- Toolkit::TextView mTitle; ///< Stores the text title.
Actor mContent; ///< Stores popup's content.
Actor mBottomBg; ///< bottom button bar background. ImageActor is replaced with Actor due to hidden image.
Actor mTailImage; ///< Stores the tail image
diff --git a/base/dali-toolkit/internal/controls/relayout-controller-impl.cpp b/base/dali-toolkit/internal/controls/relayout-controller-impl.cpp
index 2f53b67..0706c0a 100644
--- a/base/dali-toolkit/internal/controls/relayout-controller-impl.cpp
+++ b/base/dali-toolkit/internal/controls/relayout-controller-impl.cpp
@@ -28,9 +28,6 @@
#include
#endif // defined(DEBUG_ENABLED)
-// INTERNAL INCLUDES
-#include
-
namespace Dali
{
diff --git a/base/dali-toolkit/internal/controls/relayout-controller.cpp b/base/dali-toolkit/internal/controls/relayout-controller.cpp
index fa9e70e..41595d4 100644
--- a/base/dali-toolkit/internal/controls/relayout-controller.cpp
+++ b/base/dali-toolkit/internal/controls/relayout-controller.cpp
@@ -30,7 +30,6 @@
#include "dali-toolkit/public-api/controls/control.h"
#include "dali-toolkit/public-api/controls/control-impl.h"
-#include "dali-toolkit/public-api/controls/text-view/text-view.h"
namespace Dali
{
diff --git a/base/dali-toolkit/internal/controls/relayout-helper.cpp b/base/dali-toolkit/internal/controls/relayout-helper.cpp
index 6b0aeb3..d7aab5b 100644
--- a/base/dali-toolkit/internal/controls/relayout-helper.cpp
+++ b/base/dali-toolkit/internal/controls/relayout-helper.cpp
@@ -20,7 +20,6 @@
// EXTERNAL INCLUDES
#include
-#include
// INTERNAL INCLUDES
#include
@@ -60,21 +59,6 @@ Vector3 GetNaturalSize( Actor actor )
Image image = imageActor.GetImage();
size = Vector3( static_cast( image.GetWidth() ), static_cast( image.GetHeight() ), depth );
}
- else
- {
- // Get natural size for TextActor.
- TextActor textActor = TextActor::DownCast( actor );
- if( textActor )
- {
- Font font = textActor.GetFont();
- if( !font )
- {
- font = Font::New();
- }
- size = font.MeasureText( textActor.GetText() );
- size.depth = depth;
- }
- }
}
return size;
@@ -104,22 +88,7 @@ float GetHeightForWidth( Actor actor, float width )
}
else
{
- TextActor textActor = TextActor::DownCast( actor );
- if( textActor )
- {
- Font font = textActor.GetFont();
- if( !font )
- {
- font = Font::New();
- }
- size = font.MeasureText( textActor.GetText() );
-
- constrainSize = true;
- }
- else
- {
- size = actor.GetCurrentSize();
- }
+ size = actor.GetCurrentSize();
}
// Scale the actor
diff --git a/base/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.cpp b/base/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.cpp
deleted file mode 100644
index 9f83898..0000000
--- a/base/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.cpp
+++ /dev/null
@@ -1,1083 +0,0 @@
-/*
- * Copyright (c) 2014 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.
- *
- */
-
-// CLASS HEADER
-#include
-
-// EXTERNAL INCLUDES
-#include
-#include
-#include
-#include
-#include
-
-// INTERNAL INCLUDES
-#include
-
-using namespace Dali;
-
-namespace
-{
-#if defined(DEBUG_ENABLED)
- Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_TEXT_INPUT_DECORATOR");
-#endif
-
-const Vector3 DEFAULT_SELECTION_HANDLE_SIZE( 51.0f, 79.0f, 0.0f );
-const float TOP_HANDLE_TOP_OFFSET(-1.5f); // Offset between top handle and cutCopyPaste pop-up
-const float BOTTOM_HANDLE_BOTTOM_OFFSET(1.5f); // Offset between bottom handle and cutCopyPaste pop-up
-const float UI_Z_OFFSET( 0.2f ); // Text Selection Handles/Cursor z-offset.
-const Vector3 UI_OFFSET(0.0f, 0.0f, UI_Z_OFFSET); // Text Selection Handles/Cursor offset.
-const char* DEFAULT_CURSOR( DALI_IMAGE_DIR "cursor.png" );
-const Vector4 DEFAULT_CURSOR_IMAGE_9_BORDER( 2.0f, 2.0f, 2.0f, 2.0f );
-const std::size_t CURSOR_BLINK_INTERVAL = 500; // Cursor blink interval
-const float CURSOR_THICKNESS(6.0f);
-const Degree CURSOR_ANGLE_OFFSET(2.0f); // Offset from the angle
-
-const unsigned int SCROLL_TICK_INTERVAL = 50u;
-const float SCROLL_THRESHOLD = 10.f;
-const float SCROLL_SPEED = 15.f;
-
-/**
- * Whether the given position plus the cursor size offset is inside the given boundary.
- *
- * @param[in] position The given position.
- * @param[in] cursorSize The cursor size.
- * @param[in] controlSize The given boundary.
- * @param[in] threshold imaginary indent around boundary that will trigger the position to be outside of control.
- *
- * @return whether the given position is inside the given boundary.
- */
-bool IsPositionWithinControl( const Vector3& position, const Size& cursorSize, const Vector3& controlSize, const Vector2 threshold = Vector2::ZERO )
-{
- return ( position.x >= -Math::MACHINE_EPSILON_1000 + threshold.x ) &&
- ( position.x <= controlSize.width - threshold.x + Math::MACHINE_EPSILON_1000 ) &&
- ( position.y - cursorSize.height >= -Math::MACHINE_EPSILON_1000 + threshold.y ) &&
- ( position.y <= controlSize.height + Math::MACHINE_EPSILON_1000 - threshold.y);
-}
-
-}
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-Decorator::Decorator( TextViewCharacterPositioning& textViewManager, TextInputTextStyle& textStyle ):
- mTextViewCharacterPositioning( textViewManager ),
- mTextStyle( textStyle ),
- mSelectionHandleOnePosition(0),
- mSelectionHandleTwoPosition(0),
- mGrabHandlePosition(0),
- mCursorPosition( 0 ),
- mTextHighlight( textViewManager ),
- mCursorBlinkStatus( true ),
- mCursorVisibility( true ),
- mCursorRTLEnabled( false ),
- mIsGrabHandleInScrollArea( false ),
- mIsCursorInScrollArea( false ),
- mGrabHandleVisibility( false ),
- mGrabHandleEnabled( true )
-{
-}
-
-Decorator::~Decorator()
-{
-}
-
-/**
- * Bounding Box
- */
-void Decorator::SetBoundingBox( const Rect& boundingRectangle )
-{
- // Convert to world coordinates and store as a Vector4 to be compatible with Property Notifications.
- Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
-
- const float originX = boundingRectangle.x - 0.5f * stageSize.width;
- const float originY = boundingRectangle.y - 0.5f * stageSize.height;
-
- const Vector4 boundary( originX,
- originY,
- originX + boundingRectangle.width,
- originY + boundingRectangle.height );
-
- mBoundingRectangleWorldCoordinates = boundary;
-}
-
-Vector4 Decorator::GetBoundingBox() const
-{
- return mBoundingRectangleWorldCoordinates;
-}
-
-/**
- * Selection Handles
- */
-void Decorator::OnHandlePan(Actor actor, const PanGesture& gesture)
-{
- Actor selectionHandleOne = mTextInputHandles.GetSelectionHandleOne();
- Actor selectionHandleTwo = mTextInputHandles.GetSelectionHandleTwo();
-
- switch (gesture.state)
- {
- case Gesture::Started:
- // fall through so code not duplicated
- case Gesture::Continuing:
- {
- if ( actor.GetParent() == mTextInputHandles.GetSelectionHandleOne() )
- {
- MoveSelectionHandle( selectionHandleOne, mSelectionHandleOneActualPosition, mSelectionHandleOnePosition, gesture.displacement );
- HidePopUp();
- }
- else if ( actor.GetParent() == mTextInputHandles.GetSelectionHandleTwo() )
- {
- MoveSelectionHandle( selectionHandleTwo, mSelectionHandleTwoActualPosition, mSelectionHandleTwoPosition, gesture.displacement );
- HidePopUp();
- }
- else if ( actor.GetParent() == mTextInputHandles.GetGrabHandle() )
- {
- SetCursorVisibility( true );
- ShowGrabHandle( mGrabHandleVisibility && mIsGrabHandleInScrollArea );
- MoveGrabHandle( gesture.displacement );
- HidePopUp(); // Do not show popup while handle is moving
- }
- }
- break;
-
- case Gesture::Finished:
- {
- // Revert back to non-pressed selection handle images
- if ( actor.GetParent() == mTextInputHandles.GetSelectionHandleOne() )
- {
- mSelectionHandleOneActualPosition = MoveSelectionHandle( selectionHandleOne, mSelectionHandleOneActualPosition, mSelectionHandleOnePosition, gesture.displacement );
- ShowPopupCutCopyPaste();
- }
- else if ( actor.GetParent() == mTextInputHandles.GetSelectionHandleTwo() )
- {
- mSelectionHandleTwoActualPosition = MoveSelectionHandle( selectionHandleTwo, mSelectionHandleTwoActualPosition, mSelectionHandleTwoPosition, gesture.displacement );
- ShowPopupCutCopyPaste();
- }
- else if ( actor.GetParent() == mTextInputHandles.GetGrabHandle() )
- {
- MoveGrabHandle( gesture.displacement );
- SetCursorVisibility( true );
- ShowPopupCutCopyPaste();
- }
- }
- break;
- default:
- break;
- }
-}
-
-void Decorator::CreateSelectionHandles( Actor targetParent )
-{
- if ( !mPanGestureDetector )
- {
- mPanGestureDetector = PanGestureDetector::New();
- mPanGestureDetector.DetectedSignal().Connect(this, &Decorator::OnHandlePan);
- }
-
- if ( !mTextInputHandles.GetSelectionHandleOne() )
- {
- mTextInputHandles.CreateSelectionHandles();
-
- mTextInputHandles.AttachSelectionHandlesToGivenPanGesture( mPanGestureDetector );
-
- targetParent.Add( mTextInputHandles.GetSelectionHandleOne() );
- targetParent.Add( mTextInputHandles.GetSelectionHandleTwo() );
-
- SetUpHandlePropertyNotifications();
- }
-}
-
-void Decorator::RemoveSelectionHandles()
-{
- mTextInputHandles.DestorySelectionHandles();
-}
-
-Vector3 Decorator::GetSelectionHandleSize()
-{
- return DEFAULT_SELECTION_HANDLE_SIZE;
-}
-
-std::size_t Decorator::GetHandleOnePosition() const
-{
- return mSelectionHandleOnePosition;
-}
-
-std::size_t Decorator::GetHandleTwoPosition() const
-{
- return mSelectionHandleTwoPosition;
-}
-
-Vector3 Decorator::PositionSelectionHandle( Actor selectionHandle, std::size_t position )
-{
- bool direction(false);
- Vector3 alternatePosition;
- bool alternatePositionValid(false);
-
- Vector3 actualPositionOfSelectionHandle = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( position, direction, alternatePosition,alternatePositionValid );
-
- return PositionSelectionHandle( selectionHandle, actualPositionOfSelectionHandle, position );
-
-}
-
-Vector3 Decorator::PositionSelectionHandle( Actor selectionHandle, Vector3& actualPosition, std::size_t position )
-{
- const Vector3 DEFAULT_HANDLE_OFFSET(0.0f, -5.0f, 0.0f);
-
- selectionHandle.SetPosition( actualPosition += DEFAULT_HANDLE_OFFSET );
-
- return actualPosition;
-}
-
-void Decorator::SetSelectionHandlesVisibility(bool visible )
-{
- mTextInputHandles.SetSelectionHandleOneVisibility( visible );
- mTextInputHandles.SetSelectionHandleTwoVisibility( visible );
-}
-
-void Decorator::PositionSelectionHandles( std::size_t start, std::size_t end )
-{
- mSelectionHandleOnePosition = start;
- mSelectionHandleTwoPosition = end;
-
- mTextViewCharacterPositioning.UpdateTextLayoutInfo();
-
- mSelectionHandleOneActualPosition = PositionSelectionHandle( mTextInputHandles.GetSelectionHandleOne(), mSelectionHandleOnePosition );
- mSelectionHandleTwoActualPosition = PositionSelectionHandle( mTextInputHandles.GetSelectionHandleTwo(), mSelectionHandleTwoPosition );
-}
-
-Vector3 Decorator::MoveSelectionHandle( Actor selectionHandle,
- Vector3& actualSelectionHandlePosition,
- std::size_t& currentSelectionHandlePosition,
- const Vector2& displacement )
-{
- Vector3 actualHandlePosition;
- actualSelectionHandlePosition.x += displacement.x * selectionHandle.GetCurrentScale().x;
- actualSelectionHandlePosition.y += displacement.y * selectionHandle.GetCurrentScale().y;
-
- // Selection handles should jump to the nearest character
- std::size_t newHandlePosition = 0;
- newHandlePosition = mTextViewCharacterPositioning.ReturnClosestIndex( actualSelectionHandlePosition.GetVectorXY() );
-
- bool direction(false);
- Vector3 alternatePosition;
- bool alternatePositionValid(false);
- actualHandlePosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( newHandlePosition,direction, alternatePosition, alternatePositionValid );
-
- bool handleVisible = true;
-
- if ( handleVisible && // Ensure the handle is visible.
- ( newHandlePosition != currentSelectionHandlePosition ) && // Ensure the handle has moved.
- ( newHandlePosition != mSelectionHandleTwoPosition ) && // Ensure new handle position not the same position as an existing handle.
- ( newHandlePosition != mSelectionHandleOnePosition ) )
- {
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputDecorationLayouter::MoveSelectionHandle Handle visible and moved]\n");
-
- currentSelectionHandlePosition = newHandlePosition;
-
- PositionSelectionHandle( selectionHandle, actualHandlePosition, newHandlePosition );
-
- ShowUpdatedHighlight();
-
- // Set Active Style to that of first character in selection
- std::size_t firstHandleInSelection = std::min( mSelectionHandleOnePosition, mSelectionHandleTwoPosition );
-
- const TextStyle inputStyle = mTextViewCharacterPositioning.GetStyleAt( firstHandleInSelection );
- mTextStyle.SetInputStyle( inputStyle );
- }
- return actualHandlePosition; // Returns Handle position passed in if new value not assigned.
-}
-
-/**
- * GrabHandle
- */
-void Decorator::PositionGrabHandle( std::size_t positionInText )
-{
- bool direction(false);
- Vector3 alternatePosition;
- bool alternatePositionValid(false);
-
- mGrabHandlePosition = positionInText;
-
- mTextViewCharacterPositioning.UpdateTextLayoutInfo();
- mActualGrabHandlePosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( positionInText, direction, alternatePosition,alternatePositionValid );
-
- mTextInputHandles.GetGrabHandle().SetPosition( mActualGrabHandlePosition );
-}
-
-void Decorator::MoveGrabHandle( const Vector2& displacement /*, std::size_t currentHandlePosition */)
-{
- mActualGrabHandlePosition.x += displacement.x;
- mActualGrabHandlePosition.y += displacement.y;
-
- // Grab handle should jump to the nearest character and take cursor with it
- std::size_t newHandlePosition = mTextViewCharacterPositioning.ReturnClosestIndex( mActualGrabHandlePosition.GetVectorXY() );
-
- Vector3 actualHandlePosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( newHandlePosition );
-
- bool handleVisible = true;
-
- if( ( newHandlePosition != mGrabHandlePosition ) && // Only redraw cursor and do updates if position changed
- ( handleVisible ) )// and the new position is visible (if scroll is not enabled, it's always true).
- {
- mActualGrabHandlePosition = actualHandlePosition;
- mTextInputHandles.GetGrabHandle().SetPosition( mActualGrabHandlePosition );
-
- //PositionGrabHandle( newHandlePosition );
- mGrabHandlePosition = newHandlePosition;
- SetCurrentCursorPosition( mGrabHandlePosition );
- DrawCursor( mGrabHandlePosition );
-
- const std::size_t cursorPosition = GetCurrentCursorPosition();
-
- // Let keyboard know the new cursor position so can 're-capture' for prediction.
- mCursorRePositionedSignal.Emit();
-
- // Set Input Style to that of cursor position
- if ( !mTextViewCharacterPositioning.IsStyledTextEmpty() && ( cursorPosition > 0 ) )
- {
- DALI_ASSERT_DEBUG( ( 0 <= cursorPosition-1 ) && ( cursorPosition-1 < mTextViewCharacterPositioning.StyledTextSize() ) );
- }
- }
-}
-
-void Decorator::ShowGrabHandle( bool visible )
-{
- mGrabHandleVisibility = visible;
- mTextInputHandles.SetGrabHandleVisibility( visible );
-}
-
-void Decorator::CreateGrabHandle( Actor targetParent )
-{
- if ( !mPanGestureDetector )
- {
- mPanGestureDetector = PanGestureDetector::New();
- mPanGestureDetector.DetectedSignal().Connect(this, &Decorator::OnHandlePan);
- }
-
- if ( !mTextInputHandles.GetGrabHandle() )
- {
- mTextInputHandles.CreateGrabHandle();
- mTextInputHandles.AttachGrabHandleToGivenPanGesture( mPanGestureDetector );
- targetParent.Add( mTextInputHandles.GetGrabHandle() );
- }
-}
-
-void Decorator::SetGrabHandleImage( Image image )
-{
- mTextInputHandles.SetGrabHandleImage( image );
-}
-
-void Decorator::EnableGrabHandle( bool toggle)
-{
- // enables grab handle with will in turn de-activate magnifier
- mGrabHandleEnabled = toggle;
-}
-
-bool Decorator::IsGrabHandleEnabled()
-{
- // if false then magnifier will be shown instead.
- return mGrabHandleEnabled;
-}
-
-/**
- * Cursor
- */
-std::size_t Decorator::GetCurrentCursorPosition() const
-{
- return mCursorPosition;
-}
-
-void Decorator::SetCurrentCursorPosition( std::size_t newCursorPosition )
-{
- mCursorPosition = newCursorPosition;
-}
-
-void Decorator::SetCursorVisibility( bool visible )
-{
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputDecorationLayouter::SetCursorVisibility[%s]\n", ( visible )?"true":"false");
-
- mCursorVisibility = visible;
- mCursor.SetVisible( mCursorVisibility && mIsCursorInScrollArea );
- mCursorRTL.SetVisible( mCursorVisibility && mCursorRTLEnabled );
-}
-
-void Decorator::DrawCursor(const std::size_t nthChar)
-{
- std::size_t cursorPosition = GetCurrentCursorPosition();
-
- // Get height of cursor and set its size
- Size size( CURSOR_THICKNESS, 0.0f );
-
- Vector2 min, max; // out parameters for GetRowRectFromCharacterPosition
- size.height = mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( mTextViewCharacterPositioning.GetVisualPosition( cursorPosition ), min, max ).height;
-
- mCursor.SetSize(size);
-
- // If the character is italic then the cursor also tilts.
- if ( !mTextViewCharacterPositioning.IsStyledTextEmpty() && ( cursorPosition > 0 ) )
- {
- DALI_ASSERT_DEBUG( ( 0 <= cursorPosition-1 ) && ( cursorPosition-1 < mTextViewCharacterPositioning.StyledTextSize() ) );
- const TextStyle styleAtCursor = mTextViewCharacterPositioning.GetStyleAt( cursorPosition-1 );
- mCursor.SetRotation( styleAtCursor.IsItalicsEnabled() ? Degree( styleAtCursor.GetItalicsAngle() - CURSOR_ANGLE_OFFSET ) : Degree( 0.f ), Vector3::ZAXIS );
- }
-
- DALI_ASSERT_DEBUG( cursorPosition <= mTextViewCharacterPositioning.GetNumberOfCharactersInText() );
- if ( ( cursorPosition <= mTextViewCharacterPositioning.GetNumberOfCharactersInText() ) )
- {
- Vector3 altPosition; // Alternate (i.e. opposite direction) cursor position.
- bool altPositionValid( false ); // Alternate cursor validity flag.
- bool directionRTL( false ); // Need to know direction of primary cursor (in case we have 2 cursors and need to show them differently)
- Vector3 position = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( cursorPosition, directionRTL, altPosition, altPositionValid );
-
- SetAltCursorEnabled( altPositionValid );
-
- mCursor.SetPosition( position + UI_OFFSET );
- }
-}
-
-void Decorator::SetAltCursorEnabled( bool enabled )
-{
- mCursorRTLEnabled = enabled;
- mCursorRTL.SetVisible( mCursorVisibility && mCursorRTLEnabled );
-}
-
-void Decorator::SetCursorImage(Dali::Image image, const Vector4& border )
-{
- DALI_ASSERT_DEBUG ( image && "Create cursor image invalid")
-
- if ( image )
- {
- mCursor.SetImage( image );
- mCursor.SetNinePatchBorder( border );
- }
-}
-
-void Decorator::SetRTLCursorImage( Image image, const Vector4& border )
-{
- DALI_ASSERT_DEBUG ( image && "Create cursor image invalid")
-
- if ( image )
- {
- mCursorRTL.SetImage( image );
- mCursorRTL.SetNinePatchBorder( border );
- }
-}
-
-ImageActor Decorator::CreateCursor( Image cursorImage, const Vector4& border, const std::string& cursorName )
-{
- ImageActor cursor;
-
- if ( cursorImage )
- {
- cursor = ImageActor::New( cursorImage );
- }
- else
- {
- cursor = ImageActor::New( Image::New( DEFAULT_CURSOR ) );
- }
-
- cursor.SetStyle(ImageActor::STYLE_NINE_PATCH);
- cursor.SetNinePatchBorder( border );
- cursor.SetAnchorPoint(AnchorPoint::BOTTOM_CENTER);
- cursor.SetVisible(false);
- cursor.SetName( cursorName );
- return cursor;
-}
-
-void Decorator::CreateCursors( Actor targetParent )
-{
- Image mCursorImage = Image::New( DEFAULT_CURSOR );
- mCursor = CreateCursor (mCursorImage, DEFAULT_CURSOR_IMAGE_9_BORDER , "mainCursor");
- mCursorRTL = CreateCursor ( mCursorImage, DEFAULT_CURSOR_IMAGE_9_BORDER, "rtlCursor");
- targetParent.Add( mCursor );
- targetParent.Add( mCursorRTL );
-}
-
-Size Decorator::GetCursorSizeAt( std::size_t positionWithinTextToGetCursorSize )
-{
- std::size_t visualPosition = mTextViewCharacterPositioning.GetVisualPosition( positionWithinTextToGetCursorSize );
-
- Vector2 min, max;
-
- const Size cursorSize( CURSOR_THICKNESS,
- mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( visualPosition, min, max ).height );
-
- return cursorSize;
-}
-
-void Decorator::StartCursorBlinkTimer()
-{
- if ( !mCursorBlinkTimer )
- {
- mCursorBlinkTimer = Timer::New( CURSOR_BLINK_INTERVAL );
- mCursorBlinkTimer.TickSignal().Connect( this, &Decorator::OnCursorBlinkTimerTick );
- }
-
- if ( !mCursorBlinkTimer.IsRunning() )
- {
- mCursorBlinkTimer.Start();
- }
-}
-
-void Decorator::StopCursorBlinkTimer()
-{
- if ( mCursorBlinkTimer )
- {
- mCursorBlinkTimer.Stop();
- }
-}
-
-bool Decorator::OnCursorBlinkTimerTick()
-{
- // Cursor blinking
- mCursor.SetVisible( mCursorVisibility && mIsCursorInScrollArea && mCursorBlinkStatus );
- if ( mCursorRTLEnabled )
- {
- mCursorRTL.SetVisible( mCursorVisibility && mIsCursorInScrollArea && mCursorBlinkStatus );
- }
- mCursorBlinkStatus = !mCursorBlinkStatus;
-
- return true;
-}
-
-/**
- * Highlight
- */
-void Decorator::ShowUpdatedHighlight()
-{
- Toolkit::TextView::TextLayoutInfo textLayoutInfo = mTextViewCharacterPositioning.GetLayoutInfo();
- TextHighlight::HighlightInfo highlightInfo = mTextHighlight.CalculateHighlightInfo( mSelectionHandleOnePosition, mSelectionHandleTwoPosition, textLayoutInfo );
-
- // Clamp highlightInfo so they don't exceed the boundary of the control.
- const Vector3& controlSize = mTextViewCharacterPositioning.GetTextView().GetCurrentSize();
- highlightInfo.Clamp2D( Vector2::ZERO, Vector2(controlSize.x, controlSize.y) );
-
- mTextHighlight.UpdateHighlight( highlightInfo );
-}
-
-void Decorator::CreateHighlight( Actor parent )
-{
- DALI_ASSERT_DEBUG( parent && "Highlight target parent does not exist" );
-
- if ( !mHighlightMeshActor )
- {
- mHighlightMeshActor = MeshActor::New( mTextHighlight.CreateHighLightMesh() );
- mHighlightMeshActor.SetName( "HighlightMeshActor" );
- mHighlightMeshActor.SetAffectedByLighting(false);
- parent.Add( mHighlightMeshActor );
- }
-}
-
-void Decorator::RemoveHighlight()
-{
- if ( mHighlightMeshActor )
- {
- mHighlightMeshActor.Unparent();
- mHighlightMeshActor.Reset();
- // NOTE: We cannot dereference mHighlightMesh, due to a how the scene-graph MeshRenderer uses the Mesh data.
- }
-}
-
-void Decorator::HighlightVisibility( bool visiblility )
-{
- if ( mHighlightMeshActor )
- {
- mHighlightMeshActor.SetVisible( visiblility );
- }
-}
-
-/**
- * Callbacks connected to be Property notifications for Boundary checking.
- */
-// Note If PropertyNotification signal definition included Actor we would not need to duplicate functions.
-void Decorator::OnHandleOneLeavesBoundary( PropertyNotification& source)
-{
- mTextInputHandles.GetSelectionHandleOne().SetOpacity(0.0f);
-}
-
-void Decorator::OnHandleOneWithinBoundary(PropertyNotification& source)
-{
- mTextInputHandles.GetSelectionHandleOne().SetOpacity(1.0f);
-}
-
-void Decorator::OnHandleTwoLeavesBoundary( PropertyNotification& source)
-{
- mTextInputHandles.GetSelectionHandleTwo().SetOpacity(0.0f);
-}
-
-void Decorator::OnHandleTwoWithinBoundary(PropertyNotification& source)
-{
- mTextInputHandles.GetSelectionHandleTwo().SetOpacity(1.0f);
-}
-
-void Decorator::OnLeftBoundaryExceeded(PropertyNotification& source)
-{
- DALI_LOG_INFO(gLogFilter, Debug::General, "TextInputDecorationLayouter::OnLeftBoundaryExceeded\n");
- Actor selectionHandleOne = mTextInputHandles.GetSelectionHandleOne();
- selectionHandleOne.SetScale( -1.0f, 1.0f, 1.0f );
- selectionHandleOne.SetAnchorPoint( AnchorPoint::TOP_LEFT);
-}
-
-void Decorator::OnReturnToLeftBoundary(PropertyNotification& source)
-{
- DALI_LOG_INFO(gLogFilter, Debug::General, "TextInputDecorationLayouter::OnReturnToLeftBoundary\n");
- Actor selectionHandleOne = mTextInputHandles.GetSelectionHandleOne();
- selectionHandleOne.SetScale( 1.0f, 1.0f, 1.0f );
- selectionHandleOne.SetAnchorPoint( AnchorPoint::TOP_RIGHT);
-}
-
-void Decorator::OnRightBoundaryExceeded(PropertyNotification& source)
-{
- Actor selectionHandleTwo = mTextInputHandles.GetSelectionHandleTwo();
- selectionHandleTwo.SetScale( -1.0f, 1.0f, 1.0f );
- selectionHandleTwo.SetAnchorPoint( AnchorPoint::TOP_RIGHT);
-}
-
-void Decorator::OnReturnToRightBoundary(PropertyNotification& source)
-{
- Actor selectionHandleTwo = mTextInputHandles.GetSelectionHandleTwo();
- selectionHandleTwo.SetScale( 1.0f, 1.0f, 1.0f );
- selectionHandleTwo.SetAnchorPoint( AnchorPoint::TOP_LEFT);
-}
-
-void Decorator::SetUpHandlePropertyNotifications()
-{
- /* Property notifications for handles exceeding the boundary and returning back within boundary */
-
- Vector3 handlesize = GetSelectionHandleSize();
-
- Actor selectionHandleOne = mTextInputHandles.GetSelectionHandleOne();
- Actor selectionHandleTwo = mTextInputHandles.GetSelectionHandleTwo();
-
- // Exceeding horizontal boundary
- PropertyNotification leftNotification = selectionHandleOne.AddPropertyNotification( Actor::WORLD_POSITION_X, LessThanCondition( mBoundingRectangleWorldCoordinates.x + handlesize.x) );
- leftNotification.NotifySignal().Connect( this, &Decorator::OnLeftBoundaryExceeded );
-
- PropertyNotification rightNotification = selectionHandleTwo.AddPropertyNotification( Actor::WORLD_POSITION_X, GreaterThanCondition( mBoundingRectangleWorldCoordinates.z - handlesize.x ) );
- rightNotification.NotifySignal().Connect( this, &Decorator::OnRightBoundaryExceeded );
-
- // Within horizontal boundary
- PropertyNotification leftLeaveNotification = selectionHandleOne.AddPropertyNotification( Actor::WORLD_POSITION_X, GreaterThanCondition( mBoundingRectangleWorldCoordinates.x + 2*handlesize.x ) );
- leftLeaveNotification.NotifySignal().Connect( this, &Decorator::OnReturnToLeftBoundary );
-
- PropertyNotification rightLeaveNotification = selectionHandleTwo.AddPropertyNotification( Actor::WORLD_POSITION_X, LessThanCondition( mBoundingRectangleWorldCoordinates.z - 2*handlesize.x ) );
- rightLeaveNotification.NotifySignal().Connect( this, &Decorator::OnReturnToRightBoundary );
-
- // Exceeding vertical boundary
- PropertyNotification verticalExceedNotificationOne = selectionHandleOne.AddPropertyNotification( Actor::WORLD_POSITION_Y,
- OutsideCondition( mBoundingRectangleWorldCoordinates.y + handlesize.y,
- mBoundingRectangleWorldCoordinates.w - handlesize.y ) );
- verticalExceedNotificationOne.NotifySignal().Connect( this, &Decorator::OnHandleOneLeavesBoundary );
-
- PropertyNotification verticalExceedNotificationTwo = selectionHandleTwo.AddPropertyNotification( Actor::WORLD_POSITION_Y,
- OutsideCondition( mBoundingRectangleWorldCoordinates.y + handlesize.y,
- mBoundingRectangleWorldCoordinates.w - handlesize.y ) );
- verticalExceedNotificationTwo.NotifySignal().Connect( this, &Decorator::OnHandleTwoLeavesBoundary );
-
- // Within vertical boundary
- PropertyNotification verticalWithinNotificationOne = selectionHandleOne.AddPropertyNotification( Actor::WORLD_POSITION_Y,
- InsideCondition( mBoundingRectangleWorldCoordinates.y + handlesize.y,
- mBoundingRectangleWorldCoordinates.w - handlesize.y ) );
- verticalWithinNotificationOne.NotifySignal().Connect( this, &Decorator::OnHandleOneWithinBoundary );
-
- PropertyNotification verticalWithinNotificationTwo = selectionHandleTwo.AddPropertyNotification( Actor::WORLD_POSITION_Y,
- InsideCondition( mBoundingRectangleWorldCoordinates.y + handlesize.y,
- mBoundingRectangleWorldCoordinates.w - handlesize.y ) );
- verticalWithinNotificationTwo.NotifySignal().Connect( this, &Decorator::OnHandleTwoWithinBoundary );
-}
-
-/**
- * PopUp
- */
-Vector3 Decorator::PositionOfPopUpRelativeToSelectionHandles()
-{
- Vector3 position;
- Vector2 min, max;
- Vector3 topHandle;
- Size rowSize;
-
- // When text is selected, show popup above top handle (and text), or below bottom handle.
-
- // topHandle: referring to the top most point of the handle or the top line of selection.
- if ( mSelectionHandleTwoActualPosition.y > mSelectionHandleOneActualPosition.y ) // Handle may switch positions so calculate which is top.
- {
- topHandle = mSelectionHandleOneActualPosition;
- rowSize= mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( mSelectionHandleOnePosition, min, max );
- }
- else
- {
- topHandle = mSelectionHandleTwoActualPosition;
- rowSize = mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( mSelectionHandleTwoPosition, min, max );
- }
- topHandle.y += TOP_HANDLE_TOP_OFFSET - rowSize.height;
- position = Vector3(topHandle.x, topHandle.y, 0.0f);
-
- return position;
-}
-
-Vector3 Decorator::AlternatePopUpPositionRelativeToSelectionHandles()
-{
- // alternativePosition: referring to the bottom most point of the handle or the bottom line of selection.
- Vector3 alternativePosition;
- alternativePosition.y = std::max ( mSelectionHandleTwoActualPosition.y , mSelectionHandleOneActualPosition.y );
- alternativePosition.y += GetSelectionHandleSize().y + mPopUpPanel.GetSize().y + BOTTOM_HANDLE_BOTTOM_OFFSET;
-
- return alternativePosition;
-}
-
-Vector3 Decorator::PositionOfPopUpRelativeToCursor()
-{
- // When no text is selected, show PopUp at position of cursor
- Vector3 position;
- Vector2 min, max;
- std::size_t cursorPosition = GetCurrentCursorPosition();
- position = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( cursorPosition );
- const Size rowSize = mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( cursorPosition, min, max );
- position.y -= rowSize.height;
-
- return position;
-}
-
-Vector3 Decorator::AlternatePopUpPositionRelativeToCursor()
-{
- std::size_t cursorPosition = GetCurrentCursorPosition();
- Vector3 alternativePosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( cursorPosition );
-
- if ( mTextInputHandles.GetGrabHandle() )
- {
- // If grab handle enabled then position pop-up below the grab handle.
- alternativePosition.y += mTextInputHandles.GetGrabHandle().GetCurrentSize().height + mPopUpPanel.GetSize().y + BOTTOM_HANDLE_BOTTOM_OFFSET ;
- }
- else
- {
- alternativePosition.y += mPopUpPanel.GetSize().y;
- }
-
- return alternativePosition;
-
-}
-
-Vector3 Decorator::PositionOfPopUpRelativeToGrabHandle()
-{
- return Vector3::ZERO;
-}
-
-void Decorator::ShowPopUp()
-{
- Vector3 position;
- Vector3 alternativePosition;
- Size rowSize;
-
- DALI_ASSERT_DEBUG( mPopUpTarget && "PopUp Target Actor does not exist" );
-
- if( mHighlightMeshActor ) // Text Selection mode
- {
- position = PositionOfPopUpRelativeToSelectionHandles();
- }
- else // Not in Text Selection mode so position relative to cursor.
- {
- position = PositionOfPopUpRelativeToCursor();
- }
-
- // reposition popup above the desired cursor position.
- mPopUpPanel.Show( mPopUpTarget, true );
- mPopUpPanel.Self().SetPosition( position );
- mPopUpPanel.PressedSignal().Connect( this, &Decorator::OnPopupButtonPressed );
-
- SetUpPopUpPositionNotifications();
- mPopUpPanel.ApplyConfinementConstraint( mBoundingRectangleWorldCoordinates );
-}
-
-void Decorator::ShowPopUp( Actor target )
-{
- mPopUpTarget = target;
- ShowPopupCutCopyPaste();
-}
-
-void Decorator::ShowPopupCutCopyPaste()
-{
- bool isAllTextSelectedAlready = ( mTextViewCharacterPositioning.StyledTextSize() == GetSelectedText().size() );
- bool isTextEmpty = mTextViewCharacterPositioning.IsStyledTextEmpty() ;
- bool isSubsetOfTextAlreadySelected = ( !isAllTextSelectedAlready ) && mHighlightMeshActor;
-
- Clipboard clipboard = Clipboard::Get();
- bool hasClipboardGotContent = clipboard.NumberOfItems();
-
- mPopUpPanel.CreateCutCopyPastePopUp( isAllTextSelectedAlready, isTextEmpty, hasClipboardGotContent, isSubsetOfTextAlreadySelected );
- ShowPopUp();
-}
-
-void Decorator::HidePopUp( bool animate, bool signalFinished )
-{
-}
-
-void Decorator::AddPopupOption(const std::string& name, const std::string& caption, const Image icon, bool finalOption)
-{
- mPopUpPanel.AddButton(name, caption, icon, finalOption);
-}
-
-void Decorator::ClearPopup()
-{
- mPopUpPanel.Clear();
-}
-
-void Decorator::PopUpLeavesVerticalBoundary( PropertyNotification& source)
-{
- Vector3 position, alternativePosition;
-
- if( mHighlightMeshActor ) // Text Selection mode
- {
- alternativePosition = AlternatePopUpPositionRelativeToSelectionHandles();
- }
- else // Not in Text Selection mode
- {
- alternativePosition = AlternatePopUpPositionRelativeToCursor();
- // if can't be positioned above, then position below row.
- }
- // reposition popup above the desired cursor position.
- mPopUpPanel.Self().SetPosition( alternativePosition );
-}
-
-void Decorator::SetUpPopUpPositionNotifications( )
-{
- // Note Property notifications ignore any set anchor point so conditions must allow for this. Default is Top Left.
-
- // Exceeding vertical boundary
- PropertyNotification verticalExceedNotificationOne = mPopUpPanel.Self().AddPropertyNotification( Actor::WORLD_POSITION_Y,
- OutsideCondition( mBoundingRectangleWorldCoordinates.y + mPopUpPanel.GetSize().y/2,
- mBoundingRectangleWorldCoordinates.w - mPopUpPanel.GetSize().y/2 ) );
- verticalExceedNotificationOne.NotifySignal().Connect( this, &Decorator::PopUpLeavesVerticalBoundary );
-}
-
-bool Decorator::OnPopupButtonPressed( Toolkit::Button button )
-{
- mPopUpButtonPressedSignal.Emit( button );
- return false;
-}
-
-Decorator::PressedSignal& Decorator::PopUpButtonPressedSignal()
-{
- return mPopUpButtonPressedSignal;
-}
-
-Decorator::CursorPositionedSignal& Decorator::CursorRePositionedSignal()
-{
- return mCursorRePositionedSignal;
-}
-
-/**
- * Decoration Positioning during Scrolling
- */
-void Decorator::TextViewScrolled( Toolkit::TextView textView, Vector2 scrollPosition )
-{
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputDecorationLayouter::TextViewScrolled\n");
-
- const Vector3& controlSize = mTextViewCharacterPositioning.GetTextView().GetCurrentSize(); // todo Could store size and only update in Control Size change.
- Size cursorSize( CURSOR_THICKNESS, 0.f );
-
- // Updates the cursor and grab handle position and visibility.
- if( mTextInputHandles.GetGrabHandle() || mCursor )
- {
- Vector2 min, max;
- size_t cursorTextPosition = GetCurrentCursorPosition();
- cursorSize.height = mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( cursorTextPosition, min, max ).height;
-
- const Vector3 cursorPosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( cursorTextPosition );
-
- bool mIsCursorInScrollArea = IsPositionWithinControl( cursorPosition, cursorSize, controlSize );
- bool mIsGrabHandleInScrollArea = mIsCursorInScrollArea;
-
- Vector2 actualGrabHandlePosition = cursorPosition.GetVectorXY();
-
- if( mTextInputHandles.GetGrabHandle() )
- {
- ShowGrabHandle( mGrabHandleVisibility && mIsGrabHandleInScrollArea );
- PositionGrabHandle( cursorTextPosition );
- }
-
- if( mCursor )
- {
- mCursor.SetVisible( mCursorVisibility && mIsCursorInScrollArea );
- DrawCursor( cursorTextPosition );
- mCursor.SetPosition( Vector3(actualGrabHandlePosition) + UI_OFFSET );
- }
- }
-
- Actor selectionHandleOne = mTextInputHandles.GetSelectionHandleOne();
- Actor selectionHandleTwo = mTextInputHandles.GetSelectionHandleTwo();
-
- // Updates the selection handles and highlighted text position and visibility.
- if( mTextInputHandles.GetSelectionHandleOne() && mTextInputHandles.GetSelectionHandleTwo() )
- {
- const Vector3 cursorPositionOne = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( mSelectionHandleOnePosition );
- const Vector3 cursorPositionTwo = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( mSelectionHandleTwoPosition );
-
- Size cursorSize( GetCursorSizeAt( mSelectionHandleOnePosition ) );
- const bool isSelectionHandleOneVisible = IsPositionWithinControl( cursorPositionOne, cursorSize, controlSize );
-
- cursorSize = GetCursorSizeAt( mSelectionHandleTwoPosition );
- const bool isSelectionHandleTwoVisible = IsPositionWithinControl( cursorPositionTwo, cursorSize, controlSize );
-
- mSelectionHandleOneActualPosition = cursorPositionOne.GetVectorXY();
- mSelectionHandleTwoActualPosition = cursorPositionTwo.GetVectorXY();
-
- selectionHandleOne.SetVisible( isSelectionHandleOneVisible );
- selectionHandleTwo.SetVisible( isSelectionHandleTwoVisible );
-
- PositionSelectionHandle( selectionHandleOne, mSelectionHandleOneActualPosition, mSelectionHandleOnePosition );
- PositionSelectionHandle( selectionHandleTwo, mSelectionHandleTwoActualPosition, mSelectionHandleTwoPosition );
-
- if( mHighlightMeshActor )
- {
- mHighlightMeshActor.SetVisible( true );
- ShowUpdatedHighlight();
- }
- }
-}
-
-void Decorator::StartScrollTimer()
-{
- if( !mScrollTimer )
- {
- mScrollTimer = Timer::New( SCROLL_TICK_INTERVAL );
- mScrollTimer.TickSignal().Connect( this, &Decorator::OnScrollTimerTick );
- }
-
- if( !mScrollTimer.IsRunning() )
- {
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputDecorationLayouter::StartScrollTimer\n");
- mScrollTimer.Start();
- }
-}
-
-void Decorator::StopScrollTimer()
-{
- if( mScrollTimer )
- {
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputDecorationLayouter::StopScrollTimer\n");
-
- mScrollTimer.Stop();
- mScrollTimer.Reset();
- }
-}
-
-bool Decorator::OnScrollTimerTick()
-{
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputDecorationLayouter::OnScrollTimerTick\n");
-
- if ( mGrabHandleVisibility && mTextInputHandles.GetGrabHandle() )
- {
- std::size_t newGrabHandlePosition = mTextViewCharacterPositioning.ReturnClosestIndex( mActualGrabHandlePosition.GetVectorXY() );
- if ( mGrabHandlePosition != newGrabHandlePosition )
- {
- Vector2 scrollPosition = mTextViewCharacterPositioning.GetScrollPosition();
- Vector2 scrollDelta = ( mActualGrabHandlePosition - mCurrentHandlePosition ).GetVectorXY();
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputDecorationLayouter::OnScrollTimerTick scrollPosition(%f) scrollDelta(%f)\n", scrollPosition.x, scrollDelta.x);
- scrollPosition += scrollDelta;
- mTextViewCharacterPositioning.SetScrollPosition( scrollPosition );
-
- mActualGrabHandlePosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( newGrabHandlePosition ).GetVectorXY();
- }
- }
-
- Actor selectionHandleOne = mTextInputHandles.GetSelectionHandleOne();
- Actor selectionHandleTwo = mTextInputHandles.GetSelectionHandleTwo();
-
- if ( selectionHandleOne && selectionHandleTwo )
- {
- std::size_t newHandleOnePosition = mTextViewCharacterPositioning.ReturnClosestIndex( mSelectionHandleOneActualPosition.GetVectorXY() );
-
- // todo duplicated code should be a function
-
- if ( mSelectionHandleOnePosition != newHandleOnePosition )
- {
- const Vector3 actualPosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( newHandleOnePosition );
-
- Vector2 scrollDelta = ( actualPosition - mSelectionHandleOneActualPosition ).GetVectorXY();
-
- Vector2 scrollPosition = mTextViewCharacterPositioning.GetScrollPosition();
- scrollPosition += scrollDelta;
- mTextViewCharacterPositioning.SetScrollPosition( scrollPosition );
-
- mSelectionHandleOnePosition = newHandleOnePosition;
- mSelectionHandleOneActualPosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( mSelectionHandleOnePosition ).GetVectorXY();
- }
- else
- {
- mSelectionHandleOneActualPosition.x += mScrollDisplacement.x;
- mSelectionHandleOneActualPosition.y += mScrollDisplacement.y;
- }
-
- std::size_t newHandleTwoPosition = mTextViewCharacterPositioning.ReturnClosestIndex( mSelectionHandleTwoActualPosition.GetVectorXY() );
-
- if ( mSelectionHandleTwoPosition != newHandleTwoPosition )
- {
- const Vector3 actualPosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( newHandleTwoPosition );
-
- Vector2 scrollDelta = ( actualPosition - mSelectionHandleTwoActualPosition ).GetVectorXY();
-
- Vector2 scrollPosition = mTextViewCharacterPositioning.GetScrollPosition();
- scrollPosition += scrollDelta;
- mTextViewCharacterPositioning.SetScrollPosition( scrollPosition );
-
- mSelectionHandleTwoPosition = newHandleTwoPosition;
- mCurrentHandlePosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( mSelectionHandleTwoPosition ).GetVectorXY();
-
- }
- else
- {
- mSelectionHandleTwoActualPosition.x += mScrollDisplacement.x;
- mSelectionHandleTwoActualPosition.y += mScrollDisplacement.y;
- }
- }
-
- return true;
-}
-
-/**
- * Text Selection
- */
-MarkupProcessor::StyledTextArray Decorator::GetSelectedText()
-{
- MarkupProcessor::StyledTextArray currentSelectedText;
-
- if ( mHighlightMeshActor ) // Text Selected
- {
- MarkupProcessor::StyledTextArray::iterator it = mTextViewCharacterPositioning.GetStyledTextArray().begin() + std::min(mSelectionHandleOnePosition, mSelectionHandleTwoPosition);
- MarkupProcessor::StyledTextArray::iterator end = mTextViewCharacterPositioning.GetStyledTextArray().begin() + std::max(mSelectionHandleOnePosition, mSelectionHandleTwoPosition);
-
- for(; it != end; ++it)
- {
- MarkupProcessor::StyledText& styledText( *it );
- currentSelectedText.push_back( styledText );
- }
- }
- return currentSelectedText;
-}
-
-} // Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
-
diff --git a/base/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.h b/base/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.h
deleted file mode 100644
index 7d316da..0000000
--- a/base/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.h
+++ /dev/null
@@ -1,634 +0,0 @@
-#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_DECORATOR_H__
-#define __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_DECORATOR_H__
-
-/*
- * Copyright (c) 2014 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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-// INTERNAL INCLUDES
-#include
-#include
-#include
-#include
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-class Decorator;
-
-typedef IntrusivePtr DecoratorPtr;
-
-/**
- * @brief Decorator Class
- *
- * Decorations are Selection Handles, cursor, grab handle, magnifier the "cut copy paste" PopUp and Selection highlight.
- * The Decorator triggers creation of these decorations and positions them.
- * Decoration positions can be dependent on other decorations like the PopUp on the Selection handles.
- * The decorator maintains a Bounding Box which the decorations have to be positioned within, decorations can be flipped or hidden to obey this Bounding Box.
- * Scrolling of Text can effect positioning of decorations, the decorator repositions decorations in this case.
- */
-
-class Decorator : public ConnectionTracker
-{
-
-public:
-
- /**
- * @brief Constructor
- *
- * @param[in] textviewManager TextViewManager to be used
- */
- Decorator( TextViewCharacterPositioning& textviewManager, TextInputTextStyle& textStyle);
-
- /**
- * @brief Default destructor
- */
- ~Decorator();
-
- /**
- * @brief Set the dimensions of the bounding rectangle for decorations to obey.
- *
- * @param[in] boundingRectangle
- */
- void SetBoundingBox( const Rect& boundingRectangle );
-
- /**
- * @brief Get the bounding dimensions of the bounding box
- *
- * @return dimensions of the bounding box from world origin. (x, y, w, z )
- *
- * -----------------
- * | ^ |
- * | | |
- * | y |
- * | | |
- * | v |
- * |<--x--> o <--z-->|
- * | ^ |
- * | | |
- * | w |
- * | | |
- * | v |
- * -----------------
- */
- Vector4 GetBoundingBox() const;
-
- /**
- * @brief Callback when a handle is panned/moved, either selection handles or grab handle
- *
- * @param actor Handle of the selection or grab handle.
- * @param gesture Data structure with the parameters of the gesture.
- */
- void OnHandlePan(Actor actor, const PanGesture& gesture);
-
- // Selection Handles
-
- /**
- * @brief Create a left and right selection handle and parent both to the provided actor
- * @param[in] parent actor in which the handles should be added to.
- */
- void CreateSelectionHandles( Actor parent );
-
- /**
- * @brief Remove selection handles from their parent
- */
- void RemoveSelectionHandles();
-
- /**
- * @brief Get size of Selection handles
- *
- * @return size of a selection handle
- */
- Vector3 GetSelectionHandleSize();
-
- /**
- * @brief Get position of Selection handle within text
- *
- * @return character position of a selection handle one
- */
- std::size_t GetHandleOnePosition() const;
-
- /**
- * @brief Get position of Selection handle within text
- *
- * @return character position of a selection handle two
- */
- std::size_t GetHandleTwoPosition() const;
-
- /**
- * @brief Position Selection a single handle at given positions within the text string.
- *
- * @param[in] selectionHandle handle to be positioned
- * @param[in] position where to place handle
- * @return Vector3 Position of handle as a coordinate.
- */
- Vector3 PositionSelectionHandle( Actor selectionHandle, std::size_t position );
-
- /**
- * @brief Position Selection a single handle at given coordinates
- *
- * @param[in] selectionHandle handle to be positioned
- * @param[in] actualPosition coordinates to position handle
- * @param[in] position where to place handle
- * @return Vector3 Position of handle as a coordinate.
- */
- Vector3 PositionSelectionHandle( Actor selectionHandle, Vector3& actualPosition, std::size_t position );
-
- /**
- * @brief Make both selection handle visible or invisible
- * @param[in] visible true to make visible, false to fine
- */
- void SetSelectionHandlesVisibility( bool visible );
-
- /**
- * @brief Position Selection handles at given positions within the text string.
- *
- * @param[in] start where to place first handle
- * @param[in] end where to place second handle
- */
- void PositionSelectionHandles( std::size_t start, std::size_t end );
-
- /**
- * @brief Move selection handle by the given displacement.
- *
- * @param[in] selectionHandle Actor to move
- * @param[in] actualSelectionHandlePosition actual current position of the handle in x y z
- * @param[in] currentSelectionHandlePosition current position along the string
- * @param[in] displacement the x y displacement
- */
- Vector3 MoveSelectionHandle( Actor selectionHandle,
- Vector3& actualSelectionHandlePosition,
- std::size_t& currentSelectionHandlePosition,
- const Vector2& displacement );
-
- /* Grab Handle */
-
- /**
- * @brief Position GrabHandlewith depending on the the character in the text it should be placed at
- * @param[in] positonInText the character position within the text the handle should be at
- */
- void PositionGrabHandle( std::size_t positionInText );
-
- /**
- * @brief Move grab handle to the required position within the text
- *
- * @param[in] displacement Displacement of the grab handle in actor coordinates.
- */
- void MoveGrabHandle( const Vector2& displacement );
-
- /**
- * @brief Show or hide the GrabHandle is visibility is true
- *
- * @param[in] visible flag to show or not show the grab handle
- */
- void ShowGrabHandle( bool visible );
-
- /**
- * @brief Create the GrabHandle used to position cursor
- * @param[in] targetParent the Actor to parent the GrabHandle
- */
- void CreateGrabHandle( Actor targetParent );
-
- /**
- * @brief Set the image to be used as the cursor grab hander
- * @pre The text input actor has been initialised.
- * @param[in] image The image to be used.
- */
- void SetGrabHandleImage( Image image );
-
- /**
- * @brief Toggle to enable the grab handle, used to position cursor when magnifier not being used.
- * Default behaviour is to use the magnifier to position the cursor, enabling this prevents the magnifier from being shown.
- * @param[in] toggle true to enable, false to disable grab handle
- */
- void EnableGrabHandle(bool toggle);
-
- /**
- * @brief Method to check if grab handle is enabled, if false then the magnifier will be used to position cursor.
- * @return bool returns true is grab handle enabled.
- */
- bool IsGrabHandleEnabled();
-
- /* Cursor */
-
- /**
- * @brief Get the current Cursor position
- * @return current cursor position
- */
- std::size_t GetCurrentCursorPosition() const;
-
- /**
- * @brief Set the Cursor position
- * @param[in] the position the cursor should be set to
- */
- void SetCurrentCursorPosition( std::size_t newCursorPosition );
-
- /**
- * @brief Set if the cursors are visible or not.
- * @param[in] visible flag true for visible
- */
- void SetCursorVisibility( bool visible );
-
- /**
- * @brief Display cursor
- * @param[in] nthChar position in text string to display cursor
- */
- void DrawCursor( const std::size_t nthChar = 0 );
-
- /**
- * Sets alternate cursor enable state
- * @see SetCursorVisibility
- * alternate cursor will only be visible if both SetCursorVisiblity
- * and cursor enabled have been set to true.
- */
- void SetAltCursorEnabled( bool enabled );
-
- /**
- * @brief Set the image to be used for the regular left to right cursor
- * @pre The text input actor has been initialised.
- * @param[in] image The image to be used.
- * @param[in] border The nine patch border for the image.
- */
- void SetCursorImage( Image image, const Vector4& border );
-
- /**
- * @brief Set the image to be used for the Right to Left cursor
- * @pre The text input actor has been initialised.
- * @param[in] image The image to be used.
- * @param[in] border The nine patch border for the image.
- */
- void SetRTLCursorImage( Image image, const Vector4& border );
-
- /**
- * @brief Creates a cursor from the supplied image and nine patch border.
- * @param[in] cursorImage the image to be used for the cursor.
- * @param[in] border the nine patch border corresponding to the supplied image.
- * @paran[in] cursorName actor name for cursor
- * @return the image actor to be used as the cursor.
- */
- ImageActor CreateCursor( Image cursorImage, const Vector4& border, const std::string& cursorName );
-
- /**
- * @brief Creates a regular and Right-To-Left cursor and parents them to give target Actor
- * @param[in] targetParent target Actor
- */
- void CreateCursors( Actor targetParent );
-
- /**
- * @Brief Returns the cursor size at a given position in the text.
- * @return Size the size of the cursor
- */
- Size GetCursorSizeAt( std::size_t positionWithinTextToGetCursorSize );
-
- /**
- * @brief Start a timer to signal cursor to blink.
- */
- void StartCursorBlinkTimer();
-
- /**
- * @brief Stop the timer signalling the cursor to blink.
- */
- void StopCursorBlinkTimer();
-
- /**
- * @brief Callback when handle timer ticks.
- *
- * Cursor should become visible/invisible to simulate blinking.
- *
- * @return True if the timer should be keep running.
- */
- bool OnCursorBlinkTimerTick();
-
- /* Selection Highlight */
-
- /**
- * @brief Updates mesh data for selection highlight depending on handle positions and displays it.
- */
- void ShowUpdatedHighlight();
-
- /**
- * @brief Creates the Highlight used for selection
- *
- * @param[in] parent target actor in which the handles should be added to.
- */
- void CreateHighlight( Actor parent );
-
- /**
- * @brief Remove Highlight actor from it's parent
- */
- void RemoveHighlight();
-
- /**
- * @brief Set the visibility of the Highlight
- *
- * @param[in] visibility True to show and False to hide.
- */
- void HighlightVisibility( bool visiblility );
-
- /* Boundary Property Notifications when handle exceed bounding box*/
-
- /**
- * @brief PropertyNotification Callback when left boundary exceeded so handle can be flipped.
- *
- * @param[in] source PropertyNotification
- */
- void OnLeftBoundaryExceeded( PropertyNotification& source );
- /**
- * @brief PropertyNotification Callback when within left boundary so handle can be flipped back.
- *
- * @param[in] source PropertyNotification
- */
- void OnReturnToLeftBoundary( PropertyNotification& source );
- /**
- * @brief PropertyNotification Callback when right boundary exceeded so handle can be flipped.
- *
- * @param[in] source PropertyNotification
- */
- void OnRightBoundaryExceeded( PropertyNotification& source );
- /**
- * @brief PropertyNotification Callback when within right boundary so handle can be flipped back.
- *
- * @param[in] source PropertyNotification
- */
- void OnReturnToRightBoundary( PropertyNotification& source );
-
- /**
- * @brief PropertyNotification Callbacks for hiding handle one when it exceeds boundary.
- *
- * @param[in] source PropertyNotification
- */
- void OnHandleOneLeavesBoundary( PropertyNotification& source );
- /**
- * @brief PropertyNotification Callbacks for showing hidden handle one when returns within boundary
- *
- * @param[in] source PropertyNotification
- */
- void OnHandleOneWithinBoundary( PropertyNotification& source );
- /**
- * @brief PropertyNotification Callbacks for hiding handle two it when exceeds boundary.
- *
- * @param[in] source PropertyNotification
- */
- void OnHandleTwoLeavesBoundary( PropertyNotification& source );
- /**
- * @brief PropertyNotification Callbacks for showing hidden handle two when returns within boundary
- *
- * @param[in] source PropertyNotification
- */
- void OnHandleTwoWithinBoundary( PropertyNotification& source );
-
- /**
- * @brief Set up property notifications on the position of the handles to facilitate flipping and hiding when at screen boundary.
- */
- void SetUpHandlePropertyNotifications();
-
- // Cut & Paste Pop-up
-
- /**
- * @brief Calculate positioning of PopUp relative to handles
- * @return Actual position of PopUp
- */
- Vector3 PositionOfPopUpRelativeToSelectionHandles( );
-
- /**
- * @brief Calculate alternative position of PopUp relative to handles when can it not be displayed in the default upper position.
- * @return Actual position of PopUp
- */
- Vector3 AlternatePopUpPositionRelativeToSelectionHandles();
-
- /**
- * @brief Calculate positioning of PopUp relative to cursor
- * @return Actual position of PopUp
- */
- Vector3 PositionOfPopUpRelativeToCursor();
-
- /**
- * @brief Calculate alternative position of PopUp relative to cursor when can not be displayed in normal upper position.
- * @return Actual position of PopUp
- */
- Vector3 AlternatePopUpPositionRelativeToCursor();
-
- /**
- * @brief Calculate positioning of PopUp relative to GrabHandle
- * @return Actual position of PopUp
- */
- Vector3 PositionOfPopUpRelativeToGrabHandle();
-
- /**
- * @brief Show the PopUp in the provided target
- * @param[in] target target actor in which the PopUp should be added to.
- */
- void ShowPopUp( Actor target );
-
- /**
- * @brief Show PopUp in previously set Target.
- * @pre Must have previously called ShopPopUp( Actor target ) otherwise PopUp will not be shown.
- */
- void ShowPopUp();
-
- /**
- * @brief Create and Show Cut Copy Paste PopUp
- */
- void ShowPopupCutCopyPaste();
-
- /**
- * @brief Hide PopUp
- * @param[in] animate Animate or just hide instantly, default is true
- * @param[in] signalFinished Signal when finished, default is true
- */
- void HidePopUp( bool animate=true, bool signalFinished=true );
-
- /**
- * @brief Adds a popup option.
- * @brief Creates popup frame if not already created.
- * @param[in] name The unique name for this option.
- * @param[in] caption The caption (label) for this option
- * @param[in] icon the image icon to be displayed for this option
- * @param[in] finalOption Flag to indicate that this is the final option.
- * (set to true on the last option you add)
- */
- void AddPopupOption(const std::string& name, const std::string& caption, const Image icon, bool finalOption = false);
-
- /**
- * @brief Removes popup, and its options.
- */
- void ClearPopup();
-
- /**
- * @brief PropertyNotification Callbacks for flipping PopUp when exceeds boundary.
- * @param[in] source PropertyNotification
- */
- void PopUpLeavesVerticalBoundary( PropertyNotification& source );
-
- /**
- * @brief Setup position notifications when PopUp exceeds boundary
- */
- void SetUpPopUpPositionNotifications( );
-
- /**
- * @brief Callback for when a button is pressed in popup panel
- * @param[in] button handle to the button pressed.
- * @return bool consummation
- */
- bool OnPopupButtonPressed( Toolkit::Button button );
-
- // Decoration positioning during scrolling
-
- /**
- * @brief Updates the position of the decorations when Text is scrolled.
- *
- * @param[in] textView Handle of the text-view.
- * @param[in] scrollPosition The difference with the previous scroll position.
- */
- void TextViewScrolled( Toolkit::TextView textView, Vector2 scrollPosition );
-
- /**
- * @brief Creates and starts a timer to scroll the text when handles are close to the edges of the text-input.
- *
- * It only starts the timer if it's already created.
- */
- void StartScrollTimer();
-
- /**
- * @brief Stops the timer used to scroll the text.
- */
- void StopScrollTimer();
-
- /**
- * @brief Scroll Text according to handle position
- * @param[in out] handlePosition handle position within character string
- * @param[in] actual vector position of handle
- * @return updated actual vector position of handle
- */
- Vector3 ScrollRelativeToHandle( std::size_t& handlePosition, Vector3& actualHandlePosition );
-
- /**
- * @brief Callback called by the timer used to scroll the text.
- *
- * It calculates and sets a new scroll position.
- */
- bool OnScrollTimerTick();
-
- // Text Selection
-
- /**
- * @brief Function to get Text selected between the 2 selection handles.
- * @return StyledTextArray an array of
- */
- MarkupProcessor::StyledTextArray GetSelectedText();
-
-private:
-
- /**
- * @brief Copy Constructor
- * @param[in] decorator
- * Undefined/Hidden.
- */
- Decorator(const Decorator& decorator);
-
- /**
- * @Assignment Constructor
- * @param[in] rhs
- * Undefined/Hidden.
- */
- Decorator& operator=(const Decorator& rhs);
-
-public:
-
- typedef SignalV2< bool( Toolkit::Button ) > PressedSignal;
- typedef SignalV2< void () > CursorPositionedSignal;
- /**
- * @brief Signal emitted when the button is touched.
- * This is relayed from the PopUp class. It enables the owner of the Decorator to act on the PopUp button press.
- */
- PressedSignal& PopUpButtonPressedSignal();
-
- /**
- * @brief Signal emitted when the cursor is repositioned
- * @param[in] cursor the new cursor position
- */
- CursorPositionedSignal& CursorRePositionedSignal();
-
-private:
-
- Vector4 mBoundingRectangleWorldCoordinates;
-
- TextViewCharacterPositioning& mTextViewCharacterPositioning;
-
- TextInputHandles mTextInputHandles;
-
- TextInputTextStyle& mTextStyle;
-
- Vector3 mSelectionHandleOneActualPosition; // Actual x y position of handle
- Vector3 mSelectionHandleTwoActualPosition; // Actual x y position of handle
- std::size_t mSelectionHandleOnePosition; // Position of handle along the string of text
- std::size_t mSelectionHandleTwoPosition; // Position of handle along the string of text
-
- TextInputPopupNew mPopUpPanel; // PopUp used for Cut Cpoy and Paste
- Actor mPopUpTarget; // Target Actor to parent PopUp
-
- Vector3 mActualGrabHandlePosition; // Actual position of grab handle, this might not be snapped to a character
- std::size_t mGrabHandlePosition; // Position of grab handle along the string of text
- Vector3 mCurrentHandlePosition;
-
- std::size_t mCursorPosition; // Current cursor position within the text string
- ImageActor mCursor; // Cursor overlayed on Text to show where new text will be inserted
- ImageActor mCursorRTL; // Right To Left Cursor overlayed on Text (where new RTL text would be inserted)
- Animation mCursorAnimation; // Animation for cursor blinking.
- Timer mCursorBlinkTimer; // Timer to signal cursor to blink
-
- Vector2 mScrollDisplacement; // How much to scroll by
- Timer mScrollTimer; // Timer to scroll text over a period of time not all in one update.
-
- TextHighlight mTextHighlight; // Holds data required to construct the highlight
- MeshActor mHighlightMeshActor; // Mesh Actor to display highlight
-
- PanGestureDetector mPanGestureDetector;
-
- PressedSignal mPopUpButtonPressedSignal; // Signal emitted when a button within the popup is pressed.
- CursorPositionedSignal mCursorRePositionedSignal; // Signal emitted when a button when cursor position is changed.
-
- bool mCursorBlinkStatus:1; // \e true shows the cursor, \e false hides it.
- bool mCursorVisibility:1; // Should cursor be visible
- bool mCursorRTLEnabled:1; // Enable state of Alternate RTL Cursor (need to keep track of this as it's not always enabled)
- bool mIsGrabHandleInScrollArea:1; // Whether the grab handle is inside the boundaries of the text-input.
- bool mIsCursorInScrollArea:1; // Whether the cursor is inside the boundaries of the text-input.
- bool mGrabHandleVisibility:1; // Should grab handle be visible
- bool mGrabHandleEnabled:1; // Flag to enable the grab handle instead of the default magnifier.
-};
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_DECORATOR_H__
diff --git a/base/dali-toolkit/internal/controls/text-input/text-input-handles-impl.cpp b/base/dali-toolkit/internal/controls/text-input/text-input-handles-impl.cpp
deleted file mode 100644
index c4d831b..0000000
--- a/base/dali-toolkit/internal/controls/text-input/text-input-handles-impl.cpp
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * Copyright (c) 2014 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.
- *
- */
-
-// CLASS HEADER
-#include
-
-// EXTERNAL INCLUDES
-#include
-#include
-#include
-#include
-#include
-
-// INTERNAL INCLUDES
-#include
-#include
-#include
-#include
-#include
-#include
-
-using namespace Dali;
-
-namespace
-{
-const char* const DEFAULT_SELECTION_HANDLE_ONE( DALI_IMAGE_DIR "text-input-selection-handle-left.png" );
-const char* const DEFAULT_SELECTION_HANDLE_TWO( DALI_IMAGE_DIR "text-input-selection-handle-right.png" );
-const char* const DEFAULT_SELECTION_HANDLE_ONE_PRESSED( DALI_IMAGE_DIR "text-input-selection-handle-left-press.png" );
-const char* const DEFAULT_SELECTION_HANDLE_TWO_PRESSED( DALI_IMAGE_DIR "text-input-selection-handle-right-press.png" );
-
-const char* const DEFAULT_GRAB_HANDLE( DALI_IMAGE_DIR "insertpoint-icon.png" );
-
-const Vector3 DEFAULT_SELECTION_HANDLE_RELATIVE_SCALE( 1.5f, 1.5f, 1.0f );
-const Vector3 DEFAULT_GRAB_HANDLE_RELATIVE_SCALE( 1.5f, 2.0f, 1.0f );
-
-const char* const SELECTION_GRAB_AREA_ONE( "SelectionHandleOneGrabArea");
-const char* const SELECTION_GRAB_AREA_TWO( "SelectionHandleTwoGrabArea");
-const char* const GRABHANDLE_GRAB_AREA( "GrabHandleGrabArea");
-
-#if defined(DEBUG_ENABLED)
-Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "TEXT_INPUT_HANDLES" );
-#endif
-
-Actor CreateGrabArea( const std::string& name, const Vector3& relativeScale )
-{
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputHandles: CreateGrabArea\n" );
-
- Actor handleGrabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move
- handleGrabArea.SetName( name );
- handleGrabArea.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), RelativeToConstraint( relativeScale ) ) ); // grab area to be larger than text actor
- handleGrabArea.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
-
- return handleGrabArea;
-}
-
-ImageActor CreateHandle( const Vector3& anchorPoint, const Image& handleImage, const std::string& name )
-{
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputHandles: CreateSelectionHandle\n" );
-
- ImageActor selectionHandle = ImageActor::New( handleImage );
- selectionHandle.SetName( name );
- selectionHandle.SetAnchorPoint( anchorPoint );
- selectionHandle.SetDrawMode( DrawMode::OVERLAY ); // ensure handle above text
-
- return selectionHandle;
-}
-}
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-// Default constructor
-TextInputHandles::TextInputHandles():
- mSelectionHandleOne(),
- mSelectionHandleTwo(),
- mSelectionHandleOneOffset( Vector3::ZERO ),
- mSelectionHandleTwoOffset( Vector3::ZERO ),
- mSelectionHandleOneCoordinatePosition( Vector3::ZERO ),
- mSelectionHandleTwoCoordinatePosition( Vector3::ZERO ),
- mSelectionHandleOneStringPosition( 0 ),
- mSelectionHandleTwoStringPosition( 0 ),
- mIsSelectionHandleOneFlipped( false ),
- mIsSelectionHandleTwoFlipped( false )
-{
-}
-
-TextInputHandles::~TextInputHandles()
-{
-}
-
-void TextInputHandles::CreateSelectionHandles()
-{
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputHandles: CreateSelectionHandles\n" );
-
- mSelectionHandleOneImage = Image::New( DEFAULT_SELECTION_HANDLE_ONE );
- mSelectionHandleOneImagePressed = Image::New( DEFAULT_SELECTION_HANDLE_ONE_PRESSED );
- mSelectionHandleOne = CreateHandle( AnchorPoint::TOP_RIGHT, mSelectionHandleOneImage, "SelectionHandleOne" );
- mIsSelectionHandleOneFlipped = false;
-
- mHandleOneGrabArea = CreateGrabArea( SELECTION_GRAB_AREA_ONE, DEFAULT_SELECTION_HANDLE_RELATIVE_SCALE );
- mSelectionHandleOne.Add( mHandleOneGrabArea );
- mHandleOneGrabArea.TouchedSignal().Connect(this, &TextInputHandles::OnSelectionHandleTouched);
-
-// mTapDetector.Attach( mHandleOneGrabArea );
-
- mSelectionHandleTwoImage = Image::New( DEFAULT_SELECTION_HANDLE_TWO );
- mSelectionHandleTwoImagePressed = Image::New( DEFAULT_SELECTION_HANDLE_TWO_PRESSED );
- mSelectionHandleTwo = CreateHandle( AnchorPoint::TOP_LEFT, mSelectionHandleTwoImage, "SelectionHandleTwo" );
- mIsSelectionHandleTwoFlipped = false;
-
- mHandleTwoGrabArea = CreateGrabArea( SELECTION_GRAB_AREA_TWO, DEFAULT_SELECTION_HANDLE_RELATIVE_SCALE );
- mSelectionHandleTwo.Add( mHandleTwoGrabArea );
- mHandleTwoGrabArea.TouchedSignal().Connect(this, &TextInputHandles::OnSelectionHandleTouched);
-
- // mTapDetector.Attach( mHandleTwoGrabArea );
-}
-
-void TextInputHandles::DestorySelectionHandles()
-{
- if ( mSelectionHandleOne && mSelectionHandleTwo)
- {
- mSelectionHandleOne.Unparent();
- mSelectionHandleTwo.Unparent();
- mSelectionHandleOneImagePressed.Reset();
- mSelectionHandleOneImage.Reset();
- mSelectionHandleTwoImagePressed.Reset();
- mSelectionHandleTwoImage.Reset();
- mSelectionHandleOne.Reset();
- mSelectionHandleTwo.Reset();
- }
-}
-
-void TextInputHandles::SetSelectionHandleOneVisibility( bool visibility )
-{
- if ( mSelectionHandleOne )
- {
- mSelectionHandleOne.SetVisible( visibility );
- }
-}
-
-void TextInputHandles::SetSelectionHandleTwoVisibility( bool visibility )
-{
- if ( mSelectionHandleTwo )
- {
- mSelectionHandleTwo.SetVisible( visibility );
- }
-}
-
-void TextInputHandles::AttachSelectionHandlesToGivenPanGesture( PanGestureDetector& panGestureDetector )
-{
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputHandles: AttachSelectionHandlesToGivenPanGesture\n" );
-
- panGestureDetector.Attach( mHandleOneGrabArea );
- panGestureDetector.Attach( mHandleTwoGrabArea );
-}
-
-void TextInputHandles::AttachSelectionHandlesToGivenTapDetector(TapGestureDetector& tapGestureDetector )
-{
- tapGestureDetector.Attach( mHandleOneGrabArea );
- tapGestureDetector.Attach( mHandleTwoGrabArea );
-}
-
-void TextInputHandles::AttachGrabHandleToGivenPanGesture( PanGestureDetector& panGestureDetector )
-{
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputHandles: AttachGrabHandleToGivenPanGesture\n" );
-
- panGestureDetector.Attach( mGrabHandleGrabArea );
-}
-
-Actor TextInputHandles::GetSelectionHandleOne()
-{
- return mSelectionHandleOne;
-}
-
-Actor TextInputHandles::GetSelectionHandleTwo()
-{
- return mSelectionHandleTwo;
-}
-
-bool TextInputHandles::OnSelectionHandleTouched(Dali::Actor actor, const TouchEvent& touch)
-{
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputHandles: OnSelectionHandleTouched\n" );
-
- Image pressedImage;
- Image normalImage;
-
- ImageActor handleTouched = ImageActor::DownCast( actor.GetParent() ); // Hit actor would be the GrabArea hence get parent.
-
- if ( handleTouched == mSelectionHandleOne )
- {
- pressedImage = mSelectionHandleOneImagePressed;
- normalImage = mSelectionHandleOneImage;
- }
- else
- {
- pressedImage = mSelectionHandleTwoImagePressed;
- normalImage = mSelectionHandleTwoImage;
- }
-
- if (touch.GetPoint(0).state == TouchPoint::Down)
- {
- handleTouched.SetImage( pressedImage );
- }
- else if (touch.GetPoint(0).state == TouchPoint::Up )
- {
- handleTouched.SetImage( normalImage );
- }
- return false;
-}
-
-// Grab handle
-
-Actor TextInputHandles::GetGrabHandle()
-{
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputHandles: GetGrabHandle\n" );
-
- return mGrabHandle;
-}
-
-void TextInputHandles::CreateGrabHandle()
-{
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputHandles: CreateGrabHandle\n" );
-
- if ( !mGrabHandle )
- {
- if ( !mGrabHandleImage )
- {
- mGrabHandleImage = Image::New( DEFAULT_GRAB_HANDLE );
- }
-
- mGrabHandle = CreateHandle( AnchorPoint::TOP_CENTER, mGrabHandleImage, "GrabHandle" );
- mGrabHandleGrabArea = CreateGrabArea( GRABHANDLE_GRAB_AREA, DEFAULT_GRAB_HANDLE_RELATIVE_SCALE );
- mGrabHandle.Add( mGrabHandleGrabArea );
- }
-}
-
-void TextInputHandles::DestoryGrabHandle()
-{
- if ( mGrabHandle )
- {
- mGrabHandle.Unparent();
- mGrabHandleImage.Reset();
- mGrabHandle.Reset();
- }
-}
-
-void TextInputHandles::SetGrabHandleImage( Dali::Image image )
-{
- if ( mGrabHandle )
- {
- mGrabHandleImage = image;
- mGrabHandle.SetImage( mGrabHandleImage );
- }
-}
-
-void TextInputHandles::SetGrabHandleVisibility( bool visibility )
-{
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputHandles: SetGrabHandleVisibility (%s) \n", ( visibility )?"true":"false" );
-
- if ( mGrabHandle )
- {
- mGrabHandle.SetVisible( visibility );
- }
-}
-
-} // Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
-
diff --git a/base/dali-toolkit/internal/controls/text-input/text-input-handles-impl.h b/base/dali-toolkit/internal/controls/text-input/text-input-handles-impl.h
deleted file mode 100644
index c5f9013..0000000
--- a/base/dali-toolkit/internal/controls/text-input/text-input-handles-impl.h
+++ /dev/null
@@ -1,200 +0,0 @@
-#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_HANDLES_H__
-#define __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_HANDLES_H__
-
-/*
- * Copyright (c) 2014 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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include
-#include
-#include
-#include
-#include
-#include
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-/**
- * Class to create handles and alter their visualisation.
- * Not responsible for positioning.
- */
-
-class TextInputHandles : public ConnectionTracker
-{
-
-public:
-
- /**
- * Default constructor
- */
- TextInputHandles();
-
- /**
- * Destructor
- */
- ~TextInputHandles();
-
- /**
- * Create the selection handles
- */
- void CreateSelectionHandles();
-
- /**
- * Un-parents the Selection Handles and resets their Image Actors
- */
- void DestorySelectionHandles();
-
- /**
- * Set the Actor visibility on Selection Handle One
- * @param[in] visibility visibility flag
- */
- void SetSelectionHandleOneVisibility( bool visibility );
-
- /**
- * Set the Actor visibility on Selection Handle Two
- * @param[in] visibility visibility flag
- */
- void SetSelectionHandleTwoVisibility( bool visibility );
-
- /**
- * Attach the two selection handles to the pan gesture detector
- * @param[in] panGestureDetector the PanGestureDetector to attach to
- */
- void AttachSelectionHandlesToGivenPanGesture(PanGestureDetector& panGestureDetector );
-
- /**
- * Attach the two selection handles to the tap gesture detector
- * @param[in] tapGestureDetector the TapGestureDetector to attach to
- */
- void AttachSelectionHandlesToGivenTapDetector(TapGestureDetector& tapGestureDetector );
-
- /**
- * Attach the grab handle to the pan gesture detector
- * @param[in] panGestureDetector the PanGestureDetector to attach to
- */
- void AttachGrabHandleToGivenPanGesture( PanGestureDetector& panGestureDetector );
-
- /**
- * Get Selection handle one
- * @return selection handle actor
- */
- Actor GetSelectionHandleOne();
-
- /**
- * Get Selection handle two
- * @return selection handle actor
- */
- Actor GetSelectionHandleTwo();
-
- /**
- * Get the grab handle
- * @return grab handle Actor
- */
- Actor GetGrabHandle();
-
- /**
- * Create the grab handle that positions the cursor
- * @param[in] image the image to be used.
- */
- void CreateGrabHandle();
-
- /**
- * Removes and Resets GrabHandle
- */
- void DestoryGrabHandle();
-
- /**
- * Set the image to be used as the cursor grab hander
- * @pre The text input actor has been initialised.
- * @param[in] image The image to be used.
- */
- void SetGrabHandleImage( Dali::Image image );
-
- /**
- * Set the Actor visibility on the GrabHandle
- * @param[in] visibility visibility flag
- */
- void SetGrabHandleVisibility( bool visibility );
-
- /* Touch Event Callbacks */
-
- /**
- * Callback on selection handle touched.
- * Sets the image depending if handle in pressed or normal state
- * @param[in] actor touched
- * @param[in] touch touch event, used to determine if down or up event
- */
- bool OnSelectionHandleTouched(Dali::Actor actor, const TouchEvent& touch);
-
-private:
-
- /**
- * @brief Copy Constructor
- * @param[in] handles
- * Undefined/Hidden.
- */
- TextInputHandles(const TextInputHandles& handles);
-
- /**
- * @Assignment Constructor
- * @param[in] rhs
- * Undefined/Hidden.
- */
- TextInputHandles& operator=(const TextInputHandles& rhs);
-
-private:
-
- ImageActor mSelectionHandleOne; // First selection handle used for selecting text to cut&paste
- ImageActor mSelectionHandleTwo; // Second selection handle used for selecting text to cut&paste
- Actor mHandleOneGrabArea; // Invisible actor that receives pans events for the selection handle.
- Actor mHandleTwoGrabArea; // Invisible actor that receives pans events for the selection handle.
-
- Image mSelectionHandleOneImage; // image used for selection handle one
- Image mSelectionHandleOneImagePressed; // image used for selection handle one pressed state
- Image mSelectionHandleTwoImage; // image used for selection handle two
- Image mSelectionHandleTwoImagePressed; // image used for selection handle two pressed state
-
- Vector3 mSelectionHandleOneOffset; // Handle One's Offset
- Vector3 mSelectionHandleTwoOffset; // Handle Two's Offset
- Vector3 mSelectionHandleOneCoordinatePosition; // Actual x y z position of handle
- Vector3 mSelectionHandleTwoCoordinatePosition; // Actual x y z position of handle
- std::size_t mSelectionHandleOneStringPosition; // Position of handle along the string of text
- std::size_t mSelectionHandleTwoStringPosition; // Position of handle along the string of text
-
- Image mGrabHandleImage; // Image to be used for grab handle
- ImageActor mGrabHandle; // Handle used to move cursor for editing
- Actor mGrabHandleGrabArea; // invisible actor that receives pans events for the grab handle.
-
- bool mIsSelectionHandleOneFlipped:1; // Flag to know whether the handle one is flipped or not.
- bool mIsSelectionHandleTwoFlipped:1; // Flag to know whether the handle two is flipped or not.
-};
-
-
-} // namespace Internal
-
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_HANDLES_H__
diff --git a/base/dali-toolkit/internal/controls/text-input/text-input-impl.cpp b/base/dali-toolkit/internal/controls/text-input/text-input-impl.cpp
deleted file mode 100644
index 512b163..0000000
--- a/base/dali-toolkit/internal/controls/text-input/text-input-impl.cpp
+++ /dev/null
@@ -1,5542 +0,0 @@
-/*
- * Copyright (c) 2014 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.
- *
- */
-
-// CLASS HEADER
-#include
-
-// EXTERNAL INCLUDES
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-// INTERNAL INCLUDES
-#include
-#include
-#include
-#include
-
-using namespace Dali;
-
-// Local Data
-namespace
-{
-
-#if defined(DEBUG_ENABLED)
-Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_TEXT_INPUT");
-#endif
-
-const std::size_t DEFAULT_MAX_SIZE( std::numeric_limits::max() ); // Max possible number
-const std::size_t DEFAULT_NUMBER_OF_LINES_LIMIT( std::numeric_limits::max() ); // Max possible number
-const Vector3 DEFAULT_SELECTION_HANDLE_SIZE( 51.0f, 79.0f, 0.0f ); // Selection cursor image size
-const Vector3 DEFAULT_GRAB_HANDLE_RELATIVE_SIZE( 1.5f, 2.0f, 1.0f );
-const Vector3 DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE( 1.5f, 1.5f, 1.0f );
-const Vector4 LIGHTBLUE( 0.07f, 0.41f, 0.59f, 1.0f ); // Used for Selection highlight
-
-const char* DEFAULT_GRAB_HANDLE( DALI_IMAGE_DIR "insertpoint-icon.png" );
-const char* DEFAULT_SELECTION_HANDLE_ONE( DALI_IMAGE_DIR "text-input-selection-handle-left.png" );
-const char* DEFAULT_SELECTION_HANDLE_TWO( DALI_IMAGE_DIR "text-input-selection-handle-right.png" );
-const char* DEFAULT_SELECTION_HANDLE_ONE_PRESSED( DALI_IMAGE_DIR "text-input-selection-handle-left-press.png" );
-const char* DEFAULT_SELECTION_HANDLE_TWO_PRESSED( DALI_IMAGE_DIR "text-input-selection-handle-right-press.png" );
-
-const std::size_t CURSOR_BLINK_INTERVAL = 500; ///< Cursor blink interval
-const float CHARACTER_THRESHOLD( 2.5f ); ///< the threshold of a line.
-const float DISPLAYED_HIGHLIGHT_Z_OFFSET( 0.1f ); ///< 1. Highlight rendered (z-offset).
-const float DISPLAYED_TEXT_VIEW_Z_OFFSET( 0.2f ); ///< 2. Text rendered (z-offset).
-const float UI_Z_OFFSET( 0.2f ); ///< 3. Text Selection Handles/Cursor z-offset.
-
-const Vector3 UI_OFFSET(0.0f, 0.0f, UI_Z_OFFSET); ///< Text Selection Handles/Cursor offset.
-const Vector3 DEFAULT_HANDLE_ONE_OFFSET(0.0f, -5.0f, 0.0f); ///< Handle One's Offset
-const Vector3 DEFAULT_HANDLE_TWO_OFFSET(0.0f, -5.0f, 0.0f); ///< Handle Two's Offset
-const float TOP_HANDLE_TOP_OFFSET( 34.0f); ///< Offset between top handle and cutCopyPaste pop-up
-const float BOTTOM_HANDLE_BOTTOM_OFFSET(34.0f); ///< Offset between bottom handle and cutCopyPaste pop-up
-const float CURSOR_THICKNESS(4.0f);
-const Degree CURSOR_ANGLE_OFFSET(2.0f); ///< Offset from the angle of italic angle.
-const Vector4 DEFAULT_CURSOR_COLOR(1.0f, 1.0f, 1.0f, 1.0f);
-
-const std::string NEWLINE( "\n" );
-
-const TextStyle DEFAULT_TEXT_STYLE;
-
-const unsigned int SCROLL_TICK_INTERVAL = 50u;
-const float SCROLL_THRESHOLD = 10.f;
-const float SCROLL_SPEED = 15.f;
-
-/**
- * Selection state enumeration (FSM)
- */
-enum SelectionState
-{
- SelectionNone, ///< Currently not encountered selected section.
- SelectionStarted, ///< Encountered selected section
- SelectionFinished ///< Finished selected section
-};
-
-std::size_t FindVisibleCharacterLeft( std::size_t cursorPosition, const Toolkit::TextView::CharacterLayoutInfoContainer& characterLayoutInfoTable )
-{
- for( Toolkit::TextView::CharacterLayoutInfoContainer::const_reverse_iterator it = characterLayoutInfoTable.rbegin() + characterLayoutInfoTable.size() - cursorPosition, endIt = characterLayoutInfoTable.rend();
- it != endIt;
- ++it )
- {
- if( ( *it ).mIsVisible )
- {
- return --cursorPosition;
- }
-
- --cursorPosition;
- }
-
- return 0u;
-}
-
-std::size_t FindVisibleCharacterRight( std::size_t cursorPosition, const Toolkit::TextView::CharacterLayoutInfoContainer& characterLayoutInfoTable )
-{
- for( Toolkit::TextView::CharacterLayoutInfoContainer::const_iterator it = characterLayoutInfoTable.begin() + cursorPosition, endIt = characterLayoutInfoTable.end(); it < endIt; ++it )
- {
- if( ( *it ).mIsVisible )
- {
- return cursorPosition;
- }
-
- ++cursorPosition;
- }
-
- return cursorPosition;
-}
-
-/**
- * Whether the given position plus the cursor size offset is inside the given boundary.
- *
- * @param[in] position The given position.
- * @param[in] cursorSize The cursor size.
- * @param[in] controlSize The given boundary.
- *
- * @return whether the given position is inside the given boundary.
- */
-bool IsPositionInsideBoundaries( const Vector3& position, const Size& cursorSize, const Vector3& controlSize )
-{
- return ( position.x >= -Math::MACHINE_EPSILON_1000 ) &&
- ( position.x <= controlSize.width + Math::MACHINE_EPSILON_1000 ) &&
- ( position.y - cursorSize.height >= -Math::MACHINE_EPSILON_1000 ) &&
- ( position.y <= controlSize.height + Math::MACHINE_EPSILON_1000 );
-}
-
-/**
- * Splits a text in two halves.
- *
- * If the text's number of characters is odd, firstHalf has one more character.
- *
- * @param[in] text The text to be split.
- * @param[out] firstHalf The first half of the text.
- * @param[out] secondHalf The second half of the text.
- */
-void SplitText( const Toolkit::MarkupProcessor::StyledTextArray& text,
- Toolkit::MarkupProcessor::StyledTextArray& firstHalf,
- Toolkit::MarkupProcessor::StyledTextArray& secondHalf )
-{
- firstHalf.clear();
- secondHalf.clear();
-
- const std::size_t textLength = text.size();
- const std::size_t half = ( textLength / 2 ) + ( textLength % 2 );
-
- firstHalf.insert( firstHalf.end(), text.begin(), text.begin() + half );
- secondHalf.insert( secondHalf.end(), text.begin() + half, text.end() );
-}
-
-} // end of namespace
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-// Properties
-const Property::Index TextInput::HIGHLIGHT_COLOR_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX;
-const Property::Index TextInput::CUT_AND_PASTE_COLOR_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+1;
-const Property::Index TextInput::CUT_AND_PASTE_PRESSED_COLOR_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+2;
-const Property::Index TextInput::CUT_AND_PASTE_BORDER_COLOR_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+3;
-const Property::Index TextInput::CUT_AND_PASTE_ICON_COLOR_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+4;
-const Property::Index TextInput::CUT_AND_PASTE_ICON_PRESSED_COLOR_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+5;
-const Property::Index TextInput::CUT_AND_PASTE_TEXT_COLOR_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+6;
-const Property::Index TextInput::CUT_AND_PASTE_TEXT_PRESSED_COLOR_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+7;
-const Property::Index TextInput::CUT_BUTTON_POSITION_PRIORITY_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+8;
-const Property::Index TextInput::COPY_BUTTON_POSITION_PRIORITY_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+9;
-const Property::Index TextInput::PASTE_BUTTON_POSITION_PRIORITY_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+10;
-const Property::Index TextInput::SELECT_BUTTON_POSITION_PRIORITY_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+11;
-const Property::Index TextInput::SELECT_ALL_BUTTON_POSITION_PRIORITY_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+12;
-const Property::Index TextInput::CLIPBOARD_BUTTON_POSITION_PRIORITY_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+13;
-const Property::Index TextInput::POP_UP_OFFSET_FROM_TEXT_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+14;
-const Property::Index TextInput::CURSOR_COLOR_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+15;
-
-
-namespace Internal
-{
-
-namespace
-{
-
-BaseHandle Create()
-{
- return Toolkit::TextInput::New();
-}
-
-TypeRegistration typeRegistration( typeid(Toolkit::TextInput), typeid(Toolkit::Control), Create );
-
-SignalConnectorType signalConnector1( typeRegistration, Toolkit::TextInput::SIGNAL_START_INPUT, &TextInput::DoConnectSignal );
-SignalConnectorType signalConnector2( typeRegistration, Toolkit::TextInput::SIGNAL_END_INPUT, &TextInput::DoConnectSignal );
-SignalConnectorType signalConnector3( typeRegistration, Toolkit::TextInput::SIGNAL_STYLE_CHANGED, &TextInput::DoConnectSignal );
-SignalConnectorType signalConnector4( typeRegistration, Toolkit::TextInput::SIGNAL_MAX_INPUT_CHARACTERS_REACHED, &TextInput::DoConnectSignal );
-SignalConnectorType signalConnector5( typeRegistration, Toolkit::TextInput::SIGNAL_TOOLBAR_DISPLAYED, &TextInput::DoConnectSignal );
-SignalConnectorType signalConnector6( typeRegistration, Toolkit::TextInput::SIGNAL_TEXT_EXCEED_BOUNDARIES, &TextInput::DoConnectSignal );
-
-}
-
-PropertyRegistration property1( typeRegistration, "highlight-color", Toolkit::TextInput::HIGHLIGHT_COLOR_PROPERTY, Property::VECTOR4, &TextInput::SetProperty, &TextInput::GetProperty );
-PropertyRegistration property2( typeRegistration, "cut-and-paste-bg-color", Toolkit::TextInput::CUT_AND_PASTE_COLOR_PROPERTY, Property::VECTOR4, &TextInput::SetProperty, &TextInput::GetProperty );
-PropertyRegistration property3( typeRegistration, "cut-and-paste-pressed-color", Toolkit::TextInput::CUT_AND_PASTE_PRESSED_COLOR_PROPERTY, Property::VECTOR4, &TextInput::SetProperty, &TextInput::GetProperty );
-PropertyRegistration property4( typeRegistration, "cut-and-paste-icon-color", Toolkit::TextInput::CUT_AND_PASTE_ICON_COLOR_PROPERTY, Property::VECTOR4, &TextInput::SetProperty, &TextInput::GetProperty );
-PropertyRegistration property5( typeRegistration, "cut-and-paste-icon-pressed-color", Toolkit::TextInput::CUT_AND_PASTE_ICON_PRESSED_COLOR_PROPERTY, Property::VECTOR4, &TextInput::SetProperty, &TextInput::GetProperty );
-PropertyRegistration property6( typeRegistration, "cut-and-paste-text-color", Toolkit::TextInput::CUT_AND_PASTE_TEXT_COLOR_PROPERTY, Property::VECTOR4, &TextInput::SetProperty, &TextInput::GetProperty );
-PropertyRegistration property7( typeRegistration, "cut-and-paste-text-pressed-color", Toolkit::TextInput::CUT_AND_PASTE_TEXT_PRESSED_COLOR_PROPERTY, Property::VECTOR4, &TextInput::SetProperty, &TextInput::GetProperty );
-PropertyRegistration property8( typeRegistration, "cut-and-paste-border-color", Toolkit::TextInput::CUT_AND_PASTE_BORDER_COLOR_PROPERTY, Property::VECTOR4, &TextInput::SetProperty, &TextInput::GetProperty );
-PropertyRegistration property9( typeRegistration, "cut-button-position-priority", Toolkit::TextInput::CUT_BUTTON_POSITION_PRIORITY_PROPERTY, Property::UNSIGNED_INTEGER, &TextInput::SetProperty, &TextInput::GetProperty );
-PropertyRegistration property10( typeRegistration, "copy-button-position-priority", Toolkit::TextInput::COPY_BUTTON_POSITION_PRIORITY_PROPERTY, Property::UNSIGNED_INTEGER, &TextInput::SetProperty, &TextInput::GetProperty );
-PropertyRegistration property11( typeRegistration, "paste-button-position-priority", Toolkit::TextInput::PASTE_BUTTON_POSITION_PRIORITY_PROPERTY, Property::UNSIGNED_INTEGER, &TextInput::SetProperty, &TextInput::GetProperty );
-PropertyRegistration property12( typeRegistration, "select-button-position-priority", Toolkit::TextInput::SELECT_BUTTON_POSITION_PRIORITY_PROPERTY, Property::UNSIGNED_INTEGER, &TextInput::SetProperty, &TextInput::GetProperty );
-PropertyRegistration property13( typeRegistration, "select-all-button-position-priority", Toolkit::TextInput::SELECT_ALL_BUTTON_POSITION_PRIORITY_PROPERTY, Property::UNSIGNED_INTEGER, &TextInput::SetProperty, &TextInput::GetProperty );
-PropertyRegistration property14( typeRegistration, "clipboard-button-position-priority", Toolkit::TextInput::CLIPBOARD_BUTTON_POSITION_PRIORITY_PROPERTY, Property::UNSIGNED_INTEGER, &TextInput::SetProperty, &TextInput::GetProperty );
-PropertyRegistration property15( typeRegistration, "popup-offset-from-text", Toolkit::TextInput::POP_UP_OFFSET_FROM_TEXT_PROPERTY, Property::VECTOR4, &TextInput::SetProperty, &TextInput::GetProperty );
-PropertyRegistration property16( typeRegistration, "cursor-color", Toolkit::TextInput::CURSOR_COLOR_PROPERTY, Property::VECTOR4, &TextInput::SetProperty, &TextInput::GetProperty );
-
-
-// [TextInput::HighlightInfo] /////////////////////////////////////////////////
-
-void TextInput::HighlightInfo::AddQuad( float x1, float y1, float x2, float y2 )
-{
- QuadCoordinates quad(x1, y1, x2, y2);
- mQuadList.push_back( quad );
-}
-
-void TextInput::HighlightInfo::Clamp2D(const Vector2& min, const Vector2& max)
-{
- for(std::size_t i = 0;i < mQuadList.size(); i++)
- {
- QuadCoordinates& quad = mQuadList[i];
-
- quad.min.Clamp(min, max);
- quad.max.Clamp(min, max);
- } // end for
-}
-
-// [TextInput] ////////////////////////////////////////////////////////////////
-
-Dali::Toolkit::TextInput TextInput::New()
-{
- // Create the implementation
- TextInputPtr textInput(new TextInput());
- // Pass ownership to CustomActor via derived handle
- Dali::Toolkit::TextInput handle(*textInput);
- handle.SetName( "TextInput");
-
- textInput->Initialize();
- return handle;
-}
-
-TextInput::TextInput()
-:Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
- mState( StateEdit ),
- mStyledText(),
- mInputStyle(),
- mLineHeight( 0.f ),
- mDisplayedTextView(),
- mStyledPlaceHolderText(),
- mMaxStringLength( DEFAULT_MAX_SIZE ),
- mNumberOflinesLimit( DEFAULT_NUMBER_OF_LINES_LIMIT ),
- mCursorPosition( 0 ),
- mActualGrabHandlePosition( 0.0f, 0.0f, 0.0f ),
- mIsSelectionHandleOneFlipped( false ),
- mIsSelectionHandleTwoFlipped( false ),
- mSelectionHandleOneOffset( DEFAULT_HANDLE_ONE_OFFSET ),
- mSelectionHandleTwoOffset( DEFAULT_HANDLE_TWO_OFFSET ),
- mSelectionHandleOneActualPosition( 0.0f, 0.0f , 0.0f ),
- mSelectionHandleTwoActualPosition( 0.0f, 0.0f , 0.0f ),
- mSelectionHandleOnePosition( 0 ),
- mSelectionHandleTwoPosition( 0 ),
- mPreEditString(),
- mPreEditStartPosition( 0 ),
- mPreEditLength ( 0 ),
- mNumberOfSurroundingCharactersDeleted( 0 ),
- mTouchStartTime( 0 ),
- mTextLayoutInfo(),
- mCurrentCopySelecton(),
- mPopupPanel(),
- mScrollTimer(),
- mScrollDisplacement(),
- mCurrentHandlePosition(),
- mCurrentSelectionId(),
- mCurrentSelectionHandlePosition(),
- mRequestedSelection( 0, 0 ),
- mSelectionHandleFlipMargin( 0.0f, 0.0f, 0.0f, 0.0f ),
- mBoundingRectangleWorldCoordinates( 0.0f, 0.0f, 0.0f, 0.0f ),
- mClipboard(),
- mMaterialColor( LIGHTBLUE ),
- mPopupOffsetFromText ( Vector4( 0.0f, TOP_HANDLE_TOP_OFFSET, 0.0f, BOTTOM_HANDLE_BOTTOM_OFFSET ) ),
- mOverrideAutomaticAlignment( false ),
- mCursorRTLEnabled( false ),
- mClosestCursorPositionEOL ( false ),
- mCursorBlinkStatus( true ),
- mCursorVisibility( false ),
- mGrabHandleVisibility( false ),
- mIsCursorInScrollArea( true ),
- mIsGrabHandleInScrollArea( true ),
- mEditModeActive( false ),
- mEditOnTouch( true ),
- mTextSelection( true ),
- mExceedEnabled( true ),
- mGrabHandleEnabled( true ),
- mIsSelectionHandleFlipEnabled( true ),
- mPreEditFlag( false ),
- mIgnoreCommitFlag( false ),
- mIgnoreFirstCommitFlag( false ),
- mSelectingText( false ),
- mPreserveCursorPosition( false ),
- mSelectTextOnCommit( false ),
- mUnderlinedPriorToPreEdit ( false ),
- mCommitByKeyInput( false ),
- mPlaceHolderSet( false ),
- mMarkUpEnabled( false )
-{
- // Updates the line height accordingly with the input style.
- UpdateLineHeight();
-}
-
-TextInput::~TextInput()
-{
- StopCursorBlinkTimer();
-}
-
-// Public
-
-std::string TextInput::GetText() const
-{
- std::string text;
-
- // Return text-view's text only if the text-input's text is not empty
- // in order to not to return the placeholder text.
- if( !mStyledText.empty() )
- {
- text = mDisplayedTextView.GetText();
- }
-
- return text;
-}
-
-std::string TextInput::GetMarkupText() const
-{
- std::string markupString;
- MarkupProcessor::GetMarkupString( mStyledText, markupString );
-
- return markupString;
-}
-
-void TextInput::ShowPlaceholderText( const MarkupProcessor::StyledTextArray& stylePlaceHolderText )
-{
- mDisplayedTextView.SetText( stylePlaceHolderText );
- mPlaceHolderSet = true;
- mDisplayedTextView.SetScrollPosition( Vector2( 0.0f,0.0f ) );
-}
-
-void TextInput::SetPlaceholderText( const std::string& placeHolderText )
-{
- // Get the placeholder styled text array from the markup string.
- MarkupProcessor::GetStyledTextArray( placeHolderText, mStyledPlaceHolderText, IsMarkupProcessingEnabled() );
- if( mStyledText.empty() )
- {
- ShowPlaceholderText( mStyledPlaceHolderText );
- }
-}
-
-std::string TextInput::GetPlaceholderText()
-{
- // Traverses the styled placeholder array getting only the text.
- // Note that for some languages a 'character' could be represented by more than one 'char'
-
- std::string placeholderText;
- for( MarkupProcessor::StyledTextArray::const_iterator it = mStyledPlaceHolderText.begin(), endIt = mStyledPlaceHolderText.end(); it != endIt; ++it )
- {
- placeholderText.append( (*it).mText.GetText() );
- }
-
- return placeholderText ;
-}
-
-void TextInput::SetInitialText(const std::string& initialText)
-{
- DALI_LOG_INFO(gLogFilter, Debug::General, "SetInitialText string[%s]\n", initialText.c_str() );
-
- if ( mPreEditFlag ) // If in the pre-edit state and text is being set then discard text being inserted.
- {
- mPreEditFlag = false;
- mIgnoreCommitFlag = true;
- }
-
- SetText( initialText );
- PreEditReset( false ); // Reset keyboard as text changed
-}
-
-void TextInput::SetText(const std::string& initialText)
-{
- DALI_LOG_INFO(gLogFilter, Debug::General, "SetText string[%s]\n", initialText.c_str() );
-
- GetStyledTextArray( initialText, mStyledText, IsMarkupProcessingEnabled() );
-
- if( mStyledText.empty() )
- {
- ShowPlaceholderText( mStyledPlaceHolderText );
- }
- else
- {
- mDisplayedTextView.SetText( mStyledText );
- mPlaceHolderSet = false;
- }
-
- GetTextLayoutInfo();
-
- mCursorPosition = mTextLayoutInfo.mCharacterLayoutInfoTable.size();
-
- ImfManager imfManager = ImfManager::Get();
- if ( imfManager )
- {
- imfManager.SetCursorPosition( mCursorPosition );
- imfManager.SetSurroundingText( initialText );
- imfManager.NotifyCursorPosition();
- }
-
- if( IsScrollEnabled() )
- {
- ScrollTextViewToMakeCursorVisible( Vector3( mTextLayoutInfo.mScrollOffset.x, mTextLayoutInfo.mScrollOffset.y, 0.f ) );
- }
-
- ShowGrabHandleAndSetVisibility( false );
-
- RemoveHighlight();
-
- DrawCursor();
-
- EmitTextModified();
-}
-
-void TextInput::SetText( const MarkupProcessor::StyledTextArray& styleText )
-{
- DALI_LOG_INFO(gLogFilter, Debug::General, "SetText markup text\n" );
-
- mDisplayedTextView.SetText( styleText );
- mPlaceHolderSet = false;
-
- // If text alignment hasn't been manually set by application developer, then we
- // automatically determine the alignment based on the content of the text i.e. what
- // language the text begins with.
- // TODO: This should determine different alignments for each line (broken by '\n') of text.
- if(!mOverrideAutomaticAlignment)
- {
- // Determine bidi direction of first character (skipping past whitespace, numbers, and symbols)
- bool leftToRight(true);
-
- if( !styleText.empty() )
- {
- bool breakOut(false);
-
- for( MarkupProcessor::StyledTextArray::const_iterator textIter = styleText.begin(), textEndIter = styleText.end(); ( textIter != textEndIter ) && ( !breakOut ); ++textIter )
- {
- const Text& text = textIter->mText;
-
- for( std::size_t i = 0; i < text.GetLength(); ++i )
- {
- Character character( text[i] );
- if( character.GetCharacterDirection() != Character::Neutral )
- {
- leftToRight = ( character.GetCharacterDirection() == Character::LeftToRight );
- breakOut = true;
- break;
- }
- }
- }
- }
-
- // Based on this direction, either left or right align text if not manually set by application developer.
- mDisplayedTextView.SetTextAlignment( static_cast(
- ( leftToRight ? Toolkit::Alignment::HorizontalLeft : Toolkit::Alignment::HorizontalRight) |
- Toolkit::Alignment::VerticalTop ) );
- mDisplayedTextView.SetLineJustification( leftToRight ? Toolkit::TextView::Left : Toolkit::TextView::Right);
- }
-
- EmitTextModified();
-}
-
-void TextInput::SetMaxCharacterLength(std::size_t maxChars)
-{
- mMaxStringLength = maxChars;
-}
-
-void TextInput::SetNumberOfLinesLimit(std::size_t maxLines)
-{
- DALI_ASSERT_DEBUG( maxLines > 0 )
-
- if ( maxLines > 0)
- {
- mNumberOflinesLimit = maxLines;
- }
-}
-
-std::size_t TextInput::GetNumberOfLinesLimit() const
-{
- return mNumberOflinesLimit;
-}
-
-std::size_t TextInput::GetNumberOfCharacters() const
-{
- return mStyledText.size();
-}
-
-// Styling
-void TextInput::SetMaterialDiffuseColor( const Vector4& color )
-{
- mMaterialColor = color;
- if ( mCustomMaterial )
- {
- mCustomMaterial.SetDiffuseColor( mMaterialColor );
- mMeshData.SetMaterial( mCustomMaterial );
- }
-}
-
-const Vector4& TextInput::GetMaterialDiffuseColor() const
-{
- return mMaterialColor;
-}
-
-// Signals
-
-Toolkit::TextInput::InputSignalV2& TextInput::InputStartedSignal()
-{
- return mInputStartedSignalV2;
-}
-
-Toolkit::TextInput::InputSignalV2& TextInput::InputFinishedSignal()
-{
- return mInputFinishedSignalV2;
-}
-
-Toolkit::TextInput::InputSignalV2& TextInput::CutAndPasteToolBarDisplayedSignal()
-{
- return mCutAndPasteToolBarDisplayedV2;
-}
-
-Toolkit::TextInput::StyleChangedSignalV2& TextInput::StyleChangedSignal()
-{
- return mStyleChangedSignalV2;
-}
-
-Toolkit::TextInput::TextModifiedSignalType& TextInput::TextModifiedSignal()
-{
- return mTextModifiedSignal;
-}
-
-Toolkit::TextInput::MaxInputCharactersReachedSignalV2& TextInput::MaxInputCharactersReachedSignal()
-{
- return mMaxInputCharactersReachedSignalV2;
-}
-
-Toolkit::TextInput::InputTextExceedBoundariesSignalV2& TextInput::InputTextExceedBoundariesSignal()
-{
- return mInputTextExceedBoundariesSignalV2;
-}
-
-bool TextInput::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
-{
- Dali::BaseHandle handle( object );
-
- bool connected( true );
- Toolkit::TextInput textInput = Toolkit::TextInput::DownCast(handle);
-
- if( Toolkit::TextInput::SIGNAL_START_INPUT == signalName )
- {
- textInput.InputStartedSignal().Connect( tracker, functor );
- }
- else if( Toolkit::TextInput::SIGNAL_END_INPUT == signalName )
- {
- textInput.InputFinishedSignal().Connect( tracker, functor );
- }
- else if( Toolkit::TextInput::SIGNAL_STYLE_CHANGED == signalName )
- {
- textInput.StyleChangedSignal().Connect( tracker, functor );
- }
- else if( Toolkit::TextInput::SIGNAL_MAX_INPUT_CHARACTERS_REACHED == signalName )
- {
- textInput.MaxInputCharactersReachedSignal().Connect( tracker, functor );
- }
- else if( Toolkit::TextInput::SIGNAL_TEXT_EXCEED_BOUNDARIES == signalName )
- {
- textInput.InputTextExceedBoundariesSignal().Connect( tracker, functor );
- }
- else
- {
- // signalName does not match any signal
- connected = false;
- }
-
- return connected;
-}
-
-void TextInput::SetEditable(bool editMode, bool setCursorOnTouchPoint, const Vector2& touchPoint)
-{
- if(editMode)
- {
- // update line height before calculate the actual position.
- UpdateLineHeight();
-
- if(!mEditModeActive)
- {
- if( setCursorOnTouchPoint )
- {
- // Sets the cursor position for the given touch point.
- ReturnClosestIndex( touchPoint, mCursorPosition );
-
- // Creates the grab handle.
- if( IsGrabHandleEnabled() )
- {
- const Vector3 cursorPosition = GetActualPositionFromCharacterPosition(mCursorPosition);
-
- CreateGrabHandle();
-
- mActualGrabHandlePosition.x = cursorPosition.x; // Set grab handle to be at the cursor position
- mActualGrabHandlePosition.y = cursorPosition.y; // Set grab handle to be at the cursor position
- mGrabHandle.SetPosition( mActualGrabHandlePosition + UI_OFFSET );
- ShowGrabHandleAndSetVisibility( true );
-
- // Scrolls the text-view if needed.
- if( IsScrollEnabled() )
- {
- ScrollTextViewToMakeCursorVisible( cursorPosition );
- }
- }
- }
- else
- {
- mCursorPosition = mStyledText.size(); // Initially set cursor position to end of string.
- }
- }
-
- StartEditMode();
- }
- else
- {
- EndEditMode();
- }
-}
-
-bool TextInput::IsEditable() const
-{
- return mEditModeActive;
-}
-
-void TextInput::SetEditOnTouch( bool editOnTouch )
-{
- mEditOnTouch = editOnTouch;
-}
-
-bool TextInput::IsEditOnTouch() const
-{
- return mEditOnTouch;
-}
-
-void TextInput::SetTextSelectable( bool textSelectable )
-{
- mTextSelection = textSelectable;
-}
-
-bool TextInput::IsTextSelectable() const
-{
- return mTextSelection;
-}
-
-bool TextInput::IsTextSelected() const
-{
- return mHighlightMeshActor;
-}
-
-void TextInput::DeSelectText()
-{
- RemoveHighlight();
- HidePopup();
- CursorUpdate();
-}
-
-void TextInput::SetGrabHandleImage(Dali::Image image )
-{
- if (image)
- {
- CreateGrabHandle(image);
- }
-}
-
-void TextInput::SetCursorImage(Dali::Image image, const Vector4& border )
-{
- DALI_ASSERT_DEBUG ( image && "Create cursor image invalid")
-
- if ( image )
- {
- mCursor.SetImage( image );
- mCursor.SetNinePatchBorder( border );
- }
-}
-
-Vector3 TextInput::GetSelectionHandleSize()
-{
- return DEFAULT_SELECTION_HANDLE_SIZE;
-}
-
-void TextInput::SetRTLCursorImage(Dali::Image image, const Vector4& border )
-{
- DALI_ASSERT_DEBUG ( image && "Create cursor image invalid")
-
- if ( image )
- {
- mCursorRTL.SetImage( image);
- mCursorRTL.SetNinePatchBorder( border );
- }
-}
-
-void TextInput::EnableGrabHandle(bool toggle)
-{
- // enables grab handle with will in turn de-activate magnifier
- mGrabHandleEnabled = toggle;
-}
-
-bool TextInput::IsGrabHandleEnabled()
-{
- // if false then magnifier will be shown instead.
- return mGrabHandleEnabled;
-}
-
-void TextInput::EnableSelectionHandleFlip( bool toggle )
-{
- // Deprecated function. To be removed.
- mIsSelectionHandleFlipEnabled = toggle;
-}
-
-bool TextInput::IsSelectionHandleFlipEnabled()
-{
- // Deprecated function, To be removed. Returns true as handle flipping always enabled by default so handles do not exceed screen.
- return true;
-}
-
-void TextInput::SetSelectionHandleFlipMargin( const Vector4& margin )
-{
- // Deprecated function, now just stores margin for retreival, remove completely once depricated Public API removed.
- Vector3 textInputSize = mDisplayedTextView.GetCurrentSize();
- const Vector4 flipBoundary( -margin.x, -margin.y, textInputSize.width + margin.z, textInputSize.height + margin.w );
-
- mSelectionHandleFlipMargin = margin;
-}
-
-void TextInput::SetBoundingRectangle( const Rect& boundingRectangle )
-{
- // Convert to world coordinates and store as a Vector4 to be compatiable with Property Notifications.
- Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
-
- const float originX = boundingRectangle.x - 0.5f * stageSize.width;
- const float originY = boundingRectangle.y - 0.5f * stageSize.height;
-
- const Vector4 boundary( originX,
- originY,
- originX + boundingRectangle.width,
- originY + boundingRectangle.height );
-
- mBoundingRectangleWorldCoordinates = boundary;
-}
-
-const Rect TextInput::GetBoundingRectangle() const
-{
- Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
-
- const float originX = mBoundingRectangleWorldCoordinates.x + 0.5f * stageSize.width;
- const float originY = mBoundingRectangleWorldCoordinates.y + 0.5f * stageSize.height;
-
- RectboundingRect( originX, originY, mBoundingRectangleWorldCoordinates.z - mBoundingRectangleWorldCoordinates.x, mBoundingRectangleWorldCoordinates.w - mBoundingRectangleWorldCoordinates.y);
-
- return boundingRect;
-}
-
-const Vector4& TextInput::GetSelectionHandleFlipMargin()
-{
- return mSelectionHandleFlipMargin;
-}
-
-void TextInput::SetTextColor( const Vector4& color )
-{
- mDisplayedTextView.SetColor( color );
-}
-
-void TextInput::SetActiveStyle( const TextStyle& style, const TextStyle::Mask mask )
-{
- if( style != mInputStyle )
- {
- // different style.
- bool emitSignal = false;
-
- // mask: modify style according to mask, if different emit signal.
- const TextStyle oldInputStyle( mInputStyle );
-
- // Copy the new style.
- mInputStyle.Copy( style, mask );
-
- // if style has changed, emit signal.
- if( oldInputStyle != mInputStyle )
- {
- emitSignal = true;
- }
-
- // Updates the line height accordingly with the input style.
- UpdateLineHeight();
-
- // Changing font point size will require the cursor to be re-sized
- DrawCursor();
-
- if( emitSignal )
- {
- EmitStyleChangedSignal();
- }
- }
-}
-
-void TextInput::ApplyStyle( const TextStyle& style, const TextStyle::Mask mask )
-{
- if ( IsTextSelected() )
- {
- const std::size_t begin = std::min(mSelectionHandleOnePosition, mSelectionHandleTwoPosition);
- const std::size_t end = std::max(mSelectionHandleOnePosition, mSelectionHandleTwoPosition) - 1;
-
- if( !mTextLayoutInfo.mCharacterLogicalToVisualMap.empty() )
- {
- ApplyStyleToRange(style, mask, mTextLayoutInfo.mCharacterLogicalToVisualMap[begin], mTextLayoutInfo.mCharacterLogicalToVisualMap[end]);
- }
-
- // Keeps the old style to be compared with the new one.
- const TextStyle oldInputStyle( mInputStyle );
-
- // Copy only those parameters from the style which are set in the mask.
- mInputStyle.Copy( style, mask );
-
- if( mInputStyle != oldInputStyle )
- {
- // Updates the line height accordingly with the input style.
- UpdateLineHeight();
-
- EmitStyleChangedSignal();
- }
- }
-}
-
-void TextInput::ApplyStyleToAll( const TextStyle& style, const TextStyle::Mask mask )
-{
- if( !mStyledText.empty() )
- {
- ApplyStyleToRange( style, mask, 0, mStyledText.size() - 1 );
- }
-}
-
-TextStyle TextInput::GetStyleAtCursor() const
-{
- TextStyle style;
-
- if ( !mStyledText.empty() && ( mCursorPosition > 0 ) )
- {
- DALI_ASSERT_DEBUG( ( 0 <= mCursorPosition-1 ) && ( mCursorPosition-1 < mStyledText.size() ) );
- style = mStyledText.at( mCursorPosition-1 ).mStyle;
- }
- else // No text.
- {
- style = mInputStyle;
-
- if ( mInputStyle.GetFontPointSize() < Math::MACHINE_EPSILON_1000 )
- {
- Dali::Font defaultFont = Dali::Font::New();
- style.SetFontPointSize( PointSize( defaultFont.GetPointSize()) );
- }
- }
-
- return style;
-}
-
-TextStyle TextInput::GetStyleAt( std::size_t position ) const
-{
- DALI_ASSERT_DEBUG( ( 0 <= position ) && ( position <= mStyledText.size() ) );
-
- if( position >= mStyledText.size() )
- {
- position = mStyledText.size() - 1;
- }
-
- return mStyledText.at( position ).mStyle;
-}
-
-void TextInput::SetTextAlignment( Toolkit::Alignment::Type align )
-{
- mDisplayedTextView.SetTextAlignment( align );
- mOverrideAutomaticAlignment = true;
-}
-
-void TextInput::SetTextLineJustification( Toolkit::TextView::LineJustification justification )
-{
- mDisplayedTextView.SetLineJustification( justification );
- mOverrideAutomaticAlignment = true;
-}
-
-void TextInput::SetFadeBoundary( const Toolkit::TextView::FadeBoundary& fadeBoundary )
-{
- mDisplayedTextView.SetFadeBoundary( fadeBoundary );
-}
-
-const Toolkit::TextView::FadeBoundary& TextInput::GetFadeBoundary() const
-{
- return mDisplayedTextView.GetFadeBoundary();
-}
-
-Toolkit::Alignment::Type TextInput::GetTextAlignment() const
-{
- return mDisplayedTextView.GetTextAlignment();
-}
-
-void TextInput::SetMultilinePolicy( Toolkit::TextView::MultilinePolicy policy )
-{
- mDisplayedTextView.SetMultilinePolicy( policy );
-}
-
-Toolkit::TextView::MultilinePolicy TextInput::GetMultilinePolicy() const
-{
- return mDisplayedTextView.GetMultilinePolicy();
-}
-
-void TextInput::SetWidthExceedPolicy( Toolkit::TextView::ExceedPolicy policy )
-{
- mDisplayedTextView.SetWidthExceedPolicy( policy );
-}
-
-Toolkit::TextView::ExceedPolicy TextInput::GetWidthExceedPolicy() const
-{
- return mDisplayedTextView.GetWidthExceedPolicy();
-}
-
-void TextInput::SetHeightExceedPolicy( Toolkit::TextView::ExceedPolicy policy )
-{
- mDisplayedTextView.SetHeightExceedPolicy( policy );
-}
-
-Toolkit::TextView::ExceedPolicy TextInput::GetHeightExceedPolicy() const
-{
- return mDisplayedTextView.GetHeightExceedPolicy();
-}
-
-void TextInput::SetExceedEnabled( bool enable )
-{
- mExceedEnabled = enable;
-}
-
-bool TextInput::GetExceedEnabled() const
-{
- return mExceedEnabled;
-}
-
-void TextInput::SetBackground(Dali::Image image )
-{
- // TODO Should add this function and add public api to match.
-}
-
-bool TextInput::OnTouchEvent(const TouchEvent& event)
-{
- return false;
-}
-
-bool TextInput::OnKeyEvent(const KeyEvent& event)
-{
- switch( event.state )
- {
- case KeyEvent::Down:
- {
- return OnKeyDownEvent(event);
- }
- break;
-
- case KeyEvent::Up:
- {
- return OnKeyUpEvent(event);
- }
- break;
-
- default:
- {
- return false;
- }
- break;
- }
-}
-
-void TextInput::OnKeyInputFocusGained()
-{
- DALI_LOG_INFO(gLogFilter, Debug::General, ">>OnKeyInputFocusGained\n" );
-
- mEditModeActive = true;
-
- mActiveLayer.RaiseToTop(); // Ensure layer holding handles is on top
-
- mInputStyle = GetStyleAtCursor(); // Inherit style from cursor position
-
- // Updates the line height accordingly with the input style.
- UpdateLineHeight();
-
- // Connect the signals to use in text input.
- VirtualKeyboard::StatusChangedSignal().Connect( this, &TextInput::KeyboardStatusChanged );
- VirtualKeyboard::LanguageChangedSignal().Connect( this, &TextInput::SetTextDirection );
-
- // Set the text direction if empty and connect to the signal to ensure we change direction when the language changes.
- SetTextDirection();
-
- GetTextLayoutInfo();
-
- DrawCursor();
- SetCursorVisibility( true );
- StartCursorBlinkTimer();
-
- Toolkit::TextInput handle( GetOwner() );
- mInputStartedSignalV2.Emit( handle );
-
- ImfManager imfManager = ImfManager::Get();
-
- if ( imfManager )
- {
- imfManager.EventReceivedSignal().Connect(this, &TextInput::ImfEventReceived);
-
- // Notify that the text editing start.
- imfManager.Activate();
-
- // When window gain lost focus, the imf manager is deactivated. Thus when window gain focus again, the imf manager must be activated.
- imfManager.SetRestoreAfterFocusLost( true );
-
- imfManager.SetCursorPosition( mCursorPosition );
- imfManager.NotifyCursorPosition();
- }
-
- mClipboard = Clipboard::Get(); // Store handle to clipboard
-
- // Now in edit mode we can accept string to paste from clipboard
- ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
- if ( notifier )
- {
- notifier.ContentSelectedSignal().Connect( this, &TextInput::OnClipboardTextSelected );
- }
-}
-
-void TextInput::OnKeyInputFocusLost()
-{
- DALI_LOG_INFO(gLogFilter, Debug::General, ">>OnKeyInputFocusLost\n" );
-
- if( mPreEditFlag )
- {
- // If key input focus is lost, it removes the
- // underline from the last pre-edit text.
- RemovePreEditStyle();
- const std::size_t numberOfCharactersDeleted = DeletePreEdit();
- InsertAt( mPreEditString, mPreEditStartPosition, numberOfCharactersDeleted );
- EmitTextModified();
- }
-
- ImfManager imfManager = ImfManager::Get();
- if ( imfManager )
- {
- // The text editing is finished. Therefore the imf manager don't have restore activation.
- imfManager.SetRestoreAfterFocusLost( false );
-
- // Notify that the text editing finish.
- imfManager.Deactivate();
-
- imfManager.EventReceivedSignal().Disconnect(this, &TextInput::ImfEventReceived);
- }
- // Disconnect signal used the text input.
- VirtualKeyboard::LanguageChangedSignal().Disconnect( this, &TextInput::SetTextDirection );
-
- Toolkit::TextInput handle( GetOwner() );
- mInputFinishedSignalV2.Emit( handle );
- mEditModeActive = false;
- mPreEditFlag = false;
- RemoveHighlight();
- SetCursorVisibility( false );
- StopCursorBlinkTimer();
-
- ShowGrabHandleAndSetVisibility( false );
-
- mClipboard.Reset();
- // No longer in edit mode so do not want to receive string from clipboard
- ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
- if ( notifier )
- {
- notifier.ContentSelectedSignal().Disconnect( this, &TextInput::OnClipboardTextSelected );
- }
-
- Clipboard clipboard = Clipboard::Get();
- if ( clipboard )
- {
- clipboard.HideClipboard();
- }
-}
-
-void TextInput::OnControlStageConnection()
-{
- Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
-
- if ( mBoundingRectangleWorldCoordinates == Vector4::ZERO )
- {
- SetBoundingRectangle( Rect( 0.0f, 0.0f, stageSize.width, stageSize.height ));
- }
-}
-
-void TextInput::CreateActiveLayer()
-{
- Actor self = Self();
- mActiveLayer = Layer::New();
- mActiveLayer.SetName ( "ActiveLayerActor" );
-
- mActiveLayer.SetAnchorPoint( AnchorPoint::CENTER);
- mActiveLayer.SetParentOrigin( ParentOrigin::CENTER);
- mActiveLayer.SetPositionInheritanceMode( USE_PARENT_POSITION );
-
- self.Add( mActiveLayer );
- mActiveLayer.RaiseToTop();
-}
-
-void TextInput::OnInitialize()
-{
- CreateTextViewActor();
-
- SetUpTouchEvents();
-
- // Create 2 cursors (standard LTR and RTL cursor for when text can be added at
- // different positions depending on language)
- mCursor = CreateCursor(DEFAULT_CURSOR_COLOR);
- mCursorRTL = CreateCursor(DEFAULT_CURSOR_COLOR);
-
- Actor self = Self();
- self.Add( mCursor );
- self.Add( mCursorRTL );
-
- mCursorVisibility = false;
-
- CreateActiveLayer(); // todo move this so layer only created when needed.
-
- // Assign names to image actors
- mCursor.SetName("mainCursor");
- mCursorRTL.SetName("rtlCursor");
-}
-
-void TextInput::OnControlSizeSet(const Vector3& targetSize)
-{
- mDisplayedTextView.SetSize( targetSize );
- GetTextLayoutInfo();
- mActiveLayer.SetSize(targetSize);
-}
-
-void TextInput::OnRelaidOut( Vector2 size, ActorSizeContainer& container )
-{
- Relayout( mDisplayedTextView, size, container );
- Relayout( mPopupPanel.GetRootActor(), size, container );
-
- GetTextLayoutInfo();
-
- DrawCursor();
-}
-
-Vector3 TextInput::GetNaturalSize()
-{
- Vector3 naturalSize = mDisplayedTextView.GetNaturalSize();
-
- if( mEditModeActive && ( Vector3::ZERO == naturalSize ) )
- {
- // If the natural is zero, it means there is no text. Let's return the cursor height as the natural height.
- naturalSize.height = mLineHeight;
- }
-
- return naturalSize;
-}
-
-float TextInput::GetHeightForWidth( float width )
-{
- float height = mDisplayedTextView.GetHeightForWidth( width );
-
- if( mEditModeActive && ( fabsf( height ) < Math::MACHINE_EPSILON_1000 ) )
- {
- // If the height is zero, it means there is no text. Let's return the cursor height.
- height = mLineHeight;
- }
-
- return height;
-}
-
-/*end of Virtual methods from parent*/
-
-// Private Internal methods
-
-void TextInput::OnHandlePan(Actor actor, const PanGesture& gesture)
-{
- switch (gesture.state)
- {
- case Gesture::Started:
- // fall through so code not duplicated
- case Gesture::Continuing:
- {
- if (actor == mGrabArea)
- {
- SetCursorVisibility( true );
- ShowGrabHandle( mGrabHandleVisibility && mIsGrabHandleInScrollArea );
- MoveGrabHandle( gesture.displacement );
- HidePopup(); // Do not show popup whilst handle is moving
- }
- else if (actor == mHandleOneGrabArea)
- {
- // the displacement in PanGesture is affected by the actor's rotation.
- mSelectionHandleOneActualPosition.x += gesture.displacement.x * mSelectionHandleOne.GetCurrentScale().x;
- mSelectionHandleOneActualPosition.y += gesture.displacement.y * mSelectionHandleOne.GetCurrentScale().y;
-
- MoveSelectionHandle( HandleOne, gesture.displacement );
-
- mState = StateDraggingHandle;
- HidePopup();
- }
- else if (actor == mHandleTwoGrabArea)
- {
- // the displacement in PanGesture is affected by the actor's rotation.
- mSelectionHandleTwoActualPosition.x += gesture.displacement.x * mSelectionHandleTwo.GetCurrentScale().x;
- mSelectionHandleTwoActualPosition.y += gesture.displacement.y * mSelectionHandleTwo.GetCurrentScale().y;
-
- MoveSelectionHandle( HandleTwo, gesture.displacement );
-
- mState = StateDraggingHandle;
- HidePopup();
- }
- }
- break;
-
- case Gesture::Finished:
- {
- // Revert back to non-pressed selection handle images
- if (actor == mGrabArea)
- {
- mActualGrabHandlePosition = MoveGrabHandle( gesture.displacement );
- SetCursorVisibility( true );
- SetUpPopupSelection();
- ShowPopup();
- }
- if (actor == mHandleOneGrabArea)
- {
- // the displacement in PanGesture is affected by the actor's rotation.
- mSelectionHandleOneActualPosition.x += gesture.displacement.x * mSelectionHandleOne.GetCurrentScale().x;
- mSelectionHandleOneActualPosition.y += gesture.displacement.y * mSelectionHandleOne.GetCurrentScale().y;
-
- mSelectionHandleOneActualPosition = MoveSelectionHandle( HandleOne, gesture.displacement );
-
- mSelectionHandleOne.SetImage( mSelectionHandleOneImage );
- mState = StateEdit;
- ShowPopupCutCopyPaste();
- }
- if (actor == mHandleTwoGrabArea)
- {
- // the displacement in PanGesture is affected by the actor's rotation.
- mSelectionHandleTwoActualPosition.x += gesture.displacement.x * mSelectionHandleTwo.GetCurrentScale().x;
- mSelectionHandleTwoActualPosition.y += gesture.displacement.y * mSelectionHandleTwo.GetCurrentScale().y;
-
- mSelectionHandleTwoActualPosition = MoveSelectionHandle( HandleTwo, gesture.displacement );
-
- mSelectionHandleTwo.SetImage( mSelectionHandleTwoImage );
- mState = StateEdit;
- ShowPopupCutCopyPaste();
- }
- }
- break;
- default:
- break;
- }
-}
-
-// Stop the flashing animation so easy to see when moved.
-bool TextInput::OnPressDown(Dali::Actor actor, const TouchEvent& touch)
-{
- if (touch.GetPoint(0).state == TouchPoint::Down)
- {
- SetCursorVisibility( true );
- StopCursorBlinkTimer();
- }
- else if (touch.GetPoint(0).state == TouchPoint::Up)
- {
- SetCursorVisibility( true );
- StartCursorBlinkTimer();
- }
- return false;
-}
-
-// selection handle one
-bool TextInput::OnHandleOneTouched(Dali::Actor actor, const TouchEvent& touch)
-{
- if (touch.GetPoint(0).state == TouchPoint::Down)
- {
- mSelectionHandleOne.SetImage( mSelectionHandleOneImagePressed );
- }
- else if (touch.GetPoint(0).state == TouchPoint::Up)
- {
- mSelectionHandleOne.SetImage( mSelectionHandleOneImage );
- }
- return false;
-}
-
-// selection handle two
-bool TextInput::OnHandleTwoTouched(Dali::Actor actor, const TouchEvent& touch)
-{
- if (touch.GetPoint(0).state == TouchPoint::Down)
- {
- mSelectionHandleTwo.SetImage( mSelectionHandleTwoImagePressed );
- }
- else if (touch.GetPoint(0).state == TouchPoint::Up)
- {
- mSelectionHandleTwo.SetImage( mSelectionHandleTwoImage );
- }
- return false;
-}
-
-void TextInput::OnDoubleTap(Dali::Actor actor, const Dali::TapGesture& tap)
-{
- // If text exists then select nearest word.
- if ( !mStyledText.empty())
- {
- HidePopup();
-
- ShowGrabHandleAndSetVisibility( false );
-
-
- if ( mPreEditFlag )
- {
- // PreEdit will be committed here without needing a commit from IMF. Remove pre-edit underline and reset flags which
- // converts the pre-edit word being displayed to a committed word.
- if ( !mUnderlinedPriorToPreEdit )
- {
- TextStyle style;
- style.SetUnderline( false );
- ApplyStyleToRange( style, TextStyle::UNDERLINE , mPreEditStartPosition, mPreEditStartPosition + mPreEditLength -1 );
- }
- mPreEditFlag = false;
- mIgnoreCommitFlag = true; // Predictive word interrupted, text displayed will not change, no need to actually commit.
- // Reset keyboard and set true so cursor position is preserved. Otherwise cursor position will that of the committed text not new tap location.
- PreEditReset( false );
- }
- mCursorPosition = 0;
-
- mTextLayoutInfo.mScrollOffset = mDisplayedTextView.GetScrollPosition();
- ReturnClosestIndex( tap.localPoint, mCursorPosition );
-
- std::size_t start = 0;
- std::size_t end = 0;
- Dali::Toolkit::Internal::TextProcessor::FindNearestWord( mStyledText, mCursorPosition, start, end );
-
- mCursorPosition = end; // Ensure cursor is positioned at end of selected word
-
- ImfManager imfManager = ImfManager::Get();
- if ( imfManager )
- {
- imfManager.SetCursorPosition ( mCursorPosition );
- imfManager.NotifyCursorPosition();
- }
-
- if ( !mStyledText.at(end-1).mText[0].IsWhiteSpace() )
- {
- SelectText( start, end );
- ShowPopupCutCopyPaste();
- }
- else
- {
- RemoveHighlight( false ); // Remove highlight but do not auto hide popup
- HidePopup( false ); // Hide popup with setting to do auto show.
- SetUpPopupSelection( false ); // Set to false so if nearest word is whitespace it will not show cut button.
- ShowPopup();
- }
- }
- else if ( mClipboard && mClipboard.NumberOfItems() )
- {
- ShowPopupCutCopyPaste();
- }
-
- // If no text and clipboard empty then do nothing
-}
-
-// TODO: Change the function name to be more general.
-void TextInput::OnTextTap(Dali::Actor actor, const Dali::TapGesture& tap)
-{
- DALI_LOG_INFO( gLogFilter, Debug::General, "OnTap mPreEditFlag[%s] mEditOnTouch[%s] mEditModeActive[%s] ", (mPreEditFlag)?"true":"false"
- , (mEditOnTouch)?"true":"false"
- , (mEditModeActive)?"true":"false");
-
- if( mHandleOneGrabArea == actor || mHandleTwoGrabArea == actor )
- {
- return;
- }
-
- if( mGrabArea == actor )
- {
- if( mPopupPanel.GetState() == TextInputPopup::StateHidden || mPopupPanel.GetState() == TextInputPopup::StateHiding )
- {
- SetUpPopupSelection();
- ShowPopup();
- }
-
- return;
- }
-
- HidePopup();
- RemoveHighlight();
-
- mTextLayoutInfo.mScrollOffset = mDisplayedTextView.GetScrollPosition();
-
- // Initially don't create the grab handle.
- bool createGrabHandle = false;
-
- if ( !mEditModeActive )
- {
- // update line height before calculate the actual position.
- UpdateLineHeight();
-
- // Only start edit mode if TextInput configured to edit on touch
- if ( mEditOnTouch )
- {
- // Set the initial cursor position in the tap point.
- ReturnClosestIndex(tap.localPoint, mCursorPosition );
- StartEditMode();
- }
- }
- else
- {
- // Show the keyboard if it was hidden.
- if (!VirtualKeyboard::IsVisible())
- {
- VirtualKeyboard::Show();
- }
-
- // Reset keyboard as tap event has occurred.
- // Set true so cursor position is preserved. Otherwise cursor position will that of the committed text not new tap location.
- PreEditReset( true );
-
- GetTextLayoutInfo();
-
- if( !mTextLayoutInfo.mCharacterLayoutInfoTable.empty() ) // If string empty we do not need a grab handle.
- {
- // As already in edit mode, reposition cursor near tap and show grab handle for cursor, if grab handle not enabled then magnifier will be used instead.
-
- ReturnClosestIndex(tap.localPoint, mCursorPosition );
-
- DALI_LOG_INFO( gLogFilter, Debug::General, "mCursorPosition[%u]", mCursorPosition );
-
- // Notify keyboard so it can 're-capture' word for predictive text.
- // As we have done a reset, is this required, expect IMF keyboard to request this information.
- ImfManager imfManager = ImfManager::Get();
- if ( imfManager )
- {
- imfManager.SetCursorPosition ( mCursorPosition );
- imfManager.NotifyCursorPosition();
- }
- const TextStyle oldInputStyle( mInputStyle );
-
- mInputStyle = GetStyleAtCursor(); // Inherit style from cursor position
-
- DrawCursor();
-
- // Create the grab handle.
- // Grab handle is created later.
- createGrabHandle = true;
-
- if( oldInputStyle != mInputStyle )
- {
- // Updates the line height accordingly with the input style.
- UpdateLineHeight();
-
- EmitStyleChangedSignal();
- }
- }
- }
-
- // Edit mode started after grab handle created to ensure the signal InputStarted is sent last.
- // This is used to ensure if selecting text hides the grab handle then this code is run after grab handle is created,
- // otherwise the Grab handle will be shown when selecting.
- if ( createGrabHandle && IsGrabHandleEnabled() )
- {
- Vector3 altPosition; // Alternate (i.e. opposite direction) cursor position.
- bool altPositionValid; // Alternate cursor validity flag.
- bool directionRTL; // Need to know direction of primary cursor (in case we have 2 cursors and need to show them differently)
- Vector3 cursorPosition = GetActualPositionFromCharacterPosition( mCursorPosition, directionRTL, altPosition, altPositionValid );
-
- if( altPositionValid )
- {
- // Check which of the positions is the closest.
- if( fabsf( altPosition.x - tap.localPoint.x ) < fabsf( cursorPosition.x - tap.localPoint.x ) )
- {
- cursorPosition = altPosition;
- }
- }
-
- CreateGrabHandle();
-
- mActualGrabHandlePosition.x = cursorPosition.x; // Set grab handle to be at the cursor position
- mActualGrabHandlePosition.y = cursorPosition.y; // Set grab handle to be at the cursor position
- mGrabHandle.SetPosition( mActualGrabHandlePosition + UI_OFFSET );
- ShowGrabHandleAndSetVisibility( mIsGrabHandleInScrollArea );
-
- }
-}
-
-void TextInput::OnLongPress(Dali::Actor actor, const Dali::LongPressGesture& longPress)
-{
- DALI_LOG_INFO( gLogFilter, Debug::General, "OnLongPress\n" );
-
- // Ignore longpress if in selection mode already
- if( mHighlightMeshActor )
- {
- return;
- }
-
- if(longPress.state == Dali::Gesture::Started)
- {
- // Start edit mode on long press
- if ( !mEditModeActive )
- {
- StartEditMode();
- }
-
- // If text exists then select nearest word.
- if ( !mStyledText.empty())
- {
- HidePopup();
-
- ShowGrabHandleAndSetVisibility( false );
-
-
- if ( mPreEditFlag )
- {
- // PreEdit will be committed here without needing a commit from IMF. Remove pre-edit underline and reset flags which
- // converts the pre-edit word being displayed to a committed word.
- if ( !mUnderlinedPriorToPreEdit )
- {
- TextStyle style;
- style.SetUnderline( false );
- ApplyStyleToRange( style, TextStyle::UNDERLINE , mPreEditStartPosition, mPreEditStartPosition + mPreEditLength -1 );
- }
- mPreEditFlag = false;
- mIgnoreCommitFlag = true; // Predictive word interrupted, text displayed will not change, no need to actually commit.
- // Reset keyboard and set true so cursor position is preserved. Otherwise cursor position will that of the committed text not new tap location.
- PreEditReset( false );
- }
- mCursorPosition = 0;
-
- mTextLayoutInfo.mScrollOffset = mDisplayedTextView.GetScrollPosition();
- ReturnClosestIndex( longPress.localPoint, mCursorPosition );
-
- std::size_t start = 0;
- std::size_t end = 0;
- Dali::Toolkit::Internal::TextProcessor::FindNearestWord( mStyledText, mCursorPosition, start, end );
-
- mCursorPosition = end; // Ensure cursor is positioned at end of selected word
-
- ImfManager imfManager = ImfManager::Get();
- if ( imfManager )
- {
- imfManager.SetCursorPosition ( mCursorPosition );
- imfManager.NotifyCursorPosition();
- }
-
- SelectText( start, end );
- }
-
- // if no text but clipboard has content then show paste option, if no text and clipboard empty then do nothing
- if ( ( mClipboard && mClipboard.NumberOfItems() ) || !mStyledText.empty() )
- {
- ShowPopupCutCopyPaste();
- }
- }
-}
-
-void TextInput::OnClipboardTextSelected( ClipboardEventNotifier& notifier )
-{
- const Text clipboardText( notifier.GetContent() );
- PasteText( clipboardText );
-
- SetCursorVisibility( true );
- StartCursorBlinkTimer();
-
- ShowGrabHandleAndSetVisibility( false );
-
-
- HidePopup();
-}
-
-bool TextInput::OnPopupButtonPressed( Toolkit::Button button )
-{
- mPopupPanel.PressedSignal().Disconnect( this, &TextInput::OnPopupButtonPressed );
-
- const std::string& name = button.GetName();
-
- if(name == TextInputPopup::OPTION_SELECT_WORD)
- {
- std::size_t start = 0;
- std::size_t end = 0;
- Dali::Toolkit::Internal::TextProcessor::FindNearestWord( mStyledText, mCursorPosition, start, end );
-
- SelectText( start, end );
- }
- else if(name == TextInputPopup::OPTION_SELECT_ALL)
- {
- SetCursorVisibility(false);
- StopCursorBlinkTimer();
-
- std::size_t end = mTextLayoutInfo.mCharacterLayoutInfoTable.size();
- std::size_t start = 0;
-
- SelectText( start, end );
- }
- else if(name == TextInputPopup::OPTION_CUT)
- {
- bool ret = CopySelectedTextToClipboard();
-
- if ( ret )
- {
- DeleteHighlightedText( true );
- CursorUpdate();
- }
-
- SetCursorVisibility( true );
- StartCursorBlinkTimer();
-
- HidePopup();
- }
- else if(name == TextInputPopup::OPTION_COPY)
- {
- CopySelectedTextToClipboard();
-
- RemoveHighlight();
-
- SetCursorVisibility( true );
- StartCursorBlinkTimer();
-
- HidePopup();
- }
- else if(name == TextInputPopup::OPTION_PASTE)
- {
- const Text retrievedString( mClipboard.GetItem( 0 ) ); // currently can only get first item in clip board, index 0;
-
- PasteText(retrievedString);
-
- SetCursorVisibility( true );
- StartCursorBlinkTimer();
-
- ShowGrabHandleAndSetVisibility( false );
-
- HidePopup();
- }
- else if(name == TextInputPopup::OPTION_CLIPBOARD)
- {
- // In the case of clipboard being shown we do not want to show updated pop-up after hide animation completes
- // Hence pass the false parameter for signalFinished.
- HidePopup( true, false );
- mClipboard.ShowClipboard();
- }
-
- return false;
-}
-
-bool TextInput::OnCursorBlinkTimerTick()
-{
- // Cursor blinking
- mCursor.SetVisible( mCursorVisibility && mIsCursorInScrollArea && mCursorBlinkStatus );
- if ( mCursorRTLEnabled )
- {
- mCursorRTL.SetVisible( mCursorVisibility && mIsCursorInScrollArea && mCursorBlinkStatus );
- }
- mCursorBlinkStatus = !mCursorBlinkStatus;
-
- return true;
-}
-
-void TextInput::OnPopupHideFinished(TextInputPopup& popup)
-{
- popup.HideFinishedSignal().Disconnect( this, &TextInput::OnPopupHideFinished );
-
- // Change Popup menu to Cut/Copy/Paste if text has been selected.
- if(mHighlightMeshActor && mState == StateEdit)
- {
- ShowPopupCutCopyPaste();
- }
-}
-
-//FIXME this routine needs to be re-written as it contains too many branches.
-bool TextInput::OnKeyDownEvent(const KeyEvent& event)
-{
- std::string keyName = event.keyPressedName;
- std::string keyString = event.keyPressed;
-
- DALI_LOG_INFO(gLogFilter, Debug::General, "OnKeyDownEvent keyName[%s] KeyString[%s]\n", keyName.c_str(), keyString.c_str() );
-
- // Do not consume "Tab" and "Escape" keys.
- if(keyName == "Tab" || keyName == "Escape")
- {
- // Escape key to end the edit mode
- EndEditMode();
-
- return false;
- }
-
- HidePopup(); // If Pop-up shown then hides it as editing text.
-
- // Update Flag, indicates whether to update the text-input contents or not.
- // Any key stroke that results in a visual change of the text-input should
- // set this flag to true.
- bool update(false);
-
- // Whether to scroll text to cursor position.
- // Scroll is needed always the cursor is updated and after the pre-edit is received.
- bool scroll = false;
-
- if (keyName == "Return")
- {
- if ( mNumberOflinesLimit > 1) // Prevents New line character / Return adding an extra line if limit set to 1
- {
- bool preEditFlagPreviouslySet( mPreEditFlag );
-
- // replaces highlighted text with new line
- DeleteHighlightedText( false );
-
- mCursorPosition = mCursorPosition + InsertAt( Text( NEWLINE ), mCursorPosition, 0 );
-
- // If we are in pre-edit mode then pressing enter will cause a commit. But the commit string does not include the
- // '\n' character so we need to ensure that the immediately following commit knows how it occurred.
- if ( mPreEditFlag )
- {
- mCommitByKeyInput = true;
- }
-
- // If attempting to insert a new-line brings us out of PreEdit mode, then we should not ignore the next commit.
- if ( preEditFlagPreviouslySet && !mPreEditFlag )
- {
- mPreEditFlag = true;
- mIgnoreCommitFlag = false;
- }
- EmitTextModified();
- update = true;
- }
- else
- {
- RemoveHighlight();
- }
- } // Return
- else if ( keyName == "space" )
- {
- if ( mHighlightMeshActor )
- {
- // Some text is selected so erase it before adding space.
- DeleteHighlightedText( true );
- }
-
- mCursorPosition = mCursorPosition + InsertAt(Text(keyString), mCursorPosition, 0);
-
- // If we are in pre-edit mode then pressing the space-bar will cause a commit. But the commit string does not include the
- // ' ' character so we need to ensure that the immediately following commit knows how it occurred.
- if ( mPreEditFlag )
- {
- mCommitByKeyInput = true;
- }
- EmitTextModified();
- update = true;
- } // space
- else if (keyName == "BackSpace")
- {
- if ( mHighlightMeshActor )
- {
- // Some text is selected so erase it
- DeleteHighlightedText( true );
- update = true;
- }
- else
- {
- if ( mCursorPosition > 0 )
- {
- DeleteCharacter( mCursorPosition );
- update = true;
- }
- }
- EmitTextModified();
- } // BackSpace
- else if (keyName == "Right")
- {
- AdvanceCursor();
- RemoveHighlight();
- }
- else if (keyName == "Left")
- {
- AdvanceCursor(true);
- RemoveHighlight();
- }
- else // event is a character
- {
- // Some text may be selected, hiding keyboard causes an empty keystring to be sent, we don't want to delete highlight in this case
- if ( !keyString.empty() )
- {
- // replaces highlighted text with new character
- DeleteHighlightedText( false );
-
- // Received key String
- mCursorPosition += InsertAt( Text( keyString ), mCursorPosition, 0 );
- update = true;
- EmitTextModified();
- }
- }
-
- // If key event has resulted in a change in the text/cursor, then trigger a relayout of text
- // as this is a costly operation.
- if(update)
- {
- CursorUpdate();
- }
-
- if(update || scroll)
- {
- if( IsScrollEnabled() )
- {
- // Calculates the new cursor position (in actor coordinates)
- const Vector3 cursorPosition = GetActualPositionFromCharacterPosition( mCursorPosition );
-
- ScrollTextViewToMakeCursorVisible( cursorPosition );
- }
- }
-
- return true;
-}
-
-bool TextInput::OnKeyUpEvent(const KeyEvent& event)
-{
- std::string keyName = event.keyPressedName;
- std::string keyString = event.keyPressed;
-
- DALI_LOG_INFO(gLogFilter, Debug::General, "OnKeyUpEvent keyName[%s] KeyString[%s]\n", keyName.c_str(), keyString.c_str() );
-
- // The selected text become deselected when the key code is DALI_KEY_BACK.
- if( IsTextSelected() && ( keyName == "XF86Stop" || keyName == "XF86Send") )
- {
- DeSelectText();
- return true;
- }
-
- return false;
-}
-
-void TextInput::ChooseRtlSelectionHandlePosition( const Vector3& cursorPositionOne,
- const Vector3& cursorPositionTwo,
- bool altPositionValidOne,
- bool altPositionValidTwo,
- const Vector3& altPositionOne,
- const Vector3& altPositionTwo )
-{
- // TODO VCC Valid for one line.
- // Try to place the selection handles. TODO think in something better. Probably need to know the direction of the paragraph.
- if( cursorPositionOne != cursorPositionTwo )
- {
- if( cursorPositionOne.x < cursorPositionTwo.x )
- {
- mSelectionHandleOneActualPosition = cursorPositionOne;
- mSelectionHandleTwoActualPosition = cursorPositionTwo;
- }
- else
- {
- mSelectionHandleOneActualPosition = cursorPositionTwo;
- mSelectionHandleTwoActualPosition = cursorPositionOne;
- }
- }
- else
- {
- mSelectionHandleOneActualPosition = cursorPositionOne;
- if( altPositionValidOne )
- {
- if( altPositionOne.x < mSelectionHandleOneActualPosition.x )
- {
- mSelectionHandleOneActualPosition = altPositionOne;
- }
- }
- if( altPositionValidTwo )
- {
- if( altPositionTwo.x < mSelectionHandleOneActualPosition.x )
- {
- mSelectionHandleOneActualPosition = altPositionTwo;
- }
- }
-
- mSelectionHandleTwoActualPosition = cursorPositionTwo;
- if( altPositionValidTwo )
- {
- if( altPositionTwo.x > mSelectionHandleTwoActualPosition.x )
- {
- mSelectionHandleTwoActualPosition = altPositionTwo;
- }
- }
- if( altPositionValidOne )
- {
- if( altPositionOne.x > mSelectionHandleTwoActualPosition.x )
- {
- mSelectionHandleTwoActualPosition = altPositionOne;
- }
- }
- }
-}
-
-void TextInput::OnTextViewScrolled( Toolkit::TextView textView, Vector2 scrollPosition )
-{
- // Updates the stored scroll position.
- mTextLayoutInfo.mScrollOffset = textView.GetScrollPosition();
-
- const Vector3& controlSize = GetControlSize();
- Size cursorSize( CURSOR_THICKNESS, 0.f );
-
- // Updates the cursor and grab handle position and visibility.
- if( mGrabHandle || mCursor )
- {
- cursorSize.height = GetRowRectFromCharacterPosition( mCursorPosition ).height;
-
- Vector3 altPosition; // Alternate (i.e. opposite direction) cursor position.
- bool altPositionValid; // Alternate cursor validity flag.
- bool directionRTL; // Need to know direction of primary cursor (in case we have 2 cursors and need to show them differently)
- Vector3 cursorPosition = GetActualPositionFromCharacterPosition( mCursorPosition, directionRTL, altPosition, altPositionValid );
-
- if( altPositionValid )
- {
- // Check which of the positions is the closest.
- if( fabsf( altPosition.x - mActualGrabHandlePosition.x ) < fabsf( cursorPosition.x - mActualGrabHandlePosition.x ) )
- {
- cursorPosition = altPosition;
- }
- }
-
- mIsCursorInScrollArea = mIsGrabHandleInScrollArea = IsPositionInsideBoundaries( cursorPosition, cursorSize, controlSize );
-
- mActualGrabHandlePosition = cursorPosition.GetVectorXY();
-
- if( mGrabHandle )
- {
- ShowGrabHandle( mGrabHandleVisibility && mIsGrabHandleInScrollArea );
- mGrabHandle.SetPosition( mActualGrabHandlePosition + UI_OFFSET );
- }
-
- if( mCursor )
- {
- mCursor.SetVisible( mCursorVisibility && mIsCursorInScrollArea );
- mCursor.SetPosition( mActualGrabHandlePosition + UI_OFFSET );
- }
- }
-
- // Updates the selection handles and highlighted text position and visibility.
- if( mSelectionHandleOne && mSelectionHandleTwo )
- {
- Vector3 altPositionOne; // Alternate (i.e. opposite direction) cursor position.
- bool altPositionValidOne; // Alternate cursor validity flag.
- bool directionRTLOne; // Need to know direction of primary cursor (in case we have 2 cursors and need to show them differently)
- Vector3 cursorPositionOne = GetActualPositionFromCharacterPosition( mSelectionHandleOnePosition, directionRTLOne, altPositionOne, altPositionValidOne );
-
- Vector3 altPositionTwo; // Alternate (i.e. opposite direction) cursor position.
- bool altPositionValidTwo; // Alternate cursor validity flag.
- bool directionRTLTwo; // Need to know direction of primary cursor (in case we have 2 cursors and need to show them differently)
- Vector3 cursorPositionTwo = GetActualPositionFromCharacterPosition( mSelectionHandleTwoPosition, directionRTLTwo, altPositionTwo, altPositionValidTwo );
-
- // VCC TODO: This method is a hack for one line.
- ChooseRtlSelectionHandlePosition( cursorPositionOne,
- cursorPositionTwo,
- altPositionValidOne,
- altPositionValidTwo,
- altPositionOne,
- altPositionTwo );
-
- cursorSize.height = ( *( mTextLayoutInfo.mCharacterLayoutInfoTable.begin() + mSelectionHandleOnePosition ) ).mSize.height;
- const bool isSelectionHandleOneVisible = IsPositionInsideBoundaries( cursorPositionOne, cursorSize, controlSize );
- cursorSize.height = ( *( mTextLayoutInfo.mCharacterLayoutInfoTable.begin() + mSelectionHandleTwoPosition ) ).mSize.height;
- const bool isSelectionHandleTwoVisible = IsPositionInsideBoundaries( cursorPositionTwo, cursorSize, controlSize );
-
- mSelectionHandleOne.SetVisible( isSelectionHandleOneVisible );
- mSelectionHandleTwo.SetVisible( isSelectionHandleTwoVisible );
- mSelectionHandleOne.SetPosition( mSelectionHandleOneActualPosition + UI_OFFSET + mSelectionHandleOneOffset );
- mSelectionHandleTwo.SetPosition( mSelectionHandleTwoActualPosition + UI_OFFSET + mSelectionHandleTwoOffset );
-
- if( mHighlightMeshActor )
- {
- mHighlightMeshActor.SetVisible( true );
- UpdateHighlight();
- }
- }
-}
-
-void TextInput::ScrollTextViewToMakeCursorVisible( const Vector3& cursorPosition )
-{
- // Scroll the text to make the cursor visible.
- const Size cursorSize( CURSOR_THICKNESS,
- GetRowRectFromCharacterPosition( mCursorPosition ).height );
-
- // Need to scroll the text to make the cursor visible and to cover the whole text-input area.
-
- const Vector3& controlSize = GetControlSize();
-
- // Calculates the new scroll position.
- Vector2 scrollOffset = mTextLayoutInfo.mScrollOffset;
- if( ( cursorPosition.x < 0.f ) || ( cursorPosition.x > controlSize.width ) )
- {
- scrollOffset.x += cursorPosition.x;
- }
-
- if( cursorPosition.y - cursorSize.height < 0.f || cursorPosition.y > controlSize.height )
- {
- scrollOffset.y += cursorPosition.y;
- }
-
- // Sets the new scroll position.
- SetScrollPosition( Vector2::ZERO ); // TODO: need to reset to the zero position in order to make the scroll trim to work.
- SetScrollPosition( scrollOffset );
-}
-
-void TextInput::StartScrollTimer()
-{
- if( !mScrollTimer )
- {
- mScrollTimer = Timer::New( SCROLL_TICK_INTERVAL );
- mScrollTimer.TickSignal().Connect( this, &TextInput::OnScrollTimerTick );
- }
-
- if( !mScrollTimer.IsRunning() )
- {
- mScrollTimer.Start();
- }
-}
-
-void TextInput::StopScrollTimer()
-{
- if( mScrollTimer )
- {
- mScrollTimer.Stop();
- }
-}
-
-bool TextInput::OnScrollTimerTick()
-{
- // TODO: need to set the new style accordingly the new handle position.
-
- if( !( mGrabHandleVisibility && mGrabHandle ) && !( mSelectionHandleOne && mSelectionHandleTwo ) )
- {
- // nothing to do if all handles are invisible or doesn't exist.
- return true;
- }
-
- // Text scrolling
-
- // Choose between the grab handle or the selection handles.
- Vector3& actualHandlePosition = ( mGrabHandleVisibility && mGrabHandle ) ? mActualGrabHandlePosition : ( mCurrentSelectionId == HandleOne ) ? mSelectionHandleOneActualPosition : mSelectionHandleTwoActualPosition;
- std::size_t& handlePosition = ( mGrabHandleVisibility && mGrabHandle ) ? mCursorPosition : ( mCurrentSelectionId == HandleOne ) ? mSelectionHandleOnePosition : mSelectionHandleTwoPosition;
- Vector3& currentHandlePosition = ( mGrabHandleVisibility && mGrabHandle ) ? mCurrentHandlePosition : mCurrentSelectionHandlePosition;
-
- std::size_t newCursorPosition = 0;
- ReturnClosestIndex( actualHandlePosition.GetVectorXY(), newCursorPosition );
-
- // Whether the handle's position is different of the previous one and in the case of the selection handle,
- // the new selection handle's position needs to be different of the other one.
- const bool differentSelectionHandles = ( mGrabHandleVisibility && mGrabHandle ) ? newCursorPosition != handlePosition :
- ( mCurrentSelectionId == HandleOne ) ? ( newCursorPosition != handlePosition ) && ( newCursorPosition != mSelectionHandleTwoPosition ) :
- ( newCursorPosition != handlePosition ) && ( newCursorPosition != mSelectionHandleOnePosition );
-
- if( differentSelectionHandles )
- {
- handlePosition = newCursorPosition;
-
- const Vector3 actualPosition = GetActualPositionFromCharacterPosition( newCursorPosition );
-
- Vector2 scrollDelta = ( actualPosition - currentHandlePosition ).GetVectorXY();
-
- Vector2 scrollPosition = mDisplayedTextView.GetScrollPosition();
- scrollPosition += scrollDelta;
- SetScrollPosition( scrollPosition );
-
- if( mDisplayedTextView.IsScrollPositionTrimmed() )
- {
- StopScrollTimer();
- }
-
- currentHandlePosition = GetActualPositionFromCharacterPosition( newCursorPosition ).GetVectorXY();
- }
-
- actualHandlePosition.x += mScrollDisplacement.x;
- actualHandlePosition.y += mScrollDisplacement.y;
-
- return true;
-}
-
-// Public Internal Methods (public for testing purpose)
-
-void TextInput::SetUpTouchEvents()
-{
- if ( !mTapDetector )
- {
- mTapDetector = TapGestureDetector::New();
- // Attach the actors and connect the signal
- mTapDetector.Attach(Self());
-
- // As contains children which may register for tap the default control detector is not used.
- mTapDetector.DetectedSignal().Connect(this, &TextInput::OnTextTap);
- }
-
- if ( !mDoubleTapDetector )
- {
- mDoubleTapDetector = TapGestureDetector::New();
- mDoubleTapDetector.SetTapsRequired( 2 );
- mDoubleTapDetector.DetectedSignal().Connect(this, &TextInput::OnDoubleTap);
-
- // Only attach and detach the actor to the double tap detector when we enter/leave edit mode
- // so that we do not, unnecessarily, have a double tap request all the time
- }
-
- if ( !mPanGestureDetector )
- {
- mPanGestureDetector = PanGestureDetector::New();
- mPanGestureDetector.DetectedSignal().Connect(this, &TextInput::OnHandlePan);
- }
-
- if ( !mLongPressDetector )
- {
- mLongPressDetector = LongPressGestureDetector::New();
- mLongPressDetector.DetectedSignal().Connect(this, &TextInput::OnLongPress);
- mLongPressDetector.Attach(Self());
- }
-}
-
-void TextInput::CreateTextViewActor()
-{
- mDisplayedTextView = Toolkit::TextView::New();
- mDisplayedTextView.SetName( "DisplayedTextView ");
- mDisplayedTextView.SetMarkupProcessingEnabled( mMarkUpEnabled );
- mDisplayedTextView.SetParentOrigin(ParentOrigin::TOP_LEFT);
- mDisplayedTextView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- mDisplayedTextView.SetMultilinePolicy(Toolkit::TextView::SplitByWord);
- mDisplayedTextView.SetWidthExceedPolicy( Toolkit::TextView::Original );
- mDisplayedTextView.SetHeightExceedPolicy( Toolkit::TextView::Original );
- mDisplayedTextView.SetLineJustification( Toolkit::TextView::Left );
- mDisplayedTextView.SetTextAlignment( static_cast( Toolkit::Alignment::HorizontalLeft | Toolkit::Alignment::VerticalTop ) );
- mDisplayedTextView.SetPosition( Vector3( 0.0f, 0.0f, DISPLAYED_TEXT_VIEW_Z_OFFSET ) );
- mDisplayedTextView.SetSizePolicy( Toolkit::Control::Fixed, Toolkit::Control::Fixed );
-
- mDisplayedTextView.ScrolledSignal().Connect( this, &TextInput::OnTextViewScrolled );
-
- Self().Add( mDisplayedTextView );
-}
-
-// Start a timer to initiate, used by the cursor to blink.
-void TextInput::StartCursorBlinkTimer()
-{
- if ( !mCursorBlinkTimer )
- {
- mCursorBlinkTimer = Timer::New( CURSOR_BLINK_INTERVAL );
- mCursorBlinkTimer.TickSignal().Connect( this, &TextInput::OnCursorBlinkTimerTick );
- }
-
- if ( !mCursorBlinkTimer.IsRunning() )
- {
- mCursorBlinkTimer.Start();
- }
-}
-
-// Start a timer to initiate, used by the cursor to blink.
-void TextInput::StopCursorBlinkTimer()
-{
- if ( mCursorBlinkTimer )
- {
- mCursorBlinkTimer.Stop();
- }
-}
-
-void TextInput::StartEditMode()
-{
- DALI_LOG_INFO(gLogFilter, Debug::General, "TextInput StartEditMode mEditModeActive[%s]\n", (mEditModeActive)?"true":"false" );
-
- if(!mEditModeActive)
- {
- SetKeyInputFocus();
- }
-
- if ( mDoubleTapDetector )
- {
- mDoubleTapDetector.Attach( Self() );
- }
-}
-
-void TextInput::EndEditMode()
-{
- DALI_LOG_INFO(gLogFilter, Debug::General, "TextInput EndEditMode mEditModeActive[%s]\n", (mEditModeActive)?"true":"false" );
-
- ClearKeyInputFocus();
-
- if ( mDoubleTapDetector )
- {
- mDoubleTapDetector.Detach( Self() );
- }
-}
-
-void TextInput::ApplyPreEditStyle( std::size_t preEditStartPosition, std::size_t preEditStringLength )
-{
- if ( mPreEditFlag && ( preEditStringLength > 0 ) )
- {
- mUnderlinedPriorToPreEdit = mInputStyle.IsUnderlineEnabled();
- TextStyle style;
- style.SetUnderline( true );
- ApplyStyleToRange( style, TextStyle::UNDERLINE , preEditStartPosition, preEditStartPosition + preEditStringLength -1 );
- }
-}
-
-void TextInput::RemovePreEditStyle()
-{
- if ( !mUnderlinedPriorToPreEdit )
- {
- TextStyle style;
- style.SetUnderline( false );
- SetActiveStyle( style, TextStyle::UNDERLINE );
- }
-}
-
-// IMF related methods
-
-
-ImfManager::ImfCallbackData TextInput::ImfEventReceived( Dali::ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
-{
- bool update( false );
- bool preeditResetRequired ( false );
-
- if (imfEvent.eventName != ImfManager::GETSURROUNDING )
- {
- HidePopup(); // If Pop-up shown then hides it as editing text.
- }
-
- switch ( imfEvent.eventName )
- {
- case ImfManager::PREEDIT:
- {
- mIgnoreFirstCommitFlag = false;
-
- // Some text may be selected, hiding keyboard causes an empty predictive string to be sent, we don't want to delete highlight in this case
- if ( mHighlightMeshActor && (!imfEvent.predictiveString.empty()) )
- {
- // replaces highlighted text with new character
- DeleteHighlightedText( false );
- }
-
- preeditResetRequired = PreEditReceived( imfEvent.predictiveString, imfEvent.cursorOffset );
-
- if( IsScrollEnabled() )
- {
- // Calculates the new cursor position (in actor coordinates)
- const Vector3 cursorPosition = GetActualPositionFromCharacterPosition( mCursorPosition );
- ScrollTextViewToMakeCursorVisible( cursorPosition );
- }
-
- update = true;
-
- break;
- }
- case ImfManager::COMMIT:
- {
- if( mIgnoreFirstCommitFlag )
- {
- // Do not commit in this case when keyboard sends a commit when shows for the first time (work-around for imf keyboard).
- mIgnoreFirstCommitFlag = false;
- }
- else
- {
- // A Commit message is a word that has been accepted, it may have been a pre-edit word previously but now commited.
-
- // Some text may be selected, hiding keyboard causes an empty predictive string to be sent, we don't want to delete highlight in this case
- if ( mHighlightMeshActor && (!imfEvent.predictiveString.empty()) )
- {
- // replaces highlighted text with new character
- DeleteHighlightedText( false );
- }
-
- // A PreEditReset can cause a commit message to be sent, the Ignore Commit flag is used in scenarios where the word is
- // not needed, one such scenario is when the pre-edit word is too long to fit.
- if ( !mIgnoreCommitFlag )
- {
- update = CommitReceived( imfEvent.predictiveString );
- }
- else
- {
- mIgnoreCommitFlag = false; // reset ignore flag so next commit is acted upon.
- }
- }
-
- if( update )
- {
- if( IsScrollEnabled() )
- {
- // Calculates the new cursor position (in actor coordinates)
- const Vector3 cursorPosition = GetActualPositionFromCharacterPosition( mCursorPosition );
-
- ScrollTextViewToMakeCursorVisible( cursorPosition );
- }
- }
- break;
- }
- case ImfManager::DELETESURROUNDING:
- {
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfEventReceived - delete surrounding mPreEditFlag[%s] cursor offset[%d] characters to delete[%d] position to delete[%u] \n",
- (mPreEditFlag)?"true":"false", imfEvent.cursorOffset, imfEvent.numberOfChars, static_cast( mCursorPosition+imfEvent.cursorOffset) );
-
- mPreEditFlag = false;
-
- std::size_t toDelete = 0;
- std::size_t numberOfCharacters = 0;
-
- if( mHighlightMeshActor )
- {
- // delete highlighted text.
- toDelete = std::min( mSelectionHandleOnePosition, mSelectionHandleTwoPosition );
- numberOfCharacters = std::max( mSelectionHandleOnePosition, mSelectionHandleTwoPosition ) - toDelete;
- }
- else
- {
- if( static_cast(std::abs( imfEvent.cursorOffset )) < mCursorPosition )
- {
- toDelete = mCursorPosition + imfEvent.cursorOffset;
- }
- if( toDelete + imfEvent.numberOfChars > mStyledText.size() )
- {
- numberOfCharacters = mStyledText.size() - toDelete;
- }
- else
- {
- numberOfCharacters = imfEvent.numberOfChars;
- }
- }
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfEventReceived - deleteSurrounding pre-delete range mCursorPosition[%u] \n", mCursorPosition);
- DeleteRange( toDelete, numberOfCharacters );
-
- mCursorPosition = toDelete;
- mNumberOfSurroundingCharactersDeleted = numberOfCharacters;
-
- EmitTextModified();
-
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfEventReceived - deleteSurrounding post-delete range mCursorPosition[%u] \n", mCursorPosition);
- break;
- }
- case ImfManager::GETSURROUNDING:
- {
- // If text is selected/highlighted and surrounding text received we do not want the keyboard to store the word at cursor and return it as a predictive word along with
- // the next key pressed. Instead the Select function sets the cursor position and surrounding text.
- if (! ( mHighlightMeshActor || mSelectingText ) )
- {
- std::string text( GetText() );
- DALI_LOG_INFO( gLogFilter, Debug::General, "OnKey - surrounding text - set text [%s] and cursor[%u] \n", text.c_str(), mCursorPosition );
-
- imfManager.SetCursorPosition( mCursorPosition );
- imfManager.SetSurroundingText( text );
- }
-
- if( 0 != mNumberOfSurroundingCharactersDeleted )
- {
- mDisplayedTextView.RemoveTextFrom( mCursorPosition, mNumberOfSurroundingCharactersDeleted );
- mNumberOfSurroundingCharactersDeleted = 0;
-
- if( mStyledText.empty() )
- {
- ShowPlaceholderText( mStyledPlaceHolderText );
- }
- }
- break;
- }
- case ImfManager::VOID:
- {
- DALI_ASSERT_DEBUG( false );
- }
- } // end switch
-
- ImfManager::ImfCallbackData callbackData( update, mCursorPosition, GetText(), preeditResetRequired );
-
- return callbackData;
-}
-
-bool TextInput::PreEditReceived(const std::string& keyString, std::size_t cursorOffset )
-{
- mPreserveCursorPosition = false; // As in pre-edit state we should have the cursor at the end of the word displayed not last touch position.
-
- DALI_LOG_INFO(gLogFilter, Debug::General, ">>PreEditReceived preserveCursorPos[%d] mCursorPos[%d] mPreEditFlag[%d]\n",
- mPreserveCursorPosition, mCursorPosition, mPreEditFlag );
-
- bool preeditResetRequest ( false );
-
- if( mPreEditFlag ) // Already in pre-edit state.
- {
- if( mStyledText.size() >= mMaxStringLength )
- {
- DALI_LOG_INFO(gLogFilter, Debug::General, "PreEditReceived styledTextSize >= mMaxStringLength \n");
- // Cannot fit these characters into field, clear pre-edit.
- if ( !mUnderlinedPriorToPreEdit )
- {
- TextStyle style;
- style.SetUnderline( false );
- ApplyStyleToRange( style, TextStyle::UNDERLINE , mPreEditStartPosition, mPreEditStartPosition + mPreEditLength -1 );
- }
- mIgnoreCommitFlag = true;
- preeditResetRequest = false; // this will reset the keyboard's predictive suggestions.
- mPreEditFlag = false;
- EmitMaxInputCharactersReachedSignal();
- }
- else
- {
- // delete existing pre-edit string
- const std::size_t numberOfCharactersToReplace = DeletePreEdit();
-
- // Store new pre-edit string
- mPreEditString.SetText( keyString );
-
- if ( keyString.empty() )
- {
- mPreEditFlag = false;
- mCursorPosition = mPreEditStartPosition;
-
- if( mStyledText.empty() )
- {
- ShowPlaceholderText( mStyledPlaceHolderText );
- }
- else
- {
- mDisplayedTextView.RemoveTextFrom( mPreEditStartPosition, numberOfCharactersToReplace );
- }
-
- GetTextLayoutInfo();
- EmitTextModified();
- }
- else
- {
- // Insert new pre-edit string. InsertAt updates the size and position table.
- mPreEditLength = InsertAt( mPreEditString, mPreEditStartPosition, numberOfCharactersToReplace );
- // If word was too long to be inserted then cursorOffset would be out of range as keyboard assumes there is not limit. Hence use of std::min.
- mCursorPosition = mPreEditStartPosition + std::min( cursorOffset, mPreEditLength );
- ApplyPreEditStyle( mPreEditStartPosition, mPreEditLength );
- DALI_LOG_INFO(gLogFilter, Debug::General, "PreEditReceived mCursorPosition[%u] \n", mCursorPosition);
- EmitTextModified();
- }
- // cursor update to keyboard is not done here as the keyboard knows the cursor position and provides the 'cursorOffset'.
- DrawCursor();
- }
- }
- else // mPreEditFlag not set
- {
- if ( !keyString.empty() ) // Imf can send an empty pre-edit followed by Backspace instead of a commit.
- {
- DALI_LOG_INFO(gLogFilter, Debug::General, "PreEditReceived Initial Pre-Edit string \n");
- // new pre-edit so move into pre-edit state by setting flag
- mPreEditFlag = true;
- mPreEditString.SetText( keyString ); // store new pre-edit string
- mPreEditStartPosition = mCursorPosition; // store starting cursor position of pre-edit so know where to re-start from
- mPreEditLength = InsertAt( mPreEditString, mPreEditStartPosition, 0 );
- // If word was too long to be inserted then cursorOffset would be out of range as keyboard assumes there is not limit. Hence use of std::min.
- mCursorPosition = mPreEditStartPosition + std::min( cursorOffset, mPreEditLength );
- ApplyPreEditStyle( mPreEditStartPosition, mPreEditLength );
- DALI_LOG_INFO(gLogFilter, Debug::General, "PreEditReceived mCursorPosition[%u] mPreEditStartPosition[%u]\n", mCursorPosition, mPreEditStartPosition);
- // cursor update to keyboard is not done here as the keyboard knows the cursor position and provides the 'cursorOffset'.
- DrawCursor();
- EmitTextModified();
- }
- else
- {
- DALI_LOG_INFO(gLogFilter, Debug::General, "PreEditReceived with empty keyString\n");
- }
- }
-
- return preeditResetRequest;
-}
-
-bool TextInput::CommitReceived(const std::string& keyString )
-{
- DALI_LOG_INFO(gLogFilter, Debug::General, ">>CommitReceived preserveCursorPos[%d] mPreEditStartPosition [%d] mCursorPos[%d] mPreEditFlag[%d] mIgnoreCommitFlag[%s]\n",
- mPreserveCursorPosition, mPreEditStartPosition, mCursorPosition, mPreEditFlag, (mIgnoreCommitFlag)?"true":"false" );
-
- bool update( false );
-
- RemovePreEditStyle();
-
- const std::size_t styledTextSize( mStyledText.size() );
- if( styledTextSize >= mMaxStringLength )
- {
- // Cannot fit these characters into field, clear pre-edit.
- if ( mPreEditFlag )
- {
- mIgnoreCommitFlag = true;
- mPreEditFlag = false;
- }
- EmitMaxInputCharactersReachedSignal();
- }
- else
- {
- if( mPreEditFlag )
- {
- // delete existing pre-edit string
- const std::size_t numberOfCharactersToReplace = DeletePreEdit();
- mPreEditFlag = false;
-
- DALI_LOG_INFO(gLogFilter, Debug::General, "CommitReceived mPreserveCursorPosition[%s] mPreEditStartPosition[%u]\n",
- (mPreserveCursorPosition)?"true":"false", mPreEditStartPosition );
-
- if ( mPreserveCursorPosition ) // PreEditReset has been called triggering this commit.
- {
- // No need to update cursor position as Cursor location given by touch.
- InsertAt( Text( keyString ), mPreEditStartPosition, numberOfCharactersToReplace );
- mPreserveCursorPosition = false;
- }
- else
- {
- // Cursor not set by touch so needs to be re-positioned to input more text
- mCursorPosition = mPreEditStartPosition + InsertAt( Text(keyString), mPreEditStartPosition, numberOfCharactersToReplace ); // update cursor position as InsertAt, re-draw cursor with this
-
- // If a space or enter caused the commit then our string is one longer than the string given to us by the commit key.
- if ( mCommitByKeyInput )
- {
- mCursorPosition = std::min ( mCursorPosition + 1, mStyledText.size() );
- mCommitByKeyInput = false;
- }
- }
-
- EmitTextModified();
-
- if ( mSelectTextOnCommit )
- {
- SelectText(mRequestedSelection.mStartOfSelection, mRequestedSelection.mEndOfSelection );
- }
-
- update = true;
- }
- else // mPreEditFlag not set
- {
- if ( !mIgnoreCommitFlag ) // Check if this commit should be ignored.
- {
- if( mStyledText.empty() && mPlaceHolderSet )
- {
- // If the styled text is empty and the placeholder text is set, it needs to be cleared.
- mDisplayedTextView.SetText( "" );
- mNumberOfSurroundingCharactersDeleted = 0;
- mPlaceHolderSet = false;
- }
- mCursorPosition = mCursorPosition + InsertAt( Text( keyString ), mCursorPosition, mNumberOfSurroundingCharactersDeleted );
- update = true;
- mNumberOfSurroundingCharactersDeleted = 0;
- EmitTextModified();
- }
- else
- {
- mIgnoreCommitFlag = false; // Reset flag so future commits will not be ignored.
- }
- }
- }
-
- mSelectTextOnCommit = false;
-
- DALI_LOG_INFO(gLogFilter, Debug::General, "CommitReceived << mCursorPos[%d] mPreEditFlag[%d] update[%s] \n",
- mCursorPosition, mPreEditFlag, (update)?"true":"false" );
-
- return update;
-}
-
-// End of IMF related methods
-
-std::size_t TextInput::DeletePreEdit()
-{
- DALI_LOG_INFO(gLogFilter, Debug::General, ">>DeletePreEdit mPreEditFlag[%s] \n", (mPreEditFlag)?"true":"false");
-
- DALI_ASSERT_DEBUG( mPreEditFlag );
-
- const std::size_t preEditStringLength = mPreEditString.GetLength();
- const std::size_t styledTextSize = mStyledText.size();
-
- std::size_t endPosition = mPreEditStartPosition + preEditStringLength;
-
- // Prevents erase items outside mStyledText bounds.
- if( mPreEditStartPosition > styledTextSize )
- {
- DALI_ASSERT_DEBUG( !"TextInput::DeletePreEdit. mPreEditStartPosition > mStyledText.size()" );
- mPreEditStartPosition = styledTextSize;
- }
-
- if( ( endPosition > styledTextSize ) || ( endPosition < mPreEditStartPosition ) )
- {
- DALI_ASSERT_DEBUG( !"TextInput::DeletePreEdit. ( endPosition > mStyledText.size() ) || ( endPosition < mPreEditStartPosition )" );
- endPosition = styledTextSize;
- }
-
- mStyledText.erase( mStyledText.begin() + mPreEditStartPosition, mStyledText.begin() + endPosition );
-
- // DeletePreEdit() doesn't remove characters from the text-view because may be followed by an InsertAt() which inserts characters,
- // in that case, the Insert should use the returned number of deleted characters and replace the text which helps the text-view to
- // reuse glyphs.
- // In case DeletePreEdit() is not followed by an InsertAt() characters must be deleted after this call.
-
- return preEditStringLength;
-}
-
-void TextInput::PreEditReset( bool preserveCursorPosition )
-{
- DALI_LOG_INFO(gLogFilter, Debug::General, "PreEditReset preserveCursorPos[%d] mCursorPos[%d] \n",
- preserveCursorPosition, mCursorPosition);
-
- // Store flag to indicate that we do not want to lose the cursor position as the reset may have occurred due to touch event moving the cursor.
- mPreserveCursorPosition = preserveCursorPosition;
-
- // Reset incase we are in a pre-edit state.
- ImfManager imfManager = ImfManager::Get();
- if ( imfManager )
- {
- imfManager.Reset(); // Will trigger a commit message
- }
-}
-
-void TextInput::CursorUpdate()
-{
- DrawCursor();
-
- ImfManager imfManager = ImfManager::Get();
- if ( imfManager )
- {
- std::string text( GetText() );
- imfManager.SetSurroundingText( text ); // Notifying IMF of a cursor change triggers a surrounding text request so updating it now.
- imfManager.SetCursorPosition ( mCursorPosition );
- imfManager.NotifyCursorPosition();
- }
-}
-
-/* Delete highlighted characters redisplay*/
-void TextInput::DeleteHighlightedText( bool inheritStyle )
-{
- DALI_LOG_INFO( gLogFilter, Debug::General, "DeleteHighlightedText handlePosOne[%u] handlePosTwo[%u]\n", mSelectionHandleOnePosition, mSelectionHandleTwoPosition);
-
- if( mHighlightMeshActor )
- {
- mCursorPosition = std::min( mSelectionHandleOnePosition, mSelectionHandleTwoPosition );
-
- MarkupProcessor::StyledTextArray::iterator start = mStyledText.begin() + mCursorPosition;
- MarkupProcessor::StyledTextArray::iterator end = mStyledText.begin() + std::max( mSelectionHandleOnePosition, mSelectionHandleTwoPosition );
-
- // Get the styled text of the characters to be deleted as it may be needed if
- // the "exceed the text-input's boundaries" option is disabled.
- MarkupProcessor::StyledTextArray styledCharactersToDelete;
-
- styledCharactersToDelete.insert( styledCharactersToDelete.begin(), start, end );
-
- mStyledText.erase( start, end ); // erase range of characters
-
- // Remove text from TextView and update place holder text if required
-
- // Set the placeholder text only if the styled text is empty.
- if( mStyledText.empty() )
- {
- ShowPlaceholderText( mStyledPlaceHolderText );
- }
- else
- {
- const std::size_t numberOfCharacters = std::max( mSelectionHandleOnePosition, mSelectionHandleTwoPosition ) - mCursorPosition;
-
- mDisplayedTextView.RemoveTextFrom( mCursorPosition, numberOfCharacters );
-
- // It may happen than after removing a white space or a new line character,
- // two words merge, this new word could be big enough to not fit in its
- // current line, so moved to the next one, and make some part of the text to
- // exceed the text-input's boundary.
- if( !mExceedEnabled )
- {
- // Get the new text layout after removing some characters.
- mDisplayedTextView.GetTextLayoutInfo( mTextLayoutInfo );
-
- // Get text-input's size.
- const Vector3& size = GetControlSize();
-
- if( ( mTextLayoutInfo.mTextSize.width > size.width ) ||
- ( mTextLayoutInfo.mTextSize.height > size.height ) )
- {
- mDisplayedTextView.InsertTextAt( mCursorPosition, styledCharactersToDelete );
-
- mStyledText.insert( mStyledText.begin() + mCursorPosition,
- styledCharactersToDelete.begin(),
- styledCharactersToDelete.end() );
- }
- }
- }
- GetTextLayoutInfo();
-
- RemoveHighlight();
-
- EmitTextModified();
-
- if( inheritStyle )
- {
- const TextStyle oldInputStyle( mInputStyle );
-
- mInputStyle = GetStyleAtCursor(); // Inherit style from cursor position
-
- if( oldInputStyle != mInputStyle )
- {
- // Updates the line height accordingly with the input style.
- UpdateLineHeight();
-
- EmitStyleChangedSignal();
- }
- }
- }
-}
-
-void TextInput::DeleteRange( const std::size_t start, const std::size_t ncharacters )
-{
- DALI_ASSERT_DEBUG( start <= mStyledText.size() );
- DALI_ASSERT_DEBUG( !mStyledText.empty() );
-
- DALI_LOG_INFO(gLogFilter, Debug::General, ">>DeleteRange pre mStyledText[%s] mPreEditFlag[%s] \n", GetText().c_str(), (mPreEditFlag)?"true":"false");
-
-
- if ( ( !mStyledText.empty()) && ( ( start + ncharacters ) <= mStyledText.size() ) )
- {
- MarkupProcessor::StyledTextArray::iterator itStart = mStyledText.begin() + start;
- MarkupProcessor::StyledTextArray::iterator itEnd = mStyledText.begin() + start + ncharacters;
-
- mStyledText.erase(itStart, itEnd);
-
- // update the selection handles if they are visible.
- if( mHighlightMeshActor )
- {
- std::size_t& minHandle = ( mSelectionHandleOnePosition <= mSelectionHandleTwoPosition ? mSelectionHandleOnePosition : mSelectionHandleTwoPosition );
- std::size_t& maxHandle = ( mSelectionHandleTwoPosition > mSelectionHandleOnePosition ? mSelectionHandleTwoPosition : mSelectionHandleOnePosition );
-
- if( minHandle >= start + ncharacters )
- {
- minHandle -= ncharacters;
- }
- else if( ( minHandle > start ) && ( minHandle < start + ncharacters ) )
- {
- minHandle = start;
- }
-
- if( maxHandle >= start + ncharacters )
- {
- maxHandle -= ncharacters;
- }
- else if( ( maxHandle > start ) && ( maxHandle < start + ncharacters ) )
- {
- maxHandle = start;
- }
- }
-
- // Set text is not called here as currently it can not process the set text from deletion and then the set text from the in-coming pre-edit.
- }
-
- DALI_LOG_INFO(gLogFilter, Debug::General, "DeleteRange<< post mStyledText[%s] mPreEditFlag[%s] \n", GetText().c_str(), (mPreEditFlag)?"true":"false");
-
- // Although mStyledText has been set to a new text string we no longer re-draw the text or notify the cursor change.
- // This is a performance decision as the use of this function often means the text is being replaced or just deleted.
- // Mean we do not re-draw the text more than we have too.
-}
-
-/* Delete character at current cursor position and redisplay*/
-void TextInput::DeleteCharacter( std::size_t positionToDelete )
-{
- // Ensure positionToDelete is not out of bounds.
- DALI_ASSERT_DEBUG( positionToDelete <= mStyledText.size() );
- DALI_ASSERT_DEBUG( !mStyledText.empty() );
- DALI_ASSERT_DEBUG( positionToDelete > 0 );
-
- DALI_LOG_INFO(gLogFilter, Debug::General, "DeleteCharacter positionToDelete[%u]", positionToDelete );
-
-
- if ( ( !mStyledText.empty()) && ( positionToDelete > 0 ) && positionToDelete <= mStyledText.size() ) // don't try to delete if no characters left of cursor
- {
- MarkupProcessor::StyledTextArray::iterator it = mStyledText.begin() + positionToDelete - 1;
-
- // Get the styled text of the character to be deleted as it may be needed if
- // the "exceed the text-input's boundaries" option is disabled.
- const MarkupProcessor::StyledText styledCharacterToDelete( *it );
-
- mStyledText.erase(it); // erase the character left of positionToDelete
-
- if( mStyledText.empty() )
- {
- ShowPlaceholderText( mStyledPlaceHolderText );
- }
- else
- {
- mDisplayedTextView.RemoveTextFrom( positionToDelete - 1, 1 );
-
- const Character characterToDelete = styledCharacterToDelete.mText[0];
-
- // It may happen than after removing a white space or a new line character,
- // two words merge, this new word could be big enough to not fit in its
- // current line, so moved to the next one, and make some part of the text to
- // exceed the text-input's boundary.
- if( !mExceedEnabled )
- {
- if( characterToDelete.IsWhiteSpace() || characterToDelete.IsNewLine() )
- {
- // Get the new text layout after removing one character.
- mDisplayedTextView.GetTextLayoutInfo( mTextLayoutInfo );
-
- // Get text-input's size.
- const Vector3& size = GetControlSize();
-
- if( ( mTextLayoutInfo.mTextSize.width > size.width ) ||
- ( mTextLayoutInfo.mTextSize.height > size.height ) )
- {
- MarkupProcessor::StyledTextArray array;
- array.push_back( styledCharacterToDelete );
- mDisplayedTextView.InsertTextAt( positionToDelete - 1, array );
-
- mStyledText.insert( mStyledText.begin() + ( positionToDelete - 1 ), styledCharacterToDelete );
- }
- }
- }
- }
- GetTextLayoutInfo();
-
- ShowGrabHandleAndSetVisibility( false );
-
- mCursorPosition = positionToDelete -1;
-
- const TextStyle oldInputStyle( mInputStyle );
-
- mInputStyle = GetStyleAtCursor(); // Inherit style from cursor position
-
- if( oldInputStyle != mInputStyle )
- {
- // Updates the line height accordingly with the input style.
- UpdateLineHeight();
-
- EmitStyleChangedSignal();
- }
- }
-}
-
-/*Insert new character into the string and (optionally) redisplay text-input*/
-std::size_t TextInput::InsertAt( const Text& newText, const std::size_t insertionPosition, const std::size_t numberOfCharactersToReplace )
-{
- DALI_LOG_INFO(gLogFilter, Debug::General, "InsertAt insertionPosition[%u]\n", insertionPosition );
-
- // Ensure insertionPosition is not out of bounds.
- DALI_ASSERT_ALWAYS( insertionPosition <= mStyledText.size() );
-
- bool textExceedsMaximunNumberOfCharacters = false;
- bool textExceedsBoundary = false;
- std::size_t insertedStringLength = DoInsertAt( newText, insertionPosition, numberOfCharactersToReplace, textExceedsMaximunNumberOfCharacters, textExceedsBoundary );
-
- ShowGrabHandleAndSetVisibility( false );
-
- if( textExceedsMaximunNumberOfCharacters || textExceedsBoundary )
- {
- if( mPreEditFlag )
- {
- mIgnoreCommitFlag = true;
- mPreEditFlag = false;
- // A PreEditReset( false ) should be triggered from here if the keyboards predictive suggestions must be cleared.
- // Although can not directly call PreEditReset() as it will cause a recursive emit loop.
- }
-
- if( textExceedsMaximunNumberOfCharacters )
- {
- EmitMaxInputCharactersReachedSignal();
- }
-
- if( textExceedsBoundary )
- {
- EmitInputTextExceedsBoundariesSignal();
- PreEditReset( false );
- }
- }
-
- return insertedStringLength;
-}
-
-ImageActor TextInput::CreateCursor( const Vector4& color)
-{
- ImageActor cursor;
- cursor = CreateSolidColorActor(color);
- cursor.SetName( "Cursor" );
-
- cursor.SetParentOrigin(ParentOrigin::TOP_LEFT);
- cursor.SetAnchorPoint(AnchorPoint::BOTTOM_LEFT);
- cursor.SetVisible(false);
-
- return cursor;
-}
-
-void TextInput::AdvanceCursor(bool reverse, std::size_t places)
-{
- // As cursor is not moving due to grab handle, handle should be hidden.
- ShowGrabHandleAndSetVisibility( false );
-
- bool cursorPositionChanged = false;
- if (reverse)
- {
- if ( mCursorPosition >= places )
- {
- mCursorPosition = mCursorPosition - places;
- cursorPositionChanged = true;
- }
- }
- else
- {
- if ((mCursorPosition + places) <= mStyledText.size())
- {
- mCursorPosition = mCursorPosition + places;
- cursorPositionChanged = true;
- }
- }
-
- if( cursorPositionChanged )
- {
- const std::size_t cursorPositionForStyle = ( 0 == mCursorPosition ? 0 : mCursorPosition - 1 );
-
- const TextStyle oldInputStyle( mInputStyle );
- mInputStyle = GetStyleAt( cursorPositionForStyle ); // Inherit style from selected position.
-
- DrawCursor();
-
- if( oldInputStyle != mInputStyle )
- {
- // Updates the line height accordingly with the input style.
- UpdateLineHeight();
-
- EmitStyleChangedSignal();
- }
-
- ImfManager imfManager = ImfManager::Get();
- if ( imfManager )
- {
- imfManager.SetCursorPosition ( mCursorPosition );
- imfManager.NotifyCursorPosition();
- }
- }
-}
-
-void TextInput::DrawCursor()
-{
- const Size rowRect = GetRowRectFromCharacterPosition( mCursorPosition );
-
- // Get height of cursor and set its size
- Size size( CURSOR_THICKNESS, 0.0f );
- if( !mTextLayoutInfo.mCharacterLayoutInfoTable.empty() )
- {
- size.height = rowRect.height;
- }
- else
- {
- // Measure Font so know how big text will be if no initial text to measure.
- size.height = mLineHeight;
- }
-
- mCursor.SetSize(size);
-
- // If the character is italic then the cursor also tilts.
- mCursor.SetRotation( mInputStyle.IsItalicsEnabled() ? Degree( mInputStyle.GetItalicsAngle() - CURSOR_ANGLE_OFFSET ) : Degree( 0.f ), Vector3::ZAXIS );
-
- DALI_ASSERT_DEBUG( mCursorPosition <= mTextLayoutInfo.mCharacterLayoutInfoTable.size() );
-
- if( ( mCursorPosition <= mTextLayoutInfo.mCharacterLayoutInfoTable.size() ) )
- {
- Vector3 altPosition; // Alternate (i.e. opposite direction) cursor position.
- bool altPositionValid; // Alternate cursor validity flag.
- bool directionRTL; // Need to know direction of primary cursor (in case we have 2 cursors and need to show them differently)
- Vector3 position = GetActualPositionFromCharacterPosition( mCursorPosition, directionRTL, altPosition, altPositionValid );
-
- SetAltCursorEnabled( altPositionValid );
-
- if( !altPositionValid )
- {
- mCursor.SetPosition( position + UI_OFFSET );
- }
- else
- {
- size.height *= 0.5f;
- mCursor.SetSize(size);
- mCursor.SetPosition( position + UI_OFFSET - Vector3( 0.0f, directionRTL ? 0.0f : size.height, 0.0f ) );
-
- // TODO: change this cursor pos, to be the one where the cursor is sourced from.
- size.height = rowRect.height * 0.5f;
- mCursorRTL.SetSize(size);
- mCursorRTL.SetPosition( altPosition + UI_OFFSET - Vector3( 0.0f, directionRTL ? size.height : 0.0f, 0.0f ) );
- }
-
- if( IsScrollEnabled() )
- {
- // Whether cursor and grab handle are inside the boundaries of the text-input when text scroll is enabled.
- mIsCursorInScrollArea = mIsGrabHandleInScrollArea = IsPositionInsideBoundaries( position, size, GetControlSize() );
- }
- } // EditMode
-}
-
-void TextInput::SetAltCursorEnabled( bool enabled )
-{
- mCursorRTLEnabled = enabled;
- mCursorRTL.SetVisible( mCursorVisibility && mCursorRTLEnabled );
-}
-
-void TextInput::SetCursorVisibility( bool visible )
-{
- mCursorVisibility = visible;
- mCursor.SetVisible( mCursorVisibility && mIsCursorInScrollArea );
- mCursorRTL.SetVisible( mCursorVisibility && mCursorRTLEnabled );
-}
-
-void TextInput::CreateGrabHandle( Dali::Image image )
-{
- if ( !mGrabHandle )
- {
- if ( !image )
- {
- mGrabHandleImage = Image::New(DEFAULT_GRAB_HANDLE);
- }
- else
- {
- mGrabHandleImage = image;
- }
-
- mGrabHandle = ImageActor::New(mGrabHandleImage);
- mGrabHandle.SetParentOrigin(ParentOrigin::TOP_LEFT);
- mGrabHandle.SetAnchorPoint(AnchorPoint::TOP_CENTER);
-
- mGrabHandle.SetDrawMode(DrawMode::OVERLAY);
-
- ShowGrabHandleAndSetVisibility( false );
-
- CreateGrabArea( mGrabHandle );
-
- mActiveLayer.Add(mGrabHandle);
- }
-}
-
-void TextInput::CreateGrabArea( Actor& parent )
-{
- mGrabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move
- mGrabArea.SetName( "GrabArea" );
- mGrabArea.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
- mGrabArea.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), RelativeToConstraint( DEFAULT_GRAB_HANDLE_RELATIVE_SIZE ) ) ); // grab area to be larger than text actor
- mGrabArea.TouchedSignal().Connect(this,&TextInput::OnPressDown);
- mTapDetector.Attach( mGrabArea );
- mPanGestureDetector.Attach( mGrabArea );
- mLongPressDetector.Attach( mGrabArea );
-
- parent.Add(mGrabArea);
-}
-
-Vector3 TextInput::MoveGrabHandle( const Vector2& displacement )
-{
- Vector3 actualHandlePosition;
-
- if (mGrabHandle)
- {
- mActualGrabHandlePosition.x += displacement.x;
- mActualGrabHandlePosition.y += displacement.y;
-
- // Grab handle should jump to the nearest character and take cursor with it
- std::size_t newCursorPosition = 0;
- ReturnClosestIndex( mActualGrabHandlePosition.GetVectorXY(), newCursorPosition );
-
- Vector3 altPosition; // Alternate (i.e. opposite direction) cursor position.
- bool altPositionValid; // Alternate cursor validity flag.
- bool directionRTL; // Need to know direction of primary cursor (in case we have 2 cursors and need to show them differently)
- actualHandlePosition = GetActualPositionFromCharacterPosition( newCursorPosition, directionRTL, altPosition, altPositionValid );
-
- if( altPositionValid )
- {
- // Check which of the positions is the closest.
- if( fabsf( altPosition.x - mActualGrabHandlePosition.x ) < fabsf( actualHandlePosition.x - mActualGrabHandlePosition.x ) )
- {
- actualHandlePosition = altPosition;
- }
- }
-
- bool handleVisible = true;
-
- if( IsScrollEnabled() )
- {
- const Vector3 controlSize = GetControlSize();
- const Size cursorSize = GetRowRectFromCharacterPosition( newCursorPosition );
- // Scrolls the text if the handle is not in a visible position
- handleVisible = IsPositionInsideBoundaries( actualHandlePosition,
- cursorSize,
- controlSize );
-
- if( handleVisible )
- {
- StopScrollTimer();
- mCurrentHandlePosition = actualHandlePosition;
- mScrollDisplacement = Vector2::ZERO;
- }
- else
- {
- if( ( actualHandlePosition.x < SCROLL_THRESHOLD ) && ( displacement.x <= 0.f ) )
- {
- mScrollDisplacement.x = -SCROLL_SPEED;
- }
- else if( ( actualHandlePosition.x > controlSize.width - SCROLL_THRESHOLD ) && ( displacement.x >= 0.f ) )
- {
- mScrollDisplacement.x = SCROLL_SPEED;
- }
- if( ( actualHandlePosition.y < SCROLL_THRESHOLD ) && ( displacement.y <= 0.f ) )
- {
- mScrollDisplacement.y = -SCROLL_SPEED;
- }
- else if( ( actualHandlePosition.y > controlSize.height - SCROLL_THRESHOLD ) && ( displacement.y >= 0.f ) )
- {
- mScrollDisplacement.y = SCROLL_SPEED;
- }
- StartScrollTimer();
- }
- }
-
- if( handleVisible && // Only redraw cursor and do updates if position changed
- ( newCursorPosition != mCursorPosition ) ) // and the new position is visible (if scroll is not enabled, it's always true).
- {
- mCursorPosition = newCursorPosition;
-
- mGrabHandle.SetPosition( actualHandlePosition + UI_OFFSET );
-
- const TextStyle oldInputStyle( mInputStyle );
-
- mInputStyle = GetStyleAtCursor(); //Inherit style from cursor position
-
- CursorUpdate(); // Let keyboard know the new cursor position so can 're-capture' for prediction.
-
- if( oldInputStyle != mInputStyle )
- {
- // Updates the line height accordingly with the input style.
- UpdateLineHeight();
-
- EmitStyleChangedSignal();
- }
- }
- }
-
- return actualHandlePosition;
-}
-
-void TextInput::ShowGrabHandle( bool visible )
-{
- if ( IsGrabHandleEnabled() )
- {
- if( mGrabHandle )
- {
- mGrabHandle.SetVisible( mGrabHandleVisibility );
- }
- StartMonitoringStageForTouch();
- }
-}
-
-void TextInput::ShowGrabHandleAndSetVisibility( bool visible )
-{
- mGrabHandleVisibility = visible;
- ShowGrabHandle( visible );
-}
-
-// Callbacks connected to be Property notifications for Boundary checking.
-
-void TextInput::OnLeftBoundaryExceeded(PropertyNotification& source)
-{
- mIsSelectionHandleOneFlipped = true;
- mSelectionHandleOne.SetScale( -1.0f, 1.0f, 1.0f );
- mSelectionHandleOne.SetAnchorPoint( AnchorPoint::TOP_LEFT);
-}
-
-void TextInput::OnReturnToLeftBoundary(PropertyNotification& source)
-{
- mIsSelectionHandleOneFlipped = false;
- mSelectionHandleOne.SetScale( 1.0f, 1.0f, 1.0f );
- mSelectionHandleOne.SetAnchorPoint( AnchorPoint::TOP_RIGHT);
-}
-
-void TextInput::OnRightBoundaryExceeded(PropertyNotification& source)
-{
- mIsSelectionHandleTwoFlipped = true;
- mSelectionHandleTwo.SetScale( -1.0f, 1.0f, 1.0f );
- mSelectionHandleTwo.SetAnchorPoint( AnchorPoint::TOP_RIGHT);
-}
-
-void TextInput::OnReturnToRightBoundary(PropertyNotification& source)
-{
- mIsSelectionHandleTwoFlipped = false;
- mSelectionHandleTwo.SetScale( 1.0f, 1.0f, 1.0f );
- mSelectionHandleTwo.SetAnchorPoint( AnchorPoint::TOP_LEFT);
-}
-
-// todo change PropertyNotification signal definition to include Actor. Hence won't need duplicate functions.
-void TextInput::OnHandleOneLeavesBoundary( PropertyNotification& source)
-{
- mSelectionHandleOne.SetOpacity(0.0f);
-}
-
-void TextInput::OnHandleOneWithinBoundary(PropertyNotification& source)
-{
- mSelectionHandleOne.SetOpacity(1.0f);
-}
-
-void TextInput::OnHandleTwoLeavesBoundary( PropertyNotification& source)
-{
- mSelectionHandleTwo.SetOpacity(0.0f);
-}
-
-void TextInput::OnHandleTwoWithinBoundary(PropertyNotification& source)
-{
- mSelectionHandleTwo.SetOpacity(1.0f);
-}
-
-// End of Callbacks connected to be Property notifications for Boundary checking.
-
-void TextInput::SetUpHandlePropertyNotifications()
-{
- /* Property notifications for handles exceeding the boundary and returning back within boundary */
-
- Vector3 handlesize = GetSelectionHandleSize();
-
- // Exceeding horizontal boundary
- PropertyNotification leftNotification = mSelectionHandleOne.AddPropertyNotification( Actor::WORLD_POSITION_X, LessThanCondition( mBoundingRectangleWorldCoordinates.x + handlesize.x) );
- leftNotification.NotifySignal().Connect( this, &TextInput::OnLeftBoundaryExceeded );
-
- PropertyNotification rightNotification = mSelectionHandleTwo.AddPropertyNotification( Actor::WORLD_POSITION_X, GreaterThanCondition( mBoundingRectangleWorldCoordinates.z - handlesize.x ) );
- rightNotification.NotifySignal().Connect( this, &TextInput::OnRightBoundaryExceeded );
-
- // Within horizontal boundary
- PropertyNotification leftLeaveNotification = mSelectionHandleOne.AddPropertyNotification( Actor::WORLD_POSITION_X, GreaterThanCondition( mBoundingRectangleWorldCoordinates.x + 2*handlesize.x ) );
- leftLeaveNotification.NotifySignal().Connect( this, &TextInput::OnReturnToLeftBoundary );
-
- PropertyNotification rightLeaveNotification = mSelectionHandleTwo.AddPropertyNotification( Actor::WORLD_POSITION_X, LessThanCondition( mBoundingRectangleWorldCoordinates.z - 2*handlesize.x ) );
- rightLeaveNotification.NotifySignal().Connect( this, &TextInput::OnReturnToRightBoundary );
-
- // Exceeding vertical boundary
- PropertyNotification verticalExceedNotificationOne = mSelectionHandleOne.AddPropertyNotification( Actor::WORLD_POSITION_Y,
- OutsideCondition( mBoundingRectangleWorldCoordinates.y + handlesize.y,
- mBoundingRectangleWorldCoordinates.w - handlesize.y ) );
- verticalExceedNotificationOne.NotifySignal().Connect( this, &TextInput::OnHandleOneLeavesBoundary );
-
- PropertyNotification verticalExceedNotificationTwo = mSelectionHandleTwo.AddPropertyNotification( Actor::WORLD_POSITION_Y,
- OutsideCondition( mBoundingRectangleWorldCoordinates.y + handlesize.y,
- mBoundingRectangleWorldCoordinates.w - handlesize.y ) );
- verticalExceedNotificationTwo.NotifySignal().Connect( this, &TextInput::OnHandleTwoLeavesBoundary );
-
- // Within vertical boundary
- PropertyNotification verticalWithinNotificationOne = mSelectionHandleOne.AddPropertyNotification( Actor::WORLD_POSITION_Y,
- InsideCondition( mBoundingRectangleWorldCoordinates.y + handlesize.y,
- mBoundingRectangleWorldCoordinates.w - handlesize.y ) );
- verticalWithinNotificationOne.NotifySignal().Connect( this, &TextInput::OnHandleOneWithinBoundary );
-
- PropertyNotification verticalWithinNotificationTwo = mSelectionHandleTwo.AddPropertyNotification( Actor::WORLD_POSITION_Y,
- InsideCondition( mBoundingRectangleWorldCoordinates.y + handlesize.y,
- mBoundingRectangleWorldCoordinates.w - handlesize.y ) );
- verticalWithinNotificationTwo.NotifySignal().Connect( this, &TextInput::OnHandleTwoWithinBoundary );
-}
-
-void TextInput::CreateSelectionHandles( std::size_t start, std::size_t end, Dali::Image handleOneImage, Dali::Image handleTwoImage )
-{
- mSelectionHandleOnePosition = start;
- mSelectionHandleTwoPosition = end;
-
- if ( !mSelectionHandleOne )
- {
- // create normal and pressed images
- mSelectionHandleOneImage = Image::New( DEFAULT_SELECTION_HANDLE_ONE );
- mSelectionHandleOneImagePressed = Image::New( DEFAULT_SELECTION_HANDLE_ONE_PRESSED );
-
- mSelectionHandleOne = ImageActor::New( mSelectionHandleOneImage );
- mSelectionHandleOne.SetName("SelectionHandleOne");
- mSelectionHandleOne.SetParentOrigin( ParentOrigin::TOP_LEFT );
- mSelectionHandleOne.SetAnchorPoint( AnchorPoint::TOP_RIGHT ); // Change to BOTTOM_RIGHT if Look'n'Feel requires handle above text.
- mIsSelectionHandleOneFlipped = false;
- mSelectionHandleOne.SetDrawMode( DrawMode::OVERLAY ); // ensure grab handle above text
-
- mHandleOneGrabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move
- mHandleOneGrabArea.SetName("SelectionHandleOneGrabArea");
-
- mHandleOneGrabArea.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), RelativeToConstraint( DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE ) ) ); // grab area to be larger than text actor
- mHandleOneGrabArea.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
-
- mTapDetector.Attach( mHandleOneGrabArea );
- mPanGestureDetector.Attach( mHandleOneGrabArea );
-
- mHandleOneGrabArea.TouchedSignal().Connect(this,&TextInput::OnHandleOneTouched);
-
- mSelectionHandleOne.Add( mHandleOneGrabArea );
- mActiveLayer.Add( mSelectionHandleOne );
- }
-
- if ( !mSelectionHandleTwo )
- {
- // create normal and pressed images
- mSelectionHandleTwoImage = Image::New( DEFAULT_SELECTION_HANDLE_TWO );
- mSelectionHandleTwoImagePressed = Image::New( DEFAULT_SELECTION_HANDLE_TWO_PRESSED );
-
- mSelectionHandleTwo = ImageActor::New( mSelectionHandleTwoImage );
- mSelectionHandleTwo.SetName("SelectionHandleTwo");
- mSelectionHandleTwo.SetParentOrigin( ParentOrigin::TOP_LEFT );
- mSelectionHandleTwo.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- mIsSelectionHandleTwoFlipped = false;
- mSelectionHandleTwo.SetDrawMode(DrawMode::OVERLAY); // ensure grab handle above text
-
- mHandleTwoGrabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move
- mHandleTwoGrabArea.SetName("SelectionHandleTwoGrabArea");
- mHandleTwoGrabArea.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), RelativeToConstraint( DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE ) ) ); // grab area to be larger than text actor
- mHandleTwoGrabArea.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
-
- mTapDetector.Attach( mHandleTwoGrabArea );
- mPanGestureDetector.Attach( mHandleTwoGrabArea );
-
- mHandleTwoGrabArea.TouchedSignal().Connect(this, &TextInput::OnHandleTwoTouched);
-
- mSelectionHandleTwo.Add( mHandleTwoGrabArea );
-
- mActiveLayer.Add( mSelectionHandleTwo );
- }
-
- SetUpHandlePropertyNotifications();
-
- // update table as text may have changed.
- GetTextLayoutInfo();
-
- Vector3 altPositionOne; // Alternate (i.e. opposite direction) cursor position.
- bool altPositionValidOne; // Alternate cursor validity flag.
- bool directionRTLOne; // Need to know direction of primary cursor (in case we have 2 cursors and need to show them differently)
- Vector3 cursorPositionOne = GetActualPositionFromCharacterPosition( mSelectionHandleOnePosition, directionRTLOne, altPositionOne, altPositionValidOne );
-
- Vector3 altPositionTwo; // Alternate (i.e. opposite direction) cursor position.
- bool altPositionValidTwo; // Alternate cursor validity flag.
- bool directionRTLTwo; // Need to know direction of primary cursor (in case we have 2 cursors and need to show them differently)
- Vector3 cursorPositionTwo = GetActualPositionFromCharacterPosition( mSelectionHandleTwoPosition, directionRTLTwo, altPositionTwo, altPositionValidTwo );
-
- // VCC TODO: This method is a hack for one line.
- ChooseRtlSelectionHandlePosition( cursorPositionOne,
- cursorPositionTwo,
- altPositionValidOne,
- altPositionValidTwo,
- altPositionOne,
- altPositionTwo );
-
- mSelectionHandleOne.SetPosition( mSelectionHandleOneActualPosition + UI_OFFSET + mSelectionHandleOneOffset );
- mSelectionHandleTwo.SetPosition( mSelectionHandleTwoActualPosition + UI_OFFSET + mSelectionHandleTwoOffset );
-
- // Calculates and set the visibility if the scroll mode is enabled.
- bool isSelectionHandleOneVisible = true;
- bool isSelectionHandleTwoVisible = true;
- if( IsScrollEnabled() )
- {
- const Vector3& controlSize( GetControlSize() );
- isSelectionHandleOneVisible = IsPositionInsideBoundaries( mSelectionHandleOneActualPosition, Size::ZERO, controlSize );
- isSelectionHandleTwoVisible = IsPositionInsideBoundaries( mSelectionHandleTwoActualPosition, Size::ZERO, controlSize );
- mSelectionHandleOne.SetVisible( isSelectionHandleOneVisible );
- mSelectionHandleTwo.SetVisible( isSelectionHandleTwoVisible );
- }
-
- CreateHighlight(); // function will only create highlight if not already created.
-}
-
-Vector3 TextInput::MoveSelectionHandle( SelectionHandleId handleId, const Vector2& displacement )
-{
- Vector3 actualHandlePosition;
-
- if ( mSelectionHandleOne && mSelectionHandleTwo )
- {
- const Vector3& controlSize = GetControlSize();
-
- Size cursorSize( CURSOR_THICKNESS, 0.f );
-
- // Get a reference of the wanted selection handle (handle one or two).
- Vector3& actualSelectionHandlePosition = ( handleId == HandleOne ) ? mSelectionHandleOneActualPosition : mSelectionHandleTwoActualPosition;
-
- // Get a reference for the current position of the handle and a copy of its pair
- std::size_t& currentSelectionHandlePosition = ( handleId == HandleOne ) ? mSelectionHandleOnePosition : mSelectionHandleTwoPosition;
- const std::size_t pairSelectionHandlePosition = ( handleId == HandleOne ) ? mSelectionHandleTwoPosition : mSelectionHandleOnePosition;
-
- // Get a handle of the selection handle actor
- ImageActor selectionHandleActor = ( handleId == HandleOne ) ? mSelectionHandleOne : mSelectionHandleTwo;
-
- // Selection handles should jump to the nearest character
- std::size_t newHandlePosition = 0;
- ReturnClosestIndex( actualSelectionHandlePosition.GetVectorXY(), newHandlePosition );
-
- Vector3 altPosition; // Alternate (i.e. opposite direction) cursor position.
- bool altPositionValid; // Alternate cursor validity flag.
- bool directionRTL; // Need to know direction of primary cursor (in case we have 2 cursors and need to show them differently)
- actualHandlePosition = GetActualPositionFromCharacterPosition( newHandlePosition, directionRTL, altPosition, altPositionValid );
- if( altPositionValid )
- {
- // Check which of the positions is the closest.
- if( fabsf( altPosition.x - actualSelectionHandlePosition.x ) < fabsf( actualHandlePosition.x - actualSelectionHandlePosition.x ) )
- {
- actualHandlePosition = altPosition;
- }
- }
-
- bool handleVisible = true;
-
- if( IsScrollEnabled() )
- {
- mCurrentSelectionId = handleId;
-
- cursorSize.height = GetRowRectFromCharacterPosition( newHandlePosition ).height;
- // Restricts the movement of the grab handle inside the boundaries of the text-input.
- handleVisible = IsPositionInsideBoundaries( actualHandlePosition,
- cursorSize,
- controlSize );
-
- if( handleVisible )
- {
- StopScrollTimer();
- mCurrentSelectionHandlePosition = actualHandlePosition;
- mScrollDisplacement = Vector2::ZERO;
- }
- else
- {
- if( ( actualHandlePosition.x < SCROLL_THRESHOLD ) && ( displacement.x <= 0.f ) )
- {
- mScrollDisplacement.x = -SCROLL_SPEED;
- }
- else if( ( actualHandlePosition.x > controlSize.width - SCROLL_THRESHOLD ) && ( displacement.x >= 0.f ) )
- {
- mScrollDisplacement.x = SCROLL_SPEED;
- }
- if( ( actualHandlePosition.y < SCROLL_THRESHOLD ) && ( displacement.y <= 0.f ) )
- {
- mScrollDisplacement.y = -SCROLL_SPEED;
- }
- else if( ( actualHandlePosition.y > controlSize.height - SCROLL_THRESHOLD ) && ( displacement.y >= 0.f ) )
- {
- mScrollDisplacement.y = SCROLL_SPEED;
- }
- StartScrollTimer();
- }
- }
-
- if ( handleVisible && // Ensure the handle is visible.
- ( newHandlePosition != pairSelectionHandlePosition ) && // Ensure handle one is not the same position as handle two.
- ( newHandlePosition != currentSelectionHandlePosition ) ) // Ensure the handle has moved.
- {
- currentSelectionHandlePosition = newHandlePosition;
-
- Vector3 selectionHandleOffset = ( handleId == HandleOne ) ? mSelectionHandleOneOffset : mSelectionHandleTwoOffset;
- selectionHandleActor.SetPosition( actualHandlePosition + UI_OFFSET + selectionHandleOffset );
-
- UpdateHighlight();
-
- if ( handleId == HandleOne )
- {
- const TextStyle oldInputStyle( mInputStyle );
-
- // Set Active Style to that of first character in selection
- if( mSelectionHandleOnePosition < mStyledText.size() )
- {
- mInputStyle = ( mStyledText.at( mSelectionHandleOnePosition ) ).mStyle;
- }
-
- if( oldInputStyle != mInputStyle )
- {
- // Updates the line height accordingly with the input style.
- UpdateLineHeight();
-
- EmitStyleChangedSignal();
- }
- }
- }
- }
-
- return actualHandlePosition; // Returns Handle position passed in if new value not assigned.
-}
-
-void TextInput::SetSelectionHandlePosition(SelectionHandleId handleId)
-{
- const std::size_t selectionHandlePosition = ( handleId == HandleOne ) ? mSelectionHandleOnePosition : mSelectionHandleTwoPosition;
- ImageActor selectionHandleActor = ( handleId == HandleOne ) ? mSelectionHandleOne : mSelectionHandleTwo;
-
- if ( selectionHandleActor )
- {
- const Vector3 actualHandlePosition = GetActualPositionFromCharacterPosition( selectionHandlePosition );
- Vector3 selectionHandleOffset = ( handleId == HandleOne ) ? mSelectionHandleOneOffset : mSelectionHandleTwoOffset;
- selectionHandleActor.SetPosition( actualHandlePosition + UI_OFFSET + selectionHandleOffset );
-
- if( IsScrollEnabled() )
- {
- const Size cursorSize( CURSOR_THICKNESS,
- GetRowRectFromCharacterPosition( selectionHandlePosition ).height );
- selectionHandleActor.SetVisible( IsPositionInsideBoundaries( actualHandlePosition,
- cursorSize,
- GetControlSize() ) );
- }
- }
-}
-
-void TextInput::GetVisualTextSelection( std::vector& selectedVisualText, std::size_t startSelection, std::size_t endSelection )
-{
- selectedVisualText.resize( mTextLayoutInfo.mCharacterLogicalToVisualMap.size(), false );
-
- // VCC Set true/false in logical order. TODO : It needs to be checked.
-
- if( startSelection > endSelection )
- {
- std::swap( startSelection, endSelection );
- }
- std::size_t index = 0u;
- for( std::vector::iterator it = selectedVisualText.begin(), endIt = selectedVisualText.end(); it != endIt; ++it, ++index )
- {
- if( ( index < startSelection ) || ( endSelection <= index ) )
- {
- *it = false;
- }
- else
- {
- *it = true;
- }
- }
-}
-
-// Calculate the dimensions of the quads they will make the highlight mesh
-TextInput::HighlightInfo TextInput::CalculateHighlightInfo()
-{
- // At the moment there is no public API to modify the block alignment option.
-
- mNewHighlightInfo.mQuadList.clear(); // clear last quad information.
-
- if ( !mTextLayoutInfo.mCharacterLayoutInfoTable.empty() && !mTextLayoutInfo.mCharacterLogicalToVisualMap.empty() )
- {
- Toolkit::TextView::CharacterLayoutInfoContainer::iterator it = mTextLayoutInfo.mCharacterLayoutInfoTable.begin();
- Toolkit::TextView::CharacterLayoutInfoContainer::iterator end = mTextLayoutInfo.mCharacterLayoutInfoTable.end();
-
- // Get vector of flags representing characters that are selected (true) vs unselected (false).
- std::vector selectedVisualText;
- GetVisualTextSelection( selectedVisualText, mSelectionHandleOnePosition, mSelectionHandleTwoPosition );
- std::vector::iterator selectedIt = selectedVisualText.begin();
- std::vector::iterator selectedEndIt = selectedVisualText.end();
-
- SelectionState selectionState = SelectionNone; ///< Current selection status of cursor over entire text.
- float rowLeft = 0.0f;
- float rowRight = 0.0f;
- // Keep track of the TextView's min/max extents. Should be able to query this from TextView.
- float maxRowLeft = std::numeric_limits::max();
- float maxRowRight = 0.0f;
-
- Toolkit::TextView::CharacterLayoutInfoContainer::iterator lastIt = it;
-
- // Scan through entire text.
- while(it != end)
- {
- // selectionState: None when not in selection, Started when in selection, and Ended when reached end of selection.
-
- Toolkit::TextView::CharacterLayoutInfo& charInfo(*it);
- bool charSelected = false;
- if( selectedIt != selectedEndIt )
- {
- charSelected = *selectedIt++;
- }
-
- if( selectionState == SelectionNone )
- {
- if( charSelected )
- {
- selectionState = SelectionStarted;
- rowLeft = charInfo.mPosition.x - mTextLayoutInfo.mScrollOffset.x;
- rowRight = rowLeft + charInfo.mSize.width;
- }
- }
- else if( selectionState == SelectionStarted )
- {
- // break selection on:
- // 1. new line causing selection break. (\n or wordwrap)
- // 2. character not selected.
- if( !charSelected ||
- ( charInfo.mPosition.y - lastIt->mPosition.y > CHARACTER_THRESHOLD ) )
- {
- // finished selection.
- // TODO: TextView should have a table of visual rows, and each character a reference to the row
- // that it resides on. That way this enumeration is not necessary.
- Vector2 min, max;
- if(lastIt->mIsNewParagraphChar)
- {
- // If the last character is a new line, then to get the row rect, we need to scan from the character before the new line.
- lastIt = std::max( mTextLayoutInfo.mCharacterLayoutInfoTable.begin(), lastIt - 1 );
- }
- const Size rowSize( GetRowRectFromCharacterPosition( lastIt - mTextLayoutInfo.mCharacterLayoutInfoTable.begin(), min, max ) );
- maxRowLeft = std::min(maxRowLeft, min.x);
- maxRowRight = std::max(maxRowRight, max.x);
- float rowBottom = lastIt->mPosition.y - mTextLayoutInfo.mScrollOffset.y;
- float rowTop = rowBottom - rowSize.height;
-
- // Still selected, and block-align mode then set rowRight to max, so it can be clamped afterwards
- if(charSelected)
- {
- rowRight = std::numeric_limits::max();
- }
- mNewHighlightInfo.AddQuad( rowLeft, rowTop, rowRight, rowBottom );
-
- selectionState = SelectionNone;
-
- // Still selected? start a new selection
- if( charSelected )
- {
- // if block-align mode then set rowLeft to min, so it can be clamped afterwards
- rowLeft = 0.0f;
- rowRight = ( charInfo.mPosition.x - mTextLayoutInfo.mScrollOffset.x ) + charInfo.mSize.width;
- selectionState = SelectionStarted;
- }
- }
- else
- {
- // build up highlight(s) with this selection data.
- rowLeft = std::min( charInfo.mPosition.x - mTextLayoutInfo.mScrollOffset.x, rowLeft );
- rowRight = std::max( ( charInfo.mPosition.x - mTextLayoutInfo.mScrollOffset.x ) + charInfo.mSize.width, rowRight );
- }
- }
-
- lastIt = it++;
- }
-
- // If reached end, and still on selection, then close selection.
- if(it == end)
- {
- if(selectionState == SelectionStarted)
- {
- // finished selection.
- Vector2 min, max;
- if(lastIt->mIsNewParagraphChar)
- {
- lastIt = std::max( mTextLayoutInfo.mCharacterLayoutInfoTable.begin(), lastIt - 1 );
- }
- const Size rowSize( GetRowRectFromCharacterPosition( lastIt - mTextLayoutInfo.mCharacterLayoutInfoTable.begin(), min, max ) );
- maxRowLeft = std::min(maxRowLeft, min.x);
- maxRowRight = std::max(maxRowRight, max.x);
- float rowBottom = lastIt->mPosition.y - mTextLayoutInfo.mScrollOffset.y;
- float rowTop = rowBottom - rowSize.height;
- mNewHighlightInfo.AddQuad( rowLeft, rowTop, rowRight, rowBottom );
- }
- }
-
- // Get the top left and bottom right corners.
- const Toolkit::TextView::CharacterLayoutInfo& firstCharacter( *mTextLayoutInfo.mCharacterLayoutInfoTable.begin() );
- const Vector2 topLeft( maxRowLeft, firstCharacter.mPosition.y - firstCharacter.mSize.height );
- const Vector2 bottomRight( topLeft.x + mTextLayoutInfo.mTextSize.width, topLeft.y + mTextLayoutInfo.mTextSize.height );
-
- // Clamp quads so they appear to clip to borders of the whole text.
- mNewHighlightInfo.Clamp2D( topLeft, bottomRight );
-
- // For block-align align Further Clamp quads to max left and right extents
- // BlockAlign: Will adjust highlight to block:
- // i.e.
- // H[ello] (top row right = max of all rows right)
- // [--this-] (middle rows' left = min of all rows left, middle rows' right = max of all rows right)
- // [is some] (middle rows' left = min of all rows left, middle rows' right = max of all rows right)
- // [text] (bottom row left = min of all rows left)
- // (common in SMS messaging selection)
- //
- // As opposed to the default which is tight text highlighting.
- // H[ello]
- // [this]
- // [is some]
- // [text]
- // (common in regular text editors/web browser selection)
- mNewHighlightInfo.Clamp2D( Vector2(maxRowLeft, topLeft.y), Vector2(maxRowRight, bottomRight.y ) );
-
- // Finally clamp quads again so they don't exceed the boundry of the control.
- const Vector3& controlSize = GetControlSize();
- mNewHighlightInfo.Clamp2D( Vector2::ZERO, Vector2(controlSize.x, controlSize.y) );
- } // end if
-
- return mNewHighlightInfo;
-}
-
-// VCC TODO: two methods are not needed. this one is a quick hack to fix PLMs. Should implement one which support both directions.
-// This method creates one quad per character so different selection boxes for a mix of LTR and RTL languages are created.
-TextInput::HighlightInfo TextInput::CalculateHighlightInfoRtl()
-{
- // At the moment there is no public API to modify the block alignment option.
-
- mNewHighlightInfo.mQuadList.clear(); // clear last quad information.
-
- if ( !mTextLayoutInfo.mCharacterLayoutInfoTable.empty() && !mTextLayoutInfo.mCharacterLogicalToVisualMap.empty() )
- {
- Toolkit::TextView::CharacterLayoutInfoContainer::iterator it = mTextLayoutInfo.mCharacterLayoutInfoTable.begin();
- Toolkit::TextView::CharacterLayoutInfoContainer::iterator end = mTextLayoutInfo.mCharacterLayoutInfoTable.end();
-
- // Get vector of flags representing characters that are selected (true) vs unselected (false).
- std::vector selectedVisualText;
- GetVisualTextSelection( selectedVisualText, mSelectionHandleOnePosition, mSelectionHandleTwoPosition );
- std::vector::iterator selectedIt = selectedVisualText.begin();
- std::vector::iterator selectedEndIt = selectedVisualText.end();
-
- // SelectionState selectionState = SelectionNone; ///< Current selection status of cursor over entire text.
- float rowLeft = 0.0f;
- float rowRight = 0.0f;
-
- // VCC TODO this is valid for one line.
- Vector2 min, max;
- const Size rowSize = GetRowRectFromCharacterPosition( 0, min, max );
-
- // Scan through entire text.
- while(it != end)
- {
- // selectionState: None when not in selection, Started when in selection, and Ended when reached end of selection.
-
- Toolkit::TextView::CharacterLayoutInfo& charInfo(*it);
- bool charSelected = false;
- if( selectedIt != selectedEndIt )
- {
- charSelected = *selectedIt++;
- }
-
- if( charSelected )
- {
- rowLeft = charInfo.mPosition.x - mTextLayoutInfo.mScrollOffset.x;
- rowRight = rowLeft + charInfo.mSize.width;
-
- float rowBottom = charInfo.mPosition.y - mTextLayoutInfo.mScrollOffset.y;
- float rowTop = rowBottom - rowSize.height;
- mNewHighlightInfo.AddQuad( rowLeft, rowTop, rowRight, rowBottom );
- }
-
- ++it;
- }
-
- // Finally clamp quads again so they don't exceed the boundry of the control.
- const Vector3& controlSize = GetControlSize();
- mNewHighlightInfo.Clamp2D( Vector2::ZERO, Vector2(controlSize.x, controlSize.y) );
- } // end if
-
- return mNewHighlightInfo;
-}
-
-void TextInput::UpdateHighlight()
-{
-// Construct a Mesh with a texture to be used as the highlight 'box' for selected text
-//
-// Example scenarios where mesh is made from 3, 1, 2, 2 ,3 or 3 quads.
-//
-// [ TOP ] [ TOP ] [TOP ] [ TOP ] [ TOP ] [ TOP ]
-// [ MIDDLE ] [BOTTOM] [BOTTOM] [ MIDDLE ] [ MIDDLE ]
-// [ BOTTOM] [ MIDDLE ] [ MIDDLE ]
-// [BOTTOM] [ MIDDLE ]
-// [BOTTOM]
-//
-// Each quad is created as 2 triangles.
-// Middle is just 1 quad regardless of its size.
-//
-// (0,0) (0,0)
-// 0* *2 0* *2
-// TOP TOP
-// 3* *1 3* *1
-// 4* *1 4* *6
-// MIDDLE BOTTOM
-// 6* *5 7* *5
-// 6* *8
-// BOTTOM
-// 9* *7
-//
-
- if ( mHighlightMeshActor )
- {
- // vertex and triangle buffers should always be present if MeshActor is alive.
- HighlightInfo newHighlightInfo = CalculateHighlightInfoRtl();
- MeshData::VertexContainer vertices;
- Dali::MeshData::FaceIndices faceIndices;
-
- if( !newHighlightInfo.mQuadList.empty() )
- {
- std::vector::iterator iter = newHighlightInfo.mQuadList.begin();
- std::vector::iterator endIter = newHighlightInfo.mQuadList.end();
-
- // vertex position defaults to (0 0 0)
- MeshData::Vertex vertex;
- // set normal for all vertices as (0 0 1) pointing outward from TextInput Actor.
- vertex.nZ = 1.0f;
-
- for(std::size_t v = 0; iter != endIter; ++iter,v+=4 )
- {
- // Add each quad geometry (a sub-selection) to the mesh data.
-
- // 0-----1
- // |\ |
- // | \ A |
- // | \ |
- // | B \ |
- // | \|
- // 2-----3
-
- QuadCoordinates& quad = *iter;
- // top-left (v+0)
- vertex.x = quad.min.x;
- vertex.y = quad.min.y;
- vertices.push_back( vertex );
-
- // top-right (v+1)
- vertex.x = quad.max.x;
- vertex.y = quad.min.y;
- vertices.push_back( vertex );
-
- // bottom-left (v+2)
- vertex.x = quad.min.x;
- vertex.y = quad.max.y;
- vertices.push_back( vertex );
-
- // bottom-right (v+3)
- vertex.x = quad.max.x;
- vertex.y = quad.max.y;
- vertices.push_back( vertex );
-
- // triangle A (3, 1, 0)
- faceIndices.push_back( v + 3 );
- faceIndices.push_back( v + 1 );
- faceIndices.push_back( v );
-
- // triangle B (0, 2, 3)
- faceIndices.push_back( v );
- faceIndices.push_back( v + 2 );
- faceIndices.push_back( v + 3 );
-
- mMeshData.SetFaceIndices( faceIndices );
- }
-
- BoneContainer bones(0); // passed empty as bones not required
- mMeshData.SetData( vertices, faceIndices, bones, mCustomMaterial );
- mHighlightMesh.UpdateMeshData(mMeshData);
- }
- }
-}
-
-void TextInput::ClearPopup()
-{
- mPopupPanel.Clear();
-}
-
-void TextInput::AddPopupOptions()
-{
- mPopupPanel.AddPopupOptions();
-}
-
-void TextInput::SetPopupPosition( const Vector3& position, const Vector2& alternativePosition )
-{
- const Vector3& visiblePopUpSize = mPopupPanel.GetVisibileSize();
-
- Vector3 clampedPosition ( position );
- Vector3 tailOffsetPosition ( position );
-
- float xOffSet( 0.0f );
-
- Actor self = Self();
- const Vector3 textViewTopLeftWorldPosition = self.GetCurrentWorldPosition() - self.GetCurrentSize()*0.5f;
-
- const float popUpLeft = textViewTopLeftWorldPosition.x + position.x - visiblePopUpSize.width*0.5f;
- const float popUpTop = textViewTopLeftWorldPosition.y + position.y - visiblePopUpSize.height;
-
- // Clamp to left or right or of boundary
- if( popUpLeft < mBoundingRectangleWorldCoordinates.x )
- {
- xOffSet = mBoundingRectangleWorldCoordinates.x - popUpLeft ;
- }
- else if ( popUpLeft + visiblePopUpSize.width > mBoundingRectangleWorldCoordinates.z )
- {
- xOffSet = mBoundingRectangleWorldCoordinates.z - ( popUpLeft + visiblePopUpSize.width );
- }
-
- clampedPosition.x = position.x + xOffSet;
- tailOffsetPosition.x = -xOffSet;
-
- // Check if top left of PopUp outside of top bounding rectangle, if so then flip to lower position.
- bool flipTail( false );
-
- if ( popUpTop < mBoundingRectangleWorldCoordinates.y )
- {
- clampedPosition.y = alternativePosition.y + visiblePopUpSize.height;
- flipTail = true;
- }
-
- mPopupPanel.GetRootActor().SetPosition( clampedPosition );
- mPopupPanel.SetTailPosition( tailOffsetPosition, flipTail );
-}
-
-void TextInput::HidePopup(bool animate, bool signalFinished )
-{
- if ( ( mPopupPanel.GetState() == TextInputPopup::StateShowing ) || ( mPopupPanel.GetState() == TextInputPopup::StateShown ) )
- {
- mPopupPanel.Hide( animate );
-
- if( animate && signalFinished )
- {
- mPopupPanel.HideFinishedSignal().Connect( this, &TextInput::OnPopupHideFinished );
- }
- }
-}
-
-void TextInput::ShowPopup( bool animate )
-{
- Vector3 position;
- Vector2 alternativePopupPosition;
-
- if(mHighlightMeshActor && mState == StateEdit)
- {
- Vector3 topHandle;
- Vector3 bottomHandle; // referring to the bottom most point of the handle or the bottom line of selection.
- Size rowSize;
- // When text is selected, show popup above top handle (and text), or below bottom handle.
- // topHandle: referring to the top most point of the handle or the top line of selection.
- if ( mSelectionHandleTwoActualPosition.y > mSelectionHandleOneActualPosition.y )
- {
- topHandle = mSelectionHandleOneActualPosition;
- bottomHandle = mSelectionHandleTwoActualPosition;
- rowSize= GetRowRectFromCharacterPosition( mSelectionHandleOnePosition );
- }
- else
- {
- topHandle = mSelectionHandleTwoActualPosition;
- bottomHandle = mSelectionHandleOneActualPosition;
- rowSize = GetRowRectFromCharacterPosition( mSelectionHandleTwoPosition );
- }
- topHandle.y += -mPopupOffsetFromText.y - rowSize.height;
- position = Vector3(topHandle.x, topHandle.y, 0.0f);
-
- float xPosition = ( fabsf( topHandle.x - bottomHandle.x ) )*0.5f + std::min( mSelectionHandleOneActualPosition.x , mSelectionHandleTwoActualPosition.x );
-
- position.x = xPosition;
-
- // Alternative position if no upper space
- bottomHandle.y += GetSelectionHandleSize().y + mPopupOffsetFromText.w;
- alternativePopupPosition = Vector2 ( position.x, bottomHandle.y );
- }
- else
- {
- // When no text is selected, show popup at world position of grab handle or cursor
- position = GetActualPositionFromCharacterPosition( mCursorPosition );
- const Size rowSize = GetRowRectFromCharacterPosition( mCursorPosition );
- position.y -= ( mPopupOffsetFromText.y + rowSize.height );
- // if can't be positioned above, then position below row.
- alternativePopupPosition = Vector2( position.x, position.y ); // default if no grab handle
- if ( mGrabHandle )
- {
- // If grab handle enabled then position pop-up below the grab handle.
- alternativePopupPosition.y = rowSize.height + mGrabHandle.GetCurrentSize().height + mPopupOffsetFromText.w +50.0f;
- }
- }
-
- SetPopupPosition( position, alternativePopupPosition );
-
- // Show popup
- mPopupPanel.Show( Self(), animate );
- StartMonitoringStageForTouch();
-
- mPopupPanel.PressedSignal().Connect( this, &TextInput::OnPopupButtonPressed );
-}
-
-void TextInput::ShowPopupCutCopyPaste()
-{
- ClearPopup();
-
- mPopupPanel.CreateOrderedListOfOptions(); // todo Move this so only run when order has changed
- // Check the selected text is whole text or not.
- if( IsTextSelected() && ( mStyledText.size() != GetSelectedText().size() ) )
- {
- mPopupPanel.TogglePopupButtonOnOff( TextInputPopup::ButtonsSelectAll, true );
- }
-
- if ( !mStyledText.empty() && IsTextSelected() )
- {
- mPopupPanel.TogglePopupButtonOnOff( TextInputPopup::ButtonsCopy, true );
- mPopupPanel.TogglePopupButtonOnOff( TextInputPopup::ButtonsCut, true );
- }
-
- if( mClipboard && mClipboard.NumberOfItems() )
- {
- mPopupPanel.TogglePopupButtonOnOff( TextInputPopup::ButtonsPaste, true );
- mPopupPanel.TogglePopupButtonOnOff( TextInputPopup::ButtonsClipboard, true );
- }
-
- AddPopupOptions();
-
- mPopupPanel.Hide(false);
- ShowPopup();
-}
-
-void TextInput::SetUpPopupSelection( bool showCutButton )
-{
- ClearPopup();
- mPopupPanel.CreateOrderedListOfOptions(); // todo Move this so only run when order has changed
- // If no text exists then don't offer to select
- if ( !mStyledText.empty() )
- {
- mPopupPanel.TogglePopupButtonOnOff( TextInputPopup::ButtonsSelectAll, true );
- mPopupPanel.TogglePopupButtonOnOff( TextInputPopup::ButtonsSelect, true );
- mPopupPanel.TogglePopupButtonOnOff( TextInputPopup::ButtonsCut, ( showCutButton && IsTextSelected() ) );
- }
- // if clipboard has valid contents then offer paste option
- if( mClipboard && mClipboard.NumberOfItems() )
- {
- mPopupPanel.TogglePopupButtonOnOff( TextInputPopup::ButtonsPaste, true );
- mPopupPanel.TogglePopupButtonOnOff( TextInputPopup::ButtonsClipboard, true );
- }
-
- AddPopupOptions();
-
- mPopupPanel.Hide(false);
-}
-
-bool TextInput::ReturnClosestIndex(const Vector2& source, std::size_t& closestIndex )
-{
- bool found = false;
- closestIndex = 0;
-
- std::vector matchedCharacters;
- bool lastRightToLeftChar(false); /// RTL state of previous character encountered (character on the left of touch point)
- bool rightToLeftChar(false); /// RTL state of current character encountered (character on the right of touch point)
- float glyphIntersection(0.0f); /// Glyph intersection, the point between the two nearest characters touched.
-
- const Vector2 sourceScrollOffset( source + mTextLayoutInfo.mScrollOffset );
-
- if ( !mTextLayoutInfo.mCharacterLayoutInfoTable.empty() )
- {
- float closestYdifference = std::numeric_limits::max();
- std::size_t lineOffset = 0; /// Keep track of position of the first character on the matched line of interest.
- std::size_t numberOfMatchedCharacters = 0;
-
- // 1. Find closest character line to y part of source, create vector of all entries in that Y position
- // TODO: There should be an easy call to enumerate through each visual line, instead of each character on all visual lines.
-
- for( std::vector::const_iterator it = mTextLayoutInfo.mCharacterLayoutInfoTable.begin(), endIt = mTextLayoutInfo.mCharacterLayoutInfoTable.end(); it != endIt; ++it )
- {
- const Toolkit::TextView::CharacterLayoutInfo& info( *it );
- float baselinePosition = info.mPosition.y - info.mDescender;
-
- if( info.mIsVisible )
- {
- // store difference between source y point and the y position of the current character
- float currentYdifference = fabsf( sourceScrollOffset.y - ( baselinePosition ) );
-
- if( currentYdifference < closestYdifference )
- {
- // closest so far; store this difference and clear previous matchedCharacters as no longer closest
- lineOffset = it - mTextLayoutInfo.mCharacterLayoutInfoTable.begin();
- closestYdifference = currentYdifference;
- matchedCharacters.clear();
- numberOfMatchedCharacters = 0; // reset count
- }
-
- // add all characters that are on the same Y axis (within the CHARACTER_THRESHOLD) to the matched array.
- if( fabsf( closestYdifference - currentYdifference ) < CHARACTER_THRESHOLD )
- {
- // ignore new line character.
- if( !info.mIsNewParagraphChar )
- {
- matchedCharacters.push_back( info );
- numberOfMatchedCharacters++;
- }
- }
- }
- } // End of loop checking each character's y position in the character layout table
-
- // Check if last character is a newline, if it is
- // then need pretend there is an imaginary line afterwards,
- // and check if user is touching below previous line.
- const Toolkit::TextView::CharacterLayoutInfo& lastInfo( mTextLayoutInfo.mCharacterLayoutInfoTable[mTextLayoutInfo.mCharacterLayoutInfoTable.size() - 1] );
-
- if( ( lastInfo.mIsVisible ) && ( lastInfo.mIsNewParagraphChar ) && ( sourceScrollOffset.y > lastInfo.mPosition.y ) )
- {
- closestIndex = mTextLayoutInfo.mCharacterLayoutInfoTable.size();
- }
- else
- {
- // 2 Iterate through matching list of y positions and find closest matching X position.
-
- bool matched( false );
-
- // Traverse the characters in the visual order. VCC TODO: check for more than one line.
- std::size_t visualIndex = 0u;
- const std::size_t matchedCharactersSize = matchedCharacters.size();
- for( ; visualIndex < matchedCharactersSize; ++visualIndex )
- {
- const Toolkit::TextView::CharacterLayoutInfo& info( *( matchedCharacters.begin() + mTextLayoutInfo.mCharacterVisualToLogicalMap[visualIndex] ) );
-
- if( info.mIsVisible )
- {
- // stop when on left side of character's center.
- const float characterMidPointPosition = info.mPosition.x + ( info.mSize.width * 0.5f ) ;
- if( sourceScrollOffset.x < characterMidPointPosition )
- {
- if(info.mIsRightToLeftCharacter)
- {
- rightToLeftChar = true;
- }
- glyphIntersection = info.mPosition.x;
- matched = true;
- break;
- }
-
- lastRightToLeftChar = info.mIsRightToLeftCharacter;
- }
- }
-
- if( visualIndex == matchedCharactersSize )
- {
- rightToLeftChar = lastRightToLeftChar;
- }
-
- closestIndex = lineOffset + visualIndex;
-
- mClosestCursorPositionEOL = false; // reset
- if( ( visualIndex == matchedCharactersSize ) && !matched )
- {
- mClosestCursorPositionEOL = true; // Reached end of matched characters in closest line but no match so cursor should be after last character.
- }
-
- // For RTL characters, need to adjust closestIndex by 1 (as the inequality above would be reverse)
- if( rightToLeftChar && lastRightToLeftChar )
- {
- --closestIndex; // (-1 = numeric_limits::max())
- }
- }
- }
-
- // closestIndex is the visual index, need to convert it to the logical index
- if( !mTextLayoutInfo.mCharacterVisualToLogicalMap.empty() )
- {
- if( closestIndex < mTextLayoutInfo.mCharacterVisualToLogicalMap.size() )
- {
- // Checks for situations where user is touching between LTR and RTL
- // characters. To identify if the user means the end of a LTR string
- // or the beginning of an RTL string, and vice versa.
- if( closestIndex > 0 )
- {
- if( rightToLeftChar && !lastRightToLeftChar )
- {
- // [LTR] [RTL]
- // |..|..|
- // AAA BBB
- // A: In this touch range, the user is indicating that they wish to place
- // the cursor at the end of the LTR text.
- // B: In this touch range, the user is indicating that they wish to place
- // the cursor at the end of the RTL text.
-
- // Result of touching A area:
- // [.....LTR]|[RTL......]+
- //
- // |: primary cursor (for typing LTR chars)
- // +: secondary cursor (for typing RTL chars)
-
- // Result of touching B area:
- // [.....LTR]+[RTL......]|
- //
- // |: primary cursor (for typing RTL chars)
- // +: secondary cursor (for typing LTR chars)
-
- if( sourceScrollOffset.x < glyphIntersection )
- {
- --closestIndex;
- }
- }
- else if( !rightToLeftChar && lastRightToLeftChar )
- {
- if( sourceScrollOffset.x < glyphIntersection )
- {
- --closestIndex;
- }
- }
- }
-
- closestIndex = mTextLayoutInfo.mCharacterVisualToLogicalMap[closestIndex];
- // If user touched a left-side of RTL char, and the character on the left was an LTR then position logical cursor
- // one further ahead
- if( rightToLeftChar && !lastRightToLeftChar )
- {
- ++closestIndex;
- }
- }
- else if( closestIndex == std::numeric_limits::max() ) // -1 RTL (after last arabic character on line)
- {
- closestIndex = mTextLayoutInfo.mCharacterVisualToLogicalMap.size();
- }
- else if( mTextLayoutInfo.mCharacterLayoutInfoTable[ mTextLayoutInfo.mCharacterVisualToLogicalMap[ closestIndex - 1 ] ].mIsRightToLeftCharacter ) // size() LTR (after last european character on line)
- {
- closestIndex = 0;
- }
- }
-
- return found;
-}
-
-float TextInput::GetLineJustificationPosition() const
-{
- const Vector3& size = mDisplayedTextView.GetCurrentSize();
- Toolkit::Alignment::Type alignment = mDisplayedTextView.GetTextAlignment();
- float alignmentOffset = 0.f;
-
- // Work out cursor 'x' position when there are any character accordingly with the text view alignment settings.
- if( alignment & Toolkit::Alignment::HorizontalLeft )
- {
- alignmentOffset = 0.f;
- }
- else if( alignment & Toolkit::Alignment::HorizontalCenter )
- {
- alignmentOffset = 0.5f * ( size.width - mTextLayoutInfo.mTextSize.width );
- }
- else if( alignment & Toolkit::Alignment::HorizontalRight )
- {
- alignmentOffset = size.width - mTextLayoutInfo.mTextSize.width;
- }
-
- Toolkit::TextView::LineJustification justification = mDisplayedTextView.GetLineJustification();
- float justificationOffset = 0.f;
-
- switch( justification )
- {
- case Toolkit::TextView::Left:
- {
- justificationOffset = 0.f;
- break;
- }
- case Toolkit::TextView::Center:
- {
- justificationOffset = 0.5f * mTextLayoutInfo.mTextSize.width;
- break;
- }
- case Toolkit::TextView::Right:
- {
- justificationOffset = mTextLayoutInfo.mTextSize.width;
- break;
- }
- case Toolkit::TextView::Justified:
- {
- justificationOffset = 0.f;
- break;
- }
- default:
- {
- DALI_ASSERT_ALWAYS( false );
- }
- } // end switch
-
- return alignmentOffset + justificationOffset;
-}
-
-Vector3 TextInput::PositionCursorAfterWordWrap( std::size_t characterPosition ) const
-{
- /* Word wrap occurs automatically in TextView when the exceed policy moves a word to the next line when not enough space on current.
- A newline character is not inserted in this case */
-
- Vector3 cursorPosition;
-
- Toolkit::TextView::CharacterLayoutInfo currentCharInfo = mTextLayoutInfo.mCharacterLayoutInfoTable[ characterPosition ];
-
- bool noWrap = true;
-
- if( characterPosition > 0u )
- {
- Toolkit::TextView::CharacterLayoutInfo previousCharInfo = mTextLayoutInfo.mCharacterLayoutInfoTable[ characterPosition - 1u ];
-
- // If previous character on a different line then use current characters position
- if( fabsf( (currentCharInfo.mPosition.y - currentCharInfo.mDescender ) - ( previousCharInfo.mPosition.y - previousCharInfo.mDescender) ) > Math::MACHINE_EPSILON_1000 )
- {
- // VCC TODO: PositionCursorAfterWordWrap currently doesn't work for multiline. Need to check this branch.
- if ( mClosestCursorPositionEOL )
- {
- cursorPosition = Vector3( previousCharInfo.mPosition.x + previousCharInfo.mSize.width, previousCharInfo.mPosition.y, previousCharInfo.mPosition.z ) ;
- }
- else
- {
- cursorPosition = Vector3( currentCharInfo.mPosition );
- }
-
- noWrap = false;
- }
- }
-
- if( noWrap )
- {
- // If the character is left to right, the position is the character's position plus its width.
- const float ltrOffset = !currentCharInfo.mIsRightToLeftCharacter ? currentCharInfo.mSize.width : 0.f;
-
- cursorPosition.x = currentCharInfo.mPosition.x + ltrOffset;
- cursorPosition.y = currentCharInfo.mPosition.y;
- }
-
- return cursorPosition;
-}
-
-Vector3 TextInput::GetActualPositionFromCharacterPosition( std::size_t characterPosition ) const
-{
- bool direction = false;
- Vector3 alternatePosition;
- bool alternatePositionValid = false;
-
- return GetActualPositionFromCharacterPosition( characterPosition, direction, alternatePosition, alternatePositionValid );
-}
-
-Vector3 TextInput::GetActualPositionFromCharacterPosition( std::size_t characterPosition, bool& directionRTL, Vector3& alternatePosition, bool& alternatePositionValid ) const
-{
- DALI_ASSERT_DEBUG( ( mTextLayoutInfo.mCharacterLayoutInfoTable.size() == mTextLayoutInfo.mCharacterLogicalToVisualMap.size() ) &&
- ( mTextLayoutInfo.mCharacterLayoutInfoTable.size() == mTextLayoutInfo.mCharacterVisualToLogicalMap.size() ) &&
- "TextInput::GetActualPositionFromCharacterPosition. All layout tables must have the same size." );
-
- Vector3 cursorPosition( 0.f, 0.f, 0.f );
-
- alternatePositionValid = false;
- directionRTL = false;
-
- if( !mTextLayoutInfo.mCharacterLayoutInfoTable.empty() )
- {
- if( characterPosition == 0u )
- {
- // When the cursor position is at the beginning, it should be at the start of the current character.
- // If the current character is LTR, then the start is on the right side of the glyph.
- // If the current character is RTL, then the start is on the left side of the glyph.
-
- if( !( *( mTextLayoutInfo.mCharacterLayoutInfoTable.begin() ) ).mIsVisible )
- {
- characterPosition = FindVisibleCharacter( Right, 0u );
- }
-
- const Toolkit::TextView::CharacterLayoutInfo& info = mTextLayoutInfo.mCharacterLayoutInfoTable[ characterPosition ];
- const float rtlOffset = info.mIsRightToLeftCharacter ? info.mSize.width : 0.0f;
-
- cursorPosition.x = info.mPosition.x + rtlOffset;
- cursorPosition.y = info.mPosition.y;
- directionRTL = info.mIsRightToLeftCharacter;
- }
- else if( characterPosition > 0u )
- {
- // Get the direction of the paragraph.
- const std::size_t startCharacterPosition = GetRowStartFromCharacterPosition( characterPosition );
- const bool isParagraphRightToLeft = ( *( mTextLayoutInfo.mCharacterLayoutInfoTable.begin() + startCharacterPosition ) ).mIsRightToLeftCharacter;
-
- // When cursor is not at beginning, consider possibility of
- // showing 2 cursors. (whereas at beginning we only ever show one cursor)
-
- // Cursor position should be the end of the last character.
- // If the last character is LTR, then the end is on the right side of the glyph.
- // If the last character is RTL, then the end is on the left side of the glyph.
-
- --characterPosition;
-
- if( !( *( mTextLayoutInfo.mCharacterLayoutInfoTable.begin() + characterPosition ) ).mIsVisible )
- {
- characterPosition = FindVisibleCharacter( Left, characterPosition );
- }
-
- Toolkit::TextView::CharacterLayoutInfo info = mTextLayoutInfo.mCharacterLayoutInfoTable[ characterPosition ];
- if( ( characterPosition > 0u ) && info.mIsNewParagraphChar && !IsScrollEnabled() )
- {
- // VCC TODO : check for a new paragraph character.
-
- // Prevents the cursor to exceed the boundary if the last visible character is a 'new line character' and the scroll is not enabled.
- const Vector3& size = GetControlSize();
-
- if( info.mPosition.y + info.mSize.height - mDisplayedTextView.GetLineHeightOffset() > size.height )
- {
- --characterPosition;
- }
- info = mTextLayoutInfo.mCharacterLayoutInfoTable[ characterPosition ];
- }
-
- if( !info.mIsNewParagraphChar )
- {
- cursorPosition = PositionCursorAfterWordWrap( characterPosition ); // Get position of cursor/handles taking in account auto word wrap.
- }
- else
- {
- // VCC TODO : check for a new paragraph character.
-
- // When cursor points to first character on new line, position cursor at the start of this glyph.
- if( characterPosition < mTextLayoutInfo.mCharacterLayoutInfoTable.size() )
- {
- const Toolkit::TextView::CharacterLayoutInfo& infoNext = mTextLayoutInfo.mCharacterLayoutInfoTable[ characterPosition ];
- const float start( infoNext.mIsRightToLeftCharacter ? infoNext.mSize.width : 0.0f );
-
- cursorPosition.x = infoNext.mPosition.x + start;
- cursorPosition.y = infoNext.mPosition.y;
- }
- else
- {
- // If cursor points to the end of text, then can only position
- // cursor where the new line starts based on the line-justification position.
- cursorPosition.x = GetLineJustificationPosition();
-
- if( characterPosition == mTextLayoutInfo.mCharacterLogicalToVisualMap.size() )
- {
- // If this is after the last character, then we can assume that the new cursor
- // should be exactly one row below the current row.
-
- const Size rowRect = GetRowRectFromCharacterPosition( characterPosition - 1u );
- cursorPosition.y = info.mPosition.y + rowRect.height;
- }
- else
- {
- // If this is not after last character, then we can use this row's height.
- // should be exactly one row below the current row.
-
- const Size rowRect = GetRowRectFromCharacterPosition( characterPosition );
- cursorPosition.y = info.mPosition.y + rowRect.height;
- }
- }
- }
-
- directionRTL = info.mIsRightToLeftCharacter;
-
- if( 1u < mTextLayoutInfo.mCharacterLayoutInfoTable.size() )
- {
- // 1. When the cursor is neither at the beginning or the end,
- // we can show multiple cursors under situations when the cursor is
- // between RTL and LTR text...
- if( characterPosition + 1u < mTextLayoutInfo.mCharacterLayoutInfoTable.size() )
- {
- std::size_t characterAltPosition = characterPosition + 1u;
-
- const Toolkit::TextView::CharacterLayoutInfo& infoAlt = mTextLayoutInfo.mCharacterLayoutInfoTable[ characterAltPosition ];
-
- if(!info.mIsRightToLeftCharacter && infoAlt.mIsRightToLeftCharacter)
- {
- // Stuation occurs when cursor is at the end of English text (LTR) and beginning of Arabic (RTL)
- // Text: [...LTR...]|[...RTL...]
- // Cursor pos: ^
- // Alternate cursor pos: ^
- // In which case we need to display an alternate cursor for the RTL text.
-
- alternatePosition.x = infoAlt.mPosition.x + infoAlt.mSize.width;
- alternatePosition.y = infoAlt.mPosition.y;
- alternatePositionValid = true;
- }
- else if(info.mIsRightToLeftCharacter && !infoAlt.mIsRightToLeftCharacter)
- {
- // Situation occurs when cursor is at end of the Arabic text (LTR) and beginning of English (RTL)
- // Text: |[...RTL...] [...LTR....]
- // Cursor pos: ^
- // Alternate cursor pos: ^
- // In which case we need to display an alternate cursor for the RTL text.
-
- alternatePosition.x = infoAlt.mPosition.x;
- alternatePosition.y = infoAlt.mPosition.y;
- alternatePositionValid = true;
- }
- }
- else
- {
- // 2. When the cursor is at the end of the text,
- // and we have multi-directional text,
- // we can also consider showing mulitple cursors.
- // The rule here is:
- // If first and last characters on row are different
- // Directions, then two cursors need to be displayed.
-
- if( info.mIsRightToLeftCharacter != isParagraphRightToLeft )
- {
- // The last character's direction is differernt than the first one of current paragraph.
-
- // Get first
- const Toolkit::TextView::CharacterLayoutInfo& infoStart= mTextLayoutInfo.mCharacterLayoutInfoTable[ GetFirstCharacterWithSameDirection( characterPosition ) ];
-
- if(info.mIsRightToLeftCharacter)
- {
- // For text Starting as LTR and ending as RTL. End cursor position is as follows:
- // Text: [...LTR...]|[...RTL...]
- // Cursor pos: ^
- // Alternate cursor pos: ^
- // In which case we need to display an alternate cursor for the RTL text, this cursor
- // should be at the end of the given line.
-
- alternatePosition.x = infoStart.mPosition.x + infoStart.mSize.width;
- alternatePosition.y = infoStart.mPosition.y;
- alternatePositionValid = true;
- }
- else if(!info.mIsRightToLeftCharacter) // starting RTL
- {
- // For text Starting as RTL and ending as LTR. End cursor position is as follows:
- // Text: |[...RTL...] [...LTR....]
- // Cursor pos: ^
- // Alternate cursor pos: ^
- // In which case we need to display an alternate cursor for the RTL text.
-
- alternatePosition.x = infoStart.mPosition.x;
- alternatePosition.y = infoStart.mPosition.y;
- alternatePositionValid = true;
- }
- }
- }
- }
- } // characterPosition > 0
- }
- else
- {
- // If the character table is void, place the cursor accordingly the text alignment.
- const Vector3& size = GetControlSize();
-
- Toolkit::Alignment::Type alignment = mDisplayedTextView.GetTextAlignment();
- float alignmentOffset = 0.f;
-
- // Work out cursor 'x' position when there are any character accordingly with the text view alignment settings.
- if( alignment & Toolkit::Alignment::HorizontalLeft )
- {
- alignmentOffset = 0.f;
- }
- else if( alignment & Toolkit::Alignment::HorizontalCenter )
- {
- alignmentOffset = 0.5f * ( size.width );
- }
- else if( alignment & Toolkit::Alignment::HorizontalRight )
- {
- alignmentOffset = size.width;
- }
-
- // Work out cursor 'x' position when there are any character accordingly with the text view alignment settings.
- cursorPosition.x = alignmentOffset;
-
- // Work out cursor 'y' position when there are any character accordingly with the text view alignment settings.
- if( alignment & Toolkit::Alignment::VerticalTop )
- {
- cursorPosition.y = mLineHeight;
- }
- else if( alignment & Toolkit::Alignment::VerticalCenter )
- {
- cursorPosition.y = 0.5f * ( size.height + mLineHeight );
- }
- else if( alignment & Toolkit::Alignment::VerticalBottom )
- {
- cursorPosition.y = size.height;
- }
- }
-
- cursorPosition.x -= mTextLayoutInfo.mScrollOffset.x;
- cursorPosition.y -= mTextLayoutInfo.mScrollOffset.y;
-
- if( alternatePositionValid )
- {
- alternatePosition.x -= mTextLayoutInfo.mScrollOffset.x;
- alternatePosition.y -= mTextLayoutInfo.mScrollOffset.y;
- }
-
- return cursorPosition;
-}
-
-std::size_t TextInput::GetRowStartFromCharacterPosition( std::size_t logicalPosition ) const
-{
- // scan string from current position to beginning of current line to note direction of line
- while( logicalPosition )
- {
- logicalPosition--;
- if( mTextLayoutInfo.mCharacterLayoutInfoTable[logicalPosition].mIsNewParagraphChar )
- {
- logicalPosition++;
- break;
- }
- }
-
- return logicalPosition;
-}
-
-std::size_t TextInput::GetFirstCharacterWithSameDirection( std::size_t logicalPosition ) const
-{
- const bool isRightToLeft = mTextLayoutInfo.mCharacterLayoutInfoTable[logicalPosition].mIsRightToLeftCharacter;
-
- while( logicalPosition )
- {
- logicalPosition--;
- if( isRightToLeft != mTextLayoutInfo.mCharacterLayoutInfoTable[logicalPosition].mIsRightToLeftCharacter )
- {
- logicalPosition++;
- break;
- }
- }
-
- return logicalPosition;
-}
-
-Size TextInput::GetRowRectFromCharacterPosition(std::size_t characterPosition) const
-{
- Vector2 min, max;
-
- return GetRowRectFromCharacterPosition( characterPosition, min, max );
-}
-
-Size TextInput::GetRowRectFromCharacterPosition( std::size_t characterPosition, Vector2& min, Vector2& max ) const
-{
- // if we have no text content, then return position 0,0 with width 0, and height the same as cursor height.
- if( mTextLayoutInfo.mCharacterLayoutInfoTable.empty() )
- {
- min = Vector2::ZERO;
- max = Vector2(0.0f, mLineHeight);
- return max;
- }
-
- DALI_ASSERT_DEBUG( characterPosition <= mTextLayoutInfo.mCharacterLayoutInfoTable.size() );
-
- // Initializes the min and max position.
- const std::size_t initialPosition = ( characterPosition == mTextLayoutInfo.mCharacterLayoutInfoTable.size() ) ? characterPosition - 1u : characterPosition;
- min = ( *( mTextLayoutInfo.mCharacterLayoutInfoTable.begin() + initialPosition ) ).mPosition.GetVectorXY();
- max = min;
-
- bool found = false;
- // 1) Find the line where the character is laid-out.
- for( Toolkit::TextView::LineLayoutInfoContainer::const_iterator lineIt = mTextLayoutInfo.mLines.begin(), lineEndIt = mTextLayoutInfo.mLines.end();
- !found && ( lineIt != mTextLayoutInfo.mLines.end() );
- ++lineIt )
- {
- const Toolkit::TextView::LineLayoutInfo& lineInfo( *lineIt );
-
- // Index within the whole text to the last character of the current line.
- std::size_t lastCharacterOfLine = 0u;
-
- Toolkit::TextView::LineLayoutInfoContainer::const_iterator lineNextIt = lineIt + 1u;
- if( lineNextIt != lineEndIt )
- {
- lastCharacterOfLine = (*lineNextIt).mCharacterGlobalIndex - 1u;
- }
- else
- {
- lastCharacterOfLine = mTextLayoutInfo.mCharacterLayoutInfoTable.size() - 1u;
- }
-
- // Check if the given chracter position is within the line.
- if( ( lineInfo.mCharacterGlobalIndex <= initialPosition ) && ( initialPosition <= lastCharacterOfLine ) )
- {
- // 2) Get the row rect of all laid-out characters on the line.
-
- // Need to scan all characters of the line because they are in the logical position.
- for( Toolkit::TextView::CharacterLayoutInfoContainer::const_iterator it = mTextLayoutInfo.mCharacterLayoutInfoTable.begin() + lineInfo.mCharacterGlobalIndex,
- endIt = mTextLayoutInfo.mCharacterLayoutInfoTable.begin() + lastCharacterOfLine + 1u;
- it != endIt;
- ++it )
- {
- const Toolkit::TextView::CharacterLayoutInfo& characterInfo( *it );
-
- min.x = std::min( min.x, characterInfo.mPosition.x );
- min.y = std::min( min.y, characterInfo.mPosition.y );
- max.x = std::max( max.x, characterInfo.mPosition.x + characterInfo.mSize.width );
- max.y = std::max( max.y, characterInfo.mPosition.y + characterInfo.mSize.height );
- }
-
- found = true;
- }
- }
-
- return Size( max.x - min.x, max.y - min.y );
-}
-
-bool TextInput::WasTouchedCheck( const Actor& touchedActor ) const
-{
- Actor popUpPanel = mPopupPanel.GetRootActor();
-
- if ( ( touchedActor == Self() ) || ( touchedActor == popUpPanel ) )
- {
- return true;
- }
- else
- {
- Dali::Actor parent( touchedActor.GetParent() );
-
- if ( parent )
- {
- return WasTouchedCheck( parent );
- }
- }
-
- return false;
-}
-
-void TextInput::StartMonitoringStageForTouch()
-{
- Stage stage = Stage::GetCurrent();
- stage.TouchedSignal().Connect( this, &TextInput::OnStageTouched );
-}
-
-void TextInput::EndMonitoringStageForTouch()
-{
- Stage stage = Stage::GetCurrent();
- stage.TouchedSignal().Disconnect( this, &TextInput::OnStageTouched );
-}
-
-void TextInput::OnStageTouched(const TouchEvent& event)
-{
- if( event.GetPointCount() > 0 )
- {
- if ( TouchPoint::Down == event.GetPoint(0).state )
- {
- const Actor touchedActor(event.GetPoint(0).hitActor);
-
- bool popUpShown( false );
-
- if ( ( mPopupPanel.GetState() == TextInputPopup::StateShowing ) || ( mPopupPanel.GetState() == TextInputPopup::StateShown ) )
- {
- popUpShown = true;
- }
-
- bool textInputTouched = (touchedActor && WasTouchedCheck( touchedActor ));
-
- if ( ( mHighlightMeshActor || popUpShown ) && !textInputTouched )
- {
- EndMonitoringStageForTouch();
- HidePopup( true, false );
- }
-
- if ( ( IsGrabHandleEnabled() && mGrabHandle ) && !textInputTouched )
- {
- EndMonitoringStageForTouch();
- ShowGrabHandleAndSetVisibility( false );
- }
- }
- }
-}
-
-void TextInput::SelectText(std::size_t start, std::size_t end)
-{
- DALI_LOG_INFO(gLogFilter, Debug::General, "SelectText mEditModeActive[%s] grabHandle[%s] start[%u] end[%u] size[%u]\n", mEditModeActive?"true":"false",
- IsGrabHandleEnabled()?"true":"false",
- start, end, mTextLayoutInfo.mCharacterLayoutInfoTable.size() );
- DALI_ASSERT_ALWAYS( start <= mTextLayoutInfo.mCharacterLayoutInfoTable.size() && "TextInput::SelectText start out of max range" );
- DALI_ASSERT_ALWAYS( end <= mTextLayoutInfo.mCharacterLayoutInfoTable.size() && "TextInput::SelectText end out of max range" );
-
- StartMonitoringStageForTouch();
-
- if ( mEditModeActive ) // Only allow text selection when in edit mode
- {
- // When replacing highlighted text keyboard should ignore current word at cursor hence notify keyboard that the cursor is at the start of the highlight.
- mSelectingText = true;
-
- std::size_t selectionStartPosition = std::min( start, end );
-
- // Hide grab handle when selecting.
- ShowGrabHandleAndSetVisibility( false );
-
- if( start != end ) // something to select
- {
- SetCursorVisibility( false );
- StopCursorBlinkTimer();
-
- CreateSelectionHandles(start, end);
- UpdateHighlight();
-
- const TextStyle oldInputStyle( mInputStyle );
- mInputStyle = GetStyleAt( selectionStartPosition ); // Inherit style from selected position.
-
- if( oldInputStyle != mInputStyle )
- {
- // Updates the line height accordingly with the input style.
- UpdateLineHeight();
-
- EmitStyleChangedSignal();
- }
-
- HidePopup();
- }
-
- mSelectingText = false;
- }
-}
-
-MarkupProcessor::StyledTextArray TextInput::GetSelectedText()
-{
- MarkupProcessor::StyledTextArray currentSelectedText;
-
- if ( IsTextSelected() )
- {
- MarkupProcessor::StyledTextArray::iterator it = mStyledText.begin() + std::min(mSelectionHandleOnePosition, mSelectionHandleTwoPosition);
- MarkupProcessor::StyledTextArray::iterator end = mStyledText.begin() + std::max(mSelectionHandleOnePosition, mSelectionHandleTwoPosition);
-
- for(; it != end; ++it)
- {
- MarkupProcessor::StyledText& styledText( *it );
- currentSelectedText.push_back( styledText );
- }
- }
- return currentSelectedText;
-}
-
-void TextInput::ApplyStyleToRange(const TextStyle& style, const TextStyle::Mask mask, const std::size_t begin, const std::size_t end)
-{
- const std::size_t beginIndex = std::min( begin, end );
- const std::size_t endIndex = std::max( begin, end );
-
- // Apply the style
- MarkupProcessor::SetTextStyleToRange( mStyledText, style, mask, beginIndex, endIndex );
-
- // Create a styled text array used to replace the text into the text-view.
- MarkupProcessor::StyledTextArray text;
- text.insert( text.begin(), mStyledText.begin() + beginIndex, mStyledText.begin() + endIndex + 1 );
-
- mDisplayedTextView.ReplaceTextFromTo( beginIndex, ( endIndex - beginIndex ) + 1, text );
- GetTextLayoutInfo();
-
- if( IsScrollEnabled() )
- {
- // Need to set the scroll position as the text's size may have changed.
- ScrollTextViewToMakeCursorVisible( Vector3( mTextLayoutInfo.mScrollOffset.x, mTextLayoutInfo.mScrollOffset.y, 0.f ) );
- }
-
- ShowGrabHandleAndSetVisibility( false );
-
- DrawCursor();
-
- UpdateHighlight();
-
- // Set Handle positioning as the new style may have repositioned the characters.
- SetSelectionHandlePosition(HandleOne);
- SetSelectionHandlePosition(HandleTwo);
-}
-
-void TextInput::KeyboardStatusChanged(bool keyboardShown)
-{
- // Just hide the grab handle when keyboard is hidden.
- if (!keyboardShown )
- {
- ShowGrabHandleAndSetVisibility( false );
-
- // If the keyboard is not now being shown, then hide the popup panel
- mPopupPanel.Hide( true );
- }
-}
-
-// Removes highlight and resumes edit mode state
-void TextInput::RemoveHighlight( bool hidePopup )
-{
- DALI_LOG_INFO(gLogFilter, Debug::General, "RemoveHighlight\n");
-
- if ( mHighlightMeshActor )
- {
- if ( mSelectionHandleOne )
- {
- mActiveLayer.Remove( mSelectionHandleOne );
- mSelectionHandleOne.Reset();
- mSelectionHandleOneOffset.x = 0.0f;
- }
- if ( mSelectionHandleTwo )
- {
- mActiveLayer.Remove( mSelectionHandleTwo );
- mSelectionHandleTwo.Reset();
- mSelectionHandleTwoOffset.x = 0.0f;
- }
-
- mNewHighlightInfo.mQuadList.clear();
-
- Self().Remove( mHighlightMeshActor );
-
- SetCursorVisibility( true );
- StartCursorBlinkTimer();
-
- mHighlightMeshActor.Reset();
- // NOTE: We cannot dereference mHighlightMesh, due
- // to a bug in how the scene-graph MeshRenderer uses the Mesh data incorrectly.
-
- if ( hidePopup )
- {
- HidePopup();
- }
- }
-
- mSelectionHandleOnePosition = 0;
- mSelectionHandleTwoPosition = 0;
-}
-
-void TextInput::CreateHighlight()
-{
- if ( !mHighlightMeshActor )
- {
- mMeshData = MeshData( );
- mMeshData.SetHasNormals( true );
-
- mCustomMaterial = Material::New("CustomMaterial");
- mCustomMaterial.SetDiffuseColor( mMaterialColor );
-
- mMeshData.SetMaterial( mCustomMaterial );
-
- mHighlightMesh = Mesh::New( mMeshData );
-
- mHighlightMeshActor = MeshActor::New( mHighlightMesh );
- mHighlightMeshActor.SetName( "HighlightMeshActor" );
- mHighlightMeshActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
- mHighlightMeshActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- mHighlightMeshActor.SetPosition( 0.0f, 0.0f, DISPLAYED_HIGHLIGHT_Z_OFFSET );
- mHighlightMeshActor.SetAffectedByLighting(false);
-
- Self().Add(mHighlightMeshActor);
- }
-}
-
-
-bool TextInput::CopySelectedTextToClipboard()
-{
- mCurrentCopySelecton.clear();
-
- mCurrentCopySelecton = GetSelectedText();
-
- std::string stringToStore;
-
- /* Create a StyledTextArray from the selected region so can use the MarkUpProcessor to produce
- * a marked up string.
- */
- MarkupProcessor::StyledTextArray selectedText(mCurrentCopySelecton.begin(),mCurrentCopySelecton.end());
- MarkupProcessor::GetPlainString( selectedText, stringToStore );
-
- bool success = mClipboard.SetItem( stringToStore );
- return success;
-}
-
-void TextInput::PasteText( const Text& text )
-{
- // Update Flag, indicates whether to update the text-input contents or not.
- // Any key stroke that results in a visual change of the text-input should
- // set this flag to true.
- bool update = false;
- if( mHighlightMeshActor )
- {
- /* if highlighted, delete entire text, and position cursor at start of deleted text. */
- mCursorPosition = std::min(mSelectionHandleOnePosition, mSelectionHandleTwoPosition);
-
- ImfManager imfManager = ImfManager::Get();
- if ( imfManager )
- {
- imfManager.SetCursorPosition( mCursorPosition );
- imfManager.NotifyCursorPosition();
- }
- DeleteHighlightedText( true );
- update = true;
- }
-
- bool textExceedsMaximunNumberOfCharacters = false;
- bool textExceedsBoundary = false;
-
- std::size_t insertedStringLength = DoInsertAt( text, mCursorPosition, 0, textExceedsMaximunNumberOfCharacters, textExceedsBoundary );
-
- mCursorPosition += insertedStringLength;
- ImfManager imfManager = ImfManager::Get();
- if ( imfManager )
- {
- imfManager.SetCursorPosition ( mCursorPosition );
- imfManager.NotifyCursorPosition();
- }
-
- update = update || ( insertedStringLength > 0 );
- if( update )
- {
- CursorUpdate();
- EmitTextModified();
- }
-
- if( insertedStringLength < text.GetLength() )
- {
- EmitMaxInputCharactersReachedSignal();
- }
-
- if( textExceedsBoundary )
- {
- EmitInputTextExceedsBoundariesSignal();
- }
-}
-
-void TextInput::SetTextDirection()
-{
- // Put the cursor to the right if we are empty and an RTL language is being used.
- if ( mStyledText.empty() )
- {
- VirtualKeyboard::TextDirection direction( VirtualKeyboard::GetTextDirection() );
-
- // Get the current text alignment preserving the vertical alignment. Also preserve the horizontal center
- // alignment as we do not want to set the text direction if we've been asked to be in the center.
- //
- // TODO: Should split SetTextAlignment into two APIs to better handle this (sometimes apps just want to
- // set vertical alignment but are being forced to set the horizontal alignment as well with the
- // current API.
- int alignment( mDisplayedTextView.GetTextAlignment() &
- ( Toolkit::Alignment::VerticalTop |
- Toolkit::Alignment::VerticalCenter |
- Toolkit::Alignment::VerticalBottom |
- Toolkit::Alignment::HorizontalCenter ) );
- Toolkit::TextView::LineJustification justification( mDisplayedTextView.GetLineJustification() );
-
- // If our alignment is in the center, then do not change.
- if ( !( alignment & Toolkit::Alignment::HorizontalCenter ) )
- {
- alignment |= ( direction == VirtualKeyboard::LeftToRight ) ? Toolkit::Alignment::HorizontalLeft : Toolkit::Alignment::HorizontalRight;
- }
-
- // If our justification is in the center, then do not change.
- if ( justification != Toolkit::TextView::Center )
- {
- justification = ( direction == VirtualKeyboard::LeftToRight ) ? Toolkit::TextView::Left : Toolkit::TextView::Right;
- }
-
- mDisplayedTextView.SetTextAlignment( static_cast(alignment) );
- mDisplayedTextView.SetLineJustification( justification );
- }
-}
-
-void TextInput::UpdateLineHeight()
-{
- Dali::Font font = Dali::Font::New( FontParameters( mInputStyle.GetFontName(), mInputStyle.GetFontStyle(), mInputStyle.GetFontPointSize() ) );
- mLineHeight = font.GetLineHeight();
-
- // If the height exceed policy is shrink or exceed the boundaries of the text-input is not allowed, then modify the line height is needed.
-
- const bool shrink = mDisplayedTextView && ( Toolkit::TextView::ShrinkToFit == mDisplayedTextView.GetHeightExceedPolicy() ) && mStyledText.empty();
-
- if( !mExceedEnabled || shrink )
- {
- mLineHeight = std::min( mLineHeight, GetControlSize().height );
- }
-}
-
-std::size_t TextInput::FindVisibleCharacter( FindVisibleCharacterDirection direction , std::size_t cursorPosition ) const
-{
- // VCC check if we need do this in the visual order ...
- std::size_t position = 0u;
-
- const std::size_t tableSize = mTextLayoutInfo.mCharacterLayoutInfoTable.size();
-
- switch( direction )
- {
- case Left:
- {
- position = FindVisibleCharacterLeft( cursorPosition, mTextLayoutInfo.mCharacterLayoutInfoTable );
-
- if( !( *( mTextLayoutInfo.mCharacterLayoutInfoTable.begin() + ( tableSize == position ? position - 1u : position ) ) ).mIsVisible )
- {
- position = FindVisibleCharacterRight( cursorPosition, mTextLayoutInfo.mCharacterLayoutInfoTable );
- }
- break;
- }
- case Right:
- {
- position = FindVisibleCharacterRight( cursorPosition, mTextLayoutInfo.mCharacterLayoutInfoTable );
- if( !( *( mTextLayoutInfo.mCharacterLayoutInfoTable.begin() + ( tableSize == position ? position - 1u : position ) ) ).mIsVisible )
- {
- position = FindVisibleCharacterLeft( cursorPosition, mTextLayoutInfo.mCharacterLayoutInfoTable );
- }
- break;
- }
- case ByEnd:
- {
- position = FindVisibleCharacterLeft( 0u, mTextLayoutInfo.mCharacterLayoutInfoTable );
- break;
- }
- default:
- {
- DALI_ASSERT_ALWAYS( !"TextInput::FindVisibleCharacter() Unknown direction." );
- }
- }
-
- return position;
-}
-
-void TextInput::SetSortModifier( float depthOffset )
-{
- if(mDisplayedTextView)
- {
- mDisplayedTextView.SetSortModifier(depthOffset);
- }
-}
-
-void TextInput::SetSnapshotModeEnabled( bool enable )
-{
- if(mDisplayedTextView)
- {
- mDisplayedTextView.SetSnapshotModeEnabled( enable );
- }
-}
-
-bool TextInput::IsSnapshotModeEnabled() const
-{
- bool snapshotEnabled = false;
-
- if(mDisplayedTextView)
- {
- snapshotEnabled = mDisplayedTextView.IsSnapshotModeEnabled();
- }
-
- return snapshotEnabled;
-}
-
-void TextInput::SetMarkupProcessingEnabled( bool enable )
-{
- mMarkUpEnabled = enable;
-}
-
-bool TextInput::IsMarkupProcessingEnabled() const
-{
- return mMarkUpEnabled;
-}
-
-void TextInput::SetScrollEnabled( bool enable )
-{
- if( mDisplayedTextView )
- {
- mDisplayedTextView.SetScrollEnabled( enable );
- }
-
- if( !enable )
- {
- // Don't set cursor's and handle's visibility to false if they are outside the
- // boundaries of the text-input.
- mIsCursorInScrollArea = true;
- mIsGrabHandleInScrollArea = true;
- if( mSelectionHandleOne && mSelectionHandleTwo )
- {
- mSelectionHandleOne.SetVisible( true );
- mSelectionHandleTwo.SetVisible( true );
-
- if( mHighlightMeshActor )
- {
- mHighlightMeshActor.SetVisible( true );
- }
- }
- }
-}
-
-bool TextInput::IsScrollEnabled() const
-{
- bool scrollEnabled = false;
-
- if( mDisplayedTextView )
- {
- scrollEnabled = mDisplayedTextView.IsScrollEnabled();
- }
-
- return scrollEnabled;
-}
-
-void TextInput::SetScrollPosition( const Vector2& position )
-{
- if( mDisplayedTextView )
- {
- mDisplayedTextView.SetScrollPosition( position );
- }
-}
-
-Vector2 TextInput::GetScrollPosition() const
-{
- Vector2 scrollPosition;
-
- if( mDisplayedTextView )
- {
- scrollPosition = mDisplayedTextView.GetScrollPosition();
- }
-
- return scrollPosition;
-}
-
-std::size_t TextInput::DoInsertAt( const Text& text, const std::size_t position, const std::size_t numberOfCharactersToReplace, bool& textExceedsMaximunNumberOfCharacters, bool& textExceedsBoundary )
-{
- // determine number of characters that we can write to style text buffer, this is the insertStringLength
- std::size_t insertedStringLength = std::min( text.GetLength(), mMaxStringLength - mStyledText.size() );
- textExceedsMaximunNumberOfCharacters = insertedStringLength < text.GetLength();
-
- // Add style to the new input text.
- MarkupProcessor::StyledTextArray textToInsert;
- for( std::size_t i = 0; i < insertedStringLength; ++i )
- {
- const MarkupProcessor::StyledText newStyledCharacter( text[i], mInputStyle );
- textToInsert.push_back( newStyledCharacter );
- }
-
- //Insert text to the TextView.
- const bool emptyTextView = mStyledText.empty();
- if( emptyTextView && mPlaceHolderSet )
- {
- // There is no text set so call to TextView::SetText() is needed in order to clear the placeholder text.
- mDisplayedTextView.SetText( textToInsert );
- }
- else
- {
- if( 0 == numberOfCharactersToReplace )
- {
- mDisplayedTextView.InsertTextAt( position, textToInsert );
- }
- else
- {
- mDisplayedTextView.ReplaceTextFromTo( position, numberOfCharactersToReplace, textToInsert );
- }
- }
- mPlaceHolderSet = false;
-
- if( textToInsert.empty() )
- {
- // If no text has been inserted, GetTextLayoutInfo() need to be called to check whether mStyledText has some text.
- GetTextLayoutInfo();
- }
- else
- {
- // GetTextLayoutInfo() can't be used here as mStyledText is not updated yet.
- mDisplayedTextView.GetTextLayoutInfo( mTextLayoutInfo );
- }
-
- textExceedsBoundary = false;
-
- if( !mExceedEnabled )
- {
- const Vector3& size = GetControlSize();
-
- if( ( mTextLayoutInfo.mTextSize.width > size.width ) || ( mTextLayoutInfo.mTextSize.height > size.height ) )
- {
- // If new text does not fit within TextView
- mDisplayedTextView.RemoveTextFrom( position, insertedStringLength );
- // previously inserted text has been removed. Call GetTextLayoutInfo() to check whether mStyledText has some text.
- GetTextLayoutInfo();
- textExceedsBoundary = true;
- insertedStringLength = 0;
- }
-
- if( textExceedsBoundary )
- {
- // Add the part of the text which fits on the text-input.
-
- // Split the text which doesn't fit in two halves.
- MarkupProcessor::StyledTextArray firstHalf;
- MarkupProcessor::StyledTextArray secondHalf;
- SplitText( textToInsert, firstHalf, secondHalf );
-
- // Clear text. This text will be filled with the text inserted.
- textToInsert.clear();
-
- // Where to insert the text.
- std::size_t positionToInsert = position;
-
- bool end = text.GetLength() <= 1;
- while( !end )
- {
- // Insert text and check ...
- const std::size_t textLength = firstHalf.size();
- mDisplayedTextView.InsertTextAt( positionToInsert, firstHalf );
- mDisplayedTextView.GetTextLayoutInfo( mTextLayoutInfo );
-
- if( ( mTextLayoutInfo.mTextSize.width > size.width ) || ( mTextLayoutInfo.mTextSize.height > size.height ) )
- {
- // Inserted text doesn't fit.
-
- // Remove inserted text
- mDisplayedTextView.RemoveTextFrom( positionToInsert, textLength );
- mDisplayedTextView.GetTextLayoutInfo( mTextLayoutInfo );
-
- // The iteration finishes when only one character doesn't fit.
- end = textLength <= 1;
-
- if( !end )
- {
- // Prepare next two halves for next iteration.
- MarkupProcessor::StyledTextArray copyText = firstHalf;
- SplitText( copyText, firstHalf, secondHalf );
- }
- }
- else
- {
- // Text fits.
-
- // store text to be inserted in mStyledText.
- textToInsert.insert( textToInsert.end(), firstHalf.begin(), firstHalf.end() );
-
- // Increase the inserted characters counter.
- insertedStringLength += textLength;
-
- // Prepare next two halves for next iteration.
- MarkupProcessor::StyledTextArray copyText = secondHalf;
- SplitText( copyText, firstHalf, secondHalf );
-
- // Update where next text has to be inserted
- positionToInsert += textLength;
- }
- }
- }
- }
-
- if( textToInsert.empty() && emptyTextView )
- {
- // No character has been added and the text-view was empty.
- // Show the placeholder text.
- ShowPlaceholderText( mStyledPlaceHolderText );
- }
- else
- {
- MarkupProcessor::StyledTextArray::iterator it = mStyledText.begin() + position;
- mStyledText.insert( it, textToInsert.begin(), textToInsert.end() );
- mPlaceHolderSet = false;
- }
-
- return insertedStringLength;
-}
-
-void TextInput::GetTextLayoutInfo()
-{
- if( mStyledText.empty() )
- {
- // The text-input has no text, clear the text-view's layout info.
- mTextLayoutInfo = Toolkit::TextView::TextLayoutInfo();
- }
- else
- {
- if( mDisplayedTextView )
- {
- mDisplayedTextView.GetTextLayoutInfo( mTextLayoutInfo );
- }
- else
- {
- // There is no text-view.
- mTextLayoutInfo = Toolkit::TextView::TextLayoutInfo();
- }
- }
-}
-
-void TextInput::SetOffsetFromText( const Vector4& offset )
-{
- mPopupOffsetFromText = offset;
-}
-
-const Vector4& TextInput::GetOffsetFromText() const
-{
- return mPopupOffsetFromText;
-}
-
-void TextInput::SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
-{
- Toolkit::TextInput textInput = Toolkit::TextInput::DownCast( Dali::BaseHandle( object ) );
-
- if ( textInput )
- {
- TextInput& textInputImpl( GetImpl( textInput ) );
-
- switch ( propertyIndex )
- {
- case Toolkit::TextInput::HIGHLIGHT_COLOR_PROPERTY:
- {
- textInputImpl.SetMaterialDiffuseColor( value.Get< Vector4 >() );
- break;
- }
- case Toolkit::TextInput::CUT_AND_PASTE_COLOR_PROPERTY:
- {
- textInputImpl.mPopupPanel.SetCutPastePopupColor( value.Get< Vector4 >() );
- break;
- }
- case Toolkit::TextInput::CUT_AND_PASTE_PRESSED_COLOR_PROPERTY:
- {
- textInputImpl.mPopupPanel.SetCutPastePopupPressedColor( value.Get< Vector4 >() );
- break;
- }
- case Toolkit::TextInput::CUT_AND_PASTE_BORDER_COLOR_PROPERTY:
- {
- textInputImpl.mPopupPanel.SetCutPastePopupBorderColor( value.Get< Vector4 >() );
- break;
- }
- case Toolkit::TextInput::CUT_AND_PASTE_ICON_COLOR_PROPERTY:
- {
- textInputImpl.mPopupPanel.SetCutPastePopupIconColor( value.Get< Vector4 >() );
- break;
- }
- case Toolkit::TextInput::CUT_AND_PASTE_ICON_PRESSED_COLOR_PROPERTY:
- {
- textInputImpl.mPopupPanel.SetCutPastePopupIconPressedColor( value.Get< Vector4 >() );
- break;
- }
- case Toolkit::TextInput::CUT_AND_PASTE_TEXT_COLOR_PROPERTY:
- {
- textInputImpl.mPopupPanel.SetCutPastePopupTextColor( value.Get< Vector4 >() );
- break;
- }
- case Toolkit::TextInput::CUT_AND_PASTE_TEXT_PRESSED_COLOR_PROPERTY:
- {
- textInputImpl.mPopupPanel.SetCutPastePopupTextPressedColor( value.Get< Vector4 >() );
- break;
- }
- case Toolkit::TextInput::CUT_BUTTON_POSITION_PRIORITY_PROPERTY:
- {
- textInputImpl.mPopupPanel.SetButtonPriorityPosition( TextInputPopup::ButtonsCut, value.Get() );
- break;
- }
- case Toolkit::TextInput::COPY_BUTTON_POSITION_PRIORITY_PROPERTY:
- {
- textInputImpl.mPopupPanel.SetButtonPriorityPosition( TextInputPopup::ButtonsCopy, value.Get() );
- break;
- }
- case Toolkit::TextInput::PASTE_BUTTON_POSITION_PRIORITY_PROPERTY:
- {
- textInputImpl.mPopupPanel.SetButtonPriorityPosition( TextInputPopup::ButtonsPaste, value.Get() );
- break;
- }
- case Toolkit::TextInput::SELECT_BUTTON_POSITION_PRIORITY_PROPERTY:
- {
- textInputImpl.mPopupPanel.SetButtonPriorityPosition( TextInputPopup::ButtonsSelect, value.Get() );
- break;
- }
- case Toolkit::TextInput::SELECT_ALL_BUTTON_POSITION_PRIORITY_PROPERTY:
- {
- textInputImpl.mPopupPanel.SetButtonPriorityPosition( TextInputPopup::ButtonsSelectAll, value.Get() );
- break;
- }
- case Toolkit::TextInput::CLIPBOARD_BUTTON_POSITION_PRIORITY_PROPERTY:
- {
- textInputImpl.mPopupPanel.SetButtonPriorityPosition( TextInputPopup::ButtonsClipboard, value.Get() );
- break;
- }
- case Toolkit::TextInput::POP_UP_OFFSET_FROM_TEXT_PROPERTY:
- {
- textInputImpl.SetOffsetFromText( value.Get< Vector4 >() );
- break;
- }
- case Toolkit::TextInput::CURSOR_COLOR_PROPERTY:
- {
- textInputImpl.mCursor.SetColor( value.Get< Vector4 >() );
- }
- }
- }
-}
-
-Property::Value TextInput::GetProperty( BaseObject* object, Property::Index propertyIndex )
-{
- Property::Value value;
-
- Toolkit::TextInput textInput = Toolkit::TextInput::DownCast( Dali::BaseHandle( object ) );
-
- if ( textInput )
- {
- TextInput& textInputImpl( GetImpl( textInput ) );
-
- switch ( propertyIndex )
- {
- case Toolkit::TextInput::HIGHLIGHT_COLOR_PROPERTY:
- {
- value = textInputImpl.GetMaterialDiffuseColor();
- break;
- }
- case Toolkit::TextInput::CUT_AND_PASTE_COLOR_PROPERTY:
- {
- value = textInputImpl.mPopupPanel.GetCutPastePopupColor();
- break;
- }
- case Toolkit::TextInput::CUT_AND_PASTE_PRESSED_COLOR_PROPERTY:
- {
- value = textInputImpl.mPopupPanel.GetCutPastePopupPressedColor();
- break;
- }
- case Toolkit::TextInput::CUT_AND_PASTE_BORDER_COLOR_PROPERTY :
- {
- value = textInputImpl.mPopupPanel.GetCutPastePopupBorderColor();
- break;
- }
- case Toolkit::TextInput::CUT_AND_PASTE_ICON_COLOR_PROPERTY:
- {
- value = textInputImpl.mPopupPanel.GetCutPastePopupIconColor();
- break;
- }
- case Toolkit::TextInput::CUT_AND_PASTE_ICON_PRESSED_COLOR_PROPERTY:
- {
- value = textInputImpl.mPopupPanel.GetCutPastePopupIconPressedColor();
- break;
- }
- case Toolkit::TextInput::CUT_AND_PASTE_TEXT_COLOR_PROPERTY:
- {
- value = textInputImpl.mPopupPanel.GetCutPastePopupTextColor();
- break;
- }
- case Toolkit::TextInput::CUT_AND_PASTE_TEXT_PRESSED_COLOR_PROPERTY:
- {
- value = textInputImpl.mPopupPanel.GetCutPastePopupTextPressedColor();
- break;
- }
- case Toolkit::TextInput::CUT_BUTTON_POSITION_PRIORITY_PROPERTY:
- {
- value = textInputImpl.mPopupPanel.GetButtonPriorityPosition( TextInputPopup::ButtonsCut );
- break;
- }
- case Toolkit::TextInput::COPY_BUTTON_POSITION_PRIORITY_PROPERTY:
- {
- value = textInputImpl.mPopupPanel.GetButtonPriorityPosition( TextInputPopup::ButtonsCopy );
- break;
- }
- case Toolkit::TextInput::PASTE_BUTTON_POSITION_PRIORITY_PROPERTY:
- {
- value = textInputImpl.mPopupPanel.GetButtonPriorityPosition( TextInputPopup::ButtonsPaste );
- break;
- }
- case Toolkit::TextInput::SELECT_BUTTON_POSITION_PRIORITY_PROPERTY:
- {
- value = textInputImpl.mPopupPanel.GetButtonPriorityPosition( TextInputPopup::ButtonsSelect );
- break;
- }
- case Toolkit::TextInput::SELECT_ALL_BUTTON_POSITION_PRIORITY_PROPERTY:
- {
- value = textInputImpl.mPopupPanel.GetButtonPriorityPosition( TextInputPopup::ButtonsSelectAll );
- break;
- }
- case Toolkit::TextInput::CLIPBOARD_BUTTON_POSITION_PRIORITY_PROPERTY:
- {
- value = textInputImpl.mPopupPanel.GetButtonPriorityPosition( TextInputPopup::ButtonsClipboard );
- break;
- }
- case Toolkit::TextInput::POP_UP_OFFSET_FROM_TEXT_PROPERTY:
- {
- value = textInputImpl.GetOffsetFromText();
- break;
- }
- case Toolkit::TextInput::CURSOR_COLOR_PROPERTY:
- {
- value = textInputImpl.mCursor.GetCurrentColor();
- }
- }
- }
- return value;
-}
-
-void TextInput::EmitStyleChangedSignal()
-{
- // emit signal if input style changes.
- Toolkit::TextInput handle( GetOwner() );
- mStyleChangedSignalV2.Emit( handle, mInputStyle );
-}
-
-void TextInput::EmitTextModified()
-{
- // emit signal when text changes.
- Toolkit::TextInput handle( GetOwner() );
- mTextModifiedSignal.Emit( handle );
-}
-
-
-void TextInput::EmitMaxInputCharactersReachedSignal()
-{
- // emit signal if max characters is reached during text input.
- DALI_LOG_INFO(gLogFilter, Debug::General, "EmitMaxInputCharactersReachedSignal \n");
-
- Toolkit::TextInput handle( GetOwner() );
- mMaxInputCharactersReachedSignalV2.Emit( handle );
-}
-
-void TextInput::EmitInputTextExceedsBoundariesSignal()
-{
- // Emit a signal when the input text exceeds the boundaries of the text input.
-
- Toolkit::TextInput handle( GetOwner() );
- mInputTextExceedBoundariesSignalV2.Emit( handle );
-}
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
diff --git a/base/dali-toolkit/internal/controls/text-input/text-input-impl.h b/base/dali-toolkit/internal/controls/text-input/text-input-impl.h
deleted file mode 100644
index 76160de..0000000
--- a/base/dali-toolkit/internal/controls/text-input/text-input-impl.h
+++ /dev/null
@@ -1,1576 +0,0 @@
-#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_H__
-#define __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_H__
-
-/*
- * Copyright (c) 2014 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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-// INTERNAL INCLUDES
-#include
-#include
-#include
-#include
-#include
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-class TextInput;
-class TextView;
-
-typedef IntrusivePtr TextInputPtr;
-
-class TextInput : public Control
-{
-public:
-
- // Properties
- enum
- {
- TEXTINPUT_PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
- TEXTINPUT_PROPERTY_END_INDEX = TEXTINPUT_PROPERTY_START_INDEX + 512 ///< Reserving property indices
- };
-
- /**
- * Create a new TextInput
- * @return instrusive ptr to a TextInput
- */
- static Dali::Toolkit::TextInput New();
-
- /**
- * @copydoc Toolkit::TextInput::GetText
- */
- std::string GetText() const;
-
- /**
- * @copydoc Toolkit::TextInput::GetMarkupText()
- */
- std::string GetMarkupText() const;
-
- /**
- * @copydoc Toolkit::TextInput::SetPlaceholderText
- */
- void SetPlaceholderText( const std::string& placeHolderText );
-
- /**
- * @copydoc Toolkit::TextInput::SetPlaceholderText
- */
- std::string GetPlaceholderText();
-
- /**
- * @copydoc Toolkit::TextInput::SetInitialText
- */
- void SetInitialText(const std::string& initialText);
-
- /**
- * set the text to be displayed in text-input, will overwrite any existing text.
- * can be used to clear the text-input by passing an empty string.
- * @param [in] initialText text to be initially displayed
- */
- void SetText(const std::string& initialText);
-
- /**
- * @copydoc Toolkit::TextInput::SetMaxCharacterLength
- */
- void SetMaxCharacterLength(std::size_t maxChars);
-
- /**
- * @copydoc Toolkit::TextInput::SetNumberOfLinesLimit
- */
- void SetNumberOfLinesLimit(std::size_t maxLines);
-
- /**
- * @copydoc Toolkit::TextInput::GetNumberOfLinesLimit
- */
- std::size_t GetNumberOfLinesLimit() const;
-
- /**
- * @copydoc Toolkit::TextInput::GetFont
- */
- Font GetFont() const;
-
- /**
- * @copydoc Toolkit::TextInput::SetFont
- */
- void SetFont(Font font);
-
- /**
- * @copydoc Toolkit::TextInput::InputStartedSignal()
- */
- Toolkit::TextInput::InputSignalV2& InputStartedSignal();
-
- /**
- * @copydoc Toolkit::TextInput::InputFinishedSignal()
- */
- Toolkit::TextInput::InputSignalV2& InputFinishedSignal();
-
- /**
- * @copydoc Toolkit::TextInput::CutAndPasteToolBarDisplayedSignal()
- */
- Toolkit::TextInput::InputSignalV2& CutAndPasteToolBarDisplayedSignal();
-
- /**
- * @copydoc Toolkit::TextInput::StyleChangedSignal()
- */
- Toolkit::TextInput::StyleChangedSignalV2& StyleChangedSignal();
-
- /**
- * @copydoc Toolkit::TextInput::TextModifiedSignal()
- */
- Toolkit::TextInput::TextModifiedSignalType& TextModifiedSignal();
-
- /**
- * @copydoc Toolkit::TextInput::MaxInputCharactersReachedSignal()
- */
- Toolkit::TextInput::MaxInputCharactersReachedSignalV2& MaxInputCharactersReachedSignal();
-
- /**
- * @copydoc Toolkit::TextInput::InputTextExceedBoundariesSignal()
- */
- Toolkit::TextInput::InputTextExceedBoundariesSignalV2& InputTextExceedBoundariesSignal();
-
- /**
- * Connects a callback function with the object's signals.
- * @param[in] object The object providing the signal.
- * @param[in] tracker Used to disconnect the signal.
- * @param[in] signalName The signal to connect to.
- * @param[in] functor A newly allocated FunctorDelegate.
- * @return True if the signal was connected.
- * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
- */
- static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
-
- /**
- * @see Toolkit::TextInput::SetEditMode(bool editMode)
- * @see Toolkit::TextInput::SetEditMode(bool editMode, const Vector2& touchPoint)
- *
- * @param[in] editMode true or false to indicate editMode on or off.
- * @param[in] setCursorOnTouchPoint Whether to use the touch point to set the cursor position.
- * @param[in] touchPoint A position in actor coordinates within the text-input.
- */
- void SetEditable(bool editMode, bool setCursorOnTouchPoint, const Vector2& touchPoint = Vector2::ZERO);
-
- /**
- * @copydoc Toolkit::TextInput::GetEditMode
- */
- bool IsEditable() const;
-
- /**
- * @copydoc Toolkit::TextInput::SetTextSelectable
- */
- void SetTextSelectable(bool textSelectable = true);
-
- /**
- * @copydoc Toolkit::TextInput::IsTextSelectable
- */
- bool IsTextSelectable() const;
-
- /**
- * @copydoc Toolkit::TextInput::IsTextSelected
- */
- bool IsTextSelected() const;
-
- /**
- * @copydoc Toolkit::TextInput::DeSelectText
- */
- void DeSelectText();
-
- /**
- * @copydoc Toolkit::TextInput::SetEditOnTouch
- */
- void SetEditOnTouch(bool editOnTouch);
-
- /**
- * @copydoc Toolkit::TextInput::IsEditOnTouch
- */
- bool IsEditOnTouch() const;
-
- /**
- * @copydoc Toolkit::TextInput::SetGrabHandleImage
- */
- void SetGrabHandleImage(Dali::Image image);
-
- /**
- * @copydoc Toolkit::TextInput::SetCursorImage
- */
- void SetCursorImage(Dali::Image image, const Vector4& border );
-
- /**
- * @copydoc Toolkit::TextInput::GetSelectionHandleSize
- */
- Vector3 GetSelectionHandleSize();
-
- /**
- * @copydoc Toolkit::TextInput::SetRTLCursorImage
- */
- void SetRTLCursorImage(Dali::Image image, const Vector4& border );
-
- /**
- * @copydoc Toolkit::TextInput::EnableGrabHandle
- */
- void EnableGrabHandle(bool toggle);
-
- /**
- * @copydoc Toolkit::TextInput::IsGrabHandleEnabled
- */
- bool IsGrabHandleEnabled();
-
- /**
- * @copydoc Toolkit::TextInput::EnableSelectionHandleFlip
- */
- void EnableSelectionHandleFlip( bool toggle );
-
- /**
- * @copydoc Toolkit::TextInput::IsSelectionHandleFlipEnabled
- */
- bool IsSelectionHandleFlipEnabled();
-
- /**
- * @copydoc Toolkit::TextInput::SetSelectionHandleFlipMargin
- */
- void SetSelectionHandleFlipMargin( const Vector4& margin );
-
- /**
- * @copydoc Toolkit::TextInput::SetBoundingRectangle
- */
- void SetBoundingRectangle( const Rect& boundingRectangle );
-
- /**
- * @copydoc Toolkit::TextInput::GetBoundingRectangle
- */
- const Rect GetBoundingRectangle() const;
-
- /**
- * @copydoc Toolkit::TextInput::GetSelectionHandleFlipMargin
- */
- const Vector4& GetSelectionHandleFlipMargin();
-
- /**
- * @copydoc Toolkit::TextInput::SetTextColor
- */
- void SetTextColor( const Vector4& color );
-
- /**
- * @copydoc Toolkit::TextInput::SetActiveStyle
- */
- void SetActiveStyle( const TextStyle& style, const TextStyle::Mask mask );
-
- /**
- * @copydoc Toolkit::TextInput::ApplyStyle
- */
- void ApplyStyle( const TextStyle& style, const TextStyle::Mask mask );
-
- /**
- * @copydoc Toolkit::TextInput::ApplyStyleToAll
- */
- void ApplyStyleToAll( const TextStyle& style, const TextStyle::Mask mask );
-
- /**
- * @copydoc Toolkit::TextInput::GetStyleAtCursor
- */
- TextStyle GetStyleAtCursor() const;
-
- /**
- * Retrieves the character style for the given position.
- * @param[in] position The character position which style is required.
- * @return The style for the given position.
- */
- TextStyle GetStyleAt( std::size_t position ) const;
-
- /**
- * @copydoc Toolkit::TextInput::SetTextAlignment()
- */
- void SetTextAlignment( Toolkit::Alignment::Type align );
-
- /**
- * @copydoc Toolkit::TextInput::SetTextLineJustification()
- */
- void SetTextLineJustification( Toolkit::TextView::LineJustification justification );
-
- /**
- * @copydoc Toolkit::TextInput::SetFadeBoundary()
- */
- void SetFadeBoundary( const Toolkit::TextView::FadeBoundary& fadeBoundary );
-
- /**
- * @copydoc Toolkit::TextInput::GetFadeBoundary()
- */
- const Toolkit::TextView::FadeBoundary& GetFadeBoundary() const;
-
- /**
- * @copydoc Toolkit::TextInput::GetTextAlignment()
- */
- Toolkit::Alignment::Type GetTextAlignment() const;
-
- /**
- * @copydoc Toolkit::TextInput::SetMultilinePolicy()
- */
- void SetMultilinePolicy( Toolkit::TextView::MultilinePolicy policy );
-
- /**
- * @copydoc Toolkit::TextInput::GetMultilinePolicy()
- */
- Toolkit::TextView::MultilinePolicy GetMultilinePolicy() const;
-
- /**
- * @copydoc Toolkit::TextInput::SetWidthExceedPolicy()
- */
- void SetWidthExceedPolicy( Toolkit::TextView::ExceedPolicy policy );
-
- /**
- * @copydoc Toolkit::TextInput::GetWidthExceedPolicy()
- */
- Toolkit::TextView::ExceedPolicy GetWidthExceedPolicy() const;
-
- /**
- * @copydoc Toolkit::TextInput::SetHeightExceedPolicy()
- */
- void SetHeightExceedPolicy( Toolkit::TextView::ExceedPolicy policy );
-
- /**
- * @copydoc Toolkit::TextInput::GetHeightExceedPolicy()
- */
- Toolkit::TextView::ExceedPolicy GetHeightExceedPolicy() const;
-
- /**
- * @copydoc Toolkit::TextInput::SetExceedEnabled()
- */
- void SetExceedEnabled( bool enable );
-
- /**
- * @copydoc Toolkit::TextInput::GetExceedEnabled()
- */
- bool GetExceedEnabled() const;
-
- /**
- * @copydoc Toolkit::TextInput::SetBackground
- */
- void SetBackground(Dali::Image image );
-
- /**
- * @copydoc Toolkit::TextInput::SetNumberOfLines
- */
- void SetNumberOfLines(std::size_t lines);
-
- /**
- * @copydoc Toolkit::TextInput::GetNumberOfLines
- */
- std::size_t GetNumberOfLines();
-
- /**
- * @copydoc Toolkit::TextInput::GetNumberOfCharacters
- */
- std::size_t GetNumberOfCharacters() const;
-
- /**
- * Styling
- */
-
- /**
- * Set the diffuse color for the highlight
- * @param[in] color color to use
- */
- void SetMaterialDiffuseColor( const Vector4& color );
-
- /**
- * Get the diffuse color used by the highlight
- * @return color
- */
- const Vector4& GetMaterialDiffuseColor() const;
-
-private:
-
- /**
- * structure to hold each highlight box needed for text selection
- */
- struct HighlightBox
- {
- Vector3 size; ///< size of the highlight box
- Vector3 position; ///< position of highlight box
- ImageActor highlightBoxActor; ///< as actor that is the highlight box
- };
-
- /**
- * structure to hold each character in displayed string and its position from the left
- */
- struct CharPositions
- {
- char character; ///< todo change to UTF to aid multi-language support
- Vector3 position;
- Vector2 size;
- };
-
- /**
- * structure to hold coordinates of each quad, which will make up the mesh.
- */
- struct QuadCoordinates
- {
- /**
- * Default constructor
- */
- QuadCoordinates()
- {
- }
-
- /**
- * Constructor
- * @param[in] x1 left co-ordinate
- * @param[in] y1 top co-ordinate
- * @param[in] x2 right co-ordinate
- * @param[in] y2 bottom co-ordinate
- */
- QuadCoordinates(float x1, float y1, float x2, float y2)
- : min(x1, y1),
- max(x2, y2)
- {
- }
-
- Vector2 min; ///< top-left (minimum) position of quad
- Vector2 max; ///< bottom-right (maximum) position of quad
- };
-
- typedef std::vector QuadContainer;
-
- /**
- * structure for information required to build the highlight mesh
- */
- struct HighlightInfo
- {
- /**
- * Adds a Quad (2D rectangular sub-selection)
- * @param[in] x1 left co-ordinate
- * @param[in] y1 top co-ordinate
- * @param[in] x2 right co-ordinate
- * @param[in] y2 bottom co-ordinate
- */
- void AddQuad( float x1, float y1, float x2, float y2 );
-
- /**
- * Clamps all quads to fit within a min -> max 2D boundary.
- */
- void Clamp2D(const Vector2& min, const Vector2& max);
-
- QuadContainer mQuadList; ///< List of quads (sub-selections that form to create complete selection)
- };
-
- /**
- * Holds requested selection start and end points for highlighted text.
- */
- struct SelectionParameters
- {
- SelectionParameters( size_t start, size_t end )
- : mStartOfSelection( start ), mEndOfSelection( end )
- {
-
- }
-
- size_t mStartOfSelection;
- size_t mEndOfSelection;
- };
-
- enum State
- {
- StateEdit,
- StateDraggingHandle
- };
-
- enum SelectionHandleId
- {
- HandleOne, ///< Selection handle one which is on the left
- HandleTwo ///< Selection handle two which is on the right
- };
-
- /**
- * Two different behaviours are needed to convert a touch point into a character index.
- * When a tap is received and the touch point doesn't hit any character, the final character selected might
- * be different than the one selected if the event is a pan.
- * i.e. If a tap is received and the touch point doesn't hit any character the expected position of the cursor
- * would be the end or the beginning of a line. However, this behaviour would be weird while panning.
- */
- enum TouchToIndex
- {
- TapMode, ///< Touch point to character index conversion mode used for Tap events.
- DragMode ///< Touch point to character index conversion mode used for Pan events.
- };
-
- /**
- * Used to set the direction when find the next visible character.
- */
- enum FindVisibleCharacterDirection
- {
- Left, ///< Find visible characters on the left.
- Right, ///< Find visible characters on the right.
- ByEnd ///< Start finding visible characters by the end.
- };
-
- /**
- *
- */
- virtual bool OnTouchEvent(const TouchEvent& event);
-
- /**
- * From CustomActorImpl; called after the Text Input actor is touched
- * @param[in] event The KeyEvent event.
- * @return True if the event should be consumed.
- */
- virtual bool OnKeyEvent(const KeyEvent& event);
-
- /**
- * From CustomActorImpl; called when this actor gains keyboard focus.
- */
- virtual void OnKeyInputFocusGained();
-
- /**
- * From CustomActorImpl; called when this actor loses keyboard focus.
- */
- virtual void OnKeyInputFocusLost();
-
- /**
- * From Control; called whenever the control is added to the stage.
- */
- virtual void OnControlStageConnection();
-
-private: // From Control
-
- /**
- * Creation of the layer that is used by top level active parts of the TextInput like handles
- */
- void CreateActiveLayer();
-
- /**
- * @copydoc Control::OnInitialize()
- */
- virtual void OnInitialize();
-
- /**
- * @copydoc Control::OnControlSizeSet()
- */
- virtual void OnControlSizeSet(const Vector3& targetSize);
-
- /**
- * @copydoc Control::OnRelaidOut()
- */
- virtual void OnRelaidOut( Vector2 size, ActorSizeContainer& container );
-
- /**
- * Retrieves the text-input's natural size by calling TextView::GetNaturalSize().
- *
- * @return The natural size.
- */
- virtual Vector3 GetNaturalSize();
-
- /**
- * Retrieves the text-input's \e height for a given \e width by calling TextView::GetHeightForWidth().
- *
- * @param[in] width The given \e width.
- *
- * @return The \e height for the given \e width.
- */
- virtual float GetHeightForWidth( float width );
-
-protected:
-
- /**
- * Construct a new TextInput.
- */
- TextInput();
-
- /**
- * A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~TextInput();
-
-private:
-
- // Undefined
- TextInput(const TextInput&);
-
- // Undefined
- TextInput& operator=(const TextInput& rhs);
-
- /**
- * Callback when a handle is panned/moved, either selection handles or grab handle
- * @param actor Handle of the selection or grab handle.
- * @param gesture Data structure with the parameters of the gesture.
- */
- void OnHandlePan(Actor actor, const PanGesture& gesture);
-
- /**
- * Callback for touch down on Grab handle
- * @param[in] actor touched
- * @param[in] touch touch event
- */
- bool OnPressDown(Dali::Actor actor, const TouchEvent& touch);
-
- /**
- * Callback for touch down on Selection handle one
- * @param[in] actor touched
- * @param[in] touch touch event, used to determine if down or up event
- */
- bool OnHandleOneTouched(Dali::Actor actor, const TouchEvent& touch);
-
- /**
- * Callback for touch down on Selection handle two
- * @param[in] actor touched
- * @param[in] touch touch event, used to determine if down or up event
- */
- bool OnHandleTwoTouched(Dali::Actor actor, const TouchEvent& touch);
-
- /**
- * Callback for tap on TextInput
- * @param[in] actor
- * @param[in] tap touch event
- */
- void OnTextTap(Dali::Actor actor, const Dali::TapGesture& tap);
-
- /**
- * Callback for double tap on TextInput
- * @param[in] actor
- * @param[in] tap touch event
- */
- void OnDoubleTap(Dali::Actor actor, const Dali::TapGesture& tap);
-
- /**
- * Callback for long press on TextInput
- * @param[in] actor
- * @param[in] longPress long press event
- */
- void OnLongPress(Dali::Actor actor, const Dali::LongPressGesture& longPress);
-
- /**
- * Callback for the ClipboardEventNotifier when text is selected in the clipboard window.
- * @param[in] notifier The Clipboard Event Notifier.
- */
- void OnClipboardTextSelected( ClipboardEventNotifier& notifier );
-
- /**
- * Callback for when a button is pressed in popup panel
- * @param[in] button handle to the button pressed.
- */
- bool OnPopupButtonPressed( Toolkit::Button button );
-
- /**
- * Callback when handle timer ticks.
- *
- * Cursor should become visible/invisible to simulate blinking.
- *
- * @return True if the timer should be keep running.
- */
- bool OnCursorBlinkTimerTick();
-
- /**
- * Invoked upon popup Hide animation completing.
- * @note Only called for animating hide, not called for instantaneous (animate = false)
- * @param[in] popup The popup which was hidden.
- */
- void OnPopupHideFinished(TextInputPopup& popup);
-
- /**
- * Called in OnKeyEvent to handle key down events.
- * @param[in] event The KeyEvent event.
- * @return True if the event should be consumed.
- */
- bool OnKeyDownEvent(const KeyEvent& event);
-
- /**
- * Called in OnKeyEvent to handle key up events.
- * @param[in] event The KeyEvent event.
- * @return True if the event should be consumed.
- */
- bool OnKeyUpEvent(const KeyEvent& event);
-
- /**
- * Chooses from all handle position and alternative handle positions where to set the position of the two selection handles.
- *
- * @param[in] cursorPositionOne The initial position of the first selection handle.
- * @param[in] cursorPositionTwo The initial position of the second selection handle.
- * @param[in] altPositionValidOne Whether there is an alternative position for the first selection handle.
- * @param[in] altPositionValidTwo Whether there is an alternative position for the second selection handle.
- * @param[in] altPositionOne The alternative position of the first selection handle.
- * @param[in] altPositionTwo The alternative position of the second selection handle.
- */
- void ChooseRtlSelectionHandlePosition( const Vector3& cursorPositionOne,
- const Vector3& cursorPositionTwo,
- bool altPositionValidOne,
- bool altPositionValidTwo,
- const Vector3& altPositionOne,
- const Vector3& altPositionTwo );
- /**
- * Callback called when the text-view is scrolled.
- *
- * Updates the selection and grab handles, and the highlighted text.
- *
- * @param[in] textView Handle of the text-view.
- * @param[in] scrollPosition The difference with the previous scroll position.
- */
- void OnTextViewScrolled( Toolkit::TextView textView, Vector2 scrollPosition );
-
- /**
- * Scrolls the text-view to make the cursor visible.
- *
- * @param[in] cursorPosition The actual cursor position in actor coordinates.
- */
- void ScrollTextViewToMakeCursorVisible( const Vector3& cursorPosition );
-
- /**
- * Creates and starts a timer to scroll the text when handles are close to the edges of the text-input.
- *
- * It only starts the timer if it's already created.
- */
- void StartScrollTimer();
-
- /**
- * Stops the timer used to scroll the text.
- */
- void StopScrollTimer();
-
- /**
- * Callback called by the timer used to scroll the text.
- *
- * It calculates and sets a new scroll position.
- */
- bool OnScrollTimerTick();
-
-public: // Public to allow internal testing.
-
- /**
- * Register for touch events
- */
- void SetUpTouchEvents();
-
- /**
- * Sets up TextView Actor
- */
- void CreateTextViewActor();
-
- /**
- * Set Styled Text for text input.
- * @param[in] styleText The new styled text for the text input.
- */
- void SetText( const MarkupProcessor::StyledTextArray& styleText );
-
- /**
- * Start a timer to signal cursor to blink.
- */
- void StartCursorBlinkTimer();
-
- /**
- * Stop the timer signalling the cursor to blink.
- */
- void StopCursorBlinkTimer();
-
- /**
- * Starts input, setting focus and showing keyboard..
- */
- void StartEditMode();
-
- /**
- * Called when End of input and focus no longer required, keyboard is hidden.
- */
- void EndEditMode();
-
- /**
- * Applies a style to the current pre-edit / predicted word to show it is being edited.
- * @param[in] preEditStartPosition position in text array that the predicted word starts at
- * @param[in] preEditStringLength used to calculate how many characters need their style changed.
- */
- void ApplyPreEditStyle( std::size_t preEditStartPosition, std::size_t preEditStringLength );
-
- /**
- * Restores style to value before applying Pre-Edit style.
- */
- void RemovePreEditStyle();
-
- /**
- * Event received from IMF manager
- * @return ImfCallbackData data struture undicating if update is needed, cursor position and current text
- */
- ImfManager::ImfCallbackData ImfEventReceived( Dali::ImfManager& imfManager, const ImfManager::ImfEventData& test );
-
- /**
- * Called when the OnKey event is a Pre-edit string
- * @param[in] keyString String received in Pre-edit
- * @param[in] cursorOffset the cursor offset from where the pre-edit word starts
- * @return bool true if preedit reset is required.
- */
- bool PreEditReceived( const std::string& keyString, std::size_t cursorOffset );
-
- /**
- * Called when the OnKey event is a Commit string
- * @param[in] keyString String received in Comment
- * @return update flag to trigger cursor update of TextInput only when needed.
- */
- bool CommitReceived( const std::string& keyString );
-
- /**
- * Deletes Pre-edit string
- * By default it doesn't update the character's size and position table, which is a costly
- * operation. As in many cases deletion and insertion (InsertAt) of text
- * occurs in the same action i.e. preedit/commit. It makes sense to
- * delete without updating, and then insert with updating.
- *
- * @return The number of characters to be deleted.
- */
- std::size_t DeletePreEdit();
-
- /**
- * Reset all pre-edit flag and signal IMF keyboard that the current pre-edit word has been comitted.
- * This may be due to the cursor being moved by user or reached the max character limit.
- * @param[in] preserveCursorPosition Set true to keep cursor in current position, eg. touch event caused cursor to move.
- */
- void PreEditReset( bool preserveCursorPosition );
-
- /**
- * Called after cursor position needs updating.
- * Redraws cursor and notifies VirtualKeyboard
- */
- void CursorUpdate();
-
- /**
- * Delete highlighted characters
- * @param[in] inheritStyle Whether style from previous character in the string should be inherited.
- */
- void DeleteHighlightedText( bool inheritStyle );
-
- /*
- * Delete range of characters
- * @param[in] start position of characters to delete
- * @param[in] ncharacters number of characters to delete
- */
- void DeleteRange(std::size_t start, std::size_t ncharacters);
-
- /**
- * Delete character at current cursor position and redisplay
- * @param[in] positionToDelete position of character to delete
- */
- void DeleteCharacter( std::size_t positionToDelete );
-
- /**
- * Add or replaces characters to currently displayed string at cursor position
- * By default it doesn't update the character's size and position table, which is a costly
- * operation. As in many cases deletion and insertion (InsertAt) of text
- * occurs in the same action i.e. preedit/commit. It makes sense to
- * delete without updating, and then insert with updating.
- * @param[in] newText string to add to TextInput display string.
- * @param[in] insertionPosition position to insert at.
- * @param[in] numberOfCharactersToReplace The number of characters to replace.
- * @return number of characters to offset the cursor by.
- */
- std::size_t InsertAt( const Text& newText, const std::size_t insertionPosition, const std::size_t numberOfCharactersToReplace );
-
- /**
- * Creates a cursor.
- * @param[in] color the cursor color.
- * @return the image actor to be used as the cursor.
- */
- ImageActor CreateCursor( const Vector4 &color );
-
- /**
- * Moves cursor to the right
- * param[in] reverse if true then cursor moves in the reverse direction (to the left)
- * param[in] places number of character cursor should move.
- */
- void AdvanceCursor(bool reverse = false, std::size_t places = 1);
-
- /**
- * Draw a cursor / caret at position where new text should appear
- */
- void DrawCursor();
-
- /**
- * Sets cursor visibility
- * This sets visibility of the cursor. Which is comprised of 2
- * cursors. The conventional cursor, and the alternate (RTL) cursor,
- * which only appears when the cursor is at a character that can have
- * a character appended to different visual positions depending on whether that
- * character to be appended is RTL or LTR.
- * @param[in] visible true - enable visibility for cursor, false - disable visiblity for cursor
- */
- void SetCursorVisibility( bool visible );
-
- /**
- * Sets alternate cursor enable state
- * @see SetCursorVisibility
- * alternate cursor will only be visible if both SetCursorVisiblity
- * and cursor enabled have been set to true.
- */
- void SetAltCursorEnabled( bool enabled );
-
- /**
- * Create the grab handle that positions the cursor
- * @param[in] image to be used for grab handle
- *
- */
- void CreateGrabHandle(Image image=Image());
-
- /**
- * Create Grab area to be used by Grab Handle
- */
- void CreateGrabArea( Actor& parent);
-
- /**
- * Move grab handle to the required character position
- *
- * @param[in] displacement Displacement of the grab handle in actor coordinates.
- *
- * @return The new actual position the handle has been set to.
- */
- Vector3 MoveGrabHandle( const Vector2& displacement );
-
- /**
- * Show or hide the grab handle without baking the visibility flag.
- * Used when the Grab handle needs to be invisible due to text-view scrolling making it out of view
- *
- * @param[in] visible bool flag to set as true is grab handle should be shown, else false to hide.
- */
- void ShowGrabHandle( bool visible );
-
- /**
- * Show or hide the grab handle and bake the visibility flag.
- * Used when the state of text-input changes to a state which the grabhandle is not required. E.g. Selection mode starts or edit mode ends.
- * Calls ShowGrabHandle.
- *
- * @param[in] visible bool flag to set as true is grab handle should be shown, else false to hide.
- */
- void ShowGrabHandleAndSetVisibility( bool visible );
-
- /* Boundary Property Notifications when handle exceed bounding box*/
-
- /**
- * PropertyNotification Callback when left boundary exceeded so handle can be flipped.
- * @param[in] source PropertyNotification
- */
- void OnLeftBoundaryExceeded( PropertyNotification& source );
- /**
- * PropertyNotification Callback when within left boundary so handle can be flipped back.
- * @param[in] source PropertyNotification
- */
- void OnReturnToLeftBoundary( PropertyNotification& source );
- /**
- * PropertyNotification Callback when right boundary exceeded so handle can be flipped.
- * @param[in] source PropertyNotification
- */
- void OnRightBoundaryExceeded( PropertyNotification& source );
- /**
- * * PropertyNotification Callback when within right boundary so handle can be flipped back.
- * @param[in] source PropertyNotification
- */
- void OnReturnToRightBoundary( PropertyNotification& source );
-
- /**
- * PropertyNotification Callbacks for hiding handle one when it exceeds boundary.
- * @param[in] source PropertyNotification
- */
- void OnHandleOneLeavesBoundary( PropertyNotification& source );
- /**
- * PropertyNotification Callbacks for showing hidden handle one when returns within boundary
- * @param[in] source PropertyNotification
- */
- void OnHandleOneWithinBoundary( PropertyNotification& source );
- /**
- * PropertyNotification Callbacks for hiding handle two it when exceeds boundary.
- * @param[in] source PropertyNotification
- */
- void OnHandleTwoLeavesBoundary( PropertyNotification& source );
- /**
- * PropertyNotification Callbacks for showing hidden handle two when returns within boundary
- * * @param[in] source PropertyNotification
- */
- void OnHandleTwoWithinBoundary( PropertyNotification& source );
-
- /**
- * Set up property notifications on the position of the handles to facilitate flipping and hiding when at screen boundary.
- */
- void SetUpHandlePropertyNotifications();
-
- /**
- * Create the selection handles that bound text to be selected for copy/cut.
- * @param[in] start initial position of start selection handle.
- * @param[in] end initial position of end selection handle.
- * @param[in] handleOneImage (optional) to be used for selection handle
- * @param[in] handleTwoImage (optional) to be used for selection handle
- */
- void CreateSelectionHandles( std::size_t start = 0, std::size_t end = std::numeric_limits::max(), Dali::Image handleOneImage = Dali::Image(), Dali::Image handleTwoImage = Dali::Image() );
-
- /**
- * Move the selection handles to required positions in text.
- *
- * @param[in] handleId the handle to position
- * @param[in] displacement Displacement of the selection handle in actor coordinates.
- *
- * @return The new actual position the handle has been set to.
- */
- Vector3 MoveSelectionHandle(SelectionHandleId handleId, const Vector2& displacement);
-
- /**
- * Calculate and position the specified selection handle the given index position
- *
- * @param[in] handleId the handle to position
- */
- void SetSelectionHandlePosition(SelectionHandleId handleId);
-
- /**
- * Gets a table of the visual text positions which has a flag
- * for each Character. The flag is either true (character selected)
- * or false (character deselected)
- * @note startSelection can be greater or less than endSelection
- *
- * @param[in,out] selectedVisualText The vector to be resized and populated with the selected flags
- * @param[in] startSelection The start selection point for the text
- * @param[in] endSelection The end selection point for the text
- */
- void GetVisualTextSelection(std::vector& selectedVisualText, std::size_t startSelection, std::size_t endSelection);
-
- /**
- * Iterates between selection handles and computes the info required to build the highlight mesh
- */
- HighlightInfo CalculateHighlightInfo();
-
- /**
- * This method was added to fix a PLM. it creates one quad per character so the mesh can show different selection boxes when a mix of right to left and left to right text is selected.
- */
- HighlightInfo CalculateHighlightInfoRtl();
-
- /**
- * Calculates new Mesh data so highlight moves with selection handles.
- */
- void UpdateHighlight();
-
- /**
- * Removes popup, and its options.
- */
- void ClearPopup();
-
- /**
- * Adds Popup options which have been enabled.
- */
- void AddPopupOptions();
-
- /**
- * Sets popup position
- * @param[in] position The actual position for this popup.
- * @param[in] alternativePosition Alternative popup position if no space in upper area.
- */
- void SetPopupPosition(const Vector3& position, const Vector2& alternativePosition );
-
- /**
- * Hides the popup
- * @param[in] animate (optional) whether to animate popup to hide state over time (i.e. tween).
- * @param[in] signalFinished (optional) whether to perform an animation finish operation after the hide animation completes. Requires animate to be true.
- */
- void HidePopup( bool animate = true, bool signalFinished = true );
-
- /**
- * Shows the popup
- * @param[in] animate (optional) whether to animate popup to show state over time (i.e. tween).
- */
- void ShowPopup(bool animate = true);
-
- /**
- * Shows the cut-copy-paste popup
- */
- void ShowPopupCutCopyPaste();
-
- /**
- * Setup the selection popup and clipboard if relevant so the correct options are shown when ShowPopup is called.
- * @param[in] showCutButton Flag to show or hide cut button, in some cases like whitespace we do not want to cut just select.
- * default is true.
- */
- void SetUpPopupSelection( bool showCutButton = true );
-
- /**
- * Return the logical index containing the character position closest to the source.
- * Used for positioning the grab handle at characters when dragged along.
- * Two different behaviours are needed in case the source point doesn't actually touch a
- * character. @see TouchToIndex.
- * @param[in] source float to match against
- * @param[out] closestIndex index to the vector of character's size and position.
- * @return \e true if the source point is actually inside the geometry provided by TextView.
- */
- bool ReturnClosestIndex(const Vector2& source, std::size_t& closestIndex );
-
- /**
- * Returns the X-position of the current line justification
- * (relative to left of text-view container)
- * @return X position for line justification
- */
- float GetLineJustificationPosition() const;
-
- /**
- * Currently the cursor is positioned at the previous characters position plus it's width.
- * If the previous character is on a different line then this function returns the correct position.
- * @param[in] characterPosition the character position index that the cursor should be at
- * @return position of cursor/handle
- */
- Vector3 PositionCursorAfterWordWrap( std::size_t characterPosition ) const;
-
-
- /**
- * Return a vector which is the actual position for the given character position
- * The character position is where a cursor would be position for that character.
- * @param[in] characterPosition the logical (input) position in the 'string' of characters.
- *
- * @return Vector3 the actual x,y,z position
- */
- Vector3 GetActualPositionFromCharacterPosition(std::size_t characterPosition ) const;
-
- /**
- * Return a vector which is the actual position for the given character position
- * The character position is where a cursor would be positioned for that character to be inserted.
- * An additional alternatePosition is also set in circumstances where the possible writing
- * of characters would be in the opposite direction.
- * e.g. "HelloØ´ÙØ´ÙاÙؤEnglish"
- * | |
- * * +
- * [*] - Primary actual position for cursor i.e. continuing writing LTR (English)
- * [+] - Alternate actual position for cursor i.e. writing RTL (Arabic)
- *
- * @param[in] characterPosition the logical (input) position in the 'string' of characters.
- * @param[out] directionRTL Whether the actual x,y,z position is after LTR (false) or RTL (true) text.
- * @param[out] alternatePosition the actual x,y,z position of the cursor if user types
- * in alternate direction to current flow of text.
- * @param[out] alternatePositionValid whether this alternate position is valid.
- * @return Vector3 the actual x,y,z position
- */
- Vector3 GetActualPositionFromCharacterPosition(std::size_t characterPosition, bool& directionRTL, Vector3& alternatePosition, bool& alternatePositionValid ) const;
-
- /**
- * Retrieve the character position of the first character on the row of text
- * that this character resides on.
- * @param[in] logicalPosition the position in the 'string' of characters.
- * @return logical character position of start of row.
- */
- std::size_t GetRowStartFromCharacterPosition(std::size_t logicalPosition) const;
-
- /**
- * Retrieves the first character of a group of characters with the same direction.
- *
- * @param[in] logicalPosition Index to a character.
- *
- * @return Index to the character.
- */
- std::size_t GetFirstCharacterWithSameDirection( std::size_t logicalPosition ) const;
-
- /**
- * Retrieve the dimensions of this row of text that the character resides on.
- * @param[in] characterPosition the position in the 'string' of characters.
- * @return The size of the rectangle representing this row
- */
- Size GetRowRectFromCharacterPosition(std::size_t characterPosition) const;
-
- /**
- * Retrieve the dimensions (and min-max) of this row of text that the character resides on.
- * @param[in] characterPosition the position in the 'string' of characters.
- * @param[out] min the top-left position of the rectangle representing this row
- * @param[out] max the bottom-right position of the rectangle representing this row
- * @return The size of the rectangle representing this row (max - min)
- */
- Size GetRowRectFromCharacterPosition(std::size_t characterPosition, Vector2& min, Vector2& max) const;
-
- /**
- * Checks if the provided touchedActor was this text-input
- * @param[in] touchedActor the touched actor that will be checked against this text-input
- * @return true if the touchActor was the text-input or one of its children
- */
- bool WasTouchedCheck( const Actor& touchedActor ) const;
-
- /**
- * Connect to the stage touch event
- */
- void StartMonitoringStageForTouch();
-
- /**
- * Disconnect from the stage touch event
- */
- void EndMonitoringStageForTouch();
-
- /**
- * Callback for when the screen is touched, this will be connected when selection starts and disconnected when it ends.
- * @param[in] event The touch event
- */
- void OnStageTouched(const TouchEvent& event);
-
-
- /**
- * Select the text between the given values
- * @param[in] start position within array to start selection
- * @param[in] end position within array to end selection
- */
- void SelectText(std::size_t start, std::size_t end);
-
- /**
- * Gets selected text and returns it as a StyleText vector
- * @return StyledText vector that is selected.
- */
- MarkupProcessor::StyledTextArray GetSelectedText();
-
- /**
- * Applies the given style to all text, selected or not selected.
- * By default all style settings are applied but a bit mask could be used to modify only certain style settings.
- */
- void ApplyStyleToRange(const TextStyle& style, const TextStyle::Mask mask, const std::size_t begin, const std::size_t end);
-
- /**
- * Callback for when the keyboard status changes
- * @param[in] keyboardShown Whether the keyboard has just been shown or not.
- */
- void KeyboardStatusChanged(bool keyboardShown);
-
- /**
- * Hide highlight shown between selection handles.
- * @param[in] hidePopup flag to hide the popup too, default is to hide popup.
- */
- void RemoveHighlight( bool hidePopup = true );
-
- /**
- * Highlights text that has been selected
- */
- void CreateHighlight();
-
- /**
- * Copies selected text to clipboard
- * @return bool true if copy was successful.
- */
- bool CopySelectedTextToClipboard();
-
- /**
- * Pastes the given text to currently displayed string at the current cursor position
- * @param[in] text Text to be pasted
- */
- void PasteText( const Text& text );
-
- /**
- * Sets the direction of the text if it is empty.
- */
- void SetTextDirection();
-
- /**
- * Updates the line height accordingly with the current text input style.
- */
- void UpdateLineHeight();
-
- /**
- * Finds a visible character.
- *
- * The \e direction parameters specifies from where to start to look for a visible character. \e Left means start by characters in lower
- * positions than \e cursorPosition, \e Right means start by characters in greater positions than \e cursorPosition and \e ByEnd starts
- * by the last characters.
- *
- * If \e Left or \e Right is provided and any character is found, then looks in the other direction.
- *
- * @param[in] direction Direction used to find a visible character.
- * @param[in] cursorPosition Starting position.
- *
- * @return The found visible character.
- */
- std::size_t FindVisibleCharacter( const FindVisibleCharacterDirection direction , const std::size_t cursorPosition ) const;
-
- /**
- * @copydoc SetSortModifier()
- */
- void SetSortModifier( float depthOffset );
-
- /**
- * @copydoc SetSnapshotModeEnabled()
- */
- void SetSnapshotModeEnabled( bool enable );
-
- /**
- * @copydoc IsSnapshotModeEnabled()
- */
- bool IsSnapshotModeEnabled() const;
-
- /**
- * @copydoc SetScrollEnabled()
- */
- void SetScrollEnabled( bool enable );
-
- /**
- * @copydoc IsScrollEnabled()
- */
- bool IsScrollEnabled() const;
-
- /**
- * @copydoc SetScrollPosition()
- */
- void SetScrollPosition( const Vector2& position );
-
- /**
- * @copydoc GetScrollPosition()
- */
- Vector2 GetScrollPosition() const;
-
- /**
- * @brief Sets whether markup processing should be carried out.
- *
- * @param[in] enable whether markup processing is carried out or not.
- */
- void SetMarkupProcessingEnabled( bool enable );
-
- /**
- * @brief Returns whether markup processing is enabled or not
- *
- * @return true is markup processing is enabled
- */
- bool IsMarkupProcessingEnabled() const;
-
- /**
- * Insert or replaces the given text in the given position. It checks if the text exceeds the maximum allowed number of characters
- * and if it fits in the text-input's boundaries.
- *
- * @param[in] text Text to be inserted.
- * @param[in] position Position where the text is inserted.
- * @param[in] numberOfCharactersToReplace The number of characters to replace.
- * @param[out] textExceedsMaximunNumberOfCharacters The number of characters that have been inserted.
- * @param[out] textExceedsBoundary Whether the inserted text has exceeded the boundaries of the text-input.
- *
- * @return The number of characters that have been inserted.
- */
- std::size_t DoInsertAt( const Text& text, std::size_t position, std::size_t numberOfCharactersToReplace, bool& textExceedsMaximunNumberOfCharacters, bool& textExceedsBoundary );
-
- /**
- * Retrieve Text-view's layout info.
- */
- void GetTextLayoutInfo();
-
- /**
- * Set the offset for positioning Popup from the TextInput
- * @param[in] offset in the order, left, top, right, bottom
- */
- void SetOffsetFromText( const Vector4& offset );
-
- /**
- * Get the offset of the Popup from the TextInput
- * @return Vector4 with the offset in the order, left, top, right, bottom
- */
- const Vector4& GetOffsetFromText() const;
-
- /**
- * Show the Placeholder text with an already created StyleTextArray
- * @param[in] stylePlaceHolderText Required placeholder text to be used
- */
- void ShowPlaceholderText( const MarkupProcessor::StyledTextArray& stylePlaceHolderText );
-
- // Properties
-
- /**
- * Called when a property of an object of this type is set.
- * @param[in] object The object whose property is set.
- * @param[in] index The property index.
- * @param[in] value The new property value.
- */
- static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
-
- /**
- * Called to retrieve a property of an object of this type.
- * @param[in] object The object whose property is to be retrieved.
- * @param[in] index The property index.
- * @return The current value of the property.
- */
- static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
-
- /**
- * Emits the style changed signal.
- */
- void EmitStyleChangedSignal();
-
- /**
- * Emit signal when text is modified.
- */
- void EmitTextModified();
-
- /**
- * Emits max input characters reached signal.
- */
- void EmitMaxInputCharactersReachedSignal();
-
- /**
- * Emits a signal when the input text exceeds the boundaries of the text-input.
- */
- void EmitInputTextExceedsBoundariesSignal();
-
-private:
-
- State mState; ///< Current State of Text input.
- MarkupProcessor::StyledTextArray mStyledText; ///< String currently displayed by TextView with style info.
- TextStyle mInputStyle; ///< Stores the current input style.
- float mLineHeight; ///< Stores the current line height accordingly with the input style.
- Toolkit::TextView mDisplayedTextView; ///< Actor which actually display text
-
- MarkupProcessor::StyledTextArray mStyledPlaceHolderText; ///< Text used as place holder with style info.
-
- std::size_t mMaxStringLength; ///< Max number of characters for string
- std::size_t mNumberOflinesLimit; ///< Limit on the number of lines this TextInput will display.
-
- ImageActor mCursor; ///< Cursor overlayed on Text to show where new text will be inserted
- ImageActor mCursorRTL; ///< Right To Left Cursor overlayed on Text (where new RTL text would be inserted)
- Animation mCursorAnimation; ///< animator for cursor blinking.
- std::size_t mCursorPosition; ///< position along string cursor is at.
- Timer mCursorBlinkTimer; ///< Timer to signal cursor to blink
-
- Layer mActiveLayer; ///< Layer for active handles and alike that ensures they are above all else.
-
- Image mGrabHandleImage; ///< image to be used for grab handle
- ImageActor mGrabHandle; ///< Handle used to move cursor for editing
-
- Actor mGrabArea; ///< invisible actor that receives pans events for the grab handle.
- PanGestureDetector mPanGestureDetector; ///< Pan gesture for handles
- TapGestureDetector mTapDetector; ///< used to start editing
- TapGestureDetector mDoubleTapDetector; ///< double tap detector
-
- Vector3 mActualGrabHandlePosition; ///< actual position of grab handle, this might not be snapped to a character
-
- LongPressGestureDetector mLongPressDetector; ///< Gesture to start selection
-
- /*Selection handles*/
- Image mSelectionHandleOneImage; ///< image used for selection handle one
- Image mSelectionHandleOneImagePressed; ///< image used for selection handle one pressed state
- Image mSelectionHandleTwoImage; ///< image used for selection handle two
- Image mSelectionHandleTwoImagePressed; ///< image used for selection handle two pressed state
-
- bool mIsSelectionHandleOneFlipped:1; ///< Flag to know whether the handle one is flipped or not.
- bool mIsSelectionHandleTwoFlipped:1; ///< Flag to know whether the handle two is flipped or not.
- Vector3 mSelectionHandleOneOffset; ///< Handle One's Offset
- Vector3 mSelectionHandleTwoOffset; ///< Handle Two's Offset
- Vector3 mSelectionHandleOneActualPosition; ///< Actual x y position of handle
- Vector3 mSelectionHandleTwoActualPosition; ///< Actual x y position of handle
- std::size_t mSelectionHandleOnePosition; ///< Position of handle along the string of text
- std::size_t mSelectionHandleTwoPosition; ///< Position of handle along the string of text
- ImageActor mSelectionHandleOne; ///< First selection handle used for selecting text to cut&paste
- ImageActor mSelectionHandleTwo; ///< Second selection handle used for selecting text to cut&paste
- Actor mHandleOneGrabArea; ///< invisible actor that receives pans events for the selection handle.
- Actor mHandleTwoGrabArea; ///< invisible actor that receives pans events for the selection handle.
-
- Mesh mHighlightMesh; ///< Mesh Data for highlight
- MeshActor mHighlightMeshActor; ///< Mesh Actor to display highlight
- MeshData mMeshData; ///< Container to hold meshData for highlight
- Material mCustomMaterial; ///< Custom material used for highlight
- HighlightInfo mNewHighlightInfo; ///< Geometry info to create highlight.
-
- Text mPreEditString; ///< Holds current input string prior to it being committed.
- std::size_t mPreEditStartPosition; ///< Cursor position for start of pre-edit string
- std::size_t mPreEditLength; ///< Cursor position for length of current pre-edit string after purging characters that do not fit.
- std::size_t mNumberOfSurroundingCharactersDeleted; ///< Stores the number of surrounding characters deleted.
- unsigned long mTouchStartTime; ///< Touch Start time (time in ms when down press began)
-
- Toolkit::TextView::TextLayoutInfo mTextLayoutInfo; ///< It contains a table layout info per character sorted by the character's visual index (retrieved from TextView),
- ///< a reorder map that stores each character's visual (output) index according to its logical (input) index,
- ///< a reorder map that stores each character's logical (input) index according to its visual (output) index,
- ///< the text size after layout and the scroll offset.
-
- MarkupProcessor::StyledTextArray mCurrentCopySelecton; ///< Array to store copied text.
- TextInputPopup mPopupPanel; ///< Panel to house cut and paste, select all buttons.
-
- Timer mScrollTimer;
- Vector2 mScrollDisplacement;
- Vector3 mCurrentHandlePosition;
- SelectionHandleId mCurrentSelectionId;
- Vector3 mCurrentSelectionHandlePosition;
- SelectionParameters mRequestedSelection;
- Vector4 mSelectionHandleFlipMargin;
- Vector4 mBoundingRectangleWorldCoordinates;
-
- Clipboard mClipboard; ///< Handle to clipboard
-
- // Styling
- Vector4 mMaterialColor; // Color of the highlight
- Vector4 mPopupOffsetFromText; // Offset of Popup from the TextInput.
-
- bool mOverrideAutomaticAlignment:1; ///< Whether to override the alignment automatically set by the text content (e.g. european LTR or arabic RTL)
- bool mCursorRTLEnabled:1; ///< Enable state of Alternate RTL Cursor (need to keep track of this as it's not always enabled)
- bool mClosestCursorPositionEOL:1; ///< closest cursor position is end of line.
- bool mCursorBlinkStatus:1; ///< \e true shows the cursor, \e false hiddes it.
-
- bool mCursorVisibility:1; ///< Visibility status of Cursor
- bool mGrabHandleVisibility:1; ///< Visibility status of the grab handle.
-
- bool mIsCursorInScrollArea:1; ///< Whether the cursor is inside the boundaries of the text-input.
- bool mIsGrabHandleInScrollArea:1; ///< Whether the grab handle is inside the boundaries of the text-input.
-
- bool mEditModeActive:1; ///< true to indicate TextInput is in edit mode.
- bool mEditOnTouch:1; ///< true indicates edit mode starts by touching/tapping the TextInput
- bool mTextSelection:1; ///< true indicates text selection is enabled.
- bool mExceedEnabled:1; ///< Whether text-input editing text beyond its boundary is enabled or not. By default is enabled.
- bool mGrabHandleEnabled:1; ///< Flag to enable the grab handle instead of the default magnifier.
- bool mIsSelectionHandleFlipEnabled:1; ///< Flag to enable the selection handle flip
-
- bool mPreEditFlag:1; ///< Flag to indicate if key string received is still in pre-edit mode (Ecore IMF keyboard)
- bool mIgnoreCommitFlag:1; ///< Flag to indicate if the commit string should be ignored, maybe due to a keyboard reset.
- bool mIgnoreFirstCommitFlag:1; ///< Whether to ignore the first commit.
- bool mSelectingText:1; ///< Ignore surrounding text as selecting text
-
- bool mPreserveCursorPosition:1; ///< Indicates that the commit message is from a reset and does not require the cursor to be moved
-
- bool mSelectTextOnCommit:1;
-
- bool mUnderlinedPriorToPreEdit:1; ///< As predictive text adds underline style this flag enables us to revert back or keep underline.
-
- bool mCommitByKeyInput:1; ///< Set if a commit is done by key input rather than automatically (usually when a space bar or enter is pressed).
-
- bool mPlaceHolderSet:1; ///< Whether the place holder text is set.
- bool mMarkUpEnabled:1; ///< enable to scan for mark-up
-
- Toolkit::TextInput::InputSignalV2 mInputStartedSignalV2; ///< Signal emitted when input starts
- Toolkit::TextInput::InputSignalV2 mInputFinishedSignalV2; ///< Signal emitted when input ends
- Toolkit::TextInput::StyleChangedSignalV2 mStyleChangedSignalV2; ///< Signal emitted when style changes.
- Toolkit::TextInput::TextModifiedSignalType mTextModifiedSignal; ///< Signal emitted when text modified.
- Toolkit::TextInput::MaxInputCharactersReachedSignalV2 mMaxInputCharactersReachedSignalV2; ///< Signal emitted when max input characters is reached.
- Toolkit::TextInput::InputSignalV2 mCutAndPasteToolBarDisplayedV2; ///< Signal emitted when toolbar displayed
- Toolkit::TextInput::InputTextExceedBoundariesSignalV2 mInputTextExceedBoundariesSignalV2; ///< Signal emitted when input text exceeds the boundaries of the text-input.
-};
-
-} // namespace Internal
-
-// Helpers for public-api forwarding methods
-
-inline Toolkit::Internal::TextInput& GetImpl(Toolkit::TextInput& textInput)
-{
- DALI_ASSERT_ALWAYS(textInput);
-
- Dali::RefObject& handle = textInput.GetImplementation();
-
- return static_cast(handle);
-}
-
-inline const Toolkit::Internal::TextInput& GetImpl(const Toolkit::TextInput& textInput)
-{
- DALI_ASSERT_ALWAYS(textInput);
-
- const Dali::RefObject& handle = textInput.GetImplementation();
-
- return static_cast(handle);
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_H__
diff --git a/base/dali-toolkit/internal/controls/text-input/text-input-popup-impl.cpp b/base/dali-toolkit/internal/controls/text-input/text-input-popup-impl.cpp
deleted file mode 100644
index 63c82fe..0000000
--- a/base/dali-toolkit/internal/controls/text-input/text-input-popup-impl.cpp
+++ /dev/null
@@ -1,912 +0,0 @@
-/*
- * Copyright (c) 2014 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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include
-#include
-#include
-
-// INTERNAL INCLUDES
-#include
-#include
-#include
-
-using namespace Dali;
-
-#define GET_LOCALE_TEXT(string) dgettext("sys_string", string)
-
-namespace
-{
-const Vector2 DEFAULT_POPUP_INDICATOR_OFFSET(0.0f, 60.0f);
-
-// 1. For selection: should be above top of highlighted selection, or below bottom of highlighted selection + end handle.
-// 2. For cursor: should be above top of cursor, or below bottom of cursor + grab handle.
-
-/**
- * Image resource paths
- */
-const std::string POPUP_BACKGROUND( DALI_IMAGE_DIR "popup_bubble_bg.#.png" );
-const std::string POPUP_BACKGROUND_EFFECT( DALI_IMAGE_DIR "popup_bubble_bg_ef.#.png" );
-const std::string POPUP_BACKGROUND_LINE( DALI_IMAGE_DIR "popup_bubble_bg_line.#.png" );
-
-const std::string POPUP_TAIL_BOTTOM( DALI_IMAGE_DIR "popup_bubble_tail_bottom.png" );
-const std::string POPUP_TAIL_BOTTOM_EFFECT( DALI_IMAGE_DIR "popup_bubble_tail_bottom_ef.png" );
-const std::string POPUP_TAIL_BOTTOM_LINE( DALI_IMAGE_DIR "popup_bubble_tail_bottom_line.png" );
-const std::string POPUP_TAIL_TOP( DALI_IMAGE_DIR "popup_bubble_tail_top.png" );
-const std::string POPUP_TAIL_TOP_EFFECT( DALI_IMAGE_DIR "popup_bubble_tail_top_ef.png" );
-const std::string POPUP_TAIL_TOP_LINE( DALI_IMAGE_DIR "popup_bubble_tail_top_line.png" );
-
-const std::string OPTION_ICON_CLIPBOARD( DALI_IMAGE_DIR "copy_paste_icon_clipboard.png" );
-const std::string OPTION_ICON_COPY( DALI_IMAGE_DIR "copy_paste_icon_copy.png" );
-const std::string OPTION_ICON_CUT( DALI_IMAGE_DIR "copy_paste_icon_cut.png" );
-const std::string OPTION_ICON_PASTE( DALI_IMAGE_DIR "copy_paste_icon_paste.png" );
-const std::string OPTION_ICON_SELECT( DALI_IMAGE_DIR "copy_paste_icon_select.png" );
-const std::string OPTION_ICON_SELECT_ALL( DALI_IMAGE_DIR "copy_paste_icon_select_all.png" );
-
-/**
- * Constant values for building the GUI
- */
-const Vector4 POPUP_MARGIN( 14.0f, 14.0f, 14.0f, 14.0f ); ///< Margin around the popup visible background Image.
-const Vector4 POPUP_BORDER( 2.0f, 2.0f, 2.0f, 2.0f ); ///< The Border of the popup.
-const Vector2 POPUP_MIN_SIZE( 0.0f, 126.0f ); ///< The minimum size of the popup.
-const Vector2 POPUP_MAX_SIZE( 720.0f, 126.0f ); ///< The maximum size of the popup.
-const float POPUP_TAIL_Y_OFFSET( -2.25f ); ///< The y offset of the tail.
-const Vector2 POPUP_TAIL_SIZE( 36.0f, 36.0f ); ///< The size of the tail.
-const Vector2 POPUP_DIVIDER_SIZE( 1.0f, 126.0f ); ///< The size of the divider.
-
-const Vector4 OPTION_PADDING( 16.0f, 16.0f, 24.0f, 19.0f ); ///< The padding within the option to position icon and text away from the border. The order is left, right, top and bottom
-const Vector2 OPTION_MAX_SIZE( 220.0f, 126.0f ); ///< The maximum size of the option.
-const Vector2 OPTION_MIN_SIZE( 128.0f, 126.0f ); ///< The minimum size of the option.
-const Vector2 OPTION_ICON_SIZE( 45.0f, 45.0f ); ///< The size of the icon.
-const Vector2 OPTION_TEXT_MIN_SIZE( 128.0f, 30.0f ); ///< The minimum size of the text.
-const float OPTION_GAP_ICON_TEXT( 8.0f ); ///< The gap between the icon and the text
-
-const float HIDE_POPUP_ANIMATION_DURATION( 0.2f ); ///< Duration of popup hide animation in seconds.
-const float SHOW_POPUP_ANIMATION_DURATION( 0.2f ); ///< Duration of popup show animation in seconds.
-
-/**
- * Default Colors
- */
-const Vector4 DEFAULT_POPUP_BACKGROUND( Vector4( .20f, 0.29f, 0.44f, 1.0f ) );
-const Vector4 DEFAULT_POPUP_BACKGROUND_PRESSED( Vector4( 0.07f, 0.10f, 0.17f, 1.0f ) );
-const Vector4 DEFAULT_POPUP_LINE_COLOR( Vector4( 0.36f, 0.45f, 0.59f, 1.0f ) );
-const Vector4 DEFAULT_OPTION_ICON( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
-const Vector4 DEFAULT_OPTION_ICON_PRESSED( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
-const Vector4 DEFAULT_OPTION_TEXT( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
-const Vector4 DEFAULT_OPTION_TEXT_PRESSED( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
-
-} // unnamed namespace
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-const char* const TextInputPopup::SIGNAL_PRESSED = "pressed";
-const char* const TextInputPopup::SIGNAL_HIDE_FINISHED = "hide-finished";
-const char* const TextInputPopup::SIGNAL_SHOW_FINISHED = "show-finished";
-
-const char* const TextInputPopup::OPTION_SELECT_WORD = "option-select_word"; // "Select Word" popup option.
-const char* const TextInputPopup::OPTION_SELECT_ALL("option-select_all"); // "Select All" popup option.
-const char* const TextInputPopup::OPTION_CUT("option-cut"); // "Cut" popup option.
-const char* const TextInputPopup::OPTION_COPY("option-copy"); // "Copy" popup option.
-const char* const TextInputPopup::OPTION_PASTE("option-paste"); // "Paste" popup option.
-const char* const TextInputPopup::OPTION_CLIPBOARD("option-clipboard"); // "Clipboard" popup option.
-
-TextInputPopup::TextInputPopup()
-: mState(StateHidden),
- mRoot( Layer::New() ),
- mButtons(),
- mVisiblePopUpSize(),
- mPopupTailXPosition( 0.0f ),
- mContentSize(),
- mBackgroundColor( DEFAULT_POPUP_BACKGROUND ),
- mBackgroundPressedColor( DEFAULT_POPUP_BACKGROUND_PRESSED ),
- mLineColor( DEFAULT_POPUP_LINE_COLOR ),
- mIconColor( DEFAULT_OPTION_ICON ),
- mIconPressedColor( DEFAULT_OPTION_ICON_PRESSED ),
- mTextColor( DEFAULT_OPTION_TEXT ),
- mTextPressedColor( DEFAULT_OPTION_TEXT_PRESSED ),
- mSelectOptionPriority(1),
- mSelectAllOptionPriority(2),
- mCutOptionPriority(3),
- mCopyOptionPriority(4),
- mPasteOptionPriority(5),
- mClipboardOptionPriority(6),
- mPressedSignal(),
- mHideFinishedSignal(),
- mShowFinishedSignal()
-{
- mRoot.SetParentOrigin( ParentOrigin::TOP_LEFT );
- mRoot.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
-}
-
-void TextInputPopup::AddToParent( Actor parent )
-{
- Actor existingParent = mRoot.GetParent();
-
- if ( !existingParent )
- {
- parent.Add( mRoot );
- }
-}
-
-void TextInputPopup::RemoveFromParent()
-{
- Actor parent = mRoot.GetParent();
-
- if ( parent )
- {
- parent.Remove( mRoot );
- }
-}
-
-void TextInputPopup::CreateLayer( const Vector2& size )
-{
- mLayer = Layer::New();
- mLayer.SetParentOrigin(ParentOrigin::CENTER);
- mLayer.SetAnchorPoint(AnchorPoint::CENTER);
- mLayer.SetSize( size ); // matches stencil size
- mLayer.SetName("popup-mLayer");
-}
-
-void TextInputPopup::CreateStencil( const Vector2& size )
-{
- mStencil = CreateSolidColorActor( Color::BLUE );
- mStencil.SetParentOrigin( ParentOrigin::CENTER );
- mStencil.SetAnchorPoint( AnchorPoint::CENTER );
- mStencil.SetDrawMode( DrawMode::STENCIL );
- mStencil.SetVisible( true );
- mStencil.SetName( "popup-stencil" );
- mStencil.SetSize( size );
-}
-
-void TextInputPopup::OnScrollStarted( const Vector3& position )
-{
- mButtons.SetSensitive( false );
-}
-
-void TextInputPopup::OnScrollCompleted( const Vector3& position )
-{
- mButtons.SetSensitive( true );
-}
-
-void TextInputPopup::CreateScrollView()
-{
- mScrollView = Toolkit::ScrollView::New();
- mScrollView.SetName("popup-scroll-view");
- mScrollView.SetAnchorPoint( AnchorPoint::CENTER );
- mScrollView.SetParentOrigin( ParentOrigin::CENTER );
- mScrollView.SetScrollingDirection( PanGestureDetector::DIRECTION_HORIZONTAL, Degree( 40.0f ) );
- mScrollView.SetAxisAutoLock( true );
- mScrollView.ScrollStartedSignal().Connect( this, &TextInputPopup::OnScrollStarted );
- mScrollView.ScrollCompletedSignal().Connect( this, &TextInputPopup::OnScrollCompleted );
-}
-
-void TextInputPopup::UpdateScrollViewRulerAndSize( const Vector2& visibleSize )
-{
- mScrollView.SetSize( visibleSize.x, visibleSize.y );
-
- RulerPtr rulerX = new DefaultRuler(); // IntrusivePtr which is unreferenced when ScrollView is destroyed.
- RulerPtr rulerY = new DefaultRuler(); // IntrusivePtr which is unreferenced when ScrollView is destroyed.
- rulerY->Disable();
- rulerX->SetDomain( RulerDomain( 0, mContentSize.width, true ) );
- mScrollView.SetRulerX(rulerX);
- mScrollView.SetRulerY(rulerY);
-}
-
-
-void TextInputPopup::Clear()
-{
- if ( mBackground )
- {
- UnparentAndReset( mTail );
- UnparentAndReset( mStencil );
- UnparentAndReset( mBackground );
- UnparentAndReset( mButtons );
- UnparentAndReset( mScrollView );
- mDividerContainer.clear();
- RemoveFromParent();
- mState = StateHidden;
- }
-}
-
-ImageActor TextInputPopup::CreateOptionIcon( Image iconImage, const Vector4& color )
-{
- ImageActor icon = ImageActor::New( iconImage );
- icon.SetSize( OPTION_ICON_SIZE );
- icon.SetParentOrigin( ParentOrigin::TOP_CENTER );
- icon.SetAnchorPoint( AnchorPoint::TOP_CENTER );
- icon.SetColor( color );
- icon.SetY( OPTION_PADDING.z - POPUP_BORDER.y );
- return icon;
-}
-
-Toolkit::TextView TextInputPopup::CreateOptionCaption( const std::string& caption, const Vector4& color )
-{
- TextStyle style;
- style.SetTextColor( color );
-
- PointSize pointSize( Font::PixelsToPoints( OPTION_TEXT_MIN_SIZE.y ) );
- style.SetFontPointSize( pointSize );
-
- MarkupProcessor::StyledTextArray styledCaption;
- styledCaption.push_back( MarkupProcessor::StyledText( Text( caption ), style ) );
-
- Toolkit::TextView textView = Toolkit::TextView::New( styledCaption );
- textView.SetSizePolicy( Toolkit::Control::Fixed, Toolkit::Control::Fixed );
- textView.SetWidthExceedPolicy( Toolkit::TextView::EllipsizeEnd );
- textView.SetHeightExceedPolicy( Toolkit::TextView::EllipsizeEnd );
- textView.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
- textView.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
- textView.SetY( -OPTION_PADDING.w + POPUP_BORDER.w );
-
- MarkupProcessor::StyledTextArray styledCaptionEllipsize;
- MarkupProcessor::SetTextStyle( Text("..."), styledCaptionEllipsize, style );
- textView.SetEllipsizeText( styledCaptionEllipsize );
-
- const float textWidth = textView.GetWidthForHeight( OPTION_TEXT_MIN_SIZE.y );
- textView.SetSize( textWidth, OPTION_TEXT_MIN_SIZE.y );
-
- return textView;
-}
-
-void TextInputPopup::CreateBackground()
-{
- // Create background-panel if not already created (required if we have at least one option)
- if ( !mBackground )
- {
- Image bgImg = Image::New( POPUP_BACKGROUND );
- mBackground = ImageActor::New( bgImg );
- mBackground.SetAnchorPoint( AnchorPoint::CENTER );
- mBackground.SetParentOrigin( ParentOrigin::CENTER );
- mBackground.SetName( "text-input-popup-background" );
- mBackground.SetColor( mBackgroundColor );
-
- Image bgEffectImg = Image::New( POPUP_BACKGROUND_EFFECT );
- mBackgroundEffect = ImageActor::New( bgEffectImg );
- mBackgroundEffect.SetAnchorPoint( AnchorPoint::CENTER );
- mBackgroundEffect.SetParentOrigin( ParentOrigin::CENTER );
- mBackgroundEffect.SetName( "text-input-popup-background-effect" );
- mBackgroundEffect.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
- mBackgroundEffect.SetZ( 1.0f );
- mBackground.Add( mBackgroundEffect );
-
- Image bgLine = Image::New( POPUP_BACKGROUND_LINE );
- mBackgroundLine = ImageActor::New( bgLine );
- mBackgroundLine.SetAnchorPoint( AnchorPoint::CENTER);
- mBackgroundLine.SetParentOrigin( ParentOrigin::CENTER );
- mBackgroundLine.SetName( "text-input-popup-background-effect" );
- mBackgroundLine.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
- mBackgroundLine.SetColor( mLineColor );
- mBackgroundLine.SetZ( 0.1f );
- mBackgroundEffect.Add( mBackgroundLine );
-
- Hide(false);
- }
-}
-
-void TextInputPopup::CreateTail()
-{
- if ( !mTail )
- {
- Image tail = Image::New( POPUP_TAIL_BOTTOM );
- mTail = ImageActor::New( tail );
- mTail.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
- mTail.SetAnchorPoint( AnchorPoint::TOP_CENTER );
- mTail.SetName( "text-input-popup-tail" );
- mTail.SetPosition( 0.0f, POPUP_TAIL_Y_OFFSET - POPUP_BORDER.w, 1.2f );
- mTail.SetColor( mBackgroundColor );
-
- Image tailEffect = Image::New( POPUP_TAIL_BOTTOM_EFFECT );
- mTailEffect = ImageActor::New( tailEffect );
- mTailEffect.SetParentOrigin( ParentOrigin::CENTER );
- mTailEffect.SetAnchorPoint( AnchorPoint::CENTER );
- mTailEffect.SetName( "text-input-popup-tail-effect" );
- mTailEffect.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
- mTailEffect.SetZ( 0.1f );
- mTail.Add( mTailEffect );
-
- Image tailLine = Image::New( POPUP_TAIL_BOTTOM_LINE );
- mTailLine = ImageActor::New( tailLine );
- mTailLine.SetParentOrigin( ParentOrigin::CENTER );
- mTailLine.SetAnchorPoint( AnchorPoint::CENTER );
- mTailLine.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
- mTailLine.SetName( "text-input-popup-tail-line" );
- mTailLine.SetColor( mLineColor );
- mTailLine.SetZ( 0.1f );
- mTailEffect.Add( mTailLine );
- }
-}
-
-ImageActor TextInputPopup::CreateDivider()
-{
- ImageActor divider = Toolkit::CreateSolidColorActor( mLineColor );
- divider.SetParentOrigin( ParentOrigin::TOP_LEFT );
- divider.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- divider.SetSize( POPUP_DIVIDER_SIZE.width , mContentSize.height );
- divider.SetPosition( mContentSize.width - POPUP_DIVIDER_SIZE.width, 0.0f );
-
- // Keep track of all the dividers. As their height's need to be updated to the max of all
- // buttons currently added.
- mDividerContainer.push_back( divider );
-
- return divider;
-}
-
-ImageActor TextInputPopup::CreatePressedBackground( const Vector2& requiredSize )
-{
- ImageActor pressedBg = Toolkit::CreateSolidColorActor( mBackgroundPressedColor );
- pressedBg.SetDrawMode( DrawMode::OVERLAY );
- pressedBg.SetParentOrigin( ParentOrigin::CENTER );
- pressedBg.SetAnchorPoint( AnchorPoint::CENTER );
- pressedBg.SetSize( requiredSize );
- return pressedBg;
-}
-
-TextInputPopup::ButtonRequirement TextInputPopup::CreateRequiredButton( TextInputPopup::Buttons buttonId, std::size_t orderOfPriority,
- const std::string& name, const std::string& caption, Image iconImage, bool enabled )
-{
- TextInputPopup::ButtonRequirement currentButton;
- currentButton.buttonId = buttonId;
- currentButton.orderOfPriority = orderOfPriority;
- currentButton.name = name;
- currentButton.caption = caption;
- currentButton.iconImage = iconImage;
- currentButton.enabled = enabled;
-
- return currentButton;
-}
-
-void TextInputPopup::CreateOrderedListOfOptions()
-{
- mOrderListOfButtons.clear();
-
- for ( std::size_t index= 0; index < ButtonsEnumEnd; index++ )
- {
- TextInputPopup::ButtonRequirement currentButton;
-
- // Create button for each possible option using Option priority
- switch ( index )
- {
- case ButtonsCut:
- {
- Image cutIcon = Image::New( OPTION_ICON_CUT );
- currentButton = CreateRequiredButton( ButtonsCut, mCutOptionPriority, OPTION_CUT, GET_LOCALE_TEXT("IDS_COM_BODY_CUT"), cutIcon, false );
- break;
- }
- case ButtonsCopy:
- {
- Image copyIcon = Image::New( OPTION_ICON_COPY );
- currentButton = CreateRequiredButton( ButtonsCopy, mCopyOptionPriority, OPTION_COPY, GET_LOCALE_TEXT("IDS_COM_BODY_COPY"), copyIcon, false );
- break;
- }
- case ButtonsPaste:
- {
- Image pasteIcon = Image::New( OPTION_ICON_PASTE );
- currentButton = CreateRequiredButton( ButtonsPaste, mPasteOptionPriority, OPTION_PASTE, GET_LOCALE_TEXT("IDS_COM_BODY_PASTE"), pasteIcon, false );
- break;
- }
- case ButtonsSelect:
- {
- Image selectIcon = Image::New( OPTION_ICON_SELECT );
- currentButton = CreateRequiredButton( ButtonsSelect, mSelectOptionPriority, OPTION_SELECT_WORD, GET_LOCALE_TEXT("IDS_COM_SK_SELECT"), selectIcon, false );
- break;
- }
- case ButtonsSelectAll:
- {
- Image selectAllIcon = Image::New( OPTION_ICON_SELECT_ALL );
- currentButton = CreateRequiredButton( ButtonsSelectAll, mSelectAllOptionPriority, OPTION_SELECT_ALL, GET_LOCALE_TEXT("IDS_COM_BODY_SELECT_ALL"), selectAllIcon, false );
- break;
- }
- case ButtonsClipboard:
- {
- Image clipboardIcon = Image::New( OPTION_ICON_CLIPBOARD );
- currentButton = CreateRequiredButton( ButtonsClipboard, mClipboardOptionPriority, OPTION_CLIPBOARD, GET_LOCALE_TEXT("IDS_COM_BODY_CLIPBOARD"), clipboardIcon, false );
- break;
- }
- }
-
- bool match = false;
-
- // Insert button in list of buttons in order of priority setting.
- for( std::vector::iterator it = mOrderListOfButtons.begin(), endIt = mOrderListOfButtons.end(); ( it != endIt && !match ); ++it )
- {
- const ButtonRequirement& button( *it );
- if ( currentButton.orderOfPriority < button.orderOfPriority )
- {
- if ( currentButton.orderOfPriority != 0 ) // If order priority 0 then do not add button as not required.
- {
- mOrderListOfButtons.insert( it, currentButton );
- }
- match = true;
- }
- }
-
- if ( !match )
- {
- mOrderListOfButtons.push_back( currentButton );
- }
- }
-}
-
-Vector2 TextInputPopup::GetConstrainedTextSize( const Vector2& textSize )
-{
- return Vector2( std::min( textSize.width, OPTION_MAX_SIZE.width - OPTION_PADDING.x - OPTION_PADDING.y ), textSize.height );
-}
-
-void TextInputPopup::AddOption(const std::string& name, const std::string& caption, const Image iconImage, bool finalOption)
-{
- // 1. Create container for text and icon when not pressed.
- Actor optionContainer = Actor::New();
- optionContainer.SetParentOrigin( ParentOrigin::TOP_LEFT );
- optionContainer.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-
- // 2. Add text.
- Toolkit::TextView captionTextView = CreateOptionCaption( caption, mTextColor );
- optionContainer.Add( captionTextView );
-
- // 3. Add icon.
- ImageActor icon = CreateOptionIcon( iconImage, mIconColor );
- optionContainer.Add( icon );
-
- // 4. Calculate the size of option.
- const Vector2 textSize = Vector2( captionTextView.GetNaturalSize() );
- captionTextView.SetSize( GetConstrainedTextSize( textSize ) );
-
-
- const Vector2 optionSize( std::max( textSize.x, OPTION_ICON_SIZE.x ) + OPTION_PADDING.x + OPTION_PADDING.z,
- OPTION_PADDING.z + OPTION_ICON_SIZE.y + OPTION_GAP_ICON_TEXT + textSize.y + OPTION_MAX_SIZE.y );
-
-
- Vector2 constrainedOptionSize = Min( Max( optionSize, OPTION_MIN_SIZE ), OPTION_MAX_SIZE );
-
- constrainedOptionSize.height = constrainedOptionSize.height - POPUP_BORDER.y - POPUP_BORDER.z;
-
- // 5. Create a option.
- Toolkit::PushButton option = Toolkit::PushButton::New();
- option.SetSizePolicy( Toolkit::Control::Fixed, Toolkit::Control::Fixed );
- option.SetParentOrigin( ParentOrigin::TOP_LEFT );
- option.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- option.SetSize( constrainedOptionSize );
- option.SetX( mContentSize.x );
- option.SetName( name );
- option.SetAnimationTime( 0.0f );
- option.ClickedSignal().Connect( this, &TextInputPopup::OnButtonPressed );
- mButtons.Add( option );
-
- // 6. Set the normal option image.
- option.SetButtonImage( optionContainer );
-
- // 7. Update the content size.
- mContentSize.x += constrainedOptionSize.x;
- mContentSize.y = std::max ( constrainedOptionSize.y, mContentSize.y );
-
- // 8. Create the pressed container.
- Actor optionPressedContainer = Actor::New();
-
- // 9. Add option pressed background.
- Vector2 optionPressedBackgroundSize( constrainedOptionSize.x - POPUP_BORDER.x, mContentSize.y - POPUP_BORDER.y - POPUP_BORDER.w );
- ImageActor optionPressedBackground = CreatePressedBackground( optionPressedBackgroundSize );
- optionPressedContainer.Add( optionPressedBackground );
-
- // 10. Add pressed text
- Toolkit::TextView pressedCaptionTextView = CreateOptionCaption( caption, mTextPressedColor );
- pressedCaptionTextView.SetSize( GetConstrainedTextSize( Vector2( pressedCaptionTextView.GetNaturalSize() ) ) );
- optionPressedBackground.Add( pressedCaptionTextView );
-
- // 11. Add pressed icon
- ImageActor pressedIcon = CreateOptionIcon( iconImage, mIconPressedColor );
- optionPressedBackground.Add( pressedIcon );
-
- // 12. Set the pressed option image
- option.SetPressedImage( optionPressedContainer );
-
- // 13. Add the divider
- if ( !finalOption )
- {
- ImageActor divider = CreateDivider();
- mButtons.Add( divider );
- }
-}
-
-void TextInputPopup::Hide(bool animate)
-{
- if( mRoot )
- {
- if(mAnimation)
- {
- mAnimation.Clear();
- mAnimation.Reset();
- }
-
- if(animate)
- {
- mAnimation = Animation::New( HIDE_POPUP_ANIMATION_DURATION );
- mAnimation.AnimateTo( Property(mRoot, Actor::SCALE), Vector3::ZERO, AlphaFunctions::EaseOut );
- mAnimation.AnimateTo( Property(mRoot, Actor::COLOR_ALPHA), 0.0f, AlphaFunctions::EaseOut );
- mAnimation.Play();
-
- mAnimation.FinishedSignal().Connect( this, &TextInputPopup::OnHideFinished );
- mState = StateHiding;
- }
- else
- {
- mRoot.SetProperty(Actor::SCALE, Vector3::ZERO);
- mRoot.SetProperty(Actor::COLOR_ALPHA, 0.0f);
- mState = StateHidden;
- }
- }
-}
-
-void TextInputPopup::Show( Actor target, bool animate )
-{
- if( mRoot )
- {
- mRoot.SetSensitive( true );
-
- if(mAnimation)
- {
- mAnimation.Clear();
- mAnimation.Reset();
- }
-
- if ( target )
- {
- AddToParent( target );
- }
-
- if(animate)
- {
- mAnimation = Animation::New( SHOW_POPUP_ANIMATION_DURATION );
- mAnimation.AnimateTo( Property(mRoot, Actor::SCALE), Vector3::ONE, AlphaFunctions::EaseOut );
- mAnimation.AnimateTo( Property(mRoot, Actor::COLOR_ALPHA), 1.0f, AlphaFunctions::EaseOut );
- mAnimation.Play();
-
- mAnimation.FinishedSignal().Connect( this, &TextInputPopup::OnShowFinished );
- mState = StateShowing;
- }
- else
- {
- mRoot.SetProperty(Actor::SCALE, Vector3::ONE);
- mRoot.SetProperty(Actor::COLOR_ALPHA, 1.0f);
- mState = StateShown;
- }
- }
-}
-
-TextInputPopup::State TextInputPopup::GetState(void) const
-{
- return mState;
-}
-
-Actor TextInputPopup::GetRootActor() const
-{
- return mRoot;
-}
-
-// Styling
-
-void TextInputPopup::SetCutPastePopupColor( const Vector4& color )
-{
- mBackgroundColor = color;
-}
-
-const Vector4& TextInputPopup::GetCutPastePopupColor() const
-{
- return mBackgroundColor;
-}
-
-void TextInputPopup::SetCutPastePopupPressedColor( const Vector4& color )
-{
- mBackgroundPressedColor = color;
-}
-
-const Vector4& TextInputPopup::GetCutPastePopupPressedColor() const
-{
- return mBackgroundPressedColor;
-}
-
-void TextInputPopup::SetCutPastePopupBorderColor( const Vector4& color )
-{
- mLineColor = color;
-}
-
-const Vector4& TextInputPopup::GetCutPastePopupBorderColor() const
-{
- return mLineColor;
-}
-
-void TextInputPopup::SetCutPastePopupIconColor( const Vector4& color )
-{
- mIconColor = color;
-}
-
-const Vector4& TextInputPopup::GetCutPastePopupIconColor() const
-{
- return mIconColor;
-}
-
-void TextInputPopup::SetCutPastePopupIconPressedColor( const Vector4& color )
-{
- mIconPressedColor = color;
-}
-
-const Vector4& TextInputPopup::GetCutPastePopupIconPressedColor()
-{
- return mIconPressedColor;
-}
-
-void TextInputPopup::SetCutPastePopupTextColor( const Vector4& color )
-{
- mTextColor = color;
-}
-
-const Vector4& TextInputPopup::GetCutPastePopupTextColor()
-{
- return mTextColor;
-}
-
-void TextInputPopup::SetCutPastePopupTextPressedColor( const Vector4& color )
-{
- mTextPressedColor = color;
-}
-
-const Vector4& TextInputPopup::GetCutPastePopupTextPressedColor()
-{
- return mTextPressedColor;
-}
-
-void TextInputPopup::TogglePopupButtonOnOff( TextInputPopup::Buttons requiredButton, bool enable )
-{
- bool match ( false );
- for( std::vector::iterator it = mOrderListOfButtons.begin(), endIt = mOrderListOfButtons.end(); ( it != endIt && !match ); ++it )
- {
- ButtonRequirement& button( *it );
- if ( requiredButton == button.buttonId )
- {
- button.enabled = enable;
- match = true;
- }
- }
-}
-
-void TextInputPopup::SetButtonPriorityPosition( TextInputPopup::Buttons button, unsigned int priority )
-{
- switch ( button )
- {
- case ButtonsCut:
- {
- mCutOptionPriority = priority;
- break;
- }
- case ButtonsCopy:
- {
- mCopyOptionPriority = priority;
- break;
- }
- case ButtonsPaste:
- {
- mPasteOptionPriority = priority;
- break;
- }
- case ButtonsSelect:
- {
- mSelectOptionPriority = priority;
- break;
- }
- case ButtonsSelectAll:
- {
- mSelectAllOptionPriority = priority;
- break;
- }
- case ButtonsClipboard:
- {
- mClipboardOptionPriority = priority;
- break;
- }
- case ButtonsEnumEnd:
- {
- DALI_ASSERT_DEBUG( "ButtonsEnumEnd used but an invalid choice");
- break;
- }
- }
- CreateOrderedListOfOptions(); // Update list of options as priority changed.
-}
-
-unsigned int TextInputPopup::GetButtonPriorityPosition( TextInputPopup::Buttons button ) const
-{
- unsigned int priority = 0;
-
- switch ( button )
- {
- case ButtonsCut:
- {
- priority = mCutOptionPriority;
- break;
- }
- case ButtonsCopy:
- {
- priority = mCopyOptionPriority;
- break;
- }
- case ButtonsPaste:
- {
- priority = mPasteOptionPriority;
- break;
- }
- case ButtonsSelect:
- {
- priority = mSelectOptionPriority;
- break;
- }
- case ButtonsSelectAll:
- {
- priority = mSelectAllOptionPriority;
- break;
- }
- case ButtonsClipboard:
- {
- priority = mClipboardOptionPriority;
- break;
- }
- case ButtonsEnumEnd:
- {
- DALI_ASSERT_DEBUG( "ButtonsEnumEnd used but an invalid choice");
- break;
- }
- }
-
- return priority;
-}
-
-void TextInputPopup::AddPopupOptions()
-{
- mContentSize = Vector2( POPUP_MIN_SIZE.width, ( POPUP_BORDER.y + POPUP_BORDER.z ) );
-
- // 1. Create the background.
- CreateBackground();
-
- // 2. Create the tail.
- CreateTail();
-
- // 3. Create the scroll view and Actor to hold buttons.
- CreateScrollView();
-
- // Clear previous buttons
- if ( mButtons )
- {
- UnparentAndReset( mButtons );
- }
-
- mButtons = Actor::New();
- mButtons.SetParentOrigin( ParentOrigin::CENTER );
- mButtons.SetAnchorPoint( AnchorPoint::CENTER );
-
- // 4. Create the options and add into the scroll view.
- for( std::vector