From: Jinho, Lee Date: Tue, 25 Jul 2017 04:41:48 +0000 (+0900) Subject: Calculate a new height when text was changed. X-Git-Tag: dali_1.2.50~1^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=d0d1c5d3cde438a08ccb78cc9c435edebfbd9717 Calculate a new height when text was changed. Even in the same font and size, sometimes they have different heights when inputting multiple langeages. Change-Id: I83513ef4d190c71ab880f60b8ea2d788688ce0d9 --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index b1f4d07..05c9b25 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -2453,3 +2453,50 @@ int utcDaliTextFieldSomeSpecialKeys(void) END_TEST; } + +int utcDaliTextFieldSizeUpdate(void) +{ + ToolkitTestApplication application; + tet_infoline("utcDaliTextFieldSizeUpdate"); + + // Checks some special keys when the text is selected. + TextField field = TextField::New(); + DALI_TEST_CHECK( field ); + Stage::GetCurrent().Add( field ); + + float previousHeight = 0.0f; + float currentHeight = 0.0f; + const float fieldWidth = 1920.0f; + + + // "ㅁ" is bigger then "ኢ" + field.SetSize( Vector2( fieldWidth ,10.0f ) ); + field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH ); + field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT ); + + field.SetProperty( TextField::Property::TEXT, "ኢ"); + field.SetParentOrigin( ParentOrigin::TOP_LEFT ); + field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + + field.SetKeyboardFocusable(true); + KeyboardFocusManager::Get().SetCurrentFocusActor( field ); + + application.SendNotification(); + application.Render(); + + previousHeight = field.GetHeightForWidth( fieldWidth ); + DALI_TEST_EQUALS( previousHeight, field.GetProperty( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION ); + + // Add another script characters ( glyph height is defferent ) + application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) ); + application.ProcessEvent( GenerateKey( "ㅁ", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) ); + + application.SendNotification(); + application.Render(); + + currentHeight = field.GetHeightForWidth( fieldWidth ); + DALI_TEST_EQUALS( currentHeight, field.GetProperty( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION ); + DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION ); + + END_TEST; +} diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index a0daf14..1fde4bc 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -1793,7 +1793,8 @@ float Controller::GetHeightForWidth( float width ) Size layoutSize; if( fabsf( width - mImpl->mModel->mVisualModel->mControlSize.width ) > Math::MACHINE_EPSILON_1000 || - mImpl->mTextUpdateInfo.mFullRelayoutNeeded ) + mImpl->mTextUpdateInfo.mFullRelayoutNeeded || + mImpl->mTextUpdateInfo.mClearAll ) { // Operations that can be done only once until the text changes. const OperationsMask onlyOnceOperations = static_cast( CONVERT_TO_UTF32 |