From: Paul Wisbey
Date: Tue, 7 Apr 2015 10:34:34 +0000 (+0100)
Subject: Merge remote-tracking branch 'origin/tizen' into new_text
X-Git-Tag: dali_1.0.38~11^2~13
X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=56d412791a44c2a79135d2293c13fddb135c9d54;hp=125df617516edc317ab800bdf897e6d076d7b324
Merge remote-tracking branch 'origin/tizen' into new_text
Conflicts:
automated-tests/src/dali-toolkit-internal/CMakeLists.txt
dali-toolkit/internal/controls/buttons/push-button-impl.cpp
dali-toolkit/internal/controls/text-input/text-input-handles-impl.cpp
dali-toolkit/internal/controls/text-input/text-input-impl.cpp
Change-Id: Icb029929ab92e9d4c606f47c50d8d213759f09c5
---
diff --git a/README b/README
index dc7b5af..de9499c 100644
--- a/README
+++ b/README
@@ -23,7 +23,10 @@ T.O.C.
gbs build -A [TARGET_ARCH] --define "%enable_dali_smack_rules 1"
+1.3. MOBILE Profile
+-------------------
+ gbs build -A [TARGET_ARCH] --spec dali-toolkit-mobile.spec
2. Building for Ubuntu desktop
==============================
diff --git a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt
index 029c12d..e7dc7cb 100644
--- a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt
+++ b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt
@@ -8,10 +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
)
# Append list of test harness files (Won't get parsed for test cases)
diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp
index 05ced5a..8d2734b 100644
--- a/automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp
+++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp
@@ -713,7 +713,7 @@ int UtcDaliPushButtonProperties(void)
// Button::PROPERTY_LABEL_ACTOR
{
button.SetLabel( "LABEL_TEXT_CUSTOM" );
- DALI_TEST_EQUALS( "TextView", button.GetProperty( Button::Property::LABEL_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( "TextLabel", button.GetProperty( Button::Property::LABEL_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION );
Property::Map map;
map[ "type" ] = "Actor";
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 3bf0a46..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 )
- {
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_EQUALS( e.condition, "!\"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 )
- {
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_EQUALS( e.condition, "!\"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/CMakeLists.txt b/automated-tests/src/dali-toolkit/CMakeLists.txt
index a3f7172..5c19f09 100644
--- a/automated-tests/src/dali-toolkit/CMakeLists.txt
+++ b/automated-tests/src/dali-toolkit/CMakeLists.txt
@@ -51,7 +51,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
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 98fc629..736a724 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/dummy-control.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp
index e2b419e..3557c0d 100644
--- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp
+++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp
@@ -110,8 +110,7 @@ DummyControlImplOverride::~DummyControlImplOverride() { }
void DummyControlImplOverride::OnInitialize() { initializeCalled = true; }
-void DummyControlImplOverride::OnThemeChange(StyleManager change) { themeChangeCalled = true;}
-void DummyControlImplOverride::OnFontChange(bool defaultFontChange, bool defaultFontSizeChange) { fontChangeCalled = true; }
+void DummyControlImplOverride::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change ) { themeChangeCalled = change.themeChange; fontChangeCalled = change.defaultFontSizeChange; }
void DummyControlImplOverride::OnPinch(const PinchGesture& pinch) { pinchCalled = true; }
void DummyControlImplOverride::OnPan(const PanGesture& pan) { panCalled = true; }
void DummyControlImplOverride::OnTap(const TapGesture& tap) { tapCalled = true; }
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h
index d923ac18..473a01d 100644
--- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h
+++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h
@@ -102,8 +102,7 @@ private:
private: // From Internal::Control
virtual void OnInitialize();
- virtual void OnThemeChange( StyleManager styleManager );
- virtual void OnFontChange(bool defaultFontChange, bool defaultFontSizeChange);
+ virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change );
virtual void OnPinch(const PinchGesture& pinch);
virtual void OnPan(const PanGesture& pan);
virtual void OnTap(const TapGesture& tap);
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 5ab4b7d..3d4d1d5 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,145 +160,20 @@ bool TestPlatformAbstraction::IsLoading()
}
/**
- * @copydoc PlatformAbstraction::GetDefaultFontFamily()
+ * @copydoc PlatformAbstraction::GetDefaultFontDescription()
*/
-const std::string& TestPlatformAbstraction::GetDefaultFontFamily() const
+void TestPlatformAbstraction::GetDefaultFontDescription( std::string& family, std::string& style ) const
{
- mTrace.PushCall("GetDefaultFontFamily", "");
- return mGetDefaultFontFamilyResult;
+ // TODO
}
/**
* @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
+int TestPlatformAbstraction::GetDefaultFontSize() 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
+ // TODO
+ return int();
}
/**
@@ -320,42 +185,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
@@ -397,102 +226,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)
{
@@ -517,24 +265,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;
}
@@ -559,21 +292,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));
@@ -643,21 +361,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 41b06cd..a4ec8d3 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,19 @@ public:
virtual bool IsLoading();
/**
- * @copydoc PlatformAbstraction::GetDefaultFontFamily()
+ * @copydoc PlatformAbstraction::GetDefaultFontDescription()
*/
- virtual const std::string& GetDefaultFontFamily() const;
+ virtual void GetDefaultFontDescription( std::string& family, std::string& style ) 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;
+ virtual int GetDefaultFontSize() 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()
*/
@@ -219,31 +166,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
@@ -260,24 +184,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 */
@@ -326,33 +235,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-Builder.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp
index d403477..cc03bb1 100644
--- a/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp
+++ b/automated-tests/src/dali-toolkit/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':'orientation', \
- '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/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-NavigationControl.cpp b/automated-tests/src/dali-toolkit/utc-Dali-NavigationControl.cpp
index a2c7d54..4e81bf6 100644
--- a/automated-tests/src/dali-toolkit/utc-Dali-NavigationControl.cpp
+++ b/automated-tests/src/dali-toolkit/utc-Dali-NavigationControl.cpp
@@ -327,13 +327,12 @@ 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 );
+ Toolkit::NaviTitleBarStyle titleBarStyle( background, 720, 111, 68, 48, 34, 16, 11, 45, 63, 26, 14, 22 );
naviControl.CreateNavigationTitleBar( titleBarStyle, titleBarStyle );
Page naviItem = Page::New();
diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Popup.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Popup.cpp
index 0ba0800..2148042 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 84a020e..850f6a4 100644
--- a/automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp
+++ b/automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp
@@ -314,18 +314,8 @@ int UtcDaliPushButtonSetLabelText(void)
application.SendNotification();
application.Render();
- TextView textView;
-
pushButton.SetLabel( STR );
- textView = TextView::DownCast( pushButton.GetLabel() );
- DALI_TEST_CHECK( STR == textView.GetText() );
-
- TextView text = TextView::New( STR );
- pushButton.SetLabel( text );
-
- textView = TextView::DownCast( pushButton.GetLabel() );
- DALI_TEST_CHECK( STR == textView.GetText() );
END_TEST;
}
diff --git a/automated-tests/src/dali-toolkit/utc-Dali-RadioButton.cpp b/automated-tests/src/dali-toolkit/utc-Dali-RadioButton.cpp
index d53084c..a3fed65 100644
--- a/automated-tests/src/dali-toolkit/utc-Dali-RadioButton.cpp
+++ b/automated-tests/src/dali-toolkit/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/build/tizen/configure.ac b/build/tizen/configure.ac
index 1e94aa3..006e192 100644
--- a/build/tizen/configure.ac
+++ b/build/tizen/configure.ac
@@ -30,7 +30,6 @@ AC_SUBST(DALI_TOOLKIT_VERSION)
PKG_CHECK_MODULES(DALICORE, dali-core)
PKG_CHECK_MODULES(DALI, dali)
-PKG_CHECK_MODULES(FRIBIDI, fribidi)
DALI_TOOLKIT_CFLAGS=-DPLATFORM_TIZEN
@@ -90,6 +89,10 @@ else
dataReadOnlyDir=${prefix}/share/dali/
fi
+DALI_TOOLKIT_CFLAGS="$DALI_TOOLKIT_CFLAGS -DDALI_PROFILE_${enable_profile}"
+AM_CONDITIONAL([COMMON_PROFILE], [test x$enable_profile = xCOMMON])
+AM_CONDITIONAL([MOBILE_PROFILE], [test x$enable_profile = xMOBILE])
+
# v8 version 4+ requires c++11
PKG_CHECK_MODULES(V8, v8 = 3.32.7, [ pkg_check_v8=yes ], [ pkg_check_v8=no ] )
diff --git a/build/tizen/dali-toolkit/Makefile.am b/build/tizen/dali-toolkit/Makefile.am
index e966482..18ed54d 100644
--- a/build/tizen/dali-toolkit/Makefile.am
+++ b/build/tizen/dali-toolkit/Makefile.am
@@ -18,10 +18,15 @@
toolkit_images_dir = ../../../dali-toolkit/images
toolkit_sounds_dir = ../../../dali-toolkit/sounds
-toolkit_styles_dir = ../../../dali-toolkit/styles
toolkit_src_dir = ../../../dali-toolkit/internal
public_api_src_dir = ../../../dali-toolkit/public-api
+if MOBILE_PROFILE
+toolkit_styles_dir = ../../../dali-toolkit/styles/mobile
+else
+toolkit_styles_dir = ../../../dali-toolkit/styles
+endif
+
include ../../../dali-toolkit/images/file.list
include ../../../dali-toolkit/sounds/file.list
include ../../../dali-toolkit/styles/file.list
@@ -99,19 +104,17 @@ publicapishadowviewdir = $(publicapicontrolsdir)/shadow-view
publicapisliderdir = $(publicapicontrolsdir)/slider
publicapisuperblurviewdir = $(publicapicontrolsdir)/super-blur-view
publicapitableviewdir = $(publicapicontrolsdir)/table-view
-publicapitextviewdir = $(publicapicontrolsdir)/text-view
-publicapitextinputdir = $(publicapicontrolsdir)/text-input
+publicapitextcontrolsdir = $(publicapidir)/controls/text-controls
publicapitoolbardir = $(publicapicontrolsdir)/tool-bar
publicapiviewdir = $(publicapicontrolsdir)/view
-
publicapibuilderdir = $(publicapidir)/builder
publicapifocusmanagerdir = $(publicapidir)/focus-manager
-publicapimarkupprocessordir = $(publicapidir)/markup-processor
publicapishadereffectsdir = $(publicapidir)/shader-effects
publicapibubbleeffectdir = $(publicapidir)/shader-effects/bubble-effect
publicapistylingdir = $(publicapidir)/styling
publicapitransitioneffectsdir = $(publicapidir)/transition-effects
publicapiscriptingdir = $(publicapidir)/scripting
+publicapirenderingbackenddir = $(publicapidir)/text
publicapi_HEADERS = $(public_api_header_files)
publicapicontrols_HEADERS = $(public_api_controls_header_files)
@@ -139,17 +142,15 @@ publicapishadowview_HEADERS = $(public_api_shadow_view_header_files)
publicapislider_HEADERS = $(public_api_slider_header_files)
publicapisuperblurview_HEADERS = $(public_api_super_blur_view_header_files)
publicapitableview_HEADERS = $(public_api_table_view_header_files)
-publicapitextview_HEADERS = $(public_api_text_view_header_files)
-publicapitextinput_HEADERS = $(public_api_text_input_header_files)
+publicapitextcontrols_HEADERS = $(public_api_text_controls_header_files)
publicapitoolbar_HEADERS = $(public_api_tool_bar_header_files)
publicapiview_HEADERS = $(public_api_view_header_files)
-
publicapibuilder_HEADERS = $(public_api_builder_header_files)
publicapifocusmanager_HEADERS = $(public_api_focus_manager_header_files)
-publicapimarkupprocessor_HEADERS = $(public_api_markup_processor_header_files)
publicapishadereffects_HEADERS = $(public_api_shader_effects_header_files)
publicapibubbleeffect_HEADERS = $(public_api_bubble_effect_header_files)
publicapistyling_HEADERS = $(public_api_styling_header_files)
publicapitransitioneffects_HEADERS = $(public_api_transition_effects_header_files)
publicapiscripting_HEADERS = $(public_api_scripting_header_files)
+publicapirenderingbackend_HEADERS = $(public_api_rendering_backend_header_files)
diff --git a/dali-toolkit/dali-toolkit.h b/dali-toolkit/dali-toolkit.h
index ea7bec4..0e705e2 100644
--- a/dali-toolkit/dali-toolkit.h
+++ b/dali-toolkit/dali-toolkit.h
@@ -73,8 +73,8 @@
#include
#include
#include
-#include
-#include
+#include
+#include
#include
#include
@@ -82,11 +82,11 @@
#include
#include
-#include
-
#include
#include
+#include
+
#include
#include
#include
@@ -118,6 +118,8 @@
#include
#include
+#include
+
#include
#include
#include
diff --git a/dali-toolkit/internal/atlas-manager/atlas-manager-impl.cpp b/dali-toolkit/internal/atlas-manager/atlas-manager-impl.cpp
new file mode 100644
index 0000000..83bb423
--- /dev/null
+++ b/dali-toolkit/internal/atlas-manager/atlas-manager-impl.cpp
@@ -0,0 +1,851 @@
+/*
+ * Copyright (c) 2015 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 INCLUDE
+#include
+#include
+#include
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace
+{
+ const Vector2 DEFAULT_ATLAS_SIZE( 512.0f, 512.0f );
+ const Vector2 DEFAULT_BLOCK_SIZE( 32.0f, 32.0f );
+ const uint32_t SINGLE_PIXEL_PADDING( 1u );
+ const uint32_t DOUBLE_PIXEL_PADDING( SINGLE_PIXEL_PADDING << 1 );
+ const uint32_t FILLED_PIXEL( -1 );
+}
+
+AtlasManager::AtlasManager()
+: mNewAtlasSize( DEFAULT_ATLAS_SIZE ),
+ mNewBlockSize( DEFAULT_BLOCK_SIZE ),
+ mAddFailPolicy( Toolkit::AtlasManager::FAIL_ON_ADD_CREATES ),
+ mFilledPixel( FILLED_PIXEL )
+{
+}
+
+AtlasManagerPtr AtlasManager::New()
+{
+ AtlasManagerPtr internal = new AtlasManager();
+ return internal;
+}
+
+AtlasManager::~AtlasManager()
+{
+ for ( uint32_t i = 0; i < mAtlasList.size(); ++i )
+ {
+ delete[] mAtlasList[ i ].mStripBuffer;
+ }
+}
+
+Toolkit::AtlasManager::AtlasId AtlasManager::CreateAtlas( SizeType width,
+ SizeType height,
+ SizeType blockWidth,
+ SizeType blockHeight,
+ Pixel::Format pixelformat )
+{
+ // Check to see if the atlas is large enough to hold a single block even ?
+ if ( blockWidth > width || blockHeight > height )
+ {
+ DALI_LOG_ERROR("Atlas %i x %i too small. Dimensions need to be at least %ix%i\n",
+ width, height, blockWidth, blockHeight );
+ return 0;
+ }
+
+ Dali::Atlas atlas = Dali::Atlas::New( width, height, pixelformat );
+ AtlasDescriptor atlasDescriptor;
+ atlasDescriptor.mAtlas = atlas;
+ atlasDescriptor.mWidth = width;
+ atlasDescriptor.mHeight = height;
+ atlasDescriptor.mBlockWidth = blockWidth;
+ atlasDescriptor.mBlockHeight = blockHeight;
+ atlasDescriptor.mPixelFormat = pixelformat;
+ std::stringstream materialLabel;
+ materialLabel << "Atlas Material - ";
+ materialLabel << mAtlasList.size();
+ atlasDescriptor.mMaterial = Material::New( materialLabel.str() );
+ atlasDescriptor.mMaterial.SetDiffuseTexture( atlas );
+ atlasDescriptor.mNextFreeBlock = 1u; // indicate next free block will be the first ( +1 )
+
+ // What size do we need for this atlas' strip buffer ( assume 32bit pixel format )?
+ uint32_t neededStripSize =( blockWidth > blockHeight - DOUBLE_PIXEL_PADDING ? blockWidth : blockHeight - DOUBLE_PIXEL_PADDING ) << 2;
+ atlasDescriptor.mStripBuffer = new PixelBuffer[ neededStripSize ];
+ memset( atlasDescriptor.mStripBuffer, 0, neededStripSize );
+
+ atlasDescriptor.mHorizontalStrip = BufferImage::New( atlasDescriptor.mStripBuffer,
+ blockWidth,
+ SINGLE_PIXEL_PADDING,
+ pixelformat );
+
+ atlasDescriptor.mVerticalStrip = BufferImage::New( atlasDescriptor.mStripBuffer,
+ SINGLE_PIXEL_PADDING,
+ blockHeight - DOUBLE_PIXEL_PADDING,
+ pixelformat );
+ atlasDescriptor.mFilledPixelImage = BufferImage::New( reinterpret_cast< PixelBuffer* >( &mFilledPixel ), 1, 1, pixelformat );
+ atlas.Upload( atlasDescriptor.mFilledPixelImage, 0, 0 );
+ mAtlasList.push_back( atlasDescriptor );
+ return mAtlasList.size();
+}
+
+void AtlasManager::SetAddPolicy( Toolkit::AtlasManager::AddFailPolicy policy )
+{
+ mAddFailPolicy = policy;
+}
+
+void AtlasManager::Add( const BufferImage& image,
+ Toolkit::AtlasManager::AtlasSlot& slot,
+ Toolkit::AtlasManager::AtlasId atlas )
+{
+ // See if there's a slot in an atlas that matches the requirements of this image
+ // A bitmap must be sliceable into a single atlas
+ Pixel::Format pixelFormat = image.GetPixelFormat();
+ SizeType width = image.GetWidth();
+ SizeType height = image.GetHeight();
+ SizeType blockArea = 0;
+ SizeType totalBlocks = 0;
+ SizeType foundAtlas = 0;
+ SizeType index = 0;
+ slot.mImageId = 0;
+
+ AtlasSlotDescriptor desc;
+
+ // If there is a preferred atlas then check for room in that first
+ if ( atlas-- )
+ {
+ foundAtlas = CheckAtlas( atlas, width, height, pixelFormat, blockArea, totalBlocks );
+ }
+
+ // Search current atlases to see if there is a good match
+
+ while( !foundAtlas && index < mAtlasList.size() )
+ {
+ foundAtlas = CheckAtlas( index, width, height, pixelFormat, blockArea, totalBlocks );
+ ++index;
+ }
+
+ // If we can't find a suitable atlas then check the policy to determine action
+ if ( !foundAtlas-- )
+ {
+ if ( Toolkit::AtlasManager::FAIL_ON_ADD_CREATES == mAddFailPolicy )
+ {
+ SizeType newAtlas = CreateAtlas( mNewAtlasSize.x, mNewAtlasSize.y, mNewBlockSize.x, mNewBlockSize.y, pixelFormat );
+ if ( !newAtlas-- )
+ {
+ return;
+ }
+ else
+ {
+ foundAtlas = CheckAtlas( newAtlas, width, height, pixelFormat, blockArea, totalBlocks );
+ }
+ }
+
+ if ( Toolkit::AtlasManager::FAIL_ON_ADD_FAILS == mAddFailPolicy || !foundAtlas-- )
+ {
+ // Haven't found an atlas for this image!!!!!!
+ return;
+ }
+ }
+
+ // Work out where the blocks are we're going to use
+ for ( SizeType i = 0; i < blockArea; ++i )
+ {
+ // Is there currently a next free block available ?
+ if ( mAtlasList[ foundAtlas ].mNextFreeBlock )
+ {
+ // Yes, so use this for our next block
+ SizeType selectedBlock = mAtlasList[ foundAtlas ].mNextFreeBlock - 1u;
+ desc.mBlocksList.PushBack( selectedBlock );
+
+ // Any blocks going to be available after this one (adjust to store +1 )?
+ selectedBlock++;
+ selectedBlock++;
+ if ( selectedBlock > totalBlocks )
+ {
+ // No so start trying to use free blocks list
+ selectedBlock = 0;
+ }
+ mAtlasList[ foundAtlas ].mNextFreeBlock = selectedBlock;
+ }
+ else
+ {
+ // Our next block must be from the free list, fetch from the start of the list
+ desc.mBlocksList.PushBack( mAtlasList[ foundAtlas ].mFreeBlocksList[ 0 ] );
+ mAtlasList[ foundAtlas ].mFreeBlocksList.Remove( mAtlasList[ foundAtlas ].mFreeBlocksList.Begin() );
+ }
+ }
+
+ desc.mImageWidth = width;
+ desc.mImageHeight = height;
+ desc.mAtlasId = foundAtlas + 1u;
+ desc.mCount = 1u;
+
+ // See if there's a previously freed image ID that we can assign to this new image
+ uint32_t imageId = 0;
+ for ( uint32_t i = 0; i < mImageList.size(); ++i )
+ {
+ if ( !mImageList[ i ].mCount )
+ {
+ imageId = i + 1u;
+ break;
+ }
+ }
+ if ( !imageId )
+ {
+ mImageList.push_back( desc );
+ slot.mImageId = mImageList.size();
+ }
+ else
+ {
+ mImageList[ imageId - 1u ] = desc;
+ slot.mImageId = imageId;
+ }
+ slot.mAtlasId = foundAtlas + 1u;
+ UploadImage( image, desc );
+}
+
+AtlasManager::SizeType AtlasManager::CheckAtlas( SizeType atlas,
+ SizeType width,
+ SizeType height,
+ Pixel::Format pixelFormat,
+ SizeType& blockArea,
+ SizeType& totalBlocks )
+{
+ if ( pixelFormat == mAtlasList[ atlas ].mPixelFormat )
+ {
+ // Check to see if there are any unused blocks in this atlas to accomodate our image
+ SizeType blocksInX = mAtlasList[ atlas ].mWidth / mAtlasList[ atlas ].mBlockWidth;
+ SizeType blocksInY = mAtlasList[ atlas ].mHeight / mAtlasList[ atlas ].mBlockHeight;
+ totalBlocks = blocksInX * blocksInY;
+ SizeType blocksFree = mAtlasList[ atlas ].mNextFreeBlock ?
+ totalBlocks - mAtlasList[ atlas ].mNextFreeBlock + 1u :
+ mAtlasList[ atlas ].mFreeBlocksList.Size();
+
+ // Check to see if the image will fit in these blocks, if not we'll need to create a new atlas
+ if ( blocksFree
+ && width + DOUBLE_PIXEL_PADDING <= mAtlasList[ atlas ].mBlockWidth
+ && height + DOUBLE_PIXEL_PADDING <= mAtlasList[ atlas ].mBlockHeight )
+ {
+ blockArea = 1u;
+ return ( atlas + 1u );
+ }
+ }
+ return 0;
+}
+
+void AtlasManager::CreateMesh( SizeType atlas,
+ SizeType imageWidth,
+ SizeType imageHeight,
+ const Vector2& position,
+ SizeType widthInBlocks,
+ SizeType heightInBlocks,
+ Dali::MeshData& meshData,
+ AtlasSlotDescriptor& desc )
+{
+ Dali::MeshData::Vertex vertex;
+ Dali::MeshData::VertexContainer vertices;
+ Dali::MeshData::FaceIndices faces;
+ Dali::MeshData::FaceIndex faceIndex = 0;
+ meshData.SetHasNormals( false );
+ meshData.SetHasColor( true );
+ meshData.SetHasTextureCoords( true );
+
+ SizeType blockWidth = mAtlasList[ atlas ].mBlockWidth;
+ SizeType blockHeight = mAtlasList[ atlas ].mBlockHeight;
+
+ float vertexBlockWidth = static_cast< float >( blockWidth );
+ float vertexBlockHeight = static_cast< float >( blockHeight );
+
+ SizeType width = mAtlasList[ atlas ].mWidth;
+ SizeType height = mAtlasList[ atlas ].mHeight;
+
+ SizeType atlasWidthInBlocks = width / blockWidth;
+
+ // Get the normalized size of a texel in both directions
+ // TODO when texture resizing and passing texture size via uniforms is available,
+ // we will encode pixel positions into the vertex data rather than normalized
+ // meaning that geometry needn't be changed on an atlas resize
+ float texelX = 1.0f / static_cast< float >( width );
+ float texelY = 1.0f / static_cast< float >( height );
+
+ // Get the normalized size of a block in texels
+ float texelBlockWidth = texelX * vertexBlockWidth;
+ float texelBlockHeight = texelY * vertexBlockHeight;
+
+ // Get partial block space
+ float vertexEdgeWidth = static_cast< float >( imageWidth % blockWidth );
+ float vertexEdgeHeight = static_cast< float >( imageHeight % blockHeight );
+
+ // And in texels
+ float texelEdgeWidth = vertexEdgeWidth * texelX;
+ float texelEdgeHeight = vertexEdgeHeight * texelY;
+
+ // Block by block create the two triangles for the quad
+ SizeType blockIndex = 0;
+ float ndcWidth;
+ float ndcHeight;
+ float ndcVWidth;
+ float ndcVHeight;
+
+ Vector2 topLeft = position;
+
+ for ( SizeType y = 0; y < heightInBlocks; ++y )
+ {
+
+ float currentX = position.x;
+
+ if ( ( heightInBlocks - 1u ) == y && vertexEdgeHeight > 0.0f )
+ {
+ ndcHeight = texelEdgeHeight;
+ ndcVHeight = vertexEdgeHeight;
+ }
+ else
+ {
+ ndcHeight = texelBlockHeight;
+ ndcVHeight = vertexBlockHeight;
+ }
+
+ for ( SizeType x = 0; x < widthInBlocks; ++x )
+ {
+ SizeType block = desc.mBlocksList[ blockIndex++ ];
+
+ float fBlockX = texelBlockWidth * static_cast< float >( block % atlasWidthInBlocks );
+ float fBlockY = texelBlockHeight * static_cast< float >( block / atlasWidthInBlocks );
+
+ // Add on texture filtering compensation
+ fBlockX += texelX;
+ fBlockY += texelY;
+
+ if ( ( widthInBlocks - 1u ) == x && vertexEdgeWidth > 0.0f )
+ {
+ ndcWidth = texelEdgeWidth;
+ ndcVWidth = vertexEdgeWidth;
+ }
+ else
+ {
+ ndcWidth = texelBlockWidth;
+ ndcVWidth = vertexBlockWidth;
+ }
+
+ // Top left
+ vertex.x = topLeft.x;
+ vertex.y = topLeft.y;
+ vertex.z = 0.0f;
+ vertex.u = fBlockX;
+ vertex.v = fBlockY;
+
+ vertices.push_back( vertex );
+
+ // Top Right
+ vertex.x = topLeft.x + ndcVWidth;
+ vertex.y = topLeft.y;
+ vertex.z = 0.0f;
+ vertex.u = fBlockX + ndcWidth;
+ vertex.v = fBlockY;
+
+ vertices.push_back( vertex );
+
+ // Bottom Left
+ vertex.x = topLeft.x;
+ vertex.y = topLeft.y + ndcVHeight;
+ vertex.z = 0.0f;
+ vertex.u = fBlockX;
+ vertex.v = fBlockY + ndcHeight;
+
+ vertices.push_back( vertex );
+
+ // Bottom Right
+ topLeft.x += ndcVWidth;
+ vertex.x = topLeft.x;
+ vertex.y = topLeft.y + ndcVHeight;
+ vertex.z = 0.0f;
+ vertex.u = fBlockX + ndcWidth;
+ vertex.v = fBlockY + ndcHeight;
+
+ vertices.push_back( vertex );
+
+ // Six indices in counter clockwise winding
+ faces.push_back( faceIndex + 1u );
+ faces.push_back( faceIndex );
+ faces.push_back( faceIndex + 2u );
+ faces.push_back( faceIndex + 2u );
+ faces.push_back( faceIndex + 3u );
+ faces.push_back( faceIndex + 1u );
+ faceIndex += 4;
+ }
+
+ // Move down a row
+ topLeft.x = currentX;
+ topLeft.y += vertexBlockHeight;
+ }
+
+ // If there's only one block then skip this next vertex optimisation
+ if ( widthInBlocks * heightInBlocks > 1 )
+ {
+ Dali::MeshData::VertexContainer optimizedVertices;
+ OptimizeVertices( vertices, faces, optimizedVertices );
+ meshData.SetVertices( optimizedVertices );
+ }
+ else
+ {
+ meshData.SetVertices( vertices );
+ }
+
+ meshData.SetFaceIndices( faces );
+ meshData.SetMaterial( mAtlasList[ atlas ].mMaterial );
+}
+
+void AtlasManager::PrintMeshData( const MeshData& meshData )
+{
+ std::cout << "\nMesh Data for Image: VertexCount = " << meshData.GetVertexCount();
+ std::cout << ", Triangles = " << meshData.GetFaceCount() << std::endl;
+
+ Dali::MeshData::VertexContainer vertices = meshData.GetVertices();
+ Dali::MeshData::FaceIndices faces = meshData.GetFaces();
+
+ for ( SizeType v = 0; v < vertices.size(); ++v )
+ {
+ std::cout << " Vertex(" << v << ") x = " << vertices[v].x << ", ";
+ std::cout << "y = " << vertices[v].y << ", " << "z = " << vertices[v].z << ", ";
+ std::cout << "u = " << vertices[v].u << ", " << "v = " << vertices[v].v << std::endl;
+ }
+
+ std::cout << "\n Indices: ";
+ for ( SizeType i = 0; i < faces.size(); ++i )
+ {
+ std::cout << " " << faces[ i ];
+ }
+ std::cout << std::endl;
+}
+
+void AtlasManager::OptimizeVertices( const MeshData::VertexContainer& in,
+ MeshData::FaceIndices& faces,
+ MeshData::VertexContainer& out )
+{
+ unsigned short vertexIndex = 0;
+
+ // We could check to see if blocks are next to each other, but it's probably just as quick to compare verts
+ for ( SizeType i = 0; i < faces.size(); ++i )
+ {
+ // Fetch a vertex, has it already been assigned?
+ bool foundVertex = false;
+ Dali::MeshData::Vertex v = in[ faces [ i ] ];
+ for ( SizeType j = 0; j < vertexIndex; ++j )
+ {
+ if ( v.x == out[ j ].x && v.y == out[ j ].y && v.z == out[ j ].z &&
+ v.u == out[ j ].u && v.v == out[ j ].v && v.nX == out[ j ].nX &&
+ v.nY == out[ j ].nY && v.nZ == out[ j ].nZ )
+ {
+ // Yes, so store this down as the vertex to use
+ faces[ i ] = j;
+ foundVertex = true;
+ break;
+ }
+ }
+
+ // Did we find a vertex ?
+ if ( !foundVertex )
+ {
+ // Add a new vertex
+ faces[ i ] = vertexIndex++;
+ out.push_back( v );
+ }
+ }
+}
+
+void AtlasManager::StitchMesh( MeshData& first,
+ const MeshData& second,
+ bool optimize )
+{
+
+ // Would be much quicker to be able to get a non-const reference to these containers and update in situ
+ MeshData::VertexContainer v1 = first.GetVertices();
+ MeshData::VertexContainer v2 = second.GetVertices();
+ MeshData::FaceIndices f1 = first.GetFaces();
+ MeshData::FaceIndices f2 = second.GetFaces();
+
+ uint32_t vc1 = first.GetVertexCount();
+ uint32_t vc2 = second.GetVertexCount();
+
+ for ( uint32_t v = 0; v < vc2; ++v )
+ {
+ v1.push_back( v2[ v ] );
+ }
+
+ for ( uint32_t f = 0; f < f2.size(); ++f )
+ {
+ f1.push_back( f2[ f ] + vc1 );
+ }
+
+ if ( optimize )
+ {
+ MeshData::VertexContainer optimizedVertices;
+ OptimizeVertices( v1, f1, optimizedVertices );
+ first.SetVertices( optimizedVertices );
+ }
+ else
+ {
+ first.SetVertices( v1 );
+ }
+
+ first.SetFaceIndices( f1 );
+}
+
+void AtlasManager::StitchMesh( const MeshData& first,
+ const MeshData& second,
+ MeshData& out,
+ bool optimize )
+{
+ MeshData::VertexContainer v1 = first.GetVertices();
+ MeshData::VertexContainer v2 = second.GetVertices();
+ MeshData::FaceIndices f1 = first.GetFaces();
+ MeshData::FaceIndices f2 = second.GetFaces();
+
+ uint32_t vc1 = first.GetVertexCount();
+ uint32_t vc2 = second.GetVertexCount();
+
+ MeshData::VertexContainer vertices;
+
+ MeshData::FaceIndices faces;
+
+ MeshData::Vertex vertex;
+
+ for ( uint32_t v = 0; v < vc1; ++v )
+ {
+ vertices.push_back( v1[ v ] );
+ }
+
+ for ( uint32_t v = 0; v < vc2; ++v )
+ {
+ vertices.push_back( v2[ v ] );
+ }
+
+ for ( uint32_t f = 0; f < f1.size(); ++f )
+ {
+ faces.push_back( f1[ f ] );
+ }
+
+ for ( uint32_t f = 0; f < f2.size(); ++f )
+ {
+ faces.push_back( f2[ f ] + vc1 );
+ }
+
+ if ( optimize )
+ {
+ MeshData::VertexContainer optimizedVertices;
+ OptimizeVertices( vertices, faces, optimizedVertices );
+ out.SetVertices( optimizedVertices );
+ }
+ else
+ {
+ out.SetVertices( vertices );
+ }
+
+ out.SetMaterial( first.GetMaterial() );
+ out.SetFaceIndices( faces );
+}
+
+void AtlasManager::UploadImage( const BufferImage& image,
+ const AtlasSlotDescriptor& desc )
+{
+ // Get the atlas to upload the image to
+ SizeType atlas = desc.mAtlasId - 1u;
+
+ // Check to see that the pixel formats are compatible
+ if ( image.GetPixelFormat() != mAtlasList[ atlas ].mPixelFormat )
+ {
+ DALI_LOG_ERROR("Cannot upload an image with a different PixelFormat to the Atlas.\n");
+ return;
+ }
+
+ SizeType atlasBlockWidth = mAtlasList[ atlas ].mBlockWidth;
+ SizeType atlasBlockHeight = mAtlasList[ atlas ].mBlockHeight;
+ SizeType atlasWidthInBlocks = mAtlasList[ atlas ].mWidth / mAtlasList[ atlas ].mBlockWidth;
+
+ SizeType block = desc.mBlocksList[ 0 ];
+ SizeType blockX = block % atlasWidthInBlocks;
+ SizeType blockY = block / atlasWidthInBlocks;
+ SizeType blockOffsetX = blockX * atlasBlockWidth;
+ SizeType blockOffsetY = blockY * atlasBlockHeight;
+
+ SizeType width = image.GetWidth();
+ SizeType height = image.GetHeight();
+
+ // Blit image 1 pixel to the right and down into the block to compensate for texture filtering
+ if ( !mAtlasList[ atlas ].mAtlas.Upload( image,
+ blockOffsetX + SINGLE_PIXEL_PADDING,
+ blockOffsetY + SINGLE_PIXEL_PADDING ) )
+ {
+ DALI_LOG_ERROR("Uploading image to Atlas Failed!.\n");
+ }
+
+ // If this is the first block then we need to keep the first pixel free for underline texture
+ if ( block )
+ {
+
+ // Blit top strip
+ if ( !mAtlasList[ atlas ].mAtlas.Upload( mAtlasList[ atlas ].mHorizontalStrip,
+ blockOffsetX,
+ blockOffsetY ) )
+ {
+ DALI_LOG_ERROR("Uploading top strip to Atlas Failed!\n");
+ }
+
+ // Blit left strip
+ if ( !mAtlasList[ atlas ].mAtlas.Upload( mAtlasList[ atlas ].mVerticalStrip,
+ blockOffsetX,
+ blockOffsetY + SINGLE_PIXEL_PADDING ) )
+ {
+ DALI_LOG_ERROR("Uploading left strip to Atlas Failed!\n");
+ }
+ }
+
+ // Blit bottom strip
+ if ( blockOffsetY + height + DOUBLE_PIXEL_PADDING <= mAtlasList[ atlas ].mHeight )
+ {
+ if ( !mAtlasList[ atlas ].mAtlas.Upload( mAtlasList[ atlas ].mHorizontalStrip,
+ blockOffsetX,
+ blockOffsetY + height + SINGLE_PIXEL_PADDING ) )
+ {
+ DALI_LOG_ERROR("Uploading bottom strip to Atlas Failed!.\n");
+ }
+ }
+
+ // Blit right strip
+ if ( blockOffsetX + width + DOUBLE_PIXEL_PADDING <= mAtlasList[ atlas ].mWidth )
+ {
+ if ( !mAtlasList[ atlas ].mAtlas.Upload( mAtlasList[ atlas ].mVerticalStrip,
+ blockOffsetX + width + SINGLE_PIXEL_PADDING,
+ blockOffsetY + SINGLE_PIXEL_PADDING ) )
+ {
+ DALI_LOG_ERROR("Uploading right strip to Atlas Failed!.\n");
+ }
+ }
+}
+
+void AtlasManager::GenerateMeshData( ImageId id,
+ const Vector2& position,
+ MeshData& meshData )
+{
+ // Read the atlas Id to use for this image
+ SizeType imageId = id - 1u;
+ SizeType atlas = mImageList[ imageId ].mAtlasId - 1u;
+ SizeType width = mImageList[ imageId ].mImageWidth;
+ SizeType height = mImageList[ imageId ].mImageHeight;
+
+ SizeType widthInBlocks = width / mAtlasList[ atlas ].mBlockWidth;
+ if ( width % mAtlasList[ atlas ].mBlockWidth )
+ {
+ widthInBlocks++;
+ }
+ SizeType heightInBlocks = height / mAtlasList[ atlas ].mBlockHeight;
+ if ( height % mAtlasList[ atlas ].mBlockHeight )
+ {
+ heightInBlocks++;
+ }
+
+ CreateMesh( atlas, width, height, position, widthInBlocks, heightInBlocks, meshData, mImageList[ imageId ] );
+
+ // Mesh created so increase the reference count
+ mImageList[ imageId ].mCount++;
+}
+
+Dali::Atlas AtlasManager::GetAtlasContainer( AtlasId atlas ) const
+{
+ Dali::Atlas null;
+ if ( !atlas || atlas > mAtlasList.size( ) )
+ {
+
+ DALI_LOG_ERROR("Cannot get Atlas from AtlasID ( doesn't exist ).\n");
+ return null;
+ }
+ return mAtlasList[ atlas -1u ].mAtlas;
+}
+
+bool AtlasManager::Remove( ImageId id )
+{
+ // Decrements the reference count of this image, and removes the blocks if zero.
+ SizeType imageId = id - 1u;
+ bool removed = false;
+
+ if ( id > mImageList.size() )
+ {
+ DALI_LOG_ERROR("Atlas was asked to free an invalid imageID: %i\n", id );
+ return false;
+ }
+
+ // If we attempt to free an image that is already freed then do nothing, other than log
+ if ( !mImageList[ imageId ].mCount )
+ {
+ DALI_LOG_ERROR("Atlas was asked to free an imageID: %i, that has already been freed!\n", id );
+ return false;
+ }
+
+ if ( 1u == --mImageList[ imageId ].mCount )
+ {
+ // 'Remove the blocks' from this image and add to the atlas' freelist
+ removed = true;
+ mImageList[ imageId ].mCount = 0;
+ SizeType atlas = mImageList[ imageId ].mAtlasId - 1u;
+ for ( uint32_t i = 0; i < mImageList[ imageId ].mBlocksList.Size(); ++i )
+ {
+ mAtlasList[ atlas ].mFreeBlocksList.PushBack( mImageList[ imageId ].mBlocksList[ i ] );
+ }
+ }
+ return removed;
+}
+
+AtlasManager::AtlasId AtlasManager::GetAtlas( ImageId id ) const
+{
+ if ( id && id <= mImageList.size() )
+ {
+ return mImageList[ id - 1u ].mAtlasId;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+void AtlasManager::SetNewAtlasSize( const Vector2& size,
+ const Vector2& blockSize )
+{
+ mNewAtlasSize = size;
+ mNewBlockSize = blockSize;
+}
+
+Vector2 AtlasManager::GetBlockSize( AtlasId atlas )
+{
+ if ( atlas && atlas <= mAtlasList.size() )
+ {
+ return Vector2( static_cast< float >( mAtlasList[ atlas - 1u ].mBlockWidth ),
+ static_cast< float >( mAtlasList[ atlas - 1u ].mBlockHeight) );
+ }
+ else
+ {
+ return Vector2::ZERO;
+ }
+}
+
+Vector2 AtlasManager::GetAtlasSize( AtlasId atlas )
+{
+ if ( atlas && atlas <= mAtlasList.size() )
+ {
+ return Vector2( static_cast< float >( mAtlasList[ atlas - 1u ].mWidth ),
+ static_cast< float >( mAtlasList[ atlas - 1u ].mHeight ) );
+ }
+ else
+ {
+ return Vector2::ZERO;
+ }
+}
+
+AtlasManager::SizeType AtlasManager::GetFreeBlocks( AtlasId atlas ) const
+{
+ if ( atlas && atlas <= mAtlasList.size() )
+ {
+ uint32_t index = atlas - 1u;
+ uint32_t width = mAtlasList[ index ].mWidth;
+ uint32_t height = mAtlasList[ index ].mHeight;
+ uint32_t blockWidth = mAtlasList[ index ].mBlockWidth;
+ uint32_t blockHeight = mAtlasList[ index ].mBlockHeight;
+
+ SizeType widthInBlocks = width / blockWidth;
+ SizeType heightInBlocks = height / blockHeight;
+ uint32_t blockCount = widthInBlocks * heightInBlocks;
+
+ // Check free previously unallocated blocks and any free blocks
+ blockCount -= mAtlasList[ index ].mNextFreeBlock - mAtlasList[ index ].mFreeBlocksList.Size();
+ return blockCount;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+AtlasManager::SizeType AtlasManager::GetAtlasCount() const
+{
+ return mAtlasList.size();
+}
+
+Pixel::Format AtlasManager::GetPixelFormat( AtlasId atlas )
+{
+ if ( !atlas || atlas > mAtlasList.size( ) )
+ {
+
+ DALI_LOG_ERROR("Cannot get Atlas from AtlasID ( doesn't exist ).\n");
+ return Pixel::L8;
+ }
+ return mAtlasList[ atlas -1u ].mPixelFormat;
+}
+
+void AtlasManager::GetMetrics( Toolkit::AtlasManager::Metrics& metrics )
+{
+ Toolkit::AtlasManager::AtlasMetricsEntry entry;
+ uint32_t textureMemoryUsed = 0;
+ uint32_t atlasCount = mAtlasList.size();
+ metrics.mAtlasCount = atlasCount;
+ metrics.mAtlasMetrics.Resize(0);
+
+ for ( uint32_t i = 0; i < atlasCount; ++i )
+ {
+ SizeType width = mAtlasList[ i ].mWidth;
+ SizeType height = mAtlasList[ i ].mHeight;
+ SizeType blockWidth = mAtlasList[ i ].mBlockWidth;
+ SizeType blockHeight = mAtlasList[ i ].mBlockHeight;
+
+ entry.mWidth = width;
+ entry.mHeight = height;
+ entry.mBlockWidth = blockWidth;
+ entry.mBlockHeight = blockHeight;
+ entry.mTotalBlocks = ( width / blockWidth ) * ( height / blockHeight );
+ uint32_t reuseBlocks = mAtlasList[ i ].mFreeBlocksList.Size();
+ entry.mBlocksUsed = mAtlasList[ i ].mNextFreeBlock ? mAtlasList[ i ].mNextFreeBlock - reuseBlocks - 1u: entry.mTotalBlocks - reuseBlocks;
+ entry.mPixelFormat = GetPixelFormat( i + 1 );
+
+ metrics.mAtlasMetrics.PushBack( entry );
+
+ uint32_t size = width * height;
+ if ( entry.mPixelFormat == Pixel::BGRA8888 )
+ {
+ size <<= 2;
+ }
+
+ textureMemoryUsed += size;
+
+ }
+ metrics.mTextureMemoryUsed = textureMemoryUsed;
+}
+
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+
diff --git a/dali-toolkit/internal/atlas-manager/atlas-manager-impl.h b/dali-toolkit/internal/atlas-manager/atlas-manager-impl.h
new file mode 100644
index 0000000..0656da7
--- /dev/null
+++ b/dali-toolkit/internal/atlas-manager/atlas-manager-impl.h
@@ -0,0 +1,249 @@
+#ifndef __DALI_TOOLKIT_ATLAS_MANAGER_IMPL_H__
+#define __DALI_TOOLKIT_ATLAS_MANAGER_IMPL_H__
+
+/*
+ * Copyright (c) 2015 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
+
+// INTERNAL INCLUDES
+#include
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+class AtlasManager;
+
+} // namespace Toolkit
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+typedef Dali::Vector< Toolkit::AtlasManager::AtlasSlot > slotContainer;
+
+class AtlasManager;
+typedef IntrusivePtr AtlasManagerPtr;
+
+class AtlasManager : public Dali::BaseObject
+{
+public:
+
+ typedef uint32_t SizeType;
+ typedef SizeType AtlasId;
+ typedef SizeType ImageId;
+
+ /**
+ * @brief Internal storage of atlas attributes and image upload results
+ */
+ struct AtlasDescriptor
+ {
+ Dali::Atlas mAtlas; // atlas image
+ SizeType mWidth; // width of atlas
+ SizeType mHeight; // height of atlas
+ SizeType mBlockWidth; // width of a block in atlas
+ SizeType mBlockHeight; // height of a block in atlas
+ Pixel::Format mPixelFormat; // pixel format used by atlas
+ BufferImage mHorizontalStrip; // Image used to pad upload
+ BufferImage mVerticalStrip; // Image used to pad upload
+ BufferImage mFilledPixelImage; // Image used by atlas for operations such as underline
+ PixelBuffer* mStripBuffer; // Blank image buffer used to pad upload
+ Material mMaterial; // material used for atlas texture
+ SizeType mNextFreeBlock; // next free block will be placed here ( actually +1 )
+ Dali::Vector< SizeType > mFreeBlocksList; // unless there are any previously freed blocks
+ };
+
+ struct AtlasSlotDescriptor
+ {
+ SizeType mCount; // Reference count for this slot
+ SizeType mImageWidth; // Width of image stored
+ SizeType mImageHeight; // Height of image stored
+ AtlasId mAtlasId; // Image is stored in this Atlas
+ Dali::Vector< SizeType > mBlocksList; // List of blocks within atlas used for image
+ };
+
+ AtlasManager();
+
+ /**
+ * Create a new AtlasManager
+ */
+ static AtlasManagerPtr New();
+
+ virtual ~AtlasManager();
+
+ /**
+ * @copydoc: Toolkit::AtlasManager::CreateAtlas
+ */
+ AtlasId CreateAtlas( SizeType width,
+ SizeType height,
+ SizeType blockWidth,
+ SizeType blockHeight,
+ Pixel::Format pixelformat );
+
+ /**
+ * @copydoc Toolkit::AtlasManager::SetAddPolicy
+ */
+ void SetAddPolicy( Toolkit::AtlasManager::AddFailPolicy policy );
+
+ /**
+ * @copydoc Toolkit::AtlasManager::Add
+ */
+ void Add( const BufferImage& image,
+ Toolkit::AtlasManager::AtlasSlot& slot,
+ Toolkit::AtlasManager::AtlasId atlas );
+
+ /**
+ * @copydoc Toolkit::AtlasManager::GenerateMeshData
+ */
+ void GenerateMeshData( ImageId id,
+ const Vector2& position,
+ MeshData& mesh );
+
+ /**
+ * @copydoc Toolkit::AtlasManager::StitchMesh
+ */
+ void StitchMesh( MeshData& first,
+ const MeshData& second,
+ bool optimize );
+
+ /**
+ * @copydoc Toolkit::AtlasManager::StitchMesh
+ */
+ void StitchMesh( const MeshData& first,
+ const MeshData& second,
+ MeshData& out, bool optimize );
+
+ /**
+ * @copydoc Toolkit::AtlasManager::Remove
+ */
+ bool Remove( ImageId id );
+
+ /**
+ * @copydoc Toolkit::AtlasManager::GetAtlasContainer
+ */
+ Dali::Atlas GetAtlasContainer( AtlasId atlas ) const;
+
+ /**
+ * @copydoc Toolkit::AtlasManager::GetAtlas
+ */
+ AtlasId GetAtlas( ImageId id ) const;
+
+ /**
+ * @copydoc Toolkit::AtlasManager::SetNewAtlasSize
+ */
+ void SetNewAtlasSize( const Vector2& size,
+ const Vector2& blockSize );
+
+ /**
+ * @copydoc Toolkit::AtlasManager::GetAtlasSize
+ */
+ Vector2 GetAtlasSize( AtlasId atlas );
+
+ /**
+ * @copydoc Toolkit::AtlasManager::GetBlockSize
+ */
+ Vector2 GetBlockSize( AtlasId atlas );
+
+ /**
+ * @copydoc Toolkit::AtlasManager::GetFreeBlocks
+ */
+ SizeType GetFreeBlocks( AtlasId atlas ) const;
+
+ /*
+ * @copydoc Toolkit::AtlasManager::GetAtlasCount
+ */
+ SizeType GetAtlasCount() const;
+
+ /**
+ * @copydoc Toolkit::AtlasManager::GetPixelFormat
+ */
+ Pixel::Format GetPixelFormat( AtlasId atlas );
+
+ /**
+ * @copydoc Toolkit::AtlasManager::GetMetrics
+ */
+ void GetMetrics( Toolkit::AtlasManager::Metrics& metrics );
+
+private:
+
+ std::vector< AtlasDescriptor > mAtlasList; // List of atlases created
+ std::vector< AtlasSlotDescriptor > mImageList; // List of bitmaps store in atlases
+
+ SizeType CheckAtlas( SizeType atlas,
+ SizeType width,
+ SizeType height,
+ Pixel::Format pixelFormat,
+ SizeType& blockArea,
+ SizeType& totalBlocks );
+
+ void CreateMesh( SizeType atlas,
+ SizeType imageWidth,
+ SizeType imageHeight,
+ const Vector2& position,
+ SizeType widthInBlocks,
+ SizeType heightInBlocks,
+ Dali::MeshData& meshData,
+ AtlasSlotDescriptor& desc );
+
+ void OptimizeVertices( const MeshData::VertexContainer& in,
+ MeshData::FaceIndices& faces,
+ MeshData::VertexContainer& out );
+
+ void UploadImage( const BufferImage& image,
+ const AtlasSlotDescriptor& desc );
+
+ void PrintMeshData( const MeshData& meshData );
+
+ Vector2 mNewAtlasSize;
+ Vector2 mNewBlockSize;
+ Toolkit::AtlasManager::AddFailPolicy mAddFailPolicy;
+ uint32_t mFilledPixel;
+};
+
+} // namespace Internal
+
+inline const Internal::AtlasManager& GetImplementation(const Toolkit::AtlasManager& manager)
+{
+ DALI_ASSERT_ALWAYS( manager && "AtlasManager handle is empty" );
+
+ const BaseObject& handle = manager.GetBaseObject();
+
+ return static_cast(handle);
+}
+
+inline Internal::AtlasManager& GetImplementation(Toolkit::AtlasManager& manager)
+{
+ DALI_ASSERT_ALWAYS( manager && "AtlasManager handle is empty" );
+
+ BaseObject& handle = manager.GetBaseObject();
+
+ return static_cast(handle);
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+
+ #endif // __DALI_TOOLKIT_ATLAS_MANAGER_IMPL_H__
\ No newline at end of file
diff --git a/dali-toolkit/internal/atlas-manager/atlas-manager.cpp b/dali-toolkit/internal/atlas-manager/atlas-manager.cpp
new file mode 100644
index 0000000..6d21245
--- /dev/null
+++ b/dali-toolkit/internal/atlas-manager/atlas-manager.cpp
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2015 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
+
+ // INTERNAL INCLUDES
+#include
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+AtlasManager::AtlasManager()
+{
+}
+
+AtlasManager::~AtlasManager()
+{
+}
+
+AtlasManager AtlasManager::New()
+{
+ Internal::AtlasManagerPtr internal = Internal::AtlasManager::New();
+ return AtlasManager(internal.Get());
+}
+
+AtlasManager::AtlasManager(Internal::AtlasManager *impl)
+ : BaseHandle(impl)
+{
+}
+
+AtlasManager::AtlasId AtlasManager::CreateAtlas( SizeType width,
+ SizeType height,
+ SizeType blockWidth,
+ SizeType blockHeight,
+ Pixel::Format pixelformat )
+{
+ return GetImplementation(*this).CreateAtlas( width, height, blockWidth, blockHeight, pixelformat );
+}
+
+void AtlasManager::SetAddPolicy( AddFailPolicy policy )
+{
+ GetImplementation(*this).SetAddPolicy( policy );
+}
+
+void AtlasManager::Add( const BufferImage& image,
+ AtlasManager::AtlasSlot& slot,
+ AtlasManager::AtlasId atlas )
+{
+ GetImplementation(*this).Add( image, slot, atlas );
+}
+
+bool AtlasManager::Remove( ImageId id )
+{
+ return GetImplementation(*this).Remove( id );
+}
+
+void AtlasManager::GenerateMeshData( ImageId id,
+ const Vector2& position,
+ MeshData& meshData)
+{
+ GetImplementation(*this).GenerateMeshData( id,
+ position,
+ meshData );
+}
+
+void AtlasManager::StitchMesh( MeshData& first,
+ const MeshData& second,
+ bool optimize )
+{
+ GetImplementation(*this).StitchMesh( first, second, optimize );
+}
+
+void AtlasManager::StitchMesh( const MeshData& first,
+ const MeshData& second,
+ MeshData& out,
+ bool optimize )
+{
+ GetImplementation(*this).StitchMesh( first, second, out, optimize );
+}
+
+Dali::Atlas AtlasManager::GetAtlasContainer( AtlasId atlas ) const
+{
+ return GetImplementation(*this).GetAtlasContainer( atlas );
+}
+
+AtlasManager::AtlasId AtlasManager::GetAtlas( ImageId id )
+{
+ return GetImplementation(*this).GetAtlas( id );
+}
+
+Vector2 AtlasManager::GetBlockSize( AtlasId atlas )
+{
+ return GetImplementation(*this).GetBlockSize( atlas );
+}
+
+Vector2 AtlasManager::GetAtlasSize( AtlasId atlas )
+{
+ return GetImplementation(*this).GetAtlasSize( atlas );
+}
+
+AtlasManager::SizeType AtlasManager::GetFreeBlocks( AtlasId atlas )
+{
+ return GetImplementation(*this).GetFreeBlocks( atlas );
+}
+
+void AtlasManager::SetNewAtlasSize( const Vector2& size,
+ const Vector2& blockSize )
+{
+ GetImplementation(*this).SetNewAtlasSize( size, blockSize );
+}
+
+AtlasManager::SizeType AtlasManager::GetAtlasCount() const
+{
+ return GetImplementation(*this).GetAtlasCount();
+}
+
+Pixel::Format AtlasManager::GetPixelFormat( AtlasId atlas )
+{
+ return GetImplementation(*this).GetPixelFormat( atlas );
+}
+
+void AtlasManager::GetMetrics( Metrics& metrics )
+{
+ return GetImplementation(*this).GetMetrics( metrics );
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/internal/atlas-manager/atlas-manager.h b/dali-toolkit/internal/atlas-manager/atlas-manager.h
new file mode 100644
index 0000000..9263ea4
--- /dev/null
+++ b/dali-toolkit/internal/atlas-manager/atlas-manager.h
@@ -0,0 +1,396 @@
+#ifndef __DALI_TOOLKIT_ATLAS_MANAGER_H__
+#define __DALI_TOOLKIT_ATLAS_MANAGER_H__
+
+/*
+ * Copyright (c) 2015 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
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal DALI_INTERNAL
+{
+
+class AtlasManager;
+
+} // namespace Internal
+
+/**
+ * AtlasManager
+ * ------------
+ *
+ * Creates and manages additions and removals of images from Texture Atlases
+ *
+ * The AtlasManager will match pixeltype and optimal block use to determine
+ * the appropriate atlas to upload an image to.
+ *
+ * A policy can be specified to determine the action the AtlasManager will carry
+ * out, should it not be able to add an image. This can return an error, or create
+ * a new atlas of pre-determined dimensions to accomodate the new image.
+ *
+ * Images are referenced by an ImageId once they have been successfully uploaded.
+ *
+ * Once an image has been successfully uploaded, Geometry can be generated by passing
+ * the ImageId to the GenerateMeshData method and geometry can be consolidated via
+ * the StitchMesh method.
+ *
+ * Images are reference counted once mesh data has been generated. An image is removed
+ * from the Atlas via the Remove( ImageId ) method. This unreferences the image and only
+ * physically removes it from the atlas once all references have been freed.
+ *
+ * If the AddPolicy is set to generate and error if an image can't be uploaded, then it
+ * is the applications responsibility to deal with the situation. An error will be indicated
+ * with an ImageId of 0.
+ *
+ * Examples using the AtlasManager
+ *
+ * Create or obtain the AtlasManager
+ * @code
+ *
+ * AtlasManager manager = AtlasManager::Get();
+ *
+ * @endcode
+ *
+ * Set the AtlasManager AddPolicy
+ *
+ * @code
+ *
+ * // Tell the atlas manager to create a new atlas, if it needs to
+ * manager.SetAddPolicy( FAIL_ON_ADD_CREATES );
+ *
+ * // Tell the atlas manager to return an error, if it can't add an image
+ * manager.SetAddPolicy( FAIL_ON_ADD_FAILS );
+ *
+ * @endcode
+ *
+ * Simple add and removal of BufferImage to and from an atlas
+ *
+ * @code
+ *
+ * // Structure returned by AtlasManager operations
+ * AtlasSlot slot;
+ *
+ * // Add image to an atlas ( will be created if none suitable exists )
+ * manager.Add( bitmapImage, slot );
+ *
+ * // slot.mImage returns the imageId for the bitmap, slot.mAtlas indicates the atlasId
+ * // that the image was added to. The imageId is used to communicate with the AtlasManager
+ * uint32_t imageId = slot.mImage;
+ * if ( !imageId )
+ * {
+ * // Addition has failed.....
+ * }
+ * ...
+ * ...
+ * // Done with image, so remove from atlas, if not being used elsewhere
+ * manager.Remove( imageId );
+ *
+ * @endcode
+ *
+ * Create a Specific Atlas for adding BufferImages to
+ *
+ * @code
+ *
+ * // Create an RGB888 atlas of 2048x2848, with a blocksize of 128x128
+ * uint32_t atlas = manager.CreateAtlas( 2048u, 2048u, 128u, 128u, Pixel::RGB888 );
+ *
+ * // Add an image to a preferred atlas ( note not specifying atlas may still result
+ * // in the bitmap being added to the atlas above )
+ * manager.Add( bitmapImage, slot, atlas );
+ *
+ * @endcode
+ *
+ * Create Geometry for a previously added image
+ *
+ * @code
+ *
+ * // Top left corner of geometry to be generated
+ * Vector2 position( 1.0f, 1.0f );
+ *
+ * // Geometry will end up here!
+ * MeshData meshData;
+ * manager.GenerateMeshData( imageId, position, meshData );
+ *
+ * @endcode
+ *
+ * Generating Geometry from multiple images in the same atlas
+ *
+ * @code
+ *
+ * MeshData firstMesh;
+ * MeshData secondMesh;
+ * manager.GenerateMeshData( imageid_1, position_1, firstMesh );
+ * manager.GenerateMeshData( imageid_2, position_2, secondMesh );
+ *
+ * // Combine the two meshes. Passing MESH_OPTIMIZE as an optional third parameter will remove duplicate vertices
+ * manager.StitchMesh( first, second );
+ *
+ * @endcode
+ *
+ */
+
+class AtlasManager : public BaseHandle
+{
+public:
+
+ typedef uint32_t SizeType;
+ typedef SizeType AtlasId;
+ typedef SizeType ImageId;
+ static const bool MESH_OPTIMIZE = true;
+
+ /**
+ * Metrics structures to describe Atlas Manager state
+ *
+ */
+ struct AtlasMetricsEntry
+ {
+ SizeType mWidth; // width of the atlas in pixels
+ SizeType mHeight;; // height of the atlas in pixels
+ SizeType mBlockWidth; // width of a block in pixels
+ SizeType mBlockHeight; // height of a block in pixels
+ SizeType mBlocksUsed; // number of blocks used in the atlas
+ SizeType mTotalBlocks; // total blocks used by atlas
+ Pixel::Format mPixelFormat; // pixel format of the atlas
+ };
+
+ struct Metrics
+ {
+ SizeType mAtlasCount; // number of atlases
+ SizeType mTextureMemoryUsed; // texture memory used by atlases
+ Dali::Vector< AtlasMetricsEntry > mAtlasMetrics; // container of atlas information
+ };
+
+ /**
+ * Create an AtlasManager handle; this can be initialised with AtlasManager::New()
+ * Calling member functions with an uninitialised handle is not allowed.
+ */
+ AtlasManager();
+
+ /**
+ * @brief Get new instance of AtlasManager object.
+ *
+ * @return A handle to the AtlasManager control.
+ */
+ static AtlasManager New();
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~AtlasManager();
+
+ /**
+ * Policy on failing to add an image
+ */
+ enum AddFailPolicy
+ {
+ FAIL_ON_ADD_FAILS,
+ FAIL_ON_ADD_CREATES
+ };
+
+ /**
+ * @brief Container to hold result of placing texture into atlas
+ */
+ struct AtlasSlot
+ {
+ ImageId mImageId; // Id of stored Image
+ AtlasId mAtlasId; // Id of Atlas containing this slot
+ };
+
+ typedef Dali::Vector< AtlasManager::AtlasSlot > slotContainer;
+
+ /**
+ * @brief Create a blank atlas of specific dimensions and pixel format with a certain block size
+ *
+ * @param[in] width desired atlas width in pixels
+ * @param[in] height desired atlas height in pixels
+ * @param[in] blockWidth block width to use in atlas in pixels
+ * @param[in] blockHeight block height to use in atlas in pixels
+ * @param[in] pixelformat format of a pixel in atlas
+ *
+ * @return atlas Id
+ */
+ AtlasId CreateAtlas( SizeType width,
+ SizeType height,
+ SizeType blockWidth,
+ SizeType blockHeight,
+ Pixel::Format pixelformat = Pixel::RGBA8888 );
+
+ /**
+ * @brief Set the policy on failure to add an image to an atlas
+ *
+ * @param policy policy to carry out if add fails
+ */
+ void SetAddPolicy( AddFailPolicy policy );
+
+ /**
+ * @brief Attempts to add an image to the most suitable atlas
+ *
+ * @details Add Policy may dictate that a new atlas is created if it can't presently be placed.
+ * If an add is made before an atlas is created under this policy,
+ * then a default size atlas will be created
+ *
+ * @param[in] image reference to a bitmapimage
+ * @param[out] slot result of add operation
+ * @param[in] atlas optional preferred atlas
+ */
+ void Add( const BufferImage& image,
+ AtlasSlot& slot,
+ AtlasId atlas = 0 );
+
+ /**
+ * @brief Remove previously added bitmapimage from atlas
+ *
+ * @param[in] id ImageId returned in the AtlasSlot from the add operation
+ *
+ * @return if true then image has been removed from the atlas
+ */
+ bool Remove( ImageId id );
+
+ /**
+ * @brief Generate mesh data for a previously added image
+ *
+ * @param[in] id Image Id returned in the AtlasSlot from the add operation
+ * @param[in] position position of the resulting mesh in model space
+ * @param[out] mesh Mesh Data Object to populate with mesh data
+ */
+ void GenerateMeshData( ImageId id,
+ const Vector2& position,
+ MeshData& mesh );
+
+ /**
+ * @brief Append second mesh to the first mesh
+ *
+ * @param[in] first First mesh
+ * @param[in] second Second mesh
+ * @param[in] optimize should we optimize vertex data
+ */
+ void StitchMesh( MeshData& first,
+ const MeshData& second,
+ bool optimize = false );
+
+ /**
+ * @brief Combine two meshes, outputting the result into a new mesh
+ *
+ * @param[in] first First mesh
+ * @param[in] second Second mesh
+ * @param[in] optimize should we optimize vertex data
+ * @param[out] out resulting mesh
+ */
+ void StitchMesh( const MeshData& first,
+ const MeshData& second,
+ MeshData& out,
+ bool optimize = false );
+
+ /**
+ * @brief Get the BufferImage containing an atlas
+ *
+ * @param[in] atlas AtlasId returned when atlas was created
+ *
+ * @return Atlas Handle
+ */
+ Dali::Atlas GetAtlasContainer( AtlasId atlas ) const;
+
+ /**
+ * @brief Get the Id of the atlas containing an image
+ *
+ * @param[in] id ImageId
+ *
+ * @return Atlas Id
+ */
+ AtlasId GetAtlas( ImageId id );
+
+ /**
+ * @brief Get the size of the blocks used in an atlas
+ *
+ * @param[in] atlas AtlasId
+ *
+ * @return width and height of the blocks used
+ */
+ Vector2 GetBlockSize( AtlasId atlas );
+
+ /**
+ * @brief Get the current size of an atlas
+ *
+ * @param[in] atlas AtlasId
+ *
+ * @return width and height of the atlas
+ */
+ Vector2 GetAtlasSize( AtlasId atlas );
+
+ /**
+ * @brief Get the number of blocks available in an atlas
+ *
+ * @param[in] atlas AtlasId
+ *
+ * @return Number of blocks free in this atlas
+ */
+ SizeType GetFreeBlocks( AtlasId atlas );
+
+ /**
+ * @brief Sets the pixel area of any new atlas and also the individual block size
+ *
+ * @param[in] size pixel area of atlas
+ *
+ * @param blockSize pixel area in atlas for a block
+ */
+ void SetNewAtlasSize( const Vector2& size,
+ const Vector2& blockSize );
+
+ /**
+ * @brief Get the number of atlases created
+ *
+ * @return number of atlases
+ */
+ SizeType GetAtlasCount() const;
+
+ /**
+ * @brief Get the pixel format used by an atlas
+ *
+ * @param[in] atlas AtlasId
+ *
+ * @return Pixel format used by this atlas
+ */
+ Pixel::Format GetPixelFormat( AtlasId atlas );
+
+ /**
+ * @brief Fill in a metrics structure showing current status of this Atlas Manager
+ *
+ * @param[in] metrics metrics structure to be filled
+ */
+ void GetMetrics( Metrics& metrics );
+
+private:
+
+ explicit DALI_INTERNAL AtlasManager(Internal::AtlasManager *impl);
+
+};
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_ATLAS_MANAGER_H__
\ No newline at end of file
diff --git a/dali-toolkit/internal/controls/buttons/button-impl.cpp b/dali-toolkit/internal/controls/buttons/button-impl.cpp
index 0d3fcd5..c42531f 100644
--- a/dali-toolkit/internal/controls/buttons/button-impl.cpp
+++ b/dali-toolkit/internal/controls/buttons/button-impl.cpp
@@ -26,7 +26,7 @@
#include
// INTERNAL INCLUDES
-#include
+#include
/**
* Button states and contents
@@ -615,9 +615,8 @@ float Button::GetAnimationTime() const
void Button::SetLabel( const std::string& label )
{
- Toolkit::TextView textView = Toolkit::TextView::New( label );
- textView.SetWidthExceedPolicy( Toolkit::TextView::ShrinkToFit ); // Make sure our text always fits inside the button
- SetLabel( textView );
+ Toolkit::TextLabel textLabel = Toolkit::TextLabel::New( label );
+ SetLabel( textLabel );
}
void Button::SetLabel( Actor label )
diff --git a/dali-toolkit/internal/controls/buttons/push-button-impl.cpp b/dali-toolkit/internal/controls/buttons/push-button-impl.cpp
index a2cb95d..24fa230 100644
--- a/dali-toolkit/internal/controls/buttons/push-button-impl.cpp
+++ b/dali-toolkit/internal/controls/buttons/push-button-impl.cpp
@@ -23,7 +23,7 @@
#include
// INTERNAL INCLUDES
-#include
+#include
namespace Dali
{
@@ -596,13 +596,13 @@ Vector3 PushButton::GetNaturalSize()
}
// If label, test against it's size
- Toolkit::TextView textView = Toolkit::TextView::DownCast( GetLabel() );
- if( textView )
+ Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( GetLabel() );
+ if( label )
{
- Vector3 textViewSize = textView.GetNaturalSize();
+ Vector3 labelSize = label.GetNaturalSize();
- size.width = std::max( size.width, textViewSize.width + TEXT_PADDING * 2.0f );
- size.height = std::max( size.height, textViewSize.height + TEXT_PADDING * 2.0f );
+ size.width = std::max( size.width, labelSize.width + TEXT_PADDING * 2.0f );
+ size.height = std::max( size.height, labelSize.height + TEXT_PADDING * 2.0f );
}
return size;
diff --git a/dali-toolkit/internal/controls/buttons/radio-button-impl.h b/dali-toolkit/internal/controls/buttons/radio-button-impl.h
index eec11ab..d525a43 100644
--- a/dali-toolkit/internal/controls/buttons/radio-button-impl.h
+++ b/dali-toolkit/internal/controls/buttons/radio-button-impl.h
@@ -23,7 +23,6 @@
#include
// INTERNAL INCLUDES
-#include
#include
#include
#include "button-impl.h"
diff --git a/dali-toolkit/internal/controls/navigation-frame/navigation-title-bar.cpp b/dali-toolkit/internal/controls/navigation-frame/navigation-title-bar.cpp
index 4e486ba..e8ce9e0 100644
--- a/dali-toolkit/internal/controls/navigation-frame/navigation-title-bar.cpp
+++ b/dali-toolkit/internal/controls/navigation-frame/navigation-title-bar.cpp
@@ -56,12 +56,8 @@ NavigationTitleBar::NavigationTitleBar(NavigationControl& naviControl,
mTitleIconLayout= Toolkit::TableView::New( 3,2 );
SetFixedSizes();
- mTitle = Toolkit::TextView::New();
- mTitle.SetTextAlignment( Toolkit::Alignment::HorizontalLeft );
- mTitle.SetWidthExceedPolicy(Toolkit::TextView::ShrinkToFit);
- mSubTitle = Toolkit::TextView::New();
- mSubTitle.SetTextAlignment( Toolkit::Alignment::HorizontalLeft );
- mSubTitle.SetWidthExceedPolicy(Toolkit::TextView::ShrinkToFit);
+ mTitle = Toolkit::TextLabel::New();
+ mSubTitle = Toolkit::TextLabel::New();
}
void NavigationTitleBar::Update( Toolkit::Page page )
@@ -113,8 +109,7 @@ void NavigationTitleBar::Update( Toolkit::Page page )
}
// add title and subtitle(if exist)
- mTitle.SetText( page.GetTitle() );
- mTitle.SetStyleToCurrentText(mCurrentStyle->titleTextStyle);
+ mTitle.SetProperty( Toolkit::TextLabel::Property::TEXT, page.GetTitle() );
if( page.GetSubTitle().empty() ) //display title
{
mTitleLayout.SetFixedHeight( 1,mCurrentStyle->titleHeightWithoutSubtitle - mCurrentStyle->subtitleHeight );
@@ -124,8 +119,7 @@ void NavigationTitleBar::Update( Toolkit::Page page )
{
mTitleLayout.SetFixedHeight( 1, mCurrentStyle->titleHeightWithSubtitle );
mTitleLayout.AddChild( mTitle, Toolkit::TableView::CellPosition(1,0) );
- mSubTitle.SetText( page.GetSubTitle() );
- mSubTitle.SetStyleToCurrentText(mCurrentStyle->subtitleTextStyle);
+ mSubTitle.SetProperty( Toolkit::TextLabel::Property::TEXT, page.GetSubTitle() );
mTitleLayout.AddChild( mSubTitle, Toolkit::TableView::CellPosition(2,0) );
}
diff --git a/dali-toolkit/internal/controls/navigation-frame/navigation-title-bar.h b/dali-toolkit/internal/controls/navigation-frame/navigation-title-bar.h
index 0377a2e..c8200ed 100644
--- a/dali-toolkit/internal/controls/navigation-frame/navigation-title-bar.h
+++ b/dali-toolkit/internal/controls/navigation-frame/navigation-title-bar.h
@@ -21,7 +21,7 @@
// INTERNAL INCLUDES
#include
#include
-#include
+#include
#include
#include
@@ -81,8 +81,8 @@ private:
Toolkit::TableView mTitleLayout;
Toolkit::TableView mTitleIconLayout;
- Toolkit::TextView mTitle;
- Toolkit::TextView mSubTitle;
+ Toolkit::TextLabel mTitle;
+ Toolkit::TextLabel mSubTitle;
};
diff --git a/dali-toolkit/internal/controls/navigation-frame/navigation-tool-bar.h b/dali-toolkit/internal/controls/navigation-frame/navigation-tool-bar.h
index ecb3d3b..80603d8 100644
--- a/dali-toolkit/internal/controls/navigation-frame/navigation-tool-bar.h
+++ b/dali-toolkit/internal/controls/navigation-frame/navigation-tool-bar.h
@@ -20,7 +20,6 @@
// INTERNAL INCLUDES
#include
-#include
#include
#include
#include
diff --git a/dali-toolkit/internal/controls/popup/popup-impl.cpp b/dali-toolkit/internal/controls/popup/popup-impl.cpp
index 69df006..42981a3 100755
--- a/dali-toolkit/internal/controls/popup/popup-impl.cpp
+++ b/dali-toolkit/internal/controls/popup/popup-impl.cpp
@@ -262,26 +262,16 @@ void Popup::SetButtonAreaImage( Actor image )
void Popup::SetTitle( const std::string& text )
{
- Toolkit::TextView titleActor = Toolkit::TextView::New();
- titleActor.SetName( "POPUP_TITLE" );
- 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 )
-{
// Replaces the current title actor.
if( mPopupLayout )
{
mPopupLayout.RemoveChildAt( Toolkit::TableView::CellPosition( 0, 0 ) );
}
- mTitle = titleActor;
+ mTitle = Toolkit::TextLabel::New( text );
+ mTitle.SetName( "POPUP_TITLE" );
+ mTitle.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, true );
+ mTitle.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
if( mPopupLayout )
{
@@ -294,9 +284,14 @@ void Popup::SetTitle( Toolkit::TextView titleActor )
RelayoutRequest();
}
-Toolkit::TextView Popup::GetTitle() const
+std::string Popup::GetTitle() const
{
- return mTitle;
+ if( mTitle )
+ {
+ return mTitle.GetProperty( Toolkit::TextLabel::Property::TEXT );
+ }
+
+ return std::string();
}
void Popup::CreateFooter()
@@ -747,7 +742,7 @@ Vector3 Popup::GetNaturalSize()
const float titleBuffer = 0.5f;
titleNaturalSize.width += titleBuffer;
- // As TextView GetNaturalSize does not take wrapping into account, limit the width
+ // As TextLabel GetNaturalSize does not take wrapping into account, limit the width
// to that of the stage
if( titleNaturalSize.width >= maxWidth)
{
diff --git a/dali-toolkit/internal/controls/popup/popup-impl.h b/dali-toolkit/internal/controls/popup/popup-impl.h
index ec85966..efdac51 100755
--- a/dali-toolkit/internal/controls/popup/popup-impl.h
+++ b/dali-toolkit/internal/controls/popup/popup-impl.h
@@ -28,6 +28,7 @@
#include
#include
#include
+#include
namespace Dali
{
@@ -84,14 +85,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;
+ std::string GetTitle() const;
/**
* @copydoc Toolkit::Popup::AddButton
@@ -325,7 +321,7 @@ private:
Actor mBackgroundImage; ///< Stores the background image.
Actor mButtonAreaImage; ///< Stores the button background image.
- Toolkit::TextView mTitle; ///< Stores the text title.
+ Toolkit::TextLabel 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/dali-toolkit/internal/controls/slider/slider-impl.cpp b/dali-toolkit/internal/controls/slider/slider-impl.cpp
index 0cd8783..f635c13 100755
--- a/dali-toolkit/internal/controls/slider/slider-impl.cpp
+++ b/dali-toolkit/internal/controls/slider/slider-impl.cpp
@@ -348,13 +348,13 @@ void Slider::DisplayValue( float value, bool raiseSignals )
}
}
- if( mHandleValueTextView )
+ if( mHandleValueTextLabel )
{
std::stringstream ss;
ss.precision( GetValuePrecision() );
ss << std::fixed << clampledValue;
- mHandleValueTextView.SetText( ss.str() );
+ mHandleValueTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, ss.str() );
}
}
@@ -523,13 +523,13 @@ ImageActor Slider::CreatePopupArrow()
return arrow;
}
-Toolkit::TextView Slider::CreatePopupText()
+Toolkit::TextLabel Slider::CreatePopupText()
{
- Toolkit::TextView textView = Toolkit::TextView::New();
- textView.SetParentOrigin( ParentOrigin::CENTER );
- textView.SetAnchorPoint( AnchorPoint::CENTER );
- textView.SetZ( VALUE_DISPLAY_TEXT_Z );
- return textView;
+ Toolkit::TextLabel textLabel = Toolkit::TextLabel::New();
+ textLabel.SetParentOrigin( ParentOrigin::CENTER );
+ textLabel.SetAnchorPoint( AnchorPoint::CENTER );
+ textLabel.SetZ( VALUE_DISPLAY_TEXT_Z );
+ return textLabel;
}
ImageActor Slider::CreatePopup()
@@ -539,9 +539,6 @@ ImageActor Slider::CreatePopup()
popup.SetParentOrigin( ParentOrigin::TOP_CENTER );
popup.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
- mValueTextView = CreatePopupText();
- popup.Add( mValueTextView );
-
return popup;
}
@@ -574,24 +571,19 @@ void Slider::ResizeHandleRegion( const Vector2& region )
void Slider::CreateHandleValueDisplay()
{
- if( mHandle && !mHandleValueTextView )
+ if( mHandle && !mHandleValueTextLabel )
{
- mHandleValueTextView = Toolkit::TextView::New();
- mHandleValueTextView.SetParentOrigin( ParentOrigin::CENTER );
- mHandleValueTextView.SetAnchorPoint( AnchorPoint::CENTER );
- mHandleValueTextView.SetSize( GetHandleRegion() );
- mHandleValueTextView.SetZ( HANDLE_VALUE_DISPLAY_TEXT_Z );
- mHandle.Add( mHandleValueTextView );
+ mHandleValueTextLabel = Toolkit::TextLabel::New();
+ mHandleValueTextLabel.SetParentOrigin( ParentOrigin::CENTER );
+ mHandleValueTextLabel.SetAnchorPoint( AnchorPoint::CENTER );
+ mHandleValueTextLabel.SetDrawMode( DrawMode::OVERLAY );
+ mHandle.Add( mHandleValueTextLabel );
}
}
void Slider::DestroyHandleValueDisplay()
{
- if(mHandleValueTextView)
- {
- mHandleValueTextView.Unparent();
- mHandleValueTextView.Reset();
- }
+ UnparentAndReset(mHandleValueTextLabel);
}
void Slider::SetPopupTextColor( const Vector4& color )
@@ -1018,26 +1010,15 @@ bool Slider::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tr
void Slider::DisplayPopup( float value )
{
// Value displayDoConnectSignal
- if( mValueTextView )
+ if( mValueTextLabel )
{
std::stringstream ss;
ss.precision( GetValuePrecision() );
ss << std::fixed << value;
- mValueTextView.SetText( ss.str() );
- TextStyle style;
- style.SetTextColor( GetPopupTextColor() );
- mValueTextView.SetStyleToCurrentText( style, TextStyle::COLOR);
+ mValueTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, ss.str() );
if( mValueDisplay )
{
- Font font = Font::New();
- float popupWidth = font.MeasureText( ss.str() ).x + VALUE_POPUP_MARGIN * 2.0f;
- if( popupWidth < VALUE_POPUP_MIN_WIDTH )
- {
- popupWidth = VALUE_POPUP_MIN_WIDTH;
- }
-
- mPopup.SetSize( popupWidth, VALUE_POPUP_HEIGHT );
mValueDisplay.SetVisible( true );
mValueTimer.SetInterval( VALUE_VIEW_SHOW_DURATION );
diff --git a/dali-toolkit/internal/controls/slider/slider-impl.h b/dali-toolkit/internal/controls/slider/slider-impl.h
index 8fee62e..a8003c7 100755
--- a/dali-toolkit/internal/controls/slider/slider-impl.h
+++ b/dali-toolkit/internal/controls/slider/slider-impl.h
@@ -25,7 +25,7 @@
// INTERNAL INCLUDES
#include
#include
-#include
+#include
namespace Dali
{
@@ -434,7 +434,7 @@ private:
*
* @return The textview created for the popup
*/
- Toolkit::TextView CreatePopupText();
+ Toolkit::TextLabel CreatePopupText();
/**
* Create the value display for the slider
@@ -687,8 +687,8 @@ private:
ImageActor mPopup; ///< Popup backing
ImageActor mPopupArrow; ///< Popup arrow backing
- Toolkit::TextView mValueTextView; //< The text value in popup
- Toolkit::TextView mHandleValueTextView; ///< The text value on handle
+ Toolkit::TextLabel mValueTextLabel; //< The text value in popup
+ Toolkit::TextLabel mHandleValueTextLabel; ///< The text value on handle
Vector2 mHandleLastTouchPoint; ///< The last touch point for the handle
Timer mValueTimer; ///< Timer used to hide value view
diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
new file mode 100644
index 0000000..f189207
--- /dev/null
+++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
@@ -0,0 +1,646 @@
+/*
+ * Copyright (c) 2015 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
+
+// INTERNAL INCLUDES
+#include
+#include
+#include
+#include
+
+using namespace Dali::Toolkit::Text;
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace
+{
+ const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
+}
+
+namespace
+{
+
+const Scripting::StringEnum< Toolkit::Text::LayoutEngine::HorizontalAlignment > HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
+{
+ { "BEGIN", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_BEGIN },
+ { "CENTER", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_CENTER },
+ { "END", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_END },
+};
+const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] );
+
+const Scripting::StringEnum< Toolkit::Text::LayoutEngine::VerticalAlignment > VERTICAL_ALIGNMENT_STRING_TABLE[] =
+{
+ { "TOP", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_TOP },
+ { "CENTER", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_CENTER },
+ { "BOTTOM", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_BOTTOM },
+};
+const unsigned int VERTICAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( VERTICAL_ALIGNMENT_STRING_TABLE ) / sizeof( VERTICAL_ALIGNMENT_STRING_TABLE[0] );
+
+// Type registration
+BaseHandle Create()
+{
+ return Toolkit::TextField::New();
+}
+
+// Setup properties, signals and actions using the type-registry.
+DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TextField, Toolkit::Control, Create );
+
+DALI_PROPERTY_REGISTRATION( TextField, "rendering-backend", INTEGER, RENDERING_BACKEND )
+DALI_PROPERTY_REGISTRATION( TextField, "placeholder-text", STRING, PLACEHOLDER_TEXT )
+DALI_PROPERTY_REGISTRATION( TextField, "text", STRING, TEXT )
+DALI_PROPERTY_REGISTRATION( TextField, "font-family", STRING, FONT_FAMILY )
+DALI_PROPERTY_REGISTRATION( TextField, "font-style", STRING, FONT_STYLE )
+DALI_PROPERTY_REGISTRATION( TextField, "point-size", FLOAT, POINT_SIZE )
+DALI_PROPERTY_REGISTRATION( TextField, "exceed-policy", INTEGER, EXCEED_POLICY )
+DALI_PROPERTY_REGISTRATION( TextField, "primary-cursor-color", VECTOR4, PRIMARY_CURSOR_COLOR )
+DALI_PROPERTY_REGISTRATION( TextField, "secondary-cursor-color", VECTOR4, SECONDARY_CURSOR_COLOR )
+DALI_PROPERTY_REGISTRATION( TextField, "enable-cursor-blink", BOOLEAN, ENABLE_CURSOR_BLINK )
+DALI_PROPERTY_REGISTRATION( TextField, "cursor-blink-interval", FLOAT, CURSOR_BLINK_INTERVAL )
+DALI_PROPERTY_REGISTRATION( TextField, "cursor-blink-duration", FLOAT, CURSOR_BLINK_DURATION )
+DALI_PROPERTY_REGISTRATION( TextField, "grab-handle-image", STRING, GRAB_HANDLE_IMAGE )
+DALI_PROPERTY_REGISTRATION( TextField, "decoration-bounding-box", RECTANGLE, DECORATION_BOUNDING_BOX )
+DALI_PROPERTY_REGISTRATION( TextField, "horizontal-alignment", STRING, HORIZONTAL_ALIGNMENT )
+DALI_PROPERTY_REGISTRATION( TextField, "vertical-alignment", STRING, VERTICAL_ALIGNMENT )
+DALI_TYPE_REGISTRATION_END()
+
+} // namespace
+
+Toolkit::TextField TextField::New()
+{
+ // Create the implementation, temporarily owned by this handle on stack
+ IntrusivePtr< TextField > impl = new TextField();
+
+ // Pass ownership to CustomActor handle
+ Toolkit::TextField handle( *impl );
+
+ // Second-phase init of the implementation
+ // This can only be done after the CustomActor connection has been made...
+ impl->Initialize();
+
+ return handle;
+}
+
+void TextField::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
+{
+ Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) );
+
+ if( textField )
+ {
+ TextField& impl( GetImpl( textField ) );
+
+ switch( index )
+ {
+ case Toolkit::TextField::Property::RENDERING_BACKEND:
+ {
+ int backend = value.Get< int >();
+
+ if( impl.mRenderingBackend != backend )
+ {
+ impl.mRenderingBackend = backend;
+ impl.mRenderer.Reset();
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
+ {
+ if( impl.mController )
+ {
+ //impl.mController->SetPlaceholderText( value.Get< std::string >() ); TODO
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::TEXT:
+ {
+ if( impl.mController )
+ {
+ impl.mController->SetText( value.Get< std::string >() );
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::FONT_FAMILY:
+ {
+ if( impl.mController )
+ {
+ std::string fontFamily = value.Get< std::string >();
+
+ if( impl.mController->GetDefaultFontFamily() != fontFamily )
+ {
+ impl.mController->SetDefaultFontFamily( fontFamily );
+ impl.RequestTextRelayout();
+ }
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::FONT_STYLE:
+ {
+ if( impl.mController )
+ {
+ std::string fontStyle = value.Get< std::string >();
+
+ if( impl.mController->GetDefaultFontStyle() != fontStyle )
+ {
+ impl.mController->SetDefaultFontStyle( fontStyle );
+ impl.RequestTextRelayout();
+ }
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::POINT_SIZE:
+ {
+ if( impl.mController )
+ {
+ float pointSize = value.Get< float >();
+
+ if( impl.mController->GetDefaultPointSize() != pointSize /*TODO - epsilon*/ )
+ {
+ impl.mController->SetDefaultPointSize( pointSize );
+ impl.RequestTextRelayout();
+ }
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::EXCEED_POLICY:
+ {
+ impl.mExceedPolicy = value.Get< int >();
+ break;
+ }
+ case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
+ {
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetColor( PRIMARY_CURSOR, value.Get< Vector4 >() );
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
+ {
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetColor( SECONDARY_CURSOR, value.Get< Vector4 >() );
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
+ {
+ if( impl.mController )
+ {
+ impl.mController->SetEnableCursorBlink( value.Get< bool >() );
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
+ {
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetCursorBlinkInterval( value.Get< float >() );
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
+ {
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetCursorBlinkDuration( value.Get< float >() );
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
+ {
+ ResourceImage image = ResourceImage::New( value.Get< std::string >() );
+
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetGrabHandleImage( image );
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
+ {
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetBoundingBox( value.Get< Rect >() );
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
+ {
+ LayoutEngine& engine = impl.mController->GetLayoutEngine();
+ const LayoutEngine::HorizontalAlignment alignment = Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::HorizontalAlignment >( value.Get< std::string >().c_str(),
+ HORIZONTAL_ALIGNMENT_STRING_TABLE,
+ HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
+
+ if( engine.GetHorizontalAlignment() != alignment )
+ {
+ engine.SetHorizontalAlignment( alignment );
+ impl.RequestTextRelayout();
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
+ {
+ LayoutEngine& engine = impl.mController->GetLayoutEngine();
+ const LayoutEngine::VerticalAlignment alignment = Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::VerticalAlignment >( value.Get< std::string >().c_str(),
+ VERTICAL_ALIGNMENT_STRING_TABLE,
+ VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
+
+ if( engine.GetVerticalAlignment() != alignment )
+ {
+ engine.SetVerticalAlignment( alignment );
+ impl.RequestTextRelayout();
+ }
+ break;
+ }
+ } // switch
+ } // textfield
+}
+
+Property::Value TextField::GetProperty( BaseObject* object, Property::Index index )
+{
+ Property::Value value;
+
+ Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) );
+
+ if( textField )
+ {
+ TextField& impl( GetImpl( textField ) );
+
+ switch( index )
+ {
+ case Toolkit::TextField::Property::RENDERING_BACKEND:
+ {
+ value = impl.mRenderingBackend;
+ break;
+ }
+ case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
+ {
+ if( impl.mController )
+ {
+ std::string text;
+ impl.mController->GetPlaceholderText( text );
+ value = text;
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::TEXT:
+ {
+ if( impl.mController )
+ {
+ std::string text;
+ impl.mController->GetText( text );
+ value = text;
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::EXCEED_POLICY:
+ {
+ value = impl.mExceedPolicy;
+ break;
+ }
+ case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
+ {
+ if( impl.mDecorator )
+ {
+ value = impl.mDecorator->GetColor( PRIMARY_CURSOR );
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
+ {
+ if( impl.mDecorator )
+ {
+ value = impl.mDecorator->GetColor( SECONDARY_CURSOR );
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
+ {
+ value = impl.mController->GetEnableCursorBlink();
+ break;
+ }
+ case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
+ {
+ if( impl.mDecorator )
+ {
+ value = impl.mDecorator->GetCursorBlinkInterval();
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
+ {
+ if( impl.mDecorator )
+ {
+ value = impl.mDecorator->GetCursorBlinkDuration();
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
+ {
+ if( impl.mDecorator )
+ {
+ value = impl.mDecorator->GetBoundingBox();
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
+ {
+ if( impl.mController )
+ {
+ value = std::string( Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetLayoutEngine().GetHorizontalAlignment(),
+ HORIZONTAL_ALIGNMENT_STRING_TABLE,
+ HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT ) );
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
+ {
+ if( impl.mController )
+ {
+ value = std::string( Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( impl.mController->GetLayoutEngine().GetVerticalAlignment(),
+ VERTICAL_ALIGNMENT_STRING_TABLE,
+ VERTICAL_ALIGNMENT_STRING_TABLE_COUNT ) );
+ }
+ break;
+ }
+ } //switch
+ }
+
+ return value;
+}
+
+void TextField::OnInitialize()
+{
+ Actor self = Self();
+
+ mController = Text::Controller::New( *this );
+
+ mDecorator = Text::Decorator::New( *this, *mController );
+
+ mController->GetLayoutEngine().SetLayout( LayoutEngine::SINGLE_LINE_BOX );
+
+ mController->EnableTextInput( mDecorator );
+
+ // Forward input events to controller
+ EnableGestureDetection(Gesture::Tap);
+ GetTapGestureDetector().SetMaximumTapsRequired( 2 );
+ EnableGestureDetection(Gesture::Pan);
+
+ // Set BoundingBox to stage size if not already set.
+ if ( mDecorator->GetBoundingBox().IsEmpty() )
+ {
+ Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
+ mDecorator->SetBoundingBox( Rect( 0.0f, 0.0f, stageSize.width, stageSize.height ) );
+ }
+
+ // Fill-parent area by default
+ self.SetResizePolicy( FILL_TO_PARENT, WIDTH );
+ self.SetResizePolicy( FILL_TO_PARENT, HEIGHT );
+}
+
+void TextField::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change )
+{
+ GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+}
+
+Vector3 TextField::GetNaturalSize()
+{
+ return mController->GetNaturalSize();
+}
+
+float TextField::GetHeightForWidth( float width )
+{
+ return mController->GetHeightForWidth( width );
+}
+
+void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container )
+{
+ if( mController->Relayout( size ) ||
+ !mRenderer )
+ {
+ const Vector2& scrollPosition = mController->GetScrollPosition();
+ const Vector2& alignmentOffset = mController->GetAlignmentOffset();
+
+ Vector2 offset = scrollPosition + alignmentOffset;
+
+ if( mDecorator )
+ {
+ mDecorator->Relayout( size, offset );
+ }
+
+ if( !mRenderer )
+ {
+ mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
+ }
+
+ RenderableActor renderableActor;
+ if( mRenderer )
+ {
+ renderableActor = mRenderer->Render( mController->GetView() );
+ }
+
+ EnableClipping( (Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy), size );
+
+ if( renderableActor != mRenderableActor )
+ {
+ UnparentAndReset( mRenderableActor );
+ mRenderableActor = renderableActor;
+ }
+
+ if( mRenderableActor )
+ {
+ mRenderableActor.SetPosition( offset.x, offset.y );
+
+ // Make sure the actor is parented correctly with/without clipping
+ if( mClipper )
+ {
+ mClipper->GetRootActor().Add( mRenderableActor );
+ }
+ else
+ {
+ Self().Add( mRenderableActor );
+ }
+ }
+ }
+}
+
+void TextField::OnKeyInputFocusGained()
+{
+ VirtualKeyboard::StatusChangedSignal().Connect( this, &TextField::KeyboardStatusChanged );
+
+ ImfManager imfManager = ImfManager::Get();
+
+ if ( imfManager )
+ {
+ imfManager.EventReceivedSignal().Connect( this, &TextField::OnImfEvent );
+
+ // 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 );
+ }
+
+ mController->KeyboardFocusGainEvent();
+}
+
+void TextField::OnKeyInputFocusLost()
+{
+ VirtualKeyboard::StatusChangedSignal().Disconnect( this, &TextField::KeyboardStatusChanged );
+
+ 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, &TextField::OnImfEvent );
+ }
+
+ mController->KeyboardFocusLostEvent();
+}
+
+void TextField::OnTap( const TapGesture& gesture )
+{
+ // Show the keyboard if it was hidden.
+ if (!VirtualKeyboard::IsVisible())
+ {
+ VirtualKeyboard::Show();
+ }
+
+ SetKeyInputFocus();
+
+ mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x, gesture.localPoint.y );
+}
+
+void TextField::OnPan( const PanGesture& gesture )
+{
+ mController->PanEvent( gesture.state, gesture.displacement );
+}
+
+bool TextField::OnKeyEvent( const KeyEvent& event )
+{
+ if( Dali::DALI_KEY_ESCAPE == event.keyCode )
+ {
+ ClearKeyInputFocus();
+ }
+
+ return mController->KeyEvent( event );
+}
+
+ImfManager::ImfCallbackData TextField::OnImfEvent( Dali::ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
+{
+ switch ( imfEvent.eventName )
+ {
+ case ImfManager::COMMIT:
+ {
+ KeyEvent event( "", imfEvent.predictiveString, 0, 0, 0, KeyEvent::Down );
+ mController->KeyEvent( event );
+ break;
+ }
+ case ImfManager::PREEDIT: // fall through
+ case ImfManager::DELETESURROUNDING:
+ case ImfManager::GETSURROUNDING:
+ case ImfManager::VOID:
+ {
+ // do nothing
+ }
+ } // end switch
+
+ return ImfManager::ImfCallbackData();
+}
+
+void TextField::RequestTextRelayout()
+{
+ RelayoutRequest();
+}
+
+void TextField::EnableClipping( bool clipping, const Vector2& size )
+{
+ if( clipping )
+ {
+ // Not worth to created clip actor if width or height is equal to zero.
+ if( size.width > Math::MACHINE_EPSILON_1000 && size.height > Math::MACHINE_EPSILON_1000 )
+ {
+ if( !mClipper )
+ {
+ Actor self = Self();
+
+ mClipper = Clipper::New( size );
+ self.Add( mClipper->GetRootActor() );
+ self.Add( mClipper->GetImageActor() );
+ }
+ else if ( mClipper )
+ {
+ mClipper->Refresh( size );
+ }
+ }
+ }
+ else
+ {
+ // Note - this will automatically remove the root & image actors
+ mClipper.Reset();
+ }
+}
+
+void TextField::KeyboardStatusChanged(bool keyboardShown)
+{
+ // Just hide the grab handle when keyboard is hidden.
+ if (!keyboardShown )
+ {
+ mController->KeyboardFocusLostEvent();
+ }
+}
+
+TextField::TextField()
+: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
+ mRenderingBackend( DEFAULT_RENDERING_BACKEND ),
+ mExceedPolicy( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP )
+{
+}
+
+TextField::~TextField()
+{
+ mClipper.Reset();
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.h b/dali-toolkit/internal/controls/text-controls/text-field-impl.h
new file mode 100644
index 0000000..5428275
--- /dev/null
+++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.h
@@ -0,0 +1,212 @@
+#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H__
+#define __DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H__
+
+/*
+ * Copyright (c) 2015 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
+
+// INTERNAL INCLUDES
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+/**
+ * @brief A control which renders a short text string.
+ */
+class TextField : public Control, public Text::ControlInterface
+{
+public:
+
+ /**
+ * @copydoc Dali::Toollkit::TextField::New()
+ */
+ static Toolkit::TextField New();
+
+ // Properties
+
+ /**
+ * @brief 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 );
+
+ /**
+ * @brief 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 index );
+
+private: // From Control
+
+ /**
+ * @copydoc Control::OnInitialize()
+ */
+ virtual void OnInitialize();
+
+ /**
+ * @copydoc Control::OnStyleChange()
+ */
+ virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change );
+
+ /**
+ * @copydoc Control::GetNaturalSize()
+ */
+ virtual Vector3 GetNaturalSize();
+
+ /**
+ * @copydoc Control::GetHeightForWidth()
+ */
+ virtual float GetHeightForWidth( float width );
+
+ /**
+ * @copydoc Control::OnInitialize()
+ */
+ virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
+
+ /**
+ * @copydoc Control::OnKeyInputFocusGained()
+ */
+ virtual void OnKeyInputFocusGained();
+
+ /**
+ * @copydoc Control::OnKeyInputFocusLost()
+ */
+ virtual void OnKeyInputFocusLost();
+
+ /**
+ * @copydoc Control::OnTap()
+ */
+ virtual void OnTap( const TapGesture& tap );
+
+ /**
+ * @copydoc Control::OnPan()
+ */
+ virtual void OnPan( const PanGesture& gesture );
+
+ /**
+ * @copydoc Dali::CustomActorImpl::OnKeyEvent(const KeyEvent&)
+ */
+ virtual bool OnKeyEvent(const KeyEvent& event);
+
+ /**
+ * @brief Event received from IMF manager
+ *
+ * @param[in] imfManager The IMF manager.
+ * @param[in] imfEvent The event received.
+ * @return A data struture indicating if update is needed, cursor position and current text.
+ */
+ ImfManager::ImfCallbackData OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent );
+
+ /**
+ * @copydoc Text::ControlInterface::RequestTextRelayout()
+ */
+ virtual void RequestTextRelayout();
+
+private: // Implementation
+
+ /**
+ * @brief Enable or disable clipping.
+ *
+ * @param[in] clipping True if clipping should be enabled.
+ * @param[in] size The area to clip within.
+ */
+ void EnableClipping( bool clipping, const Vector2& size );
+
+ /**
+ * @brief Callback when keyboard is shown/hidden.
+ *
+ * @param[in] keyboardShown True if keyboard is shown.
+ */
+ void KeyboardStatusChanged( bool keyboardShown );
+
+ /**
+ * Construct a new TextField.
+ */
+ TextField();
+
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~TextField();
+
+private:
+
+ // Undefined copy constructor and assignment operators
+ TextField(const TextField&);
+ TextField& operator=(const TextField& rhs);
+
+private: // Data
+
+ Text::ControllerPtr mController;
+ Text::RendererPtr mRenderer;
+ Text::DecoratorPtr mDecorator;
+ Text::ClipperPtr mClipper; ///< For EXCEED_POLICY_CLIP
+
+ RenderableActor mRenderableActor;
+
+ int mRenderingBackend;
+ int mExceedPolicy;
+};
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+
+inline Toolkit::Internal::TextField& GetImpl( Toolkit::TextField& textField )
+{
+ DALI_ASSERT_ALWAYS(textField);
+
+ Dali::RefObject& handle = textField.GetImplementation();
+
+ return static_cast(handle);
+}
+
+inline const Toolkit::Internal::TextField& GetImpl( const Toolkit::TextField& textField )
+{
+ DALI_ASSERT_ALWAYS(textField);
+
+ const Dali::RefObject& handle = textField.GetImplementation();
+
+ return static_cast(handle);
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H__
diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
new file mode 100644
index 0000000..73f40e9
--- /dev/null
+++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
@@ -0,0 +1,474 @@
+/*
+ * Copyright (c) 2015 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
+
+// INTERNAL INCLUDES
+#include
+#include
+#include
+#include
+
+using Dali::Toolkit::Text::LayoutEngine;
+using Dali::Toolkit::Text::Backend;
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace
+{
+ const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
+}
+
+namespace
+{
+
+const Scripting::StringEnum< Toolkit::Text::LayoutEngine::HorizontalAlignment > HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
+{
+ { "BEGIN", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_BEGIN },
+ { "CENTER", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_CENTER },
+ { "END", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_END },
+};
+const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] );
+
+const Scripting::StringEnum< Toolkit::Text::LayoutEngine::VerticalAlignment > VERTICAL_ALIGNMENT_STRING_TABLE[] =
+{
+ { "TOP", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_TOP },
+ { "CENTER", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_CENTER },
+ { "BOTTOM", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_BOTTOM },
+};
+const unsigned int VERTICAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( VERTICAL_ALIGNMENT_STRING_TABLE ) / sizeof( VERTICAL_ALIGNMENT_STRING_TABLE[0] );
+
+// Type registration
+BaseHandle Create()
+{
+ return Toolkit::TextLabel::New();
+}
+
+// Setup properties, signals and actions using the type-registry.
+DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TextLabel, Toolkit::Control, Create );
+
+DALI_PROPERTY_REGISTRATION( TextLabel, "rendering-backend", INTEGER, RENDERING_BACKEND )
+DALI_PROPERTY_REGISTRATION( TextLabel, "text", STRING, TEXT )
+DALI_PROPERTY_REGISTRATION( TextLabel, "font-family", STRING, FONT_FAMILY )
+DALI_PROPERTY_REGISTRATION( TextLabel, "font-style", STRING, FONT_STYLE )
+DALI_PROPERTY_REGISTRATION( TextLabel, "point-size", FLOAT, POINT_SIZE )
+DALI_PROPERTY_REGISTRATION( TextLabel, "multi-line", BOOLEAN, MULTI_LINE )
+DALI_PROPERTY_REGISTRATION( TextLabel, "horizontal-alignment", STRING, HORIZONTAL_ALIGNMENT )
+DALI_PROPERTY_REGISTRATION( TextLabel, "vertical-alignment", STRING, VERTICAL_ALIGNMENT )
+DALI_PROPERTY_REGISTRATION( TextLabel, "text-color", VECTOR4, TEXT_COLOR )
+DALI_PROPERTY_REGISTRATION( TextLabel, "shadow-offset", VECTOR2, SHADOW_OFFSET )
+DALI_PROPERTY_REGISTRATION( TextLabel, "shadow-color", VECTOR4, SHADOW_COLOR )
+DALI_PROPERTY_REGISTRATION( TextLabel, "underline-enabled", BOOLEAN, UNDERLINE_ENABLED )
+DALI_PROPERTY_REGISTRATION( TextLabel, "underline-color", VECTOR4, UNDERLINE_COLOR )
+DALI_TYPE_REGISTRATION_END()
+
+} // namespace
+
+Toolkit::TextLabel TextLabel::New()
+{
+ // Create the implementation, temporarily owned by this handle on stack
+ IntrusivePtr< TextLabel > impl = new TextLabel();
+
+ // Pass ownership to CustomActor handle
+ Toolkit::TextLabel handle( *impl );
+
+ // Second-phase init of the implementation
+ // This can only be done after the CustomActor connection has been made...
+ impl->Initialize();
+
+ return handle;
+}
+
+void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
+{
+ Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( Dali::BaseHandle( object ) );
+
+ if( label )
+ {
+ TextLabel& impl( GetImpl( label ) );
+ switch( index )
+ {
+ case Toolkit::TextLabel::Property::RENDERING_BACKEND:
+ {
+ int backend = value.Get< int >();
+
+ if( impl.mRenderingBackend != backend )
+ {
+ impl.mRenderingBackend = backend;
+ impl.mRenderer.Reset();
+ impl.RequestTextRelayout();
+ }
+ break;
+ }
+ case Toolkit::TextLabel::Property::TEXT:
+ {
+ if( impl.mController )
+ {
+ impl.mController->SetText( value.Get< std::string >() );
+ impl.RequestTextRelayout();
+ }
+ break;
+ }
+ case Toolkit::TextLabel::Property::FONT_FAMILY:
+ {
+ if( impl.mController )
+ {
+ std::string fontFamily = value.Get< std::string >();
+
+ if( impl.mController->GetDefaultFontFamily() != fontFamily )
+ {
+ impl.mController->SetDefaultFontFamily( fontFamily );
+ impl.RequestTextRelayout();
+ }
+ }
+ break;
+ }
+ case Toolkit::TextLabel::Property::FONT_STYLE:
+ {
+ if( impl.mController )
+ {
+ std::string fontStyle = value.Get< std::string >();
+
+ if( impl.mController->GetDefaultFontStyle() != fontStyle )
+ {
+ impl.mController->SetDefaultFontStyle( fontStyle );
+ impl.RequestTextRelayout();
+ }
+ }
+ break;
+ }
+ case Toolkit::TextLabel::Property::POINT_SIZE:
+ {
+ if( impl.mController )
+ {
+ float pointSize = value.Get< float >();
+
+ if( impl.mController->GetDefaultPointSize() != pointSize /*TODO - epsilon*/ )
+ {
+ impl.mController->SetDefaultPointSize( pointSize );
+ impl.RequestTextRelayout();
+ }
+ }
+ break;
+ }
+ case Toolkit::TextLabel::Property::MULTI_LINE:
+ {
+ if( impl.mController )
+ {
+ LayoutEngine& engine = impl.mController->GetLayoutEngine();
+ LayoutEngine::Layout layout = value.Get< bool >() ? LayoutEngine::MULTI_LINE_BOX : LayoutEngine::SINGLE_LINE_BOX;
+
+ if( engine.GetLayout() != layout )
+ {
+ engine.SetLayout( layout );
+ impl.RequestTextRelayout();
+ }
+ }
+ break;
+ }
+ case Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT:
+ {
+ LayoutEngine& engine = impl.mController->GetLayoutEngine();
+ const LayoutEngine::HorizontalAlignment alignment = Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::HorizontalAlignment >( value.Get< std::string >().c_str(),
+ HORIZONTAL_ALIGNMENT_STRING_TABLE,
+ HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
+
+ if( engine.GetHorizontalAlignment() != alignment )
+ {
+ engine.SetHorizontalAlignment( alignment );
+ impl.RequestTextRelayout();
+ }
+ break;
+ }
+ case Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT:
+ {
+ LayoutEngine& engine = impl.mController->GetLayoutEngine();
+ const LayoutEngine::VerticalAlignment alignment = Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::VerticalAlignment >( value.Get< std::string >().c_str(),
+ VERTICAL_ALIGNMENT_STRING_TABLE,
+ VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
+
+ if( engine.GetVerticalAlignment() != alignment )
+ {
+ engine.SetVerticalAlignment( alignment );
+ impl.RequestTextRelayout();
+ }
+ break;
+ }
+
+ case Toolkit::TextLabel::Property::TEXT_COLOR:
+ {
+ if ( impl.mController )
+ {
+ Vector4 textColor = value.Get< Vector4 >();
+ if ( impl.mController->GetTextColor() != textColor )
+ {
+ impl.mController->SetTextColor( textColor );
+ impl.RequestTextRelayout();
+ }
+ }
+ break;
+ }
+
+ case Toolkit::TextLabel::Property::SHADOW_OFFSET:
+ {
+ if( impl.mController )
+ {
+ Vector2 shadowOffset = value.Get< Vector2 >();
+ if ( impl.mController->GetShadowOffset() != shadowOffset )
+ {
+ impl.mController->SetShadowOffset( shadowOffset );
+ impl.RequestTextRelayout();
+ }
+ }
+ break;
+ }
+ case Toolkit::TextLabel::Property::SHADOW_COLOR:
+ {
+ if( impl.mController )
+ {
+ Vector4 shadowColor = value.Get< Vector4 >();
+ if ( impl.mController->GetShadowColor() != shadowColor )
+ {
+ impl.mController->SetShadowColor( shadowColor );
+ impl.RequestTextRelayout();
+ }
+ }
+ break;
+ }
+ case Toolkit::TextLabel::Property::UNDERLINE_COLOR:
+ {
+ if( impl.mController )
+ {
+ Vector4 color = value.Get< Vector4 >();
+ if ( impl.mController->GetUnderlineColor() != color )
+ {
+ impl.mController->SetUnderlineColor( color );
+ impl.RequestTextRelayout();
+ }
+ }
+ break;
+ }
+ case Toolkit::TextLabel::Property::UNDERLINE_ENABLED:
+ {
+ if( impl.mController )
+ {
+ bool enabled = value.Get< bool >();
+ if ( impl.mController->IsUnderlineEnabled() != enabled )
+ {
+ impl.mController->SetUnderlineEnabled( enabled );
+ impl.RequestTextRelayout();
+ }
+ }
+ break;
+ }
+ }
+ }
+}
+
+Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index index )
+{
+ Property::Value value;
+
+ Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( Dali::BaseHandle( object ) );
+
+ if( label )
+ {
+ TextLabel& impl( GetImpl( label ) );
+ switch( index )
+ {
+ case Toolkit::TextLabel::Property::RENDERING_BACKEND:
+ {
+ value = impl.mRenderingBackend;
+ break;
+ }
+ case Toolkit::TextLabel::Property::TEXT:
+ {
+ if( impl.mController )
+ {
+ std::string text;
+ impl.mController->GetText( text );
+ value = text;
+ }
+ break;
+ }
+ case Toolkit::TextLabel::Property::MULTI_LINE:
+ {
+ if( impl.mController )
+ {
+ value = static_cast( LayoutEngine::MULTI_LINE_BOX == impl.mController->GetLayoutEngine().GetLayout() );
+ }
+ break;
+ }
+ case Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT:
+ {
+ if( impl.mController )
+ {
+ value = std::string( Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetLayoutEngine().GetHorizontalAlignment(),
+ HORIZONTAL_ALIGNMENT_STRING_TABLE,
+ HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT ) );
+ }
+ break;
+ }
+ case Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT:
+ {
+ if( impl.mController )
+ {
+ value = std::string( Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( impl.mController->GetLayoutEngine().GetVerticalAlignment(),
+ VERTICAL_ALIGNMENT_STRING_TABLE,
+ VERTICAL_ALIGNMENT_STRING_TABLE_COUNT ) );
+ }
+ break;
+ }
+ case Toolkit::TextLabel::Property::TEXT_COLOR:
+ {
+ if ( impl.mController )
+ {
+ value = impl.mController->GetTextColor();
+ }
+ break;
+ }
+ case Toolkit::TextLabel::Property::SHADOW_OFFSET:
+ {
+ if ( impl.mController )
+ {
+ value = impl.mController->GetShadowOffset();
+ }
+ break;
+ }
+ case Toolkit::TextLabel::Property::SHADOW_COLOR:
+ {
+ if ( impl.mController )
+ {
+ value = impl.mController->GetShadowColor();
+ }
+ break;
+ }
+ case Toolkit::TextLabel::Property::UNDERLINE_COLOR:
+ {
+ if ( impl.mController )
+ {
+ value = impl.mController->GetUnderlineColor();
+ }
+ break;
+ }
+ case Toolkit::TextLabel::Property::UNDERLINE_ENABLED:
+ {
+ if ( impl.mController )
+ {
+ value = impl.mController->IsUnderlineEnabled();
+ }
+ break;
+ }
+ }
+ }
+
+ return value;
+}
+
+void TextLabel::OnInitialize()
+{
+ Actor self = Self();
+
+ mController = Text::Controller::New( *this );
+
+ // Use height-for-width negotiation by default
+ self.SetResizePolicy( FILL_TO_PARENT, WIDTH );
+ self.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
+}
+
+void TextLabel::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change )
+{
+ GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+}
+
+Vector3 TextLabel::GetNaturalSize()
+{
+ return mController->GetNaturalSize();
+}
+
+float TextLabel::GetHeightForWidth( float width )
+{
+ return mController->GetHeightForWidth( width );
+}
+
+void TextLabel::OnRelayout( const Vector2& size, RelayoutContainer& container )
+{
+ if( mController->Relayout( size ) ||
+ !mRenderer )
+ {
+ if( !mRenderer )
+ {
+ mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
+ }
+
+ RenderableActor renderableActor;
+ if( mRenderer )
+ {
+ renderableActor = mRenderer->Render( mController->GetView() );
+ }
+
+ if( renderableActor != mRenderableActor )
+ {
+ UnparentAndReset( mRenderableActor );
+
+ if( renderableActor )
+ {
+ const Vector2& alignmentOffset = mController->GetAlignmentOffset();
+ renderableActor.SetPosition( alignmentOffset.x, alignmentOffset.y );
+
+ Self().Add( renderableActor );
+ }
+
+ mRenderableActor = renderableActor;
+ }
+ }
+}
+
+void TextLabel::RequestTextRelayout()
+{
+ RelayoutRequest();
+}
+
+TextLabel::TextLabel()
+: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
+ mRenderingBackend( DEFAULT_RENDERING_BACKEND )
+{
+}
+
+TextLabel::~TextLabel()
+{
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.h b/dali-toolkit/internal/controls/text-controls/text-label-impl.h
new file mode 100644
index 0000000..c69bd7c
--- /dev/null
+++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.h
@@ -0,0 +1,153 @@
+#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__
+#define __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__
+
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include
+#include
+#include
+#include
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+/**
+ * @brief A control which renders a short text string.
+ */
+class TextLabel : public Control, public Text::ControlInterface
+{
+public:
+
+ /**
+ * @copydoc Dali::Toollkit::TextLabel::New()
+ */
+ static Toolkit::TextLabel New();
+
+ // Properties
+
+ /**
+ * @brief 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 );
+
+ /**
+ * @brief 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 index );
+
+private: // From Control
+
+ /**
+ * @copydoc Control::OnInitialize()
+ */
+ virtual void OnInitialize();
+
+ /**
+ * @copydoc Control::OnStyleChange()
+ */
+ virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change );
+
+ /**
+ * @copydoc Control::OnRelayout()
+ */
+ virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
+
+ /**
+ * @copydoc Control::GetNaturalSize()
+ */
+ virtual Vector3 GetNaturalSize();
+
+ /**
+ * @copydoc Control::GetHeightForWidth()
+ */
+ virtual float GetHeightForWidth( float width );
+
+ /**
+ * @copydoc Text::ControlInterface::RequestTextRelayout()
+ */
+ virtual void RequestTextRelayout();
+
+private: // Implementation
+
+ /**
+ * Construct a new TextLabel.
+ */
+ TextLabel();
+
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~TextLabel();
+
+private:
+
+ // Undefined copy constructor and assignment operators
+ TextLabel(const TextLabel&);
+ TextLabel& operator=(const TextLabel& rhs);
+
+private: // Data
+
+ Text::ControllerPtr mController;
+ Text::RendererPtr mRenderer;
+ RenderableActor mRenderableActor;
+
+ int mRenderingBackend;
+};
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+
+inline Toolkit::Internal::TextLabel& GetImpl( Toolkit::TextLabel& textLabel )
+{
+ DALI_ASSERT_ALWAYS(textLabel);
+
+ Dali::RefObject& handle = textLabel.GetImplementation();
+
+ return static_cast(handle);
+}
+
+inline const Toolkit::Internal::TextLabel& GetImpl( const Toolkit::TextLabel& textLabel )
+{
+ DALI_ASSERT_ALWAYS(textLabel);
+
+ const Dali::RefObject& handle = textLabel.GetImplementation();
+
+ return static_cast(handle);
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__
diff --git a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp
new file mode 100644
index 0000000..6db6845
--- /dev/null
+++ b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp
@@ -0,0 +1,675 @@
+/*
+ * Copyright (c) 2015 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
+
+// INTERNAL INCLUDES
+#include
+#include
+#include
+
+// EXTERNAL INCLUDES
+#include
+#include
+#include
+#include
+#include
+
+// todo Move this to adaptor??
+#define GET_LOCALE_TEXT(string) dgettext("elementary", string)
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace
+{
+const Dali::Vector4 DEFAULT_POPUP_BACKGROUND( Dali::Vector4( .20f, 0.29f, 0.44f, 1.0f ) );
+const Dali::Vector4 DEFAULT_POPUP_BACKGROUND_PRESSED( Dali::Vector4( 0.07f, 0.10f, 0.17f, 1.0f ) );
+const Dali::Vector4 DEFAULT_POPUP_LINE_COLOR( Dali::Vector4( 0.36f, 0.45f, 0.59f, 1.0f ) );
+const Dali::Vector4 DEFAULT_OPTION_ICON( Dali::Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
+const Dali::Vector4 DEFAULT_OPTION_ICON_PRESSED( Dali::Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
+const Dali::Vector4 DEFAULT_OPTION_TEXT( Dali::Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
+const Dali::Vector4 DEFAULT_OPTION_TEXT_PRESSED( Dali::Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
+
+const std::string DEFAULT_POPUP_BACKGROUND_IMAGE( DALI_IMAGE_DIR "popup_bubble_bg.#.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" );
+
+const Dali::Vector2 DEFAULT_POPUP_MAX_SIZE( 470.0f, 120.0f ); ///< The maximum size of the popup.
+
+const float OPTION_TEXT_LINE_HEIGHT( 32.0f ); ///< The line height of the text.
+const Dali::Vector2 OPTION_ICON_SIZE( 0.f, 0.f ); ///< The size of the icon.
+const float OPTION_GAP_ICON_TEXT( 6.f ); ///< The gap between the icon and the text
+const float OPTION_MARGIN_WIDTH( 10.f ); ///< The margin between the right or lefts edge and the text or icon.
+const float OPTION_MAX_WIDTH( DEFAULT_POPUP_MAX_SIZE.width / 6 ); ///< The maximum width of the option (currently set to the max)
+const float OPTION_MIN_WIDTH( 86.0f ); ///< The minimum width of the option.
+
+const float POPUP_DIVIDER_WIDTH( 1.f ); ///< The size of the divider.
+
+const Dali::Vector2 POPUP_TAIL_SIZE( 20.0f, 16.0f ); ///< The size of the tail.
+const float POPUP_TAIL_Y_OFFSET( 5.f ); ///< The y offset of the tail (when its position is on the bottom).
+const float POPUP_TAIL_TOP_Y_OFFSET( 3.f ); ///< The y offset of the tail (when its position is on the top).
+
+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.
+
+const char* const OPTION_SELECT_WORD = "option-select_word"; // "Select Word" popup option.
+const char* const OPTION_SELECT_ALL("option-select_all"); // "Select All" popup option.
+const char* const OPTION_CUT("option-cut"); // "Cut" popup option.
+const char* const OPTION_COPY("option-copy"); // "Copy" popup option.
+const char* const OPTION_PASTE("option-paste"); // "Paste" popup option.
+const char* const OPTION_CLIPBOARD("option-clipboard"); // "Clipboard" popup option.
+
+} // namespace
+
+//// Comparison function for ButtonRequirement Priority
+//bool TextSelectionPopup::PriorityCompare( ButtonRequirement const& a, ButtonRequirement const& b )
+//{
+// return a.priority < b.priority;
+//}
+
+
+Dali::Toolkit::TextSelectionPopup TextSelectionPopup::New()
+{
+ // Create the implementation, temporarily owned by this handle on stack
+ IntrusivePtr< TextSelectionPopup > impl = new TextSelectionPopup();
+
+ // Pass ownership to CustomActor handle
+ Dali::Toolkit::TextSelectionPopup handle( *impl );
+
+ // Second-phase init of the implementation
+ // This can only be done after the CustomActor connection has been made...
+ impl->Initialize();
+
+ return handle;
+}
+
+void TextSelectionPopup::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
+{
+ Toolkit::TextSelectionPopup selectionPopup = Toolkit::TextSelectionPopup::DownCast( Dali::BaseHandle( object ) );
+
+ if( selectionPopup )
+ {
+ TextSelectionPopup& impl( GetImpl( selectionPopup ) );
+
+ switch( index )
+ {
+ case Toolkit::TextSelectionPopup::Property::POPUP_MAX_SIZE:
+ {
+ impl.SetPopupMaxSize( value.Get< Vector2 >() );
+ break;
+ }
+ case Toolkit::TextSelectionPopup::Property::POPUP_BACKGROUND_IMAGE:
+ {
+ ResourceImage image = ResourceImage::New( value.Get< std::string >() );
+ impl.SetPopupImage( POPUP_BACKGROUND, image );
+ break;
+ }
+ case Toolkit::TextSelectionPopup::Property::POPUP_CLIPBOARD_BUTTON_ICON_IMAGE:
+ {
+ ResourceImage image = ResourceImage::New( value.Get< std::string >() );
+ impl.SetPopupImage( POPUP_CLIPBOARD_BUTTON, image );
+ break;
+ }
+ case Toolkit::TextSelectionPopup::Property::POPUP_CUT_BUTTON_ICON_IMAGE:
+ {
+ ResourceImage image = ResourceImage::New( value.Get< std::string >() );
+ impl.SetPopupImage( POPUP_CUT_BUTTON_ICON, image );
+ break;
+ }
+ case Toolkit::TextSelectionPopup::Property::POPUP_COPY_BUTTON_ICON_IMAGE:
+ {
+ ResourceImage image = ResourceImage::New( value.Get< std::string >() );
+ impl.SetPopupImage( POPUP_COPY_BUTTON_ICON, image );
+ break;
+ }
+ case Toolkit::TextSelectionPopup::Property::POPUP_PASTE_BUTTON_ICON_IMAGE:
+ {
+ ResourceImage image = ResourceImage::New( value.Get< std::string >() );
+ impl.SetPopupImage( POPUP_PASTE_BUTTON_ICON, image );
+ break;
+ }
+ case Toolkit::TextSelectionPopup::Property::POPUP_SELECT_BUTTON_ICON_IMAGE:
+ {
+ ResourceImage image = ResourceImage::New( value.Get< std::string >() );
+ impl.SetPopupImage( POPUP_SELECT_BUTTON_ICON, image );
+ break;
+ }
+ case Toolkit::TextSelectionPopup::Property::POPUP_SELECT_ALL_BUTTON_ICON_IMAGE:
+ {
+ ResourceImage image = ResourceImage::New( value.Get< std::string >() );
+ impl.SetPopupImage( POPUP_SELECT_ALL_BUTTON_ICON, image );
+ break;
+ }
+ } // switch
+ } // TextSelectionPopup
+}
+
+Property::Value TextSelectionPopup::GetProperty( BaseObject* object, Property::Index index )
+{
+ Property::Value value;
+
+ Toolkit::TextSelectionPopup selectionPopup = Toolkit::TextSelectionPopup::DownCast( Dali::BaseHandle( object ) );
+
+ if( selectionPopup )
+ {
+ TextSelectionPopup& impl( GetImpl( selectionPopup ) );
+
+ switch( index )
+ {
+ case Toolkit::TextSelectionPopup::Property::POPUP_MAX_SIZE:
+ {
+ value = impl.GetPopupMaxSize();
+ break;
+ }
+ case Toolkit::TextSelectionPopup::Property::POPUP_BACKGROUND_IMAGE:
+ {
+ ResourceImage image = ResourceImage::DownCast( impl.GetPopupImage( POPUP_BACKGROUND ) );
+ if( image )
+ {
+ value = image.GetUrl();
+ }
+ break;
+ }
+ case Toolkit::TextSelectionPopup::Property::POPUP_CLIPBOARD_BUTTON_ICON_IMAGE:
+ {
+ ResourceImage image = ResourceImage::DownCast( impl.GetPopupImage( POPUP_CLIPBOARD_BUTTON ) );
+ if( image )
+ {
+ value = image.GetUrl();
+ }
+ break;
+ }
+ case Toolkit::TextSelectionPopup::Property::POPUP_CUT_BUTTON_ICON_IMAGE:
+ {
+ ResourceImage image = ResourceImage::DownCast( impl.GetPopupImage( POPUP_CUT_BUTTON_ICON ) );
+ if( image )
+ {
+ value = image.GetUrl();
+ }
+ break;
+ }
+ case Toolkit::TextSelectionPopup::Property::POPUP_COPY_BUTTON_ICON_IMAGE:
+ {
+ ResourceImage image = ResourceImage::DownCast( impl.GetPopupImage( POPUP_COPY_BUTTON_ICON ) );
+ if( image )
+ {
+ value = image.GetUrl();
+ }
+ break;
+ }
+ case Toolkit::TextSelectionPopup::Property::POPUP_PASTE_BUTTON_ICON_IMAGE:
+ {
+ ResourceImage image = ResourceImage::DownCast( impl.GetPopupImage( POPUP_PASTE_BUTTON_ICON ) );
+ if( image )
+ {
+ value = image.GetUrl();
+ }
+ break;
+ }
+ case Toolkit::TextSelectionPopup::Property::POPUP_SELECT_BUTTON_ICON_IMAGE:
+ {
+ ResourceImage image = ResourceImage::DownCast( impl.GetPopupImage( POPUP_SELECT_BUTTON_ICON ) );
+ if( image )
+ {
+ value = image.GetUrl();
+ }
+ break;
+ }
+ case Toolkit::TextSelectionPopup::Property::POPUP_SELECT_ALL_BUTTON_ICON_IMAGE:
+ {
+ ResourceImage image = ResourceImage::DownCast( impl.GetPopupImage( POPUP_SELECT_ALL_BUTTON_ICON ) );
+ if( image )
+ {
+ value = image.GetUrl();
+ }
+ break;
+ }
+ } // switch
+ }
+ return value;
+}
+
+void TextSelectionPopup::OnInitialize()
+{
+ CreatePopup();
+}
+
+void TextSelectionPopup::OnRelayout( const Vector2& size, RelayoutContainer& container )
+{
+
+}
+
+void TextSelectionPopup::SetPopupMaxSize( const Size& maxSize )
+{
+ mMaxSize = maxSize;
+}
+
+const Dali::Vector2& TextSelectionPopup::GetPopupMaxSize() const
+{
+ return mMaxSize;
+}
+
+void TextSelectionPopup::SetPopupImage( PopupParts part, Dali::Image image )
+{
+ switch ( part )
+ {
+ case POPUP_BACKGROUND :
+ {
+ mBackgroundImage = image;
+ }
+ break;
+ case POPUP_CLIPBOARD_BUTTON :
+ {
+ mClipboardIconImage = image;
+ }
+ break;
+ case POPUP_CUT_BUTTON_ICON :
+ {
+ mCutIconImage = image;
+ }
+ break;
+ case POPUP_COPY_BUTTON_ICON :
+ {
+ mCopyIconImage = image;
+ }
+ break;
+ case POPUP_PASTE_BUTTON_ICON :
+ {
+ mPasteIconImage = image;
+ }
+ break;
+ case POPUP_SELECT_BUTTON_ICON :
+ {
+ mSelectIconImage = image;
+ }
+ break;
+ case POPUP_SELECT_ALL_BUTTON_ICON :
+ {
+ mSelectAllIconImage = image;
+ }
+ break;
+
+ } // switch
+}
+
+Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part )
+{
+ switch ( part )
+ {
+ case POPUP_BACKGROUND :
+ {
+ return mBackgroundImage;
+ }
+ break;
+ case POPUP_CLIPBOARD_BUTTON :
+ {
+ return mClipboardIconImage;
+ }
+ break;
+ case POPUP_CUT_BUTTON_ICON :
+ {
+ return mCutIconImage;
+ }
+ break;
+ case POPUP_COPY_BUTTON_ICON :
+ {
+ return mCopyIconImage;
+ }
+ break;
+ case POPUP_PASTE_BUTTON_ICON :
+ {
+ return mPasteIconImage;
+ }
+ break;
+ case POPUP_SELECT_BUTTON_ICON :
+ {
+ return mSelectIconImage;
+ }
+ break;
+ case POPUP_SELECT_ALL_BUTTON_ICON :
+ {
+ return mSelectAllIconImage;
+ }
+ break;
+ default :
+ {
+ DALI_ASSERT_DEBUG( "Unknown Popup Part" );
+ }
+ } // switch
+
+ return Dali::Image();
+}
+
+ void TextSelectionPopup::CreateOrderedListOfPopupOptions()
+ {
+ mOrderListOfButtons.clear();
+
+ // Create button for each possible option using Option priority
+ if ( !mCutIconImage )
+ {
+ mCutIconImage = ResourceImage::New( OPTION_ICON_CUT );
+ }
+ mOrderListOfButtons.push_back( ButtonRequirement( ButtonsCut, mCutOptionPriority, OPTION_CUT, GET_LOCALE_TEXT("IDS_COM_BODY_CUT"), mCutIconImage, true ) );
+
+ if ( !mCopyIconImage )
+ {
+ mCopyIconImage = ResourceImage::New( OPTION_ICON_COPY );
+ }
+ mOrderListOfButtons.push_back( ButtonRequirement( ButtonsCopy, mCopyOptionPriority, OPTION_COPY, GET_LOCALE_TEXT("IDS_COM_BODY_COPY"), mCopyIconImage, true ) );
+
+ if ( !mPasteIconImage )
+ {
+ mPasteIconImage = ResourceImage::New( OPTION_ICON_PASTE );
+ }
+ mOrderListOfButtons.push_back( ButtonRequirement( ButtonsPaste, mPasteOptionPriority, OPTION_PASTE, GET_LOCALE_TEXT("IDS_COM_BODY_PASTE"), mPasteIconImage, true ) );
+
+ if ( !mSelectIconImage )
+ mSelectIconImage = ResourceImage::New( OPTION_ICON_SELECT );
+ mOrderListOfButtons.push_back( ButtonRequirement( ButtonsSelect, mSelectOptionPriority, OPTION_SELECT_WORD, GET_LOCALE_TEXT("IDS_COM_SK_SELECT"), mSelectIconImage, true ) );
+
+ if ( !mSelectAllIconImage )
+ {
+ mSelectAllIconImage = ResourceImage::New( OPTION_ICON_SELECT_ALL );
+ }
+ mOrderListOfButtons.push_back( ButtonRequirement( ButtonsSelectAll, mSelectAllOptionPriority, OPTION_SELECT_ALL, GET_LOCALE_TEXT("IDS_COM_BODY_SELECT_ALL"), mSelectAllIconImage, true ) );
+
+ if ( !mClipboardIconImage )
+ {
+ mClipboardIconImage = ResourceImage::New( OPTION_ICON_CLIPBOARD );
+ }
+ mOrderListOfButtons.push_back( ButtonRequirement( ButtonsClipboard, mClipboardOptionPriority, OPTION_CLIPBOARD, GET_LOCALE_TEXT("IDS_COM_BODY_CLIPBOARD"), mClipboardIconImage, true ) );
+
+ // Sort the buttons according their priorities.
+ std::sort( mOrderListOfButtons.begin(), mOrderListOfButtons.end(), TextSelectionPopup::ButtonPriorityCompare() );
+ }
+
+ void TextSelectionPopup::CreateBackground()
+ {
+ if ( !mBackgroundImage )
+ {
+ mBackgroundImage = ResourceImage::New( DEFAULT_POPUP_BACKGROUND_IMAGE );
+ }
+
+ NinePatchImage backgroundImageNinePatch = NinePatchImage::DownCast( mBackgroundImage );
+ if( backgroundImageNinePatch )
+ {
+ const Size ninePatchImageSize = Size( static_cast( mBackgroundImage.GetWidth() ), static_cast( mBackgroundImage.GetHeight() ) );
+ Rect childRect = backgroundImageNinePatch.GetChildRectangle();
+
+ // -1u because of the cropping.
+ mNinePatchMargins.x = childRect.x - 1u;
+ mNinePatchMargins.y = ninePatchImageSize.width - ( childRect.x + childRect.width ) - 1u;
+ mNinePatchMargins.z = childRect.y - 1u;
+ mNinePatchMargins.w = ninePatchImageSize.height - ( childRect.y + childRect.height ) - 1u;
+ }
+
+ SetBackgroundImage( mBackgroundImage );
+ SetBackgroundColor( mBackgroundColor );
+ }
+
+ void TextSelectionPopup::AddOption( Actor& parent, const std::string& name, const std::string& caption, const Image iconImage, bool finalOption, bool showIcons )
+ {
+ // 1. Create the backgrounds for the popup option both normal and pressed.
+ // Both containers will be added to a button.
+ Actor optionContainer = Actor::New();
+ optionContainer.SetRelayoutEnabled( true );
+ optionContainer.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+ optionContainer.SetDrawMode( DrawMode::OVERLAY );
+ optionContainer.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+
+ ImageActor optionPressedContainer = Toolkit::CreateSolidColorActor( mBackgroundPressedColor );
+ optionPressedContainer.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+ optionPressedContainer.SetDrawMode( DrawMode::OVERLAY );
+ optionPressedContainer.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+
+ // 2. Add text.
+ Toolkit::TextLabel captionTextLabel = Toolkit::TextLabel::New();
+ captionTextLabel.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+ captionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption );
+ // optionContainer.Add( captionTextLabel ); Temporary removed.
+
+ Toolkit::TextLabel pressedCaptionTextLabel = Toolkit::TextLabel::New();
+ pressedCaptionTextLabel.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+ pressedCaptionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption );
+ // optionPressedContainer.Add( pressedCaptionTextLabel ); Temporary removed.
+
+ // Calculates the icon/text position.
+ float iconTextOffsetY = 0.0f;
+
+ if ( showIcons )
+ {
+ // 3. Create the icons
+ ImageActor pressedIcon = ImageActor::New( iconImage );
+ ImageActor icon = ImageActor::New( iconImage );
+
+ optionContainer.Add( icon );
+ optionPressedContainer.Add( pressedIcon );
+
+ iconTextOffsetY = 0.5f * ( ( DEFAULT_POPUP_MAX_SIZE.height - mNinePatchMargins.z - mNinePatchMargins.w ) - ( OPTION_ICON_SIZE.height + OPTION_GAP_ICON_TEXT + OPTION_TEXT_LINE_HEIGHT ) );
+
+ icon.SetParentOrigin( ParentOrigin::TOP_CENTER );
+ icon.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+ icon.SetY( iconTextOffsetY );
+
+ pressedIcon.SetParentOrigin( ParentOrigin::TOP_CENTER );
+ pressedIcon.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+ pressedIcon.SetY( iconTextOffsetY );
+
+ // Layout icon + gap + text
+ captionTextLabel.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
+ pressedCaptionTextLabel.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
+ pressedCaptionTextLabel.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
+ captionTextLabel.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
+ pressedCaptionTextLabel.SetY( -iconTextOffsetY );
+ captionTextLabel.SetY( -iconTextOffsetY );
+ }
+ else
+ {
+ // Centre option text
+ captionTextLabel.SetAnchorPoint( AnchorPoint::CENTER );
+ captionTextLabel.SetParentOrigin( ParentOrigin::CENTER );
+ pressedCaptionTextLabel.SetAnchorPoint( AnchorPoint::CENTER );
+ pressedCaptionTextLabel.SetParentOrigin( ParentOrigin::CENTER );
+ }
+
+ // Calculate the size of the text.
+ Vector3 textSize = captionTextLabel.GetNaturalSize();
+ textSize.width = std::min( textSize.width, OPTION_MAX_WIDTH - 2.f * OPTION_MARGIN_WIDTH );
+
+ // Set the size to the text. Text will be ellipsized if exceeds the max width.
+ captionTextLabel.SetSize( textSize.GetVectorXY() );
+ pressedCaptionTextLabel.SetSize( textSize.GetVectorXY() );
+
+ // 4. Calculate the size of option.
+
+ // The width is the max size of the text or the icon plus the margins clamped between the option min and max size.
+ // The height is the whole popup height minus the ninepatch margins.
+ const Vector2 optionSize( std::min( OPTION_MAX_WIDTH, std::max( OPTION_MIN_WIDTH, std::max( textSize.width, OPTION_ICON_SIZE.width ) + 2.f * OPTION_MARGIN_WIDTH ) ),
+ DEFAULT_POPUP_MAX_SIZE.height - mNinePatchMargins.z - mNinePatchMargins.w );
+
+ optionContainer.SetSize( optionSize );
+ optionPressedContainer.SetSize( optionSize );
+
+ // 5. Create a option.
+ Toolkit::PushButton option = Toolkit::PushButton::New();
+ option.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+ option.SetSize( optionSize );
+ option.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ option.SetX( mContentSize.width );
+ option.SetName( name );
+ option.SetAnimationTime( 0.0f );
+ //option.ClickedSignal().Connect( this, &TextInputPopup::OnButtonPressed );
+
+ parent.Add( option );
+
+ // 6. Set the normal option image.
+ option.SetButtonImage( optionContainer );
+
+ // 7. Set the pressed option image
+ option.SetSelectedImage( optionPressedContainer );
+
+ // 8. Update the content size.
+ mContentSize.width += optionSize.width;
+ mContentSize.height = std::max ( optionSize.height, mContentSize.height );
+
+ // 9. Add the divider
+ if( !finalOption )
+ {
+ const Size size( POPUP_DIVIDER_WIDTH, mContentSize.height );
+
+ ImageActor divider = Toolkit::CreateSolidColorActor( Color::WHITE );
+ divider.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+ divider.SetSize( size );
+ divider.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ divider.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ divider.SetPosition( mContentSize.width - POPUP_DIVIDER_WIDTH, 0.0f );
+ parent.Add( divider );
+ }
+ }
+
+ void TextSelectionPopup::SetUpPopup( Size& size )
+ {
+ Actor self = Self();
+
+ // Create Layer and Stencil.
+ mStencilLayer = Layer::New();
+ ImageActor stencil = CreateSolidColorActor( Color::RED );
+ stencil.SetDrawMode( DrawMode::STENCIL );
+ stencil.SetVisible( true );
+ Actor scrollview = Actor::New(); //todo make a scrollview
+ stencil.SetRelayoutEnabled( true );
+
+ self.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+ self.SetSize( mRequiredPopUpSize ); // control matches stencil size
+
+ mStencilLayer.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+ mStencilLayer.SetSize( size ); // matches stencil size
+
+ stencil.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+ scrollview.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+ mButtons.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+
+ mStencilLayer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ scrollview.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ mButtons.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+
+ mStencilLayer.SetPosition( mNinePatchMargins.x, mNinePatchMargins.y );
+
+ self.Add( mStencilLayer );
+ mStencilLayer.Add( stencil );
+ mStencilLayer.Add( scrollview );
+ scrollview.Add( mButtons );
+ }
+
+ void TextSelectionPopup::AddPopupOptions( bool createTail, bool showIcons )
+ {
+ mShowIcons = showIcons;
+
+ mContentSize = Vector2::ZERO;
+
+ mButtons = Actor::New();
+ mButtons.SetRelayoutEnabled( true );
+
+ // Add the options into the buttons container.
+
+ // 1. Determine how many buttons are active and should be added to container.
+ std::size_t numberOfOptions = 0u;
+ for( std::vector::const_iterator it = mOrderListOfButtons.begin(), endIt = mOrderListOfButtons.end(); ( it != endIt ); ++it )
+ {
+ const ButtonRequirement& button( *it );
+ if( button.enabled )
+ {
+ ++numberOfOptions;
+ }
+ }
+
+ // 2. Iterate list of buttons and add active ones.
+ std::size_t optionsAdded = 0u;
+ for( std::vector::const_iterator it = mOrderListOfButtons.begin(), endIt = mOrderListOfButtons.end(); ( it != endIt ); ++it )
+ {
+ const ButtonRequirement& button( *it );
+ if ( button.enabled )
+ {
+ ++optionsAdded;
+ AddOption( mButtons, button.name, button.caption, button.icon, optionsAdded == numberOfOptions, mShowIcons );
+ }
+ }
+
+ // Calculate the size of the whole popup which may not be all visible.
+ mRequiredPopUpSize = Size( std::min( mMaxSize.width, mContentSize.width + mNinePatchMargins.x + mNinePatchMargins.y ), DEFAULT_POPUP_MAX_SIZE.height );
+
+ // Size of the contents within the popup
+ mVisiblePopUpSize = Size( mRequiredPopUpSize.width - mNinePatchMargins.x - mNinePatchMargins.y, mRequiredPopUpSize.height - mNinePatchMargins.z - mNinePatchMargins.w );
+ }
+
+ void TextSelectionPopup::CreatePopup()
+ {
+ if ( !mStencilLayer )
+ {
+ CreateOrderedListOfPopupOptions(); //todo Currently causes all options to be shown
+ CreateBackground();
+ AddPopupOptions( true, true );
+ SetUpPopup( mVisiblePopUpSize );
+ }
+
+ mStencilLayer.RaiseToTop();
+ }
+
+TextSelectionPopup::TextSelectionPopup()
+: Control( ControlBehaviour( CONTROL_BEHAVIOUR_NONE ) ),
+ mMaxSize ( DEFAULT_POPUP_MAX_SIZE ),
+ mVisiblePopUpSize( DEFAULT_POPUP_MAX_SIZE ),
+ mRequiredPopUpSize( DEFAULT_POPUP_MAX_SIZE ),
+ 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 ),
+ mShowIcons( true )
+{
+}
+
+TextSelectionPopup::~TextSelectionPopup()
+{
+}
+
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h
new file mode 100644
index 0000000..ffca9dd
--- /dev/null
+++ b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h
@@ -0,0 +1,306 @@
+#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_POPUP_H__
+#define __DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_POPUP_H__
+
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include
+#include
+
+// EXTERNAL INCLUDES
+#include
+#include
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace
+{
+enum PopupParts
+{
+ POPUP_BACKGROUND,
+ POPUP_CLIPBOARD_BUTTON,
+ POPUP_CUT_BUTTON_ICON,
+ POPUP_COPY_BUTTON_ICON,
+ POPUP_PASTE_BUTTON_ICON,
+ POPUP_SELECT_BUTTON_ICON,
+ POPUP_SELECT_ALL_BUTTON_ICON,
+};
+
+} // namespace
+
+class TextSelectionPopup : public Control
+{
+public:
+
+ enum Buttons
+ {
+ ButtonsCut,
+ ButtonsCopy,
+ ButtonsPaste,
+ ButtonsSelect,
+ ButtonsSelectAll,
+ ButtonsClipboard,
+ ButtonsEnumEnd
+ };
+
+ struct ButtonRequirement
+ {
+ ButtonRequirement()
+ : id( ButtonsEnumEnd ),
+ priority( 0u ),
+ name(),
+ caption(),
+ icon(),
+ enabled( false )
+ {}
+
+ ButtonRequirement( Buttons buttonId,
+ std::size_t buttonPriority,
+ const std::string& buttonName,
+ const std::string& buttonCaption,
+ Dali::Image& buttonIcon,
+ bool buttonEnabled )
+ : id( buttonId ),
+ priority( buttonPriority ),
+ name( buttonName ),
+ caption( buttonCaption ),
+ icon( buttonIcon ),
+ enabled( buttonEnabled )
+ {}
+
+ Buttons id;
+ std::size_t priority;
+ std::string name;
+ std::string caption;
+ Dali::Image icon;
+ bool enabled;
+ };
+
+ struct ButtonPriorityCompare
+ {
+ bool operator()( const ButtonRequirement& lhs, const ButtonRequirement& rhs ) const {
+ return lhs.priority < rhs.priority;
+ }
+ };
+
+// static inline bool ButtonPriorityCompare( ButtonRequirement a, ButtonRequirement b )
+// {
+// return a.priority < b.priority ? true : false;
+// }
+
+ /**
+ * @copydoc Dali::Toollkit::TextSelectionPopup::New()
+ */
+ static Toolkit::TextSelectionPopup New();
+
+ // Properties
+
+ /**
+ * @brief 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 );
+
+ /**
+ * @brief 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 index );
+
+ void CreatePopup();
+
+ void DestroyPopup();
+
+private: // From Control
+
+ /**
+ * @copydoc Control::OnInitialize()
+ */
+ virtual void OnInitialize();
+
+// /**
+// * @copydoc Control::GetNaturalSize()
+// */
+// virtual Vector3 GetNaturalSize();
+//
+// /**
+// * @copydoc Control::GetHeightForWidth()
+// */
+// virtual float GetHeightForWidth( float width );
+
+ /**
+ * @copydoc Control::OnInitialize()
+ */
+ virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
+//
+// /**
+// * Received for single & double taps
+// */
+// virtual void OnTap( const TapGesture& tap );
+//
+// /**
+// * @copydoc Text::ControlInterface::RequestTextRelayout()
+// */
+// virtual void RequestTextRelayout();
+
+ /**
+ * Set max size of Popup
+ * @param[in] maxSize Size (Vector2)
+ */
+ void SetPopupMaxSize( const Size& maxSize );
+
+ /**
+ * Get Max size of Popup
+ * @return Vector2 the max size of the Popup
+ */
+ const Dali::Vector2& GetPopupMaxSize() const;
+
+ /**
+ * @brief Sets the image for the given part of the Popup.
+ *
+ * @param[in] part The part of the pop from the Enum PopupParts
+ * @param[in] image The image to use.
+ */
+ void SetPopupImage( PopupParts part, Dali::Image image );
+
+ /**
+ * @brief Retrieves the image of the given part used by the popup
+ *
+ * @param[in] part The part of the popup
+ * @return The image used for that part.
+ */
+ Dali::Image GetPopupImage( PopupParts part );
+
+ void CreateOrderedListOfPopupOptions();
+
+ void CreateBackground();
+
+ void AddOption( Actor& parent, const std::string& name, const std::string& caption, const Image iconImage, bool finalOption, bool showIcons );
+
+ void SetUpPopup( Size& size );
+
+ void AddPopupOptions( bool createTail, bool showIcons );
+
+private: // Implementation
+
+ /**
+ * Construct a new TextField.
+ */
+ TextSelectionPopup();
+
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~TextSelectionPopup();
+
+private:
+
+ // Undefined copy constructor and assignment operators
+ TextSelectionPopup(const TextSelectionPopup&);
+ TextSelectionPopup& operator=(const TextSelectionPopup& rhs);
+
+private: // Data
+
+ Actor mButtons; // Actor which holds all the buttons, sensitivity can be set oActor buttons via this actor
+ Layer mStencilLayer; // Layer to enable clipping when buttons exceed popup
+
+ // Images to be used by the Popup
+ Image mBackgroundImage;
+ Image mCutIconImage;
+ Image mCopyIconImage;
+ Image mPasteIconImage;
+ Image mClipboardIconImage;
+ Image mSelectIconImage;
+ Image mSelectAllIconImage;
+
+ ImageActor mBackground; // The background popup panel
+ ImageActor mTail; // The tail for the popup
+ ImageActor mTailEffect; //todo remove // the tail effect
+ ImageActor mTailLine; //todo remove // The border/outline around the tail
+
+ Size mMaxSize; // Max size of the Popup
+ Size mVisiblePopUpSize; // Visible Size of popup excluding content that needs scrolling.
+ Size mRequiredPopUpSize; // Total size of popup including any invisible margin
+
+ Vector4 mNinePatchMargins; // Margins between the edge of the cropped image and the nine patch rect (left, right, top, bottom).
+
+ Size mContentSize; // Size of Content (i.e. Buttons)
+ //Animation mAnimation; // Popup Hide/Show animation.
+
+ std::vector mOrderListOfButtons; // List of buttons in the order to be displayed and a flag to indicate if needed.
+
+ Vector4 mBackgroundColor; // Color of the background of the text input popup
+ Vector4 mBackgroundPressedColor; // Color of the option background.
+ Vector4 mLineColor; // Color of the line around the text input popup
+ Vector4 mIconColor; // Color of the popup icon.
+ Vector4 mIconPressedColor; // Color of the popup icon when pressed.
+ Vector4 mTextColor; // Color of the popup text.
+ Vector4 mTextPressedColor; // Color of the popup text when pressed.
+
+ // Priority of Options/Buttons in the Cut and Paste pop-up, higher priority buttons are displayed first, left to right.
+ std::size_t mSelectOptionPriority; // Position of Select Button
+ std::size_t mSelectAllOptionPriority; // Position of Select All button
+ std::size_t mCutOptionPriority; // Position of Cut button
+ std::size_t mCopyOptionPriority; // Position of Copy button
+ std::size_t mPasteOptionPriority; // Position of Paste button
+ std::size_t mClipboardOptionPriority; // Position of Clipboard button
+
+ bool mShowIcons; // Flag to show icons
+
+};
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+
+inline Toolkit::Internal::TextSelectionPopup& GetImpl( Toolkit::TextSelectionPopup& textSelectionPopup )
+{
+ DALI_ASSERT_ALWAYS( textSelectionPopup );
+
+ Dali::RefObject& handle = textSelectionPopup.GetImplementation();
+
+ return static_cast(handle);
+}
+
+inline const Toolkit::Internal::TextSelectionPopup& GetImpl( const Toolkit::TextSelectionPopup& textSelectionPopup )
+{
+ DALI_ASSERT_ALWAYS( textSelectionPopup );
+
+ const Dali::RefObject& handle = textSelectionPopup.GetImplementation();
+
+ return static_cast(handle);
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_POPUP_H__
diff --git a/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.cpp b/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.cpp
deleted file mode 100644
index 25d30d1..0000000
--- a/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.cpp
+++ /dev/null
@@ -1,1082 +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
-
-// 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.SetOrientation( 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( ResourceImage::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 = ResourceImage::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" );
- 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::Property::WORLD_POSITION_X, LessThanCondition( mBoundingRectangleWorldCoordinates.x + handlesize.x) );
- leftNotification.NotifySignal().Connect( this, &Decorator::OnLeftBoundaryExceeded );
-
- PropertyNotification rightNotification = selectionHandleTwo.AddPropertyNotification( Actor::Property::WORLD_POSITION_X, GreaterThanCondition( mBoundingRectangleWorldCoordinates.z - handlesize.x ) );
- rightNotification.NotifySignal().Connect( this, &Decorator::OnRightBoundaryExceeded );
-
- // Within horizontal boundary
- PropertyNotification leftLeaveNotification = selectionHandleOne.AddPropertyNotification( Actor::Property::WORLD_POSITION_X, GreaterThanCondition( mBoundingRectangleWorldCoordinates.x + 2*handlesize.x ) );
- leftLeaveNotification.NotifySignal().Connect( this, &Decorator::OnReturnToLeftBoundary );
-
- PropertyNotification rightLeaveNotification = selectionHandleTwo.AddPropertyNotification( Actor::Property::WORLD_POSITION_X, LessThanCondition( mBoundingRectangleWorldCoordinates.z - 2*handlesize.x ) );
- rightLeaveNotification.NotifySignal().Connect( this, &Decorator::OnReturnToRightBoundary );
-
- // Exceeding vertical boundary
- PropertyNotification verticalExceedNotificationOne = selectionHandleOne.AddPropertyNotification( Actor::Property::WORLD_POSITION_Y,
- OutsideCondition( mBoundingRectangleWorldCoordinates.y + handlesize.y,
- mBoundingRectangleWorldCoordinates.w - handlesize.y ) );
- verticalExceedNotificationOne.NotifySignal().Connect( this, &Decorator::OnHandleOneLeavesBoundary );
-
- PropertyNotification verticalExceedNotificationTwo = selectionHandleTwo.AddPropertyNotification( Actor::Property::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::Property::WORLD_POSITION_Y,
- InsideCondition( mBoundingRectangleWorldCoordinates.y + handlesize.y,
- mBoundingRectangleWorldCoordinates.w - handlesize.y ) );
- verticalWithinNotificationOne.NotifySignal().Connect( this, &Decorator::OnHandleOneWithinBoundary );
-
- PropertyNotification verticalWithinNotificationTwo = selectionHandleTwo.AddPropertyNotification( Actor::Property::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::Property::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/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.h b/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.h
deleted file mode 100644
index 7de78bf..0000000
--- a/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 Signal< bool( Toolkit::Button ) > PressedSignal;
- typedef Signal< 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/dali-toolkit/internal/controls/text-input/text-input-handles-impl.cpp b/dali-toolkit/internal/controls/text-input/text-input-handles-impl.cpp
deleted file mode 100644
index 8249889..0000000
--- a/dali-toolkit/internal/controls/text-input/text-input-handles-impl.cpp
+++ /dev/null
@@ -1,293 +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
-
-// 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.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
- handleGrabArea.SetSizeModeFactor( relativeScale );
- 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 = ResourceImage::New( DEFAULT_SELECTION_HANDLE_ONE );
- mSelectionHandleOneImagePressed = ResourceImage::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 = ResourceImage::New( DEFAULT_SELECTION_HANDLE_TWO );
- mSelectionHandleTwoImagePressed = ResourceImage::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 = ResourceImage::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/dali-toolkit/internal/controls/text-input/text-input-handles-impl.h b/dali-toolkit/internal/controls/text-input/text-input-handles-impl.h
deleted file mode 100644
index c5f9013..0000000
--- a/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/dali-toolkit/internal/controls/text-input/text-input-impl.cpp b/dali-toolkit/internal/controls/text-input/text-input-impl.cpp
deleted file mode 100644
index fc289f8..0000000
--- a/dali-toolkit/internal/controls/text-input/text-input-impl.cpp
+++ /dev/null
@@ -1,5534 +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
-#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 char* const 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
-{
-
-namespace Internal
-{
-
-namespace // Unnamed namespace
-{
-
-BaseHandle Create()
-{
- return Toolkit::TextInput::New();
-}
-
-// Setup properties, signals and actions using the type-registry.
-DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TextInput, Toolkit::Control, Create )
-
-DALI_PROPERTY_REGISTRATION( TextInput, "highlight-color", VECTOR4, HIGHLIGHT_COLOR )
-DALI_PROPERTY_REGISTRATION( TextInput, "cut-and-paste-bg-color", VECTOR4, CUT_AND_PASTE_COLOR )
-DALI_PROPERTY_REGISTRATION( TextInput, "cut-and-paste-pressed-color", VECTOR4, CUT_AND_PASTE_PRESSED_COLOR )
-DALI_PROPERTY_REGISTRATION( TextInput, "cut-and-paste-border-color", VECTOR4, CUT_AND_PASTE_BORDER_COLOR )
-DALI_PROPERTY_REGISTRATION( TextInput, "cut-and-paste-icon-color", VECTOR4, CUT_AND_PASTE_ICON_COLOR )
-DALI_PROPERTY_REGISTRATION( TextInput, "cut-and-paste-icon-pressed-color", VECTOR4, CUT_AND_PASTE_ICON_PRESSED_COLOR )
-DALI_PROPERTY_REGISTRATION( TextInput, "cut-and-paste-text-color", VECTOR4, CUT_AND_PASTE_TEXT_COLOR )
-DALI_PROPERTY_REGISTRATION( TextInput, "cut-and-paste-text-pressed-color", VECTOR4, CUT_AND_PASTE_TEXT_PRESSED_COLOR )
-DALI_PROPERTY_REGISTRATION( TextInput, "cut-button-position-priority", UNSIGNED_INTEGER, CUT_BUTTON_POSITION_PRIORITY )
-DALI_PROPERTY_REGISTRATION( TextInput, "copy-button-position-priority", UNSIGNED_INTEGER, COPY_BUTTON_POSITION_PRIORITY )
-DALI_PROPERTY_REGISTRATION( TextInput, "paste-button-position-priority", UNSIGNED_INTEGER, PASTE_BUTTON_POSITION_PRIORITY )
-DALI_PROPERTY_REGISTRATION( TextInput, "select-button-position-priority", UNSIGNED_INTEGER, SELECT_BUTTON_POSITION_PRIORITY )
-DALI_PROPERTY_REGISTRATION( TextInput, "select-all-button-position-priority", UNSIGNED_INTEGER, SELECT_ALL_BUTTON_POSITION_PRIORITY )
-DALI_PROPERTY_REGISTRATION( TextInput, "clipboard-button-position-priority", UNSIGNED_INTEGER, CLIPBOARD_BUTTON_POSITION_PRIORITY )
-DALI_PROPERTY_REGISTRATION( TextInput, "popup-offset-from-text", VECTOR4, POP_UP_OFFSET_FROM_TEXT )
-DALI_PROPERTY_REGISTRATION( TextInput, "cursor-color", VECTOR4, CURSOR_COLOR )
-
-DALI_SIGNAL_REGISTRATION( TextInput, "start-input", SIGNAL_START_INPUT )
-DALI_SIGNAL_REGISTRATION( TextInput, "end-input", SIGNAL_END_INPUT )
-DALI_SIGNAL_REGISTRATION( TextInput, "style-changed", SIGNAL_STYLE_CHANGED )
-DALI_SIGNAL_REGISTRATION( TextInput, "max-input-characters-reached", SIGNAL_MAX_INPUT_CHARACTERS_REACHED )
-DALI_SIGNAL_REGISTRATION( TextInput, "toolbar-displayed", SIGNAL_TOOLBAR_DISPLAYED )
-DALI_SIGNAL_REGISTRATION( TextInput, "text-exceed-boundaries", SIGNAL_TEXT_EXCEED_BOUNDARIES )
-
-DALI_TYPE_REGISTRATION_END()
-
-}
-
-// [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::InputSignalType& TextInput::InputStartedSignal()
-{
- return mInputStartedSignal;
-}
-
-Toolkit::TextInput::InputSignalType& TextInput::InputFinishedSignal()
-{
- return mInputFinishedSignal;
-}
-
-Toolkit::TextInput::InputSignalType& TextInput::CutAndPasteToolBarDisplayedSignal()
-{
- return mCutAndPasteToolBarDisplayed;
-}
-
-Toolkit::TextInput::StyleChangedSignalType& TextInput::StyleChangedSignal()
-{
- return mStyleChangedSignal;
-}
-
-Toolkit::TextInput::TextModifiedSignalType& TextInput::TextModifiedSignal()
-{
- return mTextModifiedSignal;
-}
-
-Toolkit::TextInput::MaxInputCharactersReachedSignalType& TextInput::MaxInputCharactersReachedSignal()
-{
- return mMaxInputCharactersReachedSignal;
-}
-
-Toolkit::TextInput::InputTextExceedBoundariesSignalType& TextInput::InputTextExceedBoundariesSignal()
-{
- return mInputTextExceedBoundariesSignal;
-}
-
-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( 0 == strcmp( signalName.c_str(), SIGNAL_START_INPUT ) )
- {
- textInput.InputStartedSignal().Connect( tracker, functor );
- }
- else if( 0 == strcmp( signalName.c_str(), SIGNAL_END_INPUT ) )
- {
- textInput.InputFinishedSignal().Connect( tracker, functor );
- }
- else if( 0 == strcmp( signalName.c_str(), SIGNAL_STYLE_CHANGED ) )
- {
- textInput.StyleChangedSignal().Connect( tracker, functor );
- }
- else if( 0 == strcmp( signalName.c_str(), SIGNAL_MAX_INPUT_CHARACTERS_REACHED ) )
- {
- textInput.MaxInputCharactersReachedSignal().Connect( tracker, functor );
- }
- else if( 0 == strcmp( signalName.c_str(), SIGNAL_TOOLBAR_DISPLAYED ) )
- {
- textInput.CutAndPasteToolBarDisplayedSignal().Connect( tracker, functor );
- }
- else if( 0 == strcmp( signalName.c_str(), SIGNAL_TEXT_EXCEED_BOUNDARIES ) )
- {
- 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