From: HyunJu Shin Date: Mon, 24 Jul 2017 02:51:07 +0000 (+0000) Subject: Merge "Line wrap mode property is added." into devel/master X-Git-Tag: dali_1.2.50~7 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=7cca1061ed3db08d2e7f511a8f6ef707e688703d;hp=-c Merge "Line wrap mode property is added." into devel/master --- 7cca1061ed3db08d2e7f511a8f6ef707e688703d diff --combined automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp index d884271,cca5414..a052525 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp @@@ -26,6 -26,7 +26,6 @@@ #include #include #include -#include #include using namespace Dali; @@@ -766,6 -767,12 +766,6 @@@ int UtcDaliTextEditorSetPropertyP(void editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" ); DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION ); - // Check placeholder text properties when focused. - editor.SetProperty( DevelControl::Property::STATE, "FOCUSED" ); - editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Focused Placeholder Text" ); - DALI_TEST_EQUALS( editor.GetProperty( DevelControl::Property::STATE ), (int)DevelControl::FOCUSED, TEST_LOCATION ); - DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Focused Placeholder Text"), TEST_LOCATION ); - // Check placeholder text's color property. editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED ); DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION ); @@@ -779,7 -786,6 +779,7 @@@ Property::Map placeholderPixelSizeMapGet; Property::Map placeholderFontstyleMap; placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text"; + placeholderPixelSizeMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused"; placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE; placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial"; placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f; @@@ -796,7 -802,6 +796,7 @@@ Property::Map placeholderMapSet; Property::Map placeholderMapGet; placeholderMapSet["placeholderText"] = "Setting Placeholder Text"; + placeholderMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused"; placeholderMapSet["placeholderColor"] = Color::RED; placeholderMapSet["placeholderFontFamily"] = "Arial"; placeholderMapSet["placeholderPointSize"] = 12.0f; @@@ -2182,3 -2187,37 +2182,37 @@@ int utcDaliTextEditorScrollStateChanged END_TEST; } + int UtcDaliToolkitTextEditorTextWarpMode(void) + { + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode"); + + int lineCount =0 ; + + TextEditor editor = TextEditor::New(); + editor.SetSize( 150.0f, 300.f ); + editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" ); + + Stage::GetCurrent().Add( editor ); + + editor.SetProperty( DevelTextEditor::Property::LINE_WRAP_MODE, "WORD" ); + + application.SendNotification(); + application.Render(); + + lineCount = editor.GetProperty( DevelTextEditor::Property::LINE_COUNT ); + DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION ); + + + + editor.SetProperty( DevelTextEditor::Property::LINE_WRAP_MODE, "CHARACTER" ); + + application.SendNotification(); + application.Render(); + + + lineCount = editor.GetProperty( DevelTextEditor::Property::LINE_COUNT ); + DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION ); + + END_TEST; + } diff --combined dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h index b2dc43a,e76a443..50f6af5 --- a/dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h +++ b/dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h @@@ -145,15 -145,14 +145,15 @@@ namespace Propert * @code * Property::Map propertyMap; * propertyMap["placeholderText"] = "Setting Placeholder Text"; + * propertyMap["placeholderTextFocused"] = "Setting Placeholder Text Focused"; * propertyMap["placeholderColor"] = Color::RED; * propertyMap["placeholderFontFamily"] = "Arial"; * propertyMap["placeholderPointSize"] = 12.0f; * * Property::Map fontStyleMap; - * fontstyleMap.Insert( "weight", "bold" ); - * fontstyleMap.Insert( "width", "condensed" ); - * fontstyleMap.Insert( "slant", "italic" ); + * fontStyleMap.Insert( "weight", "bold" ); + * fontStyleMap.Insert( "width", "condensed" ); + * fontStyleMap.Insert( "slant", "italic" ); * propertyMap["placeholderFontStyle"] = fontStyleMap; * * editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, propertyMap ); @@@ -161,7 -160,13 +161,13 @@@ * * @details name "placeholder", type MAP */ - PLACEHOLDER + PLACEHOLDER, + + /** + * @brief line wrap mode when the text lines over layout width. + * @details name "lineWrapMode", type string. + */ + LINE_WRAP_MODE }; } // namespace Property diff --combined dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp index e763f2c,d340cf4..ccddda5 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@@ -76,6 -76,14 +76,14 @@@ const Scripting::StringEnum HORIZONTAL_ }; const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] ); + + const Scripting::StringEnum LINE_WRAP_MODE_STRING_TABLE[] = + { + { "WORD", Toolkit::Text::Layout::LineWrap::WORD }, + { "CHARACTER", Toolkit::Text::Layout::LineWrap::CHARACTER } + }; + const unsigned int LINE_WRAP_MODE_STRING_TABLE_COUNT = sizeof( LINE_WRAP_MODE_STRING_TABLE ) / sizeof( LINE_WRAP_MODE_STRING_TABLE[0] ); + const char* const SCROLL_BAR_POSITION("sourcePosition"); const char* const SCROLL_BAR_POSITION_MIN("sourcePositionMin"); const char* const SCROLL_BAR_POSITION_MAX("sourcePositionMax"); @@@ -141,6 -149,7 +149,7 @@@ DALI_DEVEL_PROPERTY_REGISTRATION( Toolk DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "placeholderTextColor", VECTOR4, PLACEHOLDER_TEXT_COLOR ) DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "enableSelection", BOOLEAN, ENABLE_SELECTION ) DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "placeholder", MAP, PLACEHOLDER ) + DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "lineWrapMode", STRING, LINE_WRAP_MODE ) DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "textChanged", SIGNAL_TEXT_CHANGED ) DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED ) @@@ -674,7 -683,7 +683,7 @@@ void TextEditor::SetProperty( BaseObjec const std::string& text = value.Get< std::string >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor::OnPropertySet %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str() ); - impl.mController->SetPlaceholderText( text ); + impl.mController->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text ); } break; } @@@ -712,6 -721,21 +721,21 @@@ } break; } + case Toolkit::DevelTextEditor::Property::LINE_WRAP_MODE: + { + const std::string& wrapModeStr = value.Get< std::string >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p LINE_WRAP_MODE %s\n", impl.mController.Get(), wrapModeStr.c_str() ); + + Layout::LineWrap::Mode lineWrapMode( Layout::LineWrap::WORD ); + if( Scripting::GetEnumeration< Layout::LineWrap::Mode >( wrapModeStr.c_str(), + LINE_WRAP_MODE_STRING_TABLE, + LINE_WRAP_MODE_STRING_TABLE_COUNT, + lineWrapMode ) ) + { + impl.mController->SetLineWrapMode( lineWrapMode ); + } + break; + } } // switch } // texteditor } @@@ -1060,7 -1084,7 +1084,7 @@@ Property::Value TextEditor::GetProperty if( impl.mController ) { std::string text; - impl.mController->GetPlaceholderText( text ); + impl.mController->GetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text ); value = text; } break; @@@ -1088,6 -1112,13 +1112,13 @@@ value = map; break; } + case Toolkit::DevelTextEditor::Property::LINE_WRAP_MODE: + { + if( impl.mController ) + { + value = impl.mController->GetLineWrapMode(); + } + } } //switch } diff --combined dali-toolkit/internal/text/text-controller.cpp index fbd26bf,7f190e2..feb620b --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@@ -48,7 -48,6 +48,7 @@@ const float MAX_FLOAT = std::numeric_li const std::string EMPTY_STRING(""); const char * const PLACEHOLDER_TEXT = "placeholderText"; +const char * const PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused"; const char * const PLACEHOLDER_COLOR = "placeholderColor"; const char * const PLACEHOLDER_FONT_FAMILY = "placeholderFontFamily"; const char * const PLACEHOLDER_FONT_STYLE = "placeholderFontStyle"; @@@ -392,6 -391,34 +392,34 @@@ Layout::VerticalAlignment Controller::G return mImpl->mModel->mVerticalAlignment; } + void Controller::SetLineWrapMode( Layout::LineWrap::Mode lineWrapMode ) + { + if( lineWrapMode != mImpl->mModel->mLineWrapMode ) + { + // Set the text wrap mode. + mImpl->mModel->mLineWrapMode = lineWrapMode; + + + // Update Text layout for applying wrap mode + mImpl->mOperationsPending = static_cast( mImpl->mOperationsPending | + ALIGN | + LAYOUT | + UPDATE_LAYOUT_SIZE | + REORDER ); + mImpl->mTextUpdateInfo.mCharacterIndex = 0u; + mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters; + mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count(); + + // Request relayout + mImpl->RequestRelayout(); + } + } + + Layout::LineWrap::Mode Controller::GetLineWrapMode() const + { + return mImpl->mModel->mLineWrapMode; + } + void Controller::SetTextElideEnabled( bool enabled ) { mImpl->mModel->mElideEnabled = enabled; @@@ -532,6 -559,22 +560,6 @@@ void Controller::GetText( std::string& } } -void Controller::SetPlaceholderText( const std::string& text ) -{ - if( NULL != mImpl->mEventData ) - { - mImpl->mEventData->mPlaceholderText = text; - - // Update placeholder if there is no text - if( mImpl->IsShowingPlaceholderText() || - ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) ) - { - ShowPlaceholderText(); - } - } -} - -// This is overloading function for PLACEHOLDER_TEXT_FOCUSED in text-field void Controller::SetPlaceholderText( PlaceholderType type, const std::string& text ) { if( NULL != mImpl->mEventData ) @@@ -554,6 -597,15 +582,6 @@@ } } -void Controller::GetPlaceholderText( std::string& text ) const -{ - if( NULL != mImpl->mEventData ) - { - text = mImpl->mEventData->mPlaceholderText; - } -} - -// This is overloading function for PLACEHOLDER_TEXT_FOCUSED in text-field void Controller::GetPlaceholderText( PlaceholderType type, std::string& text ) const { if( NULL != mImpl->mEventData ) @@@ -1894,13 -1946,7 +1922,13 @@@ void Controller::SetPlaceholderProperty { std::string text = ""; value.Get( text ); - SetPlaceholderText( text ); + SetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text ); + } + else if( key == PLACEHOLDER_TEXT_FOCUSED ) + { + std::string text = ""; + value.Get( text ); + SetPlaceholderText( Controller::PLACEHOLDER_TYPE_ACTIVE, text ); } else if( key == PLACEHOLDER_COLOR ) { @@@ -1946,15 -1992,7 +1974,15 @@@ void Controller::GetPlaceholderProperty { if( NULL != mImpl->mEventData ) { - map[ PLACEHOLDER_TEXT ] = mImpl->mEventData->mPlaceholderText; + if( !mImpl->mEventData->mPlaceholderTextActive.empty() ) + { + map[ PLACEHOLDER_TEXT_FOCUSED ] = mImpl->mEventData->mPlaceholderTextActive; + } + if( !mImpl->mEventData->mPlaceholderTextInactive.empty() ) + { + map[ PLACEHOLDER_TEXT ] = mImpl->mEventData->mPlaceholderTextInactive; + } + map[ PLACEHOLDER_COLOR ] = mImpl->mEventData->mPlaceholderTextColor; map[ PLACEHOLDER_FONT_FAMILY ] = GetPlaceholderFontFamily(); @@@ -3195,7 -3233,8 +3223,8 @@@ bool Controller::DoRelayout( const Size charactersToGlyphBuffer, glyphsPerCharacterBuffer, totalNumberOfGlyphs, - mImpl->mModel->mHorizontalAlignment ); + mImpl->mModel->mHorizontalAlignment, + mImpl->mModel->mLineWrapMode ); // Resize the vector of positions to have the same size than the vector of glyphs. Vector& glyphPositions = mImpl->mModel->mVisualModel->mGlyphPositions; @@@ -3544,17 -3583,27 +3573,17 @@@ void Controller::ShowPlaceholderText( const char* text( NULL ); size_t size( 0 ); - if( !mImpl->mEventData->mPlaceholderTextActive.empty() || !mImpl->mEventData->mPlaceholderTextInactive.empty() ) + // TODO - Switch Placeholder text when changing state + if( ( EventData::INACTIVE != mImpl->mEventData->mState ) && + ( 0u != mImpl->mEventData->mPlaceholderTextActive.c_str() ) ) { - if( ( EventData::INACTIVE != mImpl->mEventData->mState ) && - ( 0u != mImpl->mEventData->mPlaceholderTextActive.c_str() ) ) - { - text = mImpl->mEventData->mPlaceholderTextActive.c_str(); - size = mImpl->mEventData->mPlaceholderTextActive.size(); - } - else - { - text = mImpl->mEventData->mPlaceholderTextInactive.c_str(); - size = mImpl->mEventData->mPlaceholderTextInactive.size(); - } + text = mImpl->mEventData->mPlaceholderTextActive.c_str(); + size = mImpl->mEventData->mPlaceholderTextActive.size(); } else { - if( 0u != mImpl->mEventData->mPlaceholderText.c_str() ) - { - text = mImpl->mEventData->mPlaceholderText.c_str(); - size = mImpl->mEventData->mPlaceholderText.size(); - } + text = mImpl->mEventData->mPlaceholderTextInactive.c_str(); + size = mImpl->mEventData->mPlaceholderTextInactive.size(); } mImpl->mTextUpdateInfo.mCharacterIndex = 0u; diff --combined dali-toolkit/internal/text/text-controller.h index 3d7639d,054c1f3..aeee224 --- a/dali-toolkit/internal/text/text-controller.h +++ b/dali-toolkit/internal/text/text-controller.h @@@ -26,9 -26,11 +26,11 @@@ #include #include #include + #include #include #include + namespace Dali { @@@ -343,6 -345,18 +345,18 @@@ public: // Configure the text controlle Layout::VerticalAlignment GetVerticalAlignment() const; /** + * @brief Sets the text's wrap mode + * @param[in] text wrap mode The unit of wrapping + */ + void SetLineWrapMode( Layout::LineWrap::Mode textWarpMode ); + + /** + * @brief Retrieve text wrap mode previously set. + * @return text wrap mode + */ + Layout::LineWrap::Mode GetLineWrapMode() const; + + /** * @brief Enable or disable the text elide. * * @param[in] enabled Whether to enable the text elide. @@@ -466,6 -480,13 +480,6 @@@ public: // Update /** * @brief Replaces any placeholder text previously set. * - * @param[in] text A string of UTF-8 characters. - */ - void SetPlaceholderText( const std::string& text ); - - /** - * @brief Replaces any placeholder text previously set. - * * @param[in] type Different placeholder-text can be shown when the control is active/inactive. * @param[in] text A string of UTF-8 characters. */ @@@ -474,6 -495,13 +488,6 @@@ /** * @brief Retrieve any placeholder text previously set. * - * @param[out] A string of UTF-8 characters. - */ - void GetPlaceholderText( std::string& text ) const; - - /** - * @brief Retrieve any placeholder text previously set. - * * @param[in] type Different placeholder-text can be shown when the control is active/inactive. * @param[out] A string of UTF-8 characters. */