From: Adeel Kazmi Date: Mon, 5 Jun 2017 10:19:20 +0000 (+0000) Subject: Merge "Text scroller renderer bug fix" into devel/master X-Git-Tag: dali_1.2.43~7 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=5e86784bcfbc88120549a72284a23b98adbc90ae;hp=1f83af06cada9c16b052c7f68e887378d5a7fd31 Merge "Text scroller renderer bug fix" into devel/master --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp index 5cacd19..9fd6789 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include using namespace Dali; @@ -93,9 +94,13 @@ const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableSc const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration"; const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration"; const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize"; +const char* const PROPERTY_NAME_LINE_COUNT = "lineCount"; +const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText"; +const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor"; const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND; +const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f ); const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color. const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval @@ -433,6 +438,9 @@ int UtcDaliTextEditorGetPropertyP(void) DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION ); DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION ); DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == DevelTextEditor::Property::PIXEL_SIZE ); + DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == DevelTextEditor::Property::LINE_COUNT ); + DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT ); + DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ); END_TEST; } @@ -725,6 +733,20 @@ int UtcDaliTextEditorSetPropertyP(void) editor.SetProperty( DevelTextEditor::Property::PIXEL_SIZE, 20.f ); DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + // Check placeholder text properties. + 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 ); + END_TEST; } @@ -1935,3 +1957,28 @@ int utcDaliTextEditorFontStylePropertyStringP(void) END_TEST; } +int utcDaliTextEditorGetPropertyLinecountP(void) +{ + ToolkitTestApplication application; + + tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property"); + + int lineCount =0 ; + + TextEditor editor = TextEditor::New(); + editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ; + editor.SetProperty( TextEditor::Property::TEXT, + "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST "); + + Stage::GetCurrent().Add( editor ); + + editor.SetSize( 100.0f, 100.0f ); + lineCount = editor.GetProperty( DevelTextEditor::Property::LINE_COUNT ); + DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION ); + + editor.SetSize( 50.0f, 100.0f ); + lineCount = editor.GetProperty( DevelTextEditor::Property::LINE_COUNT ); + DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION ); + + END_TEST; +} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp index 4c1e449..4e1fd0f 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -559,7 +559,7 @@ int UtcDaliToolkitTextlabelScrollingP(void) ToolkitTestApplication application; tet_infoline(" UtcDaliToolkitTextLabelScrollingP"); TextLabel labelImmediate = TextLabel::New("Some text to scroll"); - TextLabel labelFinished = TextLabel::New("Some text to scroll"); + TextLabel labelFinished = TextLabel::New("مرحبا بالعالم"); DALI_TEST_CHECK( labelImmediate ); DALI_TEST_CHECK( labelFinished ); @@ -605,6 +605,206 @@ int UtcDaliToolkitTextlabelScrollingP(void) END_TEST; } +int UtcDaliToolkitTextlabelScrollingCenterAlignP(void) +{ + ToolkitTestApplication application; + TextLabel labelShort = TextLabel::New("Some text to scroll"); + TextLabel labelLong = TextLabel::New("Some text to scroll that is greater than the width of the text. The quick brown fox jumps over the lazy dog. Hello World, we meet again!"); + + DALI_TEST_CHECK( labelShort ); + DALI_TEST_CHECK( labelLong ); + // Avoid a crash when core load gl resources. + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + Stage::GetCurrent().Add( labelShort ); + // Turn on all the effects + labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false ); + labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); + labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f ); + labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 ); + labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f ); + labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE ); + + Stage::GetCurrent().Add( labelLong ); + // Turn on all the effects + labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false ); + labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); + labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f ); + labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 ); + labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f ); + labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP ); + + try + { + // Render some text with the shared atlas backend + labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true ); + labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true ); + application.SendNotification(); + application.Render(); + + labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false ); + labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false ); + application.SendNotification(); + application.Render(); + + } + catch( ... ) + { + tet_result(TET_FAIL); + } + + END_TEST; +} + +int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void) +{ + ToolkitTestApplication application; + TextLabel labelShort = TextLabel::New("مرحبا بالعالم"); + TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي"); + + DALI_TEST_CHECK( labelShort ); + DALI_TEST_CHECK( labelLong ); + // Avoid a crash when core load gl resources. + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + Stage::GetCurrent().Add( labelShort ); + // Turn on all the effects + labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false ); + labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); + labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f ); + labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 ); + labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f ); + labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE ); + + Stage::GetCurrent().Add( labelLong ); + // Turn on all the effects + labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false ); + labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); + labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f ); + labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 ); + labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f ); + labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP ); + + try + { + // Render some text with the shared atlas backend + labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true ); + labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true ); + application.SendNotification(); + application.Render(); + + labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false ); + labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false ); + application.SendNotification(); + application.Render(); + + } + catch( ... ) + { + tet_result(TET_FAIL); + } + + END_TEST; +} + +int UtcDaliToolkitTextlabelScrollingEndAlignP(void) +{ + ToolkitTestApplication application; + TextLabel labelShort = TextLabel::New("Some text to scroll"); + TextLabel labelLong = TextLabel::New("Some text to scroll that is greater than the width of the text. The quick brown fox jumps over the lazy dog. Hello World, we meet again!"); + + DALI_TEST_CHECK( labelShort ); + DALI_TEST_CHECK( labelLong ); + // Avoid a crash when core load gl resources. + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + Stage::GetCurrent().Add( labelShort ); + // Turn on all the effects + labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false ); + labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" ); + labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f ); + labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 ); + labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f ); + labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE ); + + Stage::GetCurrent().Add( labelLong ); + // Turn on all the effects + labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false ); + labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" ); + labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f ); + labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 ); + labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f ); + labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP ); + + try + { + // Render some text with the shared atlas backend + labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true ); + labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true ); + application.SendNotification(); + application.Render(); + + labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false ); + labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false ); + application.SendNotification(); + application.Render(); + + } + catch( ... ) + { + tet_result(TET_FAIL); + } + + END_TEST; +} + +int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void) +{ + ToolkitTestApplication application; + TextLabel labelShort = TextLabel::New("مرحبا بالعالم"); + TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي"); + + DALI_TEST_CHECK( labelShort ); + DALI_TEST_CHECK( labelLong ); + // Avoid a crash when core load gl resources. + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + Stage::GetCurrent().Add( labelShort ); + // Turn on all the effects + labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false ); + labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" ); + labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f ); + labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 ); + labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f ); + labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE ); + + Stage::GetCurrent().Add( labelLong ); + // Turn on all the effects + labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false ); + labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" ); + labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f ); + labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 ); + labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f ); + labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP ); + + try + { + // Render some text with the shared atlas backend + labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true ); + labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true ); + application.SendNotification(); + application.Render(); + + labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false ); + labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false ); + application.SendNotification(); + application.Render(); + + } + catch( ... ) + { + tet_result(TET_FAIL); + } + + END_TEST; +} + int UtcDaliToolkitTextlabelScrollingInterruptedP(void) { ToolkitTestApplication application; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp index fd9f77f..1222bd5 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp @@ -53,8 +53,8 @@ Property::Map DefaultTransform() transformMap .Add( Toolkit::DevelVisual::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) ) .Add( Toolkit::DevelVisual::Transform::Property::SIZE, Vector2(1.0f, 1.0f) ) - .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::CENTER ) - .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER ) + .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN ) + .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN ) .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_POLICY, Vector2( Toolkit::DevelVisual::Transform::Policy::RELATIVE, Toolkit::DevelVisual::Transform::Policy::RELATIVE ) ) .Add( Toolkit::DevelVisual::Transform::Property::SIZE_POLICY, Vector2( Toolkit::DevelVisual::Transform::Policy::RELATIVE, Toolkit::DevelVisual::Transform::Policy::RELATIVE ) ); return transformMap; @@ -1437,12 +1437,12 @@ int UtcDaliVisualGetTransform(void) { Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::ORIGIN ); DALI_TEST_CHECK( typeValue ); - DALI_TEST_CHECK( (Toolkit::Align::Type)typeValue->Get() == Toolkit::Align::CENTER ); + DALI_TEST_CHECK( (Toolkit::Align::Type)typeValue->Get() == Toolkit::Align::TOP_BEGIN ); } { Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT ); DALI_TEST_CHECK( typeValue ); - DALI_TEST_CHECK( (Toolkit::Align::Type)typeValue->Get() == Toolkit::Align::CENTER ); + DALI_TEST_CHECK( (Toolkit::Align::Type)typeValue->Get() == Toolkit::Align::TOP_BEGIN ); } END_TEST; @@ -1454,7 +1454,7 @@ static void TestTransform( ToolkitTestApplication& application, Visual::Base vis transform.Insert( DevelVisual::Transform::Property::OFFSET, Vector2(10.0f, 10.0f) ); transform.Insert( DevelVisual::Transform::Property::SIZE, Vector2(0.2f, 0.2f) ); transform.Insert( DevelVisual::Transform::Property::OFFSET_POLICY, Vector2( Toolkit::DevelVisual::Transform::Policy::ABSOLUTE, Toolkit::DevelVisual::Transform::Policy::ABSOLUTE ) ); - transform.Insert( DevelVisual::Transform::Property::ORIGIN, "TOP_BEGIN" ); + transform.Insert( DevelVisual::Transform::Property::ORIGIN, "CENTER" ); transform.Insert( DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::BOTTOM_END ); visual.SetTransformAndSize( transform, Vector2(100, 100) ); @@ -1488,7 +1488,7 @@ static void TestTransform( ToolkitTestApplication& application, Visual::Base vis { Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::ORIGIN ); DALI_TEST_CHECK( typeValue ); - DALI_TEST_EQUALS( (Toolkit::Align::Type)typeValue->Get(), Toolkit::Align::TOP_BEGIN, TEST_LOCATION ); + DALI_TEST_EQUALS( (Toolkit::Align::Type)typeValue->Get(), Toolkit::Align::CENTER, TEST_LOCATION ); } { Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT ); @@ -1529,7 +1529,7 @@ static void TestTransform( ToolkitTestApplication& application, Visual::Base vis index = renderer.GetPropertyIndex( "origin" ); DALI_TEST_CHECK( index != Property::INVALID_INDEX ); Vector2 parentOrigin = renderer.GetProperty( index ); - DALI_TEST_EQUALS( parentOrigin, Vector2(-0.5f,-0.5f), TEST_LOCATION ); + DALI_TEST_EQUALS( parentOrigin, Vector2(0.0f,0.0f), TEST_LOCATION ); index = renderer.GetPropertyIndex( "anchorPoint" ); DALI_TEST_CHECK( index != Property::INVALID_INDEX ); @@ -1556,12 +1556,12 @@ static void TestTransform( ToolkitTestApplication& application, Visual::Base vis offsetSizeMode = renderer.GetProperty( renderer.GetPropertyIndex( "offsetSizeMode" ) ); DALI_TEST_EQUALS( offsetSizeMode, Vector4(0.0f,0.0f,1.0f,1.0f), TEST_LOCATION ); - //Parent origin and anchor point should have default values + //Parent origin and anchor point should have the default values parentOrigin = renderer.GetProperty( renderer.GetPropertyIndex( "origin" ) ); - DALI_TEST_EQUALS( parentOrigin, Vector2(0.0f,0.0f), TEST_LOCATION ); + DALI_TEST_EQUALS( parentOrigin, Vector2(-0.5f,-0.5f), TEST_LOCATION ); anchorPoint = renderer.GetProperty( renderer.GetPropertyIndex( "anchorPoint" ) ); - DALI_TEST_EQUALS( anchorPoint, Vector2(0.0f,0.0f), TEST_LOCATION ); + DALI_TEST_EQUALS( anchorPoint, Vector2(0.5f,0.5f), TEST_LOCATION ); } int UtcDaliVisualSetTransform0(void) diff --git a/dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h b/dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h index cff3a39..473adba 100644 --- a/dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h +++ b/dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h @@ -109,7 +109,26 @@ namespace Property * @brief The size of font in pixels. * @details name "pixelSize", type float */ - PIXEL_SIZE + PIXEL_SIZE, + + /** + * @brief The line count of text. + * @details name "lineCount", type int + * @note this property is read-only. + */ + LINE_COUNT, + + /** + * @brief The text to display when the TextEditor is empty and inactive. + * @details name "placeholderText", type string + */ + PLACEHOLDER_TEXT, + + /** + * @brief The placeholder-text color. + * @details name "placeholderTextColor", type vector4 + */ + PLACEHOLDER_TEXT_COLOR }; } // namespace Property diff --git a/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h b/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h index 40c6c70..12e9c75 100644 --- a/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h +++ b/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h @@ -83,6 +83,13 @@ namespace Property * values FINISH_LOOP, IMMEDIATE, defualt FINISH_LOOP */ AUTO_SCROLL_STOP_MODE = OUTLINE + 4, + + /* + * @brief The line count of text. + * @details name "lineCount", type int + * @node this property is read-only. + */ + LINE_COUNT = OUTLINE + 5 }; } // namespace Property diff --git a/dali-toolkit/devel-api/visuals/visual-properties-devel.h b/dali-toolkit/devel-api/visuals/visual-properties-devel.h index adecf39..18362b6 100644 --- a/dali-toolkit/devel-api/visuals/visual-properties-devel.h +++ b/dali-toolkit/devel-api/visuals/visual-properties-devel.h @@ -136,6 +136,7 @@ enum Type * @brief The origin of the visual within its control area. * @details Name "origin", type Align::Type (Property::INTEGER) or Property::STRING. * @see Toolkit::Align + * @note The default is Align::TOP_BEGIN. */ ORIGIN, @@ -143,6 +144,7 @@ enum Type * @brief The anchor-point of the visual * @details Name "anchorPoint", type Align::Type (Property::INTEGER) or Property::STRING. * @see Toolkit::Align + * @note The default is Align::TOP_BEGIN. */ ANCHOR_POINT, diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp index 5be99a6..ca78a26 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -32,6 +32,7 @@ // INTERNAL INCLUDES #include #include +#include #include #include #include @@ -134,6 +135,9 @@ DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "enableScrollBar", DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "scrollBarShowDuration", FLOAT, SCROLL_BAR_SHOW_DURATION ) DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "scrollBarFadeDuration", FLOAT, SCROLL_BAR_FADE_DURATION ) DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "pixelSize", FLOAT, PIXEL_SIZE ) +DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextEditor, "lineCount", INTEGER, LINE_COUNT ) +DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "placeholderText", STRING, PLACEHOLDER_TEXT ) +DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "placeholderTextColor", VECTOR4, PLACEHOLDER_TEXT_COLOR ) DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "textChanged", SIGNAL_TEXT_CHANGED ) DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED ) @@ -660,6 +664,32 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P } break; } + case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT: + { + if( impl.mController ) + { + 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 ); + } + break; + } + case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR: + { + if( impl.mController ) + { + const Vector4& textColor = value.Get< Vector4 >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p PLACEHOLDER_TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a ); + + if( impl.mController->GetPlaceholderTextColor() != textColor ) + { + impl.mController->SetPlaceholderTextColor( textColor ); + impl.mRenderer.Reset(); + } + } + break; + } } // switch } // texteditor } @@ -994,6 +1024,33 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind } break; } + case Toolkit::DevelTextEditor::Property::LINE_COUNT: + { + if( impl.mController ) + { + float width = textEditor.GetProperty( Actor::Property::SIZE_WIDTH ).Get(); + value = impl.mController->GetLineCount( width ); + } + break; + } + case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT: + { + if( impl.mController ) + { + std::string text; + impl.mController->GetPlaceholderText( text ); + value = text; + } + break; + } + case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR: + { + if( impl.mController ) + { + value = impl.mController->GetPlaceholderTextColor(); + } + break; + } } //switch } @@ -1459,6 +1516,15 @@ void TextEditor::UpdateScrollBar() mScrollBar.SetScrollPropertySource(self, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize); + // Set style name of ScrollBar for styling + mScrollBar.SetStyleName("TextEditorScrollBar"); + Toolkit::Control scrollIndicator = Toolkit::Control::DownCast( mScrollBar.GetScrollIndicator() ); + if( scrollIndicator ) + { + // Set style name of ScrollBarIndicator for styling + scrollIndicator.SetStyleName("TextEditorScrollBarIndicator"); + } + self.Add( mScrollBar ); } else diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp index b1c031c..5f17f00 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -117,7 +117,8 @@ DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "outline", MAP DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "pixelSize", FLOAT, PIXEL_SIZE ) DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "ellipsis", BOOLEAN, ELLIPSIS ) DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollLoopDelay", FLOAT, AUTO_SCROLL_LOOP_DELAY ) -DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollStopMode", STRING, AUTO_SCROLL_STOP_MODE ) +DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollStopMode", STRING, AUTO_SCROLL_STOP_MODE ) +DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextLabel, "lineCount", INTEGER, LINE_COUNT ) DALI_TYPE_REGISTRATION_END() @@ -349,7 +350,7 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr { if( impl.mTextScroller ) { - impl.mTextScroller->SetLoopCount( 0 ); // Causes the current animation to finish playing (0) + impl.mTextScroller->StopScrolling(); } } // If request is enable (true) then start autoscroll as not already running @@ -736,6 +737,15 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde } break; } + case Toolkit::DevelTextLabel::Property::LINE_COUNT: + { + if( impl.mController ) + { + float width = label.GetProperty( Actor::Property::SIZE_WIDTH ).Get(); + value = impl.mController->GetLineCount( width ); + } + break; + } } } @@ -881,7 +891,7 @@ void TextLabel::SetUpAutoScrolling() // If speed, loopCount or gap not set via property system then will need to create a TextScroller with defaults mTextScroller = Text::TextScroller::New( *this ); } - mTextScroller->SetParameters( mRenderableActor, controlSize, offScreenSize, direction, alignmentOffset ); + mTextScroller->SetParameters( mRenderableActor, controlSize, offScreenSize, direction, alignmentOffset, mController->GetHorizontalAlignment() ); Actor self = Self(); self.Add( mTextScroller->GetScrollingText() ); diff --git a/dali-toolkit/internal/text/layouts/layout-alignment.h b/dali-toolkit/internal/text/layouts/layout-alignment.h index df61ff2..339b321 100644 --- a/dali-toolkit/internal/text/layouts/layout-alignment.h +++ b/dali-toolkit/internal/text/layouts/layout-alignment.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_LAYOUT_ALIGNMENT_H /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,6 +53,12 @@ enum VerticalAlignment VERTICAL_ALIGN_BOTTOM }; +enum AlignmentCount +{ + HORIZONTAL_ALIGN_COUNT = HORIZONTAL_ALIGN_END + 1, + VERTICAL_ALIGN_COUNT = VERTICAL_ALIGN_BOTTOM + 1 +}; + } // namespace Layout } // namespace Text diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index d09e1ed..f119650 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -70,6 +70,7 @@ namespace Text EventData::EventData( DecoratorPtr decorator ) : mDecorator( decorator ), mImfManager(), + mPlaceholderText(), mPlaceholderTextActive(), mPlaceholderTextInactive(), mPlaceholderTextColor( 0.8f, 0.8f, 0.8f, 0.8f ), diff --git a/dali-toolkit/internal/text/text-controller-impl.h b/dali-toolkit/internal/text/text-controller-impl.h index 3014edb..e9d99f1 100644 --- a/dali-toolkit/internal/text/text-controller-impl.h +++ b/dali-toolkit/internal/text/text-controller-impl.h @@ -104,6 +104,7 @@ struct EventData DecoratorPtr mDecorator; ///< Pointer to the decorator. ImfManager mImfManager; ///< The Input Method Framework Manager. + std::string mPlaceholderText; ///< The text to display when the TextField is empty. std::string mPlaceholderTextActive; ///< The text to display when the TextField is empty with key-input focus. std::string mPlaceholderTextInactive; ///< The text to display when the TextField is empty and inactive. Vector4 mPlaceholderTextColor; ///< The in/active placeholder text color. @@ -383,10 +384,9 @@ struct Controller::Impl */ bool IsPlaceholderAvailable() const { - return ( mEventData && - ( !mEventData->mPlaceholderTextInactive.empty() || - !mEventData->mPlaceholderTextActive.empty() ) - ); + return ( mEventData && ( !mEventData->mPlaceholderText.empty() || + !mEventData->mPlaceholderTextInactive.empty() || + !mEventData->mPlaceholderTextActive.empty() ) ); } bool IsShowingPlaceholderText() const @@ -399,7 +399,8 @@ struct Controller::Impl */ bool IsFocusedPlaceholderAvailable() const { - return ( mEventData && !mEventData->mPlaceholderTextActive.empty() ); + return ( mEventData && ( !mEventData->mPlaceholderTextActive.empty() || + !mEventData->mPlaceholderText.empty() ) ); } bool IsShowingRealText() const diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index a502200..f9445b5 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -512,6 +512,22 @@ void Controller::GetText( std::string& text ) const } } +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 ) @@ -534,6 +550,15 @@ void Controller::SetPlaceholderText( PlaceholderType type, const std::string& te } } +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 ) @@ -1599,6 +1624,13 @@ float Controller::GetHeightForWidth( float width ) return layoutSize.height; } +int Controller::GetLineCount( float width ) +{ + GetHeightForWidth( width ); + int numberofLines = mImpl->mModel->GetNumberOfLines(); + return numberofLines; +} + const ModelInterface* const Controller::GetTextModel() const { return mImpl->mModel.Get(); @@ -3195,17 +3227,27 @@ void Controller::ShowPlaceholderText() const char* text( NULL ); size_t size( 0 ); - // TODO - Switch placeholder text styles when changing state - if( ( EventData::INACTIVE != mImpl->mEventData->mState ) && - ( 0u != mImpl->mEventData->mPlaceholderTextActive.c_str() ) ) + if( !mImpl->mEventData->mPlaceholderTextActive.empty() || !mImpl->mEventData->mPlaceholderTextInactive.empty() ) { - text = mImpl->mEventData->mPlaceholderTextActive.c_str(); - size = mImpl->mEventData->mPlaceholderTextActive.size(); + 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(); + } } else { - text = mImpl->mEventData->mPlaceholderTextInactive.c_str(); - size = mImpl->mEventData->mPlaceholderTextInactive.size(); + if( 0u != mImpl->mEventData->mPlaceholderText.c_str() ) + { + text = mImpl->mEventData->mPlaceholderText.c_str(); + size = mImpl->mEventData->mPlaceholderText.size(); + } } mImpl->mTextUpdateInfo.mCharacterIndex = 0u; diff --git a/dali-toolkit/internal/text/text-controller.h b/dali-toolkit/internal/text/text-controller.h index 7562394..c6b01a4 100644 --- a/dali-toolkit/internal/text/text-controller.h +++ b/dali-toolkit/internal/text/text-controller.h @@ -454,6 +454,13 @@ 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. */ @@ -462,6 +469,13 @@ public: // Update. /** * @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. */ @@ -910,6 +924,13 @@ public: // Queries & retrieves. float GetHeightForWidth( float width ); /** + * @brief Retrieves the text's number of lines for a given width. + * @param[in] width The width of the text's area. + * @ return The number of lines. + */ + int GetLineCount( float width ); + + /** * @brief Retrieves the text's model. * * @return A pointer to the text's model. diff --git a/dali-toolkit/internal/text/text-scroller.cpp b/dali-toolkit/internal/text/text-scroller.cpp index adcf901..590f919 100644 --- a/dali-toolkit/internal/text/text-scroller.cpp +++ b/dali-toolkit/internal/text/text-scroller.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,7 +58,7 @@ const char* VERTEX_SHADER_SCROLL = DALI_COMPOSE_SHADER( uniform mediump float uDelta;\n uniform mediump vec2 uTextureSize; uniform mediump float uGap;\n - uniform mediump float uRtl;\n + uniform mediump float uAlign;\n \n void main()\n {\n @@ -70,7 +70,7 @@ const char* VERTEX_SHADER_SCROLL = DALI_COMPOSE_SHADER( float smallTextPadding = max(uSize.x - uTextureSize.x, 0. );\n float gap = max( uGap, smallTextPadding );\n float delta = floor ( uDelta ) + 0.5; - vTexCoord.x = ( delta + ( uRtl * ( uTextureSize.x - uSize.x ) ) + ( aPosition.x * uSize.x ) )/ ( uTextureSize.x + gap );\n + vTexCoord.x = ( delta + ( uAlign * ( uTextureSize.x - uSize.x ) ) + ( aPosition.x * uSize.x ) )/ ( uTextureSize.x + gap );\n vTexCoord.y = ( 0.5 + floor( aPosition.y * uSize.y ) )/ ( uTextureSize.y ) ;\n vRatio = uTextureSize.x / ( uTextureSize.x + gap );\n gl_Position = uProjection * vertexPosition; @@ -96,6 +96,54 @@ const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER( ); /** + * @brief How the text should be aligned when scrolling the text. + * + * 0.0f aligns the text to the left, 1.0f aligns the text to the right. + * The final alignment depends on three factors: + * 1) The alignment value of the text label (Use Text::Layout::HorizontalAlignment enumerations). + * 2) The text direction, i.e. whether it's LTR or RTL (0 = LTR, 1 = RTL). + * 3) Whether the text is greater than the size of the control ( 0 = Text width <= Control width, 1 = Text width > Control width ). + */ +const float ALIGNMENT_TABLE[ Text::Layout::HORIZONTAL_ALIGN_COUNT ][ 2 ][ 2 ] = +{ + // HORIZONTAL_ALIGN_BEGIN + { + { // LTR + 0.0f, // Text width <= Control width + 0.0f // Text width > Control width + }, + { // RTL + 1.0f, // Text width <= Control width + 1.0f // Text width > Control width + } + }, + + // HORIZONTAL_ALIGN_CENTER + { + { // LTR + 0.5f, // Text width <= Control width + 0.0f // Text width > Control width + }, + { // RTL + 0.5f, // Text width <= Control width + 1.0f // Text width > Control width + } + }, + + // HORIZONTAL_ALIGN_END + { + { // LTR + 1.0f, // Text width <= Control width + 0.0f // Text width > Control width + }, + { // RTL + 0.0f, // Text width <= Control width + 1.0f // Text width > Control width + } + } +}; + +/** * @brief Create and set up a camera for the render task to use * * @param[in] sizeOfTarget size of the source camera to look at @@ -225,35 +273,11 @@ int TextScroller::GetSpeed() const void TextScroller::SetLoopCount( int loopCount ) { - if ( loopCount > 0 ) + if ( loopCount >= 0 ) { mLoopCount = loopCount; } - if ( mScrollAnimation && mScrollAnimation.GetState() == Animation::PLAYING ) - { - if ( loopCount == 0 ) // Request to stop looping - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetLoopCount Single loop forced\n" ); - switch( mStopMode ) - { - case DevelTextLabel::AutoScrollStopMode::IMMEDIATE: - { - mScrollAnimation.Stop(); - break; - } - case DevelTextLabel::AutoScrollStopMode::FINISH_LOOP: - { - mScrollAnimation.SetLoopCount( 1 ); // As animation already playing this allows the current animation to finish instead of trying to stop mid-way - break; - } - default: - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Undifined AutoScrollStopMode\n" ); - } - } - } - } DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetLoopCount [%d] Status[%s]\n", mLoopCount, (loopCount)?"looping":"stop" ); } @@ -278,6 +302,32 @@ void TextScroller::SetStopMode( DevelTextLabel::AutoScrollStopMode::Type stopMod mStopMode = stopMode; } +void TextScroller::StopScrolling() +{ + if ( mScrollAnimation && mScrollAnimation.GetState() == Animation::PLAYING ) + { + switch( mStopMode ) + { + case DevelTextLabel::AutoScrollStopMode::IMMEDIATE: + { + mScrollAnimation.Stop(); + CleanUp(); + mScrollerInterface.ScrollingFinished(); + break; + } + case DevelTextLabel::AutoScrollStopMode::FINISH_LOOP: + { + mScrollAnimation.SetLoopCount( 1 ); // As animation already playing this allows the current animation to finish instead of trying to stop mid-way + break; + } + default: + { + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Undifined AutoScrollStopMode\n" ); + } + } + } +} + DevelTextLabel::AutoScrollStopMode::Type TextScroller::GetStopMode() const { return mStopMode; @@ -309,15 +359,27 @@ TextScroller::~TextScroller() CleanUp(); } -void TextScroller::SetParameters( Actor sourceActor, const Size& controlSize, const Size& offScreenSize, CharacterDirection direction, float alignmentOffset ) +void TextScroller::SetParameters( Actor sourceActor, const Size& controlSize, const Size& offScreenSize, CharacterDirection direction, float alignmentOffset, Layout::HorizontalAlignment horizontalAlignment ) { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetParameters controlSize[%f,%f] offscreenSize[%f,%f] direction[%d] alignmentOffset[%f]\n", controlSize.x, controlSize.y, offScreenSize.x, offScreenSize.y, direction, alignmentOffset ); CleanUp(); // If already scrolling then restart with new parameters + float animationProgress = 0.0f; + int remainedLoop = mLoopCount; if ( mScrollAnimation ) { + if( mScrollAnimation.GetState() == Animation::PLAYING ) + { + animationProgress = mScrollAnimation.GetCurrentProgress(); + + if( mLoopCount > 0 ) // If not a ininity loop, then calculate remained loop + { + remainedLoop = mLoopCount - ( mScrollAnimation.GetCurrentLoop() ); + remainedLoop = ( remainedLoop <= 0 ? 1 : remainedLoop ); + } + } mScrollAnimation.Clear(); } @@ -328,24 +390,58 @@ void TextScroller::SetParameters( Actor sourceActor, const Size& controlSize, co CreateRenderer( offscreenRenderTargetForText, renderer ); CreateRenderTask( sourceActor, mOffscreenCameraActor, offscreenRenderTargetForText, mRenderTask ); - // Reposition camera to match alignment of target, RTL text has direction=true - if ( direction ) - { - mOffscreenCameraActor.SetX( alignmentOffset + offScreenSize.width*0.5f ); - } - else + float xPosition = 0.0f; + switch( horizontalAlignment ) { - mOffscreenCameraActor.SetX( offScreenSize.width * 0.5f ); + case Layout::HORIZONTAL_ALIGN_BEGIN: + { + // Reposition camera to match alignment of target, RTL text has direction=true + if ( direction ) + { + xPosition = alignmentOffset + offScreenSize.width * 0.5f; + } + else + { + xPosition = offScreenSize.width * 0.5f; + } + break; + } + + case Layout::HORIZONTAL_ALIGN_CENTER: + { + xPosition = controlSize.width * 0.5f; + break; + } + + case Layout::HORIZONTAL_ALIGN_END: + { + // Reposition camera to match alignment of target, RTL text has direction=true + if ( direction ) + { + xPosition = offScreenSize.width * 0.5f; + } + else + { + xPosition = alignmentOffset + offScreenSize.width * 0.5f; + } + break; + } } + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetParameters xPosition[%f]\n", xPosition ); + + mOffscreenCameraActor.SetX( xPosition ); mOffscreenCameraActor.SetY( offScreenSize.height * 0.5f ); - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetParameters mWrapGap[%f]\n", mWrapGap ) + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetParameters mWrapGap[%f]\n", mWrapGap ); + + const float align = ALIGNMENT_TABLE[ horizontalAlignment ][ direction ][ offScreenSize.width > controlSize.width ]; + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetParameters align[%f]\n", align ); mScrollingTextActor = Actor::New(); mScrollingTextActor.AddRenderer( renderer ); mScrollingTextActor.RegisterProperty( "uTextureSize", offScreenSize ); - mScrollingTextActor.RegisterProperty( "uRtl", ((direction)?1.0f:0.0f) ); + mScrollingTextActor.RegisterProperty( "uAlign", align ); mScrollingTextActor.RegisterProperty( "uGap", mWrapGap ); mScrollingTextActor.SetSize( controlSize.width, std::min( offScreenSize.height, controlSize.height ) ); mScrollDeltaIndex = mScrollingTextActor.RegisterProperty( "uDelta", 0.0f ); @@ -358,7 +454,8 @@ void TextScroller::SetParameters( Actor sourceActor, const Size& controlSize, co scrollAmount = -scrollAmount; // reverse direction of scrollung } - StartScrolling( scrollAmount, scrollDuration, mLoopCount ); + StartScrolling( scrollAmount, scrollDuration, remainedLoop ); + mScrollAnimation.SetCurrentProgress(animationProgress); } void TextScroller::AutoScrollAnimationFinished( Dali::Animation& animation ) diff --git a/dali-toolkit/internal/text/text-scroller.h b/dali-toolkit/internal/text/text-scroller.h index f6c0b87..2d611bb 100644 --- a/dali-toolkit/internal/text/text-scroller.h +++ b/dali-toolkit/internal/text/text-scroller.h @@ -2,7 +2,7 @@ #define __DALI_TOOLKIT_TEXT_SCROLLER_H__ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,10 +22,11 @@ #include #include #include -#include // INTERNAL INCLUDES +#include #include +#include namespace Dali { @@ -66,7 +67,7 @@ public: * @param[in] alignmentOffset alignment of source text * */ - void SetParameters( Actor sourceActor, const Size& controlSize, const Size& offScreenSize, CharacterDirection direction, float alignmentOffset ); + void SetParameters( Actor sourceActor, const Size& controlSize, const Size& offScreenSize, CharacterDirection direction, float alignmentOffset, Layout::HorizontalAlignment horizontalAlignment ); /** * @brief Set the gap distance to elapse before the text wraps around @@ -123,6 +124,11 @@ public: void SetStopMode( DevelTextLabel::AutoScrollStopMode::Type stopMode ); /** + * @brief Stop the auto scrolling. + */ + void StopScrolling(); + + /** * @brief Get the mode of scrolling stop * @return stopMode type when text scrolling is stoped. */ diff --git a/dali-toolkit/internal/visuals/visual-base-data-impl.cpp b/dali-toolkit/internal/visuals/visual-base-data-impl.cpp index 4b14eca..16af15d 100644 --- a/dali-toolkit/internal/visuals/visual-base-data-impl.cpp +++ b/dali-toolkit/internal/visuals/visual-base-data-impl.cpp @@ -241,8 +241,8 @@ Internal::Visual::Base::Impl::Transform::Transform() : mOffset( 0.0f,0.0f ), mSize( 1.0f,1.0f ), mOffsetSizeMode( 0.0f,0.0f,0.0f,0.0f ), - mOrigin( Toolkit::Align::CENTER ), - mAnchorPoint( Toolkit::Align::CENTER ) + mOrigin( Toolkit::Align::TOP_BEGIN ), + mAnchorPoint( Toolkit::Align::TOP_BEGIN ) { } @@ -252,8 +252,8 @@ void Internal::Visual::Base::Impl::Transform::SetPropertyMap( const Property::Ma mOffset = Vector2( 0.0f,0.0f ); mSize = Vector2( 1.0f,1.0f ); mOffsetSizeMode = Vector4( 0.0f,0.0f,0.0f,0.0f ); - mOrigin = Toolkit::Align::CENTER; - mAnchorPoint = Toolkit::Align::CENTER; + mOrigin = Toolkit::Align::TOP_BEGIN; + mAnchorPoint = Toolkit::Align::TOP_BEGIN; UpdatePropertyMap( map ); } diff --git a/dali-toolkit/public-api/dali-toolkit-version.cpp b/dali-toolkit/public-api/dali-toolkit-version.cpp index c4d336c..a96fab6 100644 --- a/dali-toolkit/public-api/dali-toolkit-version.cpp +++ b/dali-toolkit/public-api/dali-toolkit-version.cpp @@ -31,7 +31,7 @@ namespace Toolkit const unsigned int TOOLKIT_MAJOR_VERSION = 1; const unsigned int TOOLKIT_MINOR_VERSION = 2; -const unsigned int TOOLKIT_MICRO_VERSION = 41; +const unsigned int TOOLKIT_MICRO_VERSION = 42; const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__; #ifdef DEBUG_ENABLED diff --git a/packaging/dali-toolkit.spec b/packaging/dali-toolkit.spec index dca59a9..c34d9aa 100644 --- a/packaging/dali-toolkit.spec +++ b/packaging/dali-toolkit.spec @@ -1,6 +1,6 @@ Name: dali-toolkit Summary: The OpenGLES Canvas Core Library Toolkit -Version: 1.2.41 +Version: 1.2.42 Release: 1 Group: System/Libraries License: Apache-2.0 and BSD-3-Clause and MIT