From: dongsug song Date: Wed, 23 Nov 2016 12:12:02 +0000 (-0800) Subject: Merge "Update README for dali-swig" into devel/master X-Git-Tag: dali_1.2.16~7 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=a68dbe03813fd3db34c81f4e6960572e8882930b;hp=888a6d8a0f33095753487d7d0f5a8a0a0c2b9a83 Merge "Update README for dali-swig" into devel/master --- diff --git a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt index 4a9a003..99ee1db 100644 --- a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt @@ -21,6 +21,8 @@ SET(TC_SOURCES utc-Dali-VisualFactoryResolveUrl.cpp utc-Dali-Visuals.cpp utc-Dali-Text-Markup.cpp + utc-Dali-Text-Typesetter.cpp + utc-Dali-Text-ViewModel.cpp ) # Append list of test harness files (Won't get parsed for test cases) @@ -53,7 +55,7 @@ LIST(APPEND TC_SOURCES ../dali-toolkit/dali-toolkit-test-utils/test-render-controller.cpp ../dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp ../dali-toolkit/dali-toolkit-test-utils/test-native-image.cpp - dali-toolkit-test-utils/toolkit-text-model.cpp + dali-toolkit-test-utils/toolkit-text-utils.cpp ) diff --git a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-model.cpp b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp similarity index 76% rename from automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-model.cpp rename to automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp index 104b3c8..31d81af 100644 --- a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-model.cpp +++ b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp @@ -15,9 +15,11 @@ * */ -#include "toolkit-text-model.h" +// FILE HEADER +#include "toolkit-text-utils.h" // EXTERNAL INCLUDES +#include #include // INTERNAL INCLUDES @@ -260,25 +262,26 @@ void CreateTextModel( const std::string& text, } // 9) Layout the text - LayoutEngine layoutEngine; + Layout::Engine layoutEngine; layoutEngine.SetMetrics( metrics ); - layoutEngine.SetLayout( LayoutEngine::MULTI_LINE_BOX ); + layoutEngine.SetLayout( Layout::Engine::MULTI_LINE_BOX ); // Set the layout parameters. const Vector& charactersToGlyph = visualModel->mCharactersToGlyph; const Vector& glyphsPerCharacter = visualModel->mGlyphsPerCharacter; - LayoutParameters layoutParameters( textArea, - utf32Characters.Begin(), - lineBreakInfo.Begin(), - wordBreakInfo.Begin(), - ( 0u != characterDirections.Count() ) ? characterDirections.Begin() : NULL, - glyphs.Begin(), - glyphsToCharactersMap.Begin(), - charactersPerGlyph.Begin(), - charactersToGlyph.Begin(), - glyphsPerCharacter.Begin(), - numberOfGlyphs ); + Layout::Parameters layoutParameters( textArea, + utf32Characters.Begin(), + lineBreakInfo.Begin(), + wordBreakInfo.Begin(), + ( 0u != characterDirections.Count() ) ? characterDirections.Begin() : NULL, + glyphs.Begin(), + glyphsToCharactersMap.Begin(), + charactersPerGlyph.Begin(), + charactersToGlyph.Begin(), + glyphsPerCharacter.Begin(), + numberOfGlyphs, + Layout::HORIZONTAL_ALIGN_BEGIN ); Vector& lines = visualModel->mLines; @@ -296,7 +299,8 @@ void CreateTextModel( const std::string& text, layoutEngine.LayoutText( layoutParameters, glyphPositions, lines, - layoutSize ); + layoutSize, + false ); // 10) Reorder the lines if( 0u != bidirectionalInfo.Count() ) @@ -333,10 +337,91 @@ void CreateTextModel( const std::string& text, layoutEngine.Align( textArea, 0u, numberOfCharacters, + Layout::HORIZONTAL_ALIGN_BEGIN, lines ); } } +void ConfigureTextLabel( ControllerPtr controller ) +{ + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); + fontClient.SetDpi( 93u, 93u ); + + // Set the text layout as multi-line. + controller->GetLayoutEngine().SetLayout( Layout::Engine::MULTI_LINE_BOX ); + + // Set cursor's width to zero. + controller->GetLayoutEngine().SetCursorWidth( 0 ); + + // Disables the text input. + controller->EnableTextInput( NULL ); + + // Disables the vertical scrolling. + controller->SetVerticalScrollEnabled( false ); + + // Disables the horizontal scrolling. + controller->SetHorizontalScrollEnabled( false ); + + // Enable the text elide. + controller->SetTextElideEnabled( true ); +} + +void ConfigureTextField( ControllerPtr controller ) +{ + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); + fontClient.SetDpi( 93u, 93u ); + + // Creates a decorator. + Text::DecoratorPtr decorator = Text::Decorator::New( *controller, + *controller ); + + // Set the text layout as multi-line. + controller->GetLayoutEngine().SetLayout( Layout::Engine::SINGLE_LINE_BOX ); + + // Enables the text input. + controller->EnableTextInput( decorator ); + + // Enables the vertical scrolling after the text input has been enabled. + controller->SetVerticalScrollEnabled( false ); + + // Disables the horizontal scrolling. + controller->SetHorizontalScrollEnabled( true ); + + // No maximum number of characters. + controller->SetMaximumNumberOfCharacters( 50u ); + + // Disable the text elide. + controller->SetTextElideEnabled( false ); +} + +void ConfigureTextEditor( ControllerPtr controller ) +{ + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); + fontClient.SetDpi( 93u, 93u ); + + // Creates a decorator. + Text::DecoratorPtr decorator = Text::Decorator::New( *controller, + *controller ); + + // Set the text layout as multi-line. + controller->GetLayoutEngine().SetLayout( Layout::Engine::MULTI_LINE_BOX ); + + // Enables the text input. + controller->EnableTextInput( decorator ); + + // Enables the vertical scrolling after the text input has been enabled. + controller->SetVerticalScrollEnabled( true ); + + // Disables the horizontal scrolling. + controller->SetHorizontalScrollEnabled( false ); + + // No maximum number of characters. + controller->SetMaximumNumberOfCharacters( std::numeric_limits::max() ); + + // Disable the text elide. + controller->SetTextElideEnabled( false ); +} + } // namespace Text } // namespace Toolkit diff --git a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-model.h b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.h similarity index 73% rename from automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-model.h rename to automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.h index 288627f..2391cb1 100644 --- a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-model.h +++ b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.h @@ -1,5 +1,5 @@ -#ifndef __DALI_TOOLKIT_TEXT_MODEL_H__ -#define __DALI_TOOLKIT_TEXT_MODEL_H__ +#ifndef __DALI_TOOLKIT_TEXT_UTILS_H__ +#define __DALI_TOOLKIT_TEXT_UTILS_H__ /* * Copyright (c) 2016 Samsung Electronics Co., Ltd. @@ -18,12 +18,11 @@ * */ -// EXTERNAL INCLUDES - // INTERNAL INCLUDES #include #include #include +#include namespace Dali { @@ -70,10 +69,31 @@ void CreateTextModel( const std::string& text, VisualModelPtr& visualModel, MetricsPtr& metrics ); +/** + * @brief Configures the text @p controller similarly to the one configured by the text-label. + * + * @param[in,out] The text controller to configure. + */ +void ConfigureTextLabel( ControllerPtr controller ); + +/** + * @brief Configures the text @p controller similarly to the one configured by the text-field. + * + * @param[in,out] The text controller to configure. + */ +void ConfigureTextField( ControllerPtr controller ); + +/** + * @brief Configures the text @p controller similarly to the one configured by the text-editor. + * + * @param[in,out] The text controller to configure. + */ +void ConfigureTextEditor( ControllerPtr controller ); + } // namespace Text } // namespace Toolkit } // namespace Dali -#endif // __DALI_TOOLKIT_TEXT_MODEL_H__ +#endif // __DALI_TOOLKIT_TEXT_UTILS_H__ diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-BidirectionalSupport.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-BidirectionalSupport.cpp index 629e4f3..37b5277 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-BidirectionalSupport.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-BidirectionalSupport.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include using namespace Dali; using namespace Toolkit; diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-LogicalModel.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-LogicalModel.cpp index 25a724c..f8df615 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-LogicalModel.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-LogicalModel.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include using namespace Dali; diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp index cdb29f9..b92f090 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp @@ -19,10 +19,10 @@ #include #include -#include #include #include +#include #include #include #include @@ -43,34 +43,6 @@ const char* const OPTION_CLIPBOARD("optionClipboard"); // "Clipboard" popup const Size CONTROL_SIZE( 300.f, 60.f ); -const std::string DEFAULT_FONT_DIR( "/resources/fonts" ); - -class ControlImpl : public ControlInterface, public Text::EditableControlInterface -{ -public: - ControlImpl() - : ControlInterface() - {} - - virtual ~ControlImpl() - {} - - virtual void AddDecoration( Actor& actor, bool needsClipping ) - {} - - virtual void RequestTextRelayout() - {} - - virtual void TextChanged() - {} - - virtual void MaxLengthReached() - {} - - virtual void InputStyleChanged( InputStyle::Mask inputStyleMask ) - {} -}; - std::string gClipboardText; void ContentSelectedCallback( ClipboardEventNotifier& notifier ) { @@ -86,9 +58,73 @@ int UtcDaliTextController(void) // Creates a text controller. ControllerPtr controller = Controller::New(); + DALI_TEST_CHECK( controller ); + + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliTextControllerSetGetScrollEnabled(void) +{ + tet_infoline(" UtcDaliTextControllerSetGetScrollEnabled"); + ToolkitTestApplication application; + // Creates a text controller. + ControllerPtr controller = Controller::New(); DALI_TEST_CHECK( controller ); + // Configures the text controller similarly to the text-editor. + ConfigureTextEditor( controller ); + + DALI_TEST_CHECK( !controller->IsHorizontalScrollEnabled() ); + DALI_TEST_CHECK( controller->IsVerticalScrollEnabled() ); + + // Configures the text controller similarly to the text-field. + ConfigureTextField( controller ); + + DALI_TEST_CHECK( controller->IsHorizontalScrollEnabled() ); + DALI_TEST_CHECK( !controller->IsVerticalScrollEnabled() ); + + // Configures the text controller similarly to the text-label. + ConfigureTextLabel( controller ); + + DALI_TEST_CHECK( !controller->IsHorizontalScrollEnabled() ); + DALI_TEST_CHECK( !controller->IsVerticalScrollEnabled() ); + + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliTextControllerSetIsTextElide(void) +{ + tet_infoline(" UtcDaliTextControllerSetIsTextElide"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + DALI_TEST_CHECK( controller ); + + // Configures the text controller similarly to the text-editor. + ConfigureTextEditor( controller ); + DALI_TEST_EQUALS( false, controller->IsTextElideEnabled(), TEST_LOCATION ); + + controller->SetTextElideEnabled( true ); + DALI_TEST_EQUALS( true, controller->IsTextElideEnabled(), TEST_LOCATION ); + + // Configures the text controller similarly to the text-field. + ConfigureTextField( controller ); + DALI_TEST_EQUALS( false, controller->IsTextElideEnabled(), TEST_LOCATION ); + + controller->SetTextElideEnabled( true ); + DALI_TEST_EQUALS( true, controller->IsTextElideEnabled(), TEST_LOCATION ); + + // Configures the text controller similarly to the text-label. + ConfigureTextLabel( controller ); + DALI_TEST_EQUALS( true, controller->IsTextElideEnabled(), TEST_LOCATION ); + + controller->SetTextElideEnabled( false ); + DALI_TEST_EQUALS( false, controller->IsTextElideEnabled(), TEST_LOCATION ); + tet_result(TET_PASS); END_TEST; } @@ -100,7 +136,6 @@ int UtcDaliTextControllerEnableCursorBlinking(void) // Creates a text controller. ControllerPtr controller = Controller::New(); - DALI_TEST_CHECK( controller ); // There is no text input enabled. diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Cursor.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Cursor.cpp index 195c81b..1755b8b 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Cursor.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Cursor.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include using namespace Dali; diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp index 4d42843..80c4631 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include using namespace Dali; using namespace Toolkit; @@ -51,7 +51,7 @@ struct LayoutTextData float* positions; unsigned int numberOfLines; LineRun* lines; - LayoutEngine::Layout layout; + Layout::Engine::Type layout; unsigned int startIndex; unsigned int numberOfGlyphs; bool ellipsis:1; @@ -152,24 +152,24 @@ bool LayoutTextTest( const LayoutTextData& data ) glyphPositions.Begin() + data.startIndex + data.numberOfGlyphs ); // 3) Layout - LayoutEngine engine; + Layout::Engine engine; engine.SetMetrics( metrics ); - engine.SetTextEllipsisEnabled( data.ellipsis ); engine.SetLayout( data.layout ); const Length totalNumberOfGlyphs = visualModel->mGlyphs.Count(); - LayoutParameters layoutParameters( data.textArea, - logicalModel->mText.Begin(), - logicalModel->mLineBreakInfo.Begin(), - logicalModel->mWordBreakInfo.Begin(), - ( 0u != logicalModel->mCharacterDirections.Count() ) ? logicalModel->mCharacterDirections.Begin() : NULL, - visualModel->mGlyphs.Begin(), - visualModel->mGlyphsToCharacters.Begin(), - visualModel->mCharactersPerGlyph.Begin(), - visualModel->mCharactersToGlyph.Begin(), - visualModel->mGlyphsPerCharacter.Begin(), - totalNumberOfGlyphs ); + Layout::Parameters layoutParameters( data.textArea, + logicalModel->mText.Begin(), + logicalModel->mLineBreakInfo.Begin(), + logicalModel->mWordBreakInfo.Begin(), + ( 0u != logicalModel->mCharacterDirections.Count() ) ? logicalModel->mCharacterDirections.Begin() : NULL, + visualModel->mGlyphs.Begin(), + visualModel->mGlyphsToCharacters.Begin(), + visualModel->mCharactersPerGlyph.Begin(), + visualModel->mCharactersToGlyph.Begin(), + visualModel->mGlyphsPerCharacter.Begin(), + totalNumberOfGlyphs, + Layout::HORIZONTAL_ALIGN_BEGIN ); layoutParameters.isLastNewParagraph = isLastNewParagraph; @@ -184,7 +184,8 @@ bool LayoutTextTest( const LayoutTextData& data ) const bool updated = engine.LayoutText( layoutParameters, glyphPositions, lines, - layoutSize ); + layoutSize, + data.ellipsis ); // 4) Compare the results. @@ -369,20 +370,21 @@ bool ReLayoutRightToLeftLinesTest( const ReLayoutRightToLeftLinesData& data ) metrics ); // 2) Call the ReLayoutRightToLeftLines() method. - LayoutEngine engine; + Layout::Engine engine; engine.SetMetrics( metrics ); - LayoutParameters layoutParameters( data.textArea, - logicalModel->mText.Begin(), - logicalModel->mLineBreakInfo.Begin(), - logicalModel->mWordBreakInfo.Begin(), - ( 0u != logicalModel->mCharacterDirections.Count() ) ? logicalModel->mCharacterDirections.Begin() : NULL, - visualModel->mGlyphs.Begin(), - visualModel->mGlyphsToCharacters.Begin(), - visualModel->mCharactersPerGlyph.Begin(), - visualModel->mCharactersToGlyph.Begin(), - visualModel->mGlyphsPerCharacter.Begin(), - visualModel->mGlyphs.Count() ); + Layout::Parameters layoutParameters( data.textArea, + logicalModel->mText.Begin(), + logicalModel->mLineBreakInfo.Begin(), + logicalModel->mWordBreakInfo.Begin(), + ( 0u != logicalModel->mCharacterDirections.Count() ) ? logicalModel->mCharacterDirections.Begin() : NULL, + visualModel->mGlyphs.Begin(), + visualModel->mGlyphsToCharacters.Begin(), + visualModel->mCharactersPerGlyph.Begin(), + visualModel->mCharactersToGlyph.Begin(), + visualModel->mGlyphsPerCharacter.Begin(), + visualModel->mGlyphs.Count(), + Layout::HORIZONTAL_ALIGN_BEGIN ); layoutParameters.numberOfBidirectionalInfoRuns = logicalModel->mBidirectionalLineInfo.Count(); layoutParameters.lineBidirectionalInfoRunsBuffer = logicalModel->mBidirectionalLineInfo.Begin(); @@ -424,17 +426,17 @@ bool ReLayoutRightToLeftLinesTest( const ReLayoutRightToLeftLinesData& data ) struct AlignData { - std::string description; - std::string text; - Size textArea; - unsigned int numberOfFonts; - FontDescriptionRun* fontDescriptions; - LayoutEngine::HorizontalAlignment horizontalAlignment; - LayoutEngine::VerticalAlignment verticalAlignment; - unsigned int startIndex; - unsigned int numberOfCharacters; - unsigned int numberOfLines; - float* lineOffsets; + std::string description; + std::string text; + Size textArea; + unsigned int numberOfFonts; + FontDescriptionRun* fontDescriptions; + Layout::HorizontalAlignment horizontalAlignment; + Layout::VerticalAlignment verticalAlignment; + unsigned int startIndex; + unsigned int numberOfCharacters; + unsigned int numberOfLines; + float* lineOffsets; }; bool AlignTest( const AlignData& data ) @@ -477,15 +479,13 @@ bool AlignTest( const AlignData& data ) metrics ); // Call the Align method. - LayoutEngine engine; + Layout::Engine engine; engine.SetMetrics( metrics ); - engine.SetHorizontalAlignment( data.horizontalAlignment ); - engine.SetVerticalAlignment( data.verticalAlignment ); - engine.Align( data.textArea, data.startIndex, data.numberOfCharacters, + data.horizontalAlignment, visualModel->mLines ); // Compare results. @@ -556,61 +556,12 @@ int UtcDaliTextLayoutSetGetLayout(void) ToolkitTestApplication application; tet_infoline(" UtcDaliTextLayoutSetGetLayout"); - LayoutEngine engine; - - DALI_TEST_CHECK( LayoutEngine::SINGLE_LINE_BOX == engine.GetLayout() ); - - engine.SetLayout( LayoutEngine::MULTI_LINE_BOX ); - DALI_TEST_CHECK( LayoutEngine::MULTI_LINE_BOX == engine.GetLayout() ); - - tet_result(TET_PASS); - END_TEST; -} - -int UtcDaliTextLayoutSetGetTextEllipsisEnabled(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliTextLayoutSetGetTextEllipsisEnabled"); - - LayoutEngine engine; - - DALI_TEST_CHECK( !engine.GetTextEllipsisEnabled() ); - - engine.SetTextEllipsisEnabled( true ); - DALI_TEST_CHECK( engine.GetTextEllipsisEnabled() ); - - tet_result(TET_PASS); - END_TEST; -} - -int UtcDaliTextLayoutSetGetHorizontalAlignment(void) -{ - ToolkitTestApplication application; - tet_infoline(" "); - - LayoutEngine engine; + Layout::Engine engine; - DALI_TEST_CHECK( LayoutEngine::HORIZONTAL_ALIGN_BEGIN == engine.GetHorizontalAlignment() ); - - engine.SetHorizontalAlignment( LayoutEngine::HORIZONTAL_ALIGN_END ); - DALI_TEST_CHECK( LayoutEngine::HORIZONTAL_ALIGN_END == engine.GetHorizontalAlignment() ); - - tet_result(TET_PASS); - END_TEST; -} - -int UtcDaliTextLayoutSetGetVerticalAlignment(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliTextLayoutSetGetVerticalAlignment"); - - LayoutEngine engine; - - DALI_TEST_CHECK( LayoutEngine::VERTICAL_ALIGN_TOP == engine.GetVerticalAlignment() ); - - engine.SetVerticalAlignment( LayoutEngine::VERTICAL_ALIGN_TOP ); - DALI_TEST_CHECK( LayoutEngine::VERTICAL_ALIGN_TOP == engine.GetVerticalAlignment() ); + DALI_TEST_CHECK( Layout::Engine::SINGLE_LINE_BOX == engine.GetLayout() ); + engine.SetLayout( Layout::Engine::MULTI_LINE_BOX ); + DALI_TEST_CHECK( Layout::Engine::MULTI_LINE_BOX == engine.GetLayout() ); tet_result(TET_PASS); END_TEST; @@ -621,7 +572,7 @@ int UtcDaliTextLayoutSetGetCursorWidth(void) ToolkitTestApplication application; tet_infoline(" "); - LayoutEngine engine; + Layout::Engine engine; DALI_TEST_EQUALS( 1, engine.GetCursorWidth(), TEST_LOCATION ); @@ -651,7 +602,7 @@ int UtcDaliTextLayoutNoText(void) NULL, 0u, NULL, - LayoutEngine::MULTI_LINE_BOX, + Layout::Engine::MULTI_LINE_BOX, 0u, 0u, false, @@ -705,7 +656,7 @@ int UtcDaliTextLayoutSmallTextArea01(void) NULL, 0u, NULL, - LayoutEngine::MULTI_LINE_BOX, + Layout::Engine::MULTI_LINE_BOX, 0u, 11u, false, @@ -775,7 +726,7 @@ int UtcDaliTextLayoutSmallTextArea02(void) positions, 1u, lines.Begin(), - LayoutEngine::SINGLE_LINE_BOX, + Layout::Engine::SINGLE_LINE_BOX, 0u, 11u, false, @@ -918,7 +869,7 @@ int UtcDaliTextLayoutMultilineText01(void) positions, 5u, lines.Begin(), - LayoutEngine::MULTI_LINE_BOX, + Layout::Engine::MULTI_LINE_BOX, 0u, 48u, false, @@ -1126,7 +1077,7 @@ int UtcDaliTextLayoutMultilineText02(void) positions, 6u, lines.Begin(), - LayoutEngine::MULTI_LINE_BOX, + Layout::Engine::MULTI_LINE_BOX, 0u, 55u, false, @@ -1227,7 +1178,7 @@ int UtcDaliTextLayoutMultilineText03(void) positions, 3u, lines.Begin(), - LayoutEngine::MULTI_LINE_BOX, + Layout::Engine::MULTI_LINE_BOX, 0u, 29u, false, @@ -1313,7 +1264,7 @@ int UtcDaliTextLayoutMultilineText04(void) positions, 2u, lines.Begin(), - LayoutEngine::MULTI_LINE_BOX, + Layout::Engine::MULTI_LINE_BOX, 0u, 13u, false, @@ -1427,7 +1378,7 @@ int UtcDaliTextLayoutMultilineText05(void) positions, 2u, lines.Begin(), - LayoutEngine::MULTI_LINE_BOX, + Layout::Engine::MULTI_LINE_BOX, 0u, 17u, false, @@ -1983,7 +1934,7 @@ int UtcDaliTextUpdateLayout01(void) positions, 19u, lines.Begin(), - LayoutEngine::MULTI_LINE_BOX, + Layout::Engine::MULTI_LINE_BOX, 0u, 64u, false, @@ -2539,7 +2490,7 @@ int UtcDaliTextUpdateLayout02(void) positions, 19u, lines.Begin(), - LayoutEngine::MULTI_LINE_BOX, + Layout::Engine::MULTI_LINE_BOX, 64u, 64u, false, @@ -3095,7 +3046,7 @@ int UtcDaliTextUpdateLayout03(void) positions, 19u, lines.Begin(), - LayoutEngine::MULTI_LINE_BOX, + Layout::Engine::MULTI_LINE_BOX, 128u, 64u, false, @@ -3171,7 +3122,7 @@ int UtcDaliTextLayoutEllipsis01(void) positions, 1u, lines.Begin(), - LayoutEngine::SINGLE_LINE_BOX, + Layout::Engine::SINGLE_LINE_BOX, 0u, 51u, true, @@ -3261,7 +3212,7 @@ int UtcDaliTextLayoutEllipsis02(void) positions, 2u, lines.Begin(), - LayoutEngine::MULTI_LINE_BOX, + Layout::Engine::MULTI_LINE_BOX, 0u, 51u, true, @@ -3403,7 +3354,7 @@ int UtcDaliTextLayoutEllipsis03(void) positions, 1u, lines.Begin(), - LayoutEngine::SINGLE_LINE_BOX, + Layout::Engine::SINGLE_LINE_BOX, 0u, 72u, true, @@ -3559,7 +3510,7 @@ int UtcDaliTextLayoutEllipsis04(void) positions, 2u, lines.Begin(), - LayoutEngine::MULTI_LINE_BOX, + Layout::Engine::MULTI_LINE_BOX, 0u, 72u, true, @@ -3633,7 +3584,7 @@ int UtcDaliTextLayoutEllipsis05(void) positions, 1u, lines.Begin(), - LayoutEngine::MULTI_LINE_BOX, + Layout::Engine::MULTI_LINE_BOX, 0u, 11u, true, @@ -4186,8 +4137,8 @@ int UtcDaliTextAlign01(void) textArea, 6u, fontDescriptionRuns.Begin(), - LayoutEngine::HORIZONTAL_ALIGN_BEGIN, - LayoutEngine::VERTICAL_ALIGN_TOP, + Layout::HORIZONTAL_ALIGN_BEGIN, + Layout::VERTICAL_ALIGN_TOP, 0u, 22u, 6u, @@ -4305,8 +4256,8 @@ int UtcDaliTextAlign02(void) textArea, 6u, fontDescriptionRuns.Begin(), - LayoutEngine::HORIZONTAL_ALIGN_BEGIN, - LayoutEngine::VERTICAL_ALIGN_TOP, + Layout::HORIZONTAL_ALIGN_BEGIN, + Layout::VERTICAL_ALIGN_TOP, 22u, 26u, 6u, @@ -4424,8 +4375,8 @@ int UtcDaliTextAlign03(void) textArea, 6u, fontDescriptionRuns.Begin(), - LayoutEngine::HORIZONTAL_ALIGN_BEGIN, - LayoutEngine::VERTICAL_ALIGN_TOP, + Layout::HORIZONTAL_ALIGN_BEGIN, + Layout::VERTICAL_ALIGN_TOP, 48u, 26u, 6u, @@ -4543,8 +4494,8 @@ int UtcDaliTextAlign04(void) textArea, 6u, fontDescriptionRuns.Begin(), - LayoutEngine::HORIZONTAL_ALIGN_CENTER, - LayoutEngine::VERTICAL_ALIGN_TOP, + Layout::HORIZONTAL_ALIGN_CENTER, + Layout::VERTICAL_ALIGN_TOP, 0u, 22u, 6u, @@ -4662,8 +4613,8 @@ int UtcDaliTextAlign05(void) textArea, 6u, fontDescriptionRuns.Begin(), - LayoutEngine::HORIZONTAL_ALIGN_CENTER, - LayoutEngine::VERTICAL_ALIGN_TOP, + Layout::HORIZONTAL_ALIGN_CENTER, + Layout::VERTICAL_ALIGN_TOP, 22u, 26u, 6u, @@ -4781,8 +4732,8 @@ int UtcDaliTextAlign06(void) textArea, 6u, fontDescriptionRuns.Begin(), - LayoutEngine::HORIZONTAL_ALIGN_CENTER, - LayoutEngine::VERTICAL_ALIGN_TOP, + Layout::HORIZONTAL_ALIGN_CENTER, + Layout::VERTICAL_ALIGN_TOP, 48u, 26u, 6u, @@ -4900,8 +4851,8 @@ int UtcDaliTextAlign07(void) textArea, 6u, fontDescriptionRuns.Begin(), - LayoutEngine::HORIZONTAL_ALIGN_END, - LayoutEngine::VERTICAL_ALIGN_TOP, + Layout::HORIZONTAL_ALIGN_END, + Layout::VERTICAL_ALIGN_TOP, 0u, 22u, 6u, @@ -5019,8 +4970,8 @@ int UtcDaliTextAlign08(void) textArea, 6u, fontDescriptionRuns.Begin(), - LayoutEngine::HORIZONTAL_ALIGN_END, - LayoutEngine::VERTICAL_ALIGN_TOP, + Layout::HORIZONTAL_ALIGN_END, + Layout::VERTICAL_ALIGN_TOP, 22u, 26u, 6u, @@ -5138,8 +5089,8 @@ int UtcDaliTextAlign09(void) textArea, 6u, fontDescriptionRuns.Begin(), - LayoutEngine::HORIZONTAL_ALIGN_END, - LayoutEngine::VERTICAL_ALIGN_TOP, + Layout::HORIZONTAL_ALIGN_END, + Layout::VERTICAL_ALIGN_TOP, 48u, 26u, 6u, @@ -5154,3 +5105,18 @@ int UtcDaliTextAlign09(void) tet_result(TET_PASS); END_TEST; } + +int UtcDaliTextLayoutSetGetDefaultLineSpacing(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextLayoutSetGetDefaultLineSpacing"); + + Layout::Engine engine; + DALI_TEST_EQUALS( 0.f, engine.GetDefaultLineSpacing(), Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + + engine.SetDefaultLineSpacing( 10.f ); + DALI_TEST_EQUALS( 10.f, engine.GetDefaultLineSpacing(), Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + + tet_result(TET_PASS); + END_TEST; +} diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Markup.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Markup.cpp index 23f7e51..87db667 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Markup.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Markup.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Shaping.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Shaping.cpp index 7b319fb..e4464fd 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Shaping.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Shaping.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include using namespace Dali; using namespace Toolkit; diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Typesetter.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Typesetter.cpp new file mode 100644 index 0000000..63f9a22 --- /dev/null +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Typesetter.cpp @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +using namespace Dali; +using namespace Toolkit; +using namespace Text; + +namespace +{ +const std::string DEFAULT_FONT_DIR( "/resources/fonts" ); +const PointSize26Dot6 EMOJI_FONT_SIZE = 62u * 64u; +} // namespace + +int UtcDaliTextTypesetter(void) +{ + tet_infoline(" UtcDaliTextTypesetter"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + // Tests the rendering controller has been created. + TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() ); + DALI_TEST_CHECK( typesetter ); + + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliTextTypesetterGetViewModel(void) +{ + tet_infoline(" UtcDaliTextTypesetter"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + // Tests the rendering controller has been created. + TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() ); + DALI_TEST_CHECK( typesetter ); + + // Tests the view model has been created. + ViewModel* model = typesetter->GetViewModel(); + DALI_TEST_CHECK( NULL != model ); + + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliTextRenderingControllerRender(void) +{ + tet_infoline(" UtcDaliTextRenderingControllerRender"); + ToolkitTestApplication application; + + // Load some fonts. + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); + + char* pathNamePtr = get_current_dir_name(); + const std::string pathName( pathNamePtr ); + free( pathNamePtr ); + + fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenColorEmoji.ttf", EMOJI_FONT_SIZE ); + fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf" ); + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + // Configures the text controller similarly to the text-label. + ConfigureTextLabel( controller ); + + // Sets the text. + controller->SetMarkupProcessorEnabled( true ); + controller->SetText( "Hello world \xF0\x9F\x98\x81" ); + + // Creates the text's model and relais-out the text. + const Size relayoutSize( 120.f, 60.f ); + controller->Relayout( relayoutSize ); + + // Tests the rendering controller has been created. + TypesetterPtr renderingController = Typesetter::New( controller->GetTextModel() ); + DALI_TEST_CHECK( renderingController ); + + // Renders the text and creates the final bitmap. + PixelData bitmap = renderingController->Render( relayoutSize ); + DALI_TEST_CHECK( bitmap ); + + DALI_TEST_EQUALS( 120u, bitmap.GetWidth(), TEST_LOCATION ); + DALI_TEST_EQUALS( 60u, bitmap.GetHeight(), TEST_LOCATION ); + DALI_TEST_EQUALS( Pixel::RGBA8888, bitmap.GetPixelFormat(), TEST_LOCATION ); + + // Changes vertical alignment. + controller->SetVerticalAlignment( Layout::VERTICAL_ALIGN_CENTER ); + controller->Relayout( relayoutSize ); + + // Renders the text and creates the final bitmap. + bitmap = renderingController->Render( relayoutSize ); + DALI_TEST_CHECK( bitmap ); + + DALI_TEST_EQUALS( 120u, bitmap.GetWidth(), TEST_LOCATION ); + DALI_TEST_EQUALS( 60u, bitmap.GetHeight(), TEST_LOCATION ); + DALI_TEST_EQUALS( Pixel::RGBA8888, bitmap.GetPixelFormat(), TEST_LOCATION ); + + controller->SetVerticalAlignment( Layout::VERTICAL_ALIGN_BOTTOM ); + controller->Relayout( relayoutSize ); + + // Renders the text and creates the final bitmap. + bitmap = renderingController->Render( relayoutSize ); + DALI_TEST_CHECK( bitmap ); + + DALI_TEST_EQUALS( 120u, bitmap.GetWidth(), TEST_LOCATION ); + DALI_TEST_EQUALS( 60u, bitmap.GetHeight(), TEST_LOCATION ); + DALI_TEST_EQUALS( Pixel::RGBA8888, bitmap.GetPixelFormat(), TEST_LOCATION ); + + tet_result(TET_PASS); + END_TEST; +} diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp new file mode 100644 index 0000000..422e6ac --- /dev/null +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp @@ -0,0 +1,653 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +using namespace Dali; +using namespace Toolkit; +using namespace Text; + +namespace +{ + +const std::string DEFAULT_FONT_DIR( "/resources/fonts" ); + +const Size CONTROL_SIZE( 200.f, 400.f ); +const Size CONTROL_SMALL_SIZE( 50.f, 100.f ); +const char* LOREM_IPSUM = "Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.\n" + "Usu ne nisl maiorum iudicabit, veniam epicurei oporteat eos an.\n" + "Ne nec nulla regione albucius, mea doctus delenit ad!\n" + "Et everti blandit adversarium mei, eam porro neglegentur suscipiantur an.\n" + "Quidam corpora at duo. An eos possim scripserit?\n\n" + "Aťqui dicant sěnťenťíae aň vel!\n" + "Vis viris médiocrem elaboraret ét, verear civibus moderatius ex duo!\n" + "Án veri laborě iňtěgré quó, mei aď poššit lobortis, mei prompťa čonsťitůťó eů.\n" + "Aliquip sanctůs delicáta quí ěá, et natum aliquam est?\n" + "Asšúm sapěret usu ůť.\n" + "Síť ut apeirián laboramúš percipitur, sůas hařum ín éos?\n"; +const Vector2 LOREM_SCROLL_POSITION( 0.f, -208.f ); +const Length LOREM_NUMBER_OF_LINES = 32u; +const Length LOREM_NUMBER_OF_LINES_ELIDED = 21u; +const Length LOREM_NUMBER_OF_GLYPHS = 632; +const Length LOREM_NUMBER_OF_GLYPHS_ELIDED = 397u; + +// The expected layout size for UtcDaliTextViewModelGetLayoutSize +const Size LAYOUT_SIZE( 190.f, 48.f ); + +// The expected color indices for UtcDaliTextViewModelGetColors +const ColorIndex COLOR_INDICES[] = { 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 2u, 2u, 2u, 2u, 2u, 1u, 1u, 1u, 1u, 1u, 3u, 1u, 1u, 1u, 0u, 0u, 0u, 0u }; +const Length NUMBER_OF_COLORS = 3u; +const Vector4 COLORS[] = { Color::RED, Color::BLUE, Color::GREEN }; + +struct ElideData +{ + std::string description; + std::string text; + Vector2 size; + unsigned int numberOfLines; + unsigned int numberOfGlyphs; + float* positions; +}; + +bool ElideTest( const ElideData& data ) +{ + std::cout << " testing : " << data.description << std::endl; + + // Load some fonts. + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); + fontClient.SetDpi( 93u, 93u ); + + char* pathNamePtr = get_current_dir_name(); + const std::string pathName( pathNamePtr ); + free( pathNamePtr ); + + fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf" ); + fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf" ); + fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansArabicRegular.ttf" ); + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + // Tests the rendering controller has been created. + TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() ); + DALI_TEST_CHECK( typesetter ); + + // Tests the view model has been created. + ViewModel* model = typesetter->GetViewModel(); + DALI_TEST_CHECK( NULL != model ); + + // Configures the text controller similarly to the text-label. + ConfigureTextLabel( controller ); + + // Sets a text and relais-out. + controller->SetMarkupProcessorEnabled( true ); + + controller->SetText( data.text ); + controller->Relayout( data.size ); + + // Elide the glyphs. + model->ElideGlyphs(); + + if( data.numberOfLines != model->GetNumberOfLines() ) + { + std::cout << " different number of lines : " << model->GetNumberOfLines() << ", expected : " << data.numberOfLines << std::endl; + return false; + } + + if( data.numberOfGlyphs != model->GetNumberOfGlyphs() ) + { + std::cout << " different number of glyphs : " << model->GetNumberOfGlyphs() << ", expected : " << data.numberOfGlyphs << std::endl; + return false; + } + + const Vector2* const layoutBuffer = model->GetLayout(); + const Length numberOfLines = model->GetNumberOfLines(); + + if( numberOfLines != 0u ) + { + const LineRun& lastLine = *( model->GetLines() + numberOfLines - 1u ); + const Length numberOfLastLineGlyphs = data.numberOfGlyphs - lastLine.glyphRun.glyphIndex; + + std::cout << " last line alignment offset : " << lastLine.alignmentOffset << std::endl; + + for( unsigned int index = 0u; index < numberOfLastLineGlyphs; ++index ) + { + if( *( data.positions + index ) != ( lastLine.alignmentOffset + ( *( layoutBuffer + lastLine.glyphRun.glyphIndex + index ) ).x ) ) + { + std::cout << " different layout :"; + for( unsigned int i = 0; i < numberOfLastLineGlyphs; ++i ) + { + std::cout << " " << ( lastLine.alignmentOffset + ( *( layoutBuffer + lastLine.glyphRun.glyphIndex + i ) ).x ); + } + std::cout << std::endl; + std::cout << " expected :"; + for( unsigned int i = 0; i < numberOfLastLineGlyphs; ++i ) + { + std::cout << " " << *( data.positions + i ); + } + std::cout << std::endl; + return false; + } + } + } + + return true; +} + +} // namespace + +int UtcDaliTextViewModel(void) +{ + tet_infoline(" UtcDaliTextViewModel"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + // Tests the rendering controller has been created. + TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() ); + DALI_TEST_CHECK( typesetter ); + + // Tests the view model has been created. + ViewModel* model = typesetter->GetViewModel(); + DALI_TEST_CHECK( NULL != model ); + + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliTextViewModelGetControlSize(void) +{ + tet_infoline(" UtcDaliTextViewModelGetControlSize"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + // Tests the rendering controller has been created. + TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() ); + DALI_TEST_CHECK( typesetter ); + + // Tests the view model has been created. + ViewModel* model = typesetter->GetViewModel(); + DALI_TEST_CHECK( NULL != model ); + + // Configures the text controller similarly to the text-editor. + ConfigureTextEditor( controller ); + + // The text has not been laid-out. The stored control's size should be zero. + DALI_TEST_EQUALS( Size::ZERO, model->GetControlSize(), TEST_LOCATION ); + + // Sets a text and relais-out. + controller->SetText( "Hello world" ); + controller->Relayout( CONTROL_SIZE ); + + // The control's size should be stored now. + DALI_TEST_EQUALS( CONTROL_SIZE, model->GetControlSize(), TEST_LOCATION ); + + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliTextViewModelGetLayoutSize(void) +{ + tet_infoline(" UtcDaliTextViewModelGetLayoutSize"); + ToolkitTestApplication application; + + // Load some fonts. + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); + fontClient.SetDpi( 93u, 93u ); + + char* pathNamePtr = get_current_dir_name(); + const std::string pathName( pathNamePtr ); + free( pathNamePtr ); + + fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf" ); + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + // Tests the rendering controller has been created. + TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() ); + DALI_TEST_CHECK( typesetter ); + + // Tests the view model has been created. + ViewModel* model = typesetter->GetViewModel(); + DALI_TEST_CHECK( NULL != model ); + + // Configures the text controller similarly to the text-editor. + ConfigureTextEditor( controller ); + + // The text has not been laid-out. The stored control's size should be zero. + DALI_TEST_EQUALS( Size::ZERO, model->GetLayoutSize(), TEST_LOCATION ); + + // Sets a text and relais-out. + controller->SetMarkupProcessorEnabled( true ); + controller->SetText( "Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum." ); + controller->Relayout( CONTROL_SIZE ); + + // The control's size should be stored now. + DALI_TEST_EQUALS( LAYOUT_SIZE, model->GetLayoutSize(), TEST_LOCATION ); + + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliTextViewModelGetScrollPosition(void) +{ + tet_infoline(" UtcDaliTextViewModelGetScrollPosition"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + // Tests the rendering controller has been created. + TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() ); + DALI_TEST_CHECK( typesetter ); + + // Tests the view model has been created. + ViewModel* model = typesetter->GetViewModel(); + DALI_TEST_CHECK( NULL != model ); + + // Configures the text controller similarly to the text-editor. + ConfigureTextEditor( controller ); + + // No text has been set. The scroll position should be zero. + DALI_TEST_EQUALS( Vector2::ZERO, model->GetScrollPosition(), TEST_LOCATION ); + + // Gains the keyboard focus, sets a big text and relais-out. + controller->KeyboardFocusGainEvent(); + controller->SetText( LOREM_IPSUM ); + controller->Relayout( CONTROL_SIZE ); + + // The text should be scrolled to the end. + DALI_TEST_EQUALS( LOREM_SCROLL_POSITION, model->GetScrollPosition(), TEST_LOCATION ); + + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliTextViewModelGetAlignment(void) +{ + tet_infoline(" UtcDaliTextViewModelGetAlignment"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + // Tests the rendering controller has been created. + TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() ); + DALI_TEST_CHECK( typesetter ); + + // Tests the view model has been created. + ViewModel* model = typesetter->GetViewModel(); + DALI_TEST_CHECK( NULL != model ); + + DALI_TEST_EQUALS( Layout::HORIZONTAL_ALIGN_BEGIN, model->GetHorizontalAlignment(), TEST_LOCATION ); + DALI_TEST_EQUALS( Layout::VERTICAL_ALIGN_TOP, model->GetVerticalAlignment(), TEST_LOCATION ); + + controller->SetHorizontalAlignment( Layout::HORIZONTAL_ALIGN_CENTER ); + controller->SetVerticalAlignment( Layout::VERTICAL_ALIGN_CENTER ); + + DALI_TEST_EQUALS( Layout::HORIZONTAL_ALIGN_CENTER, model->GetHorizontalAlignment(), TEST_LOCATION ); + DALI_TEST_EQUALS( Layout::VERTICAL_ALIGN_CENTER, model->GetVerticalAlignment(), TEST_LOCATION ); + + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliTextViewModelIsTextElideEnabled(void) +{ + tet_infoline(" UtcDaliTextViewModelIsTextElideEnabled"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + // Tests the rendering controller has been created. + TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() ); + DALI_TEST_CHECK( typesetter ); + + // Tests the view model has been created. + ViewModel* model = typesetter->GetViewModel(); + DALI_TEST_CHECK( NULL != model ); + + // Configures the text controller similarly to the text-editor. + ConfigureTextEditor( controller ); + + // Elide text should be disabled. + DALI_TEST_CHECK( !model->IsTextElideEnabled() ); + + // Configures the text controller similarly to the text-label. + ConfigureTextLabel( controller ); + + // Elide text should be enabled. + DALI_TEST_CHECK( model->IsTextElideEnabled() ); + + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliTextViewModelGetLines(void) +{ + tet_infoline(" UtcDaliTextViewModelGetLines"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + // Tests the rendering controller has been created. + TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() ); + DALI_TEST_CHECK( typesetter ); + + // Tests the view model has been created. + ViewModel* model = typesetter->GetViewModel(); + DALI_TEST_CHECK( NULL != model ); + + // Configures the text controller similarly to the text-editor. + ConfigureTextEditor( controller ); + + // The number of lines should be zero. + DALI_TEST_EQUALS( 0u, model->GetNumberOfLines(), TEST_LOCATION ); + DALI_TEST_CHECK( NULL == model->GetLines() ); + + // Sets a text and relais-out. + controller->SetText( LOREM_IPSUM ); + controller->Relayout( CONTROL_SIZE ); + + DALI_TEST_EQUALS( LOREM_NUMBER_OF_LINES, model->GetNumberOfLines(), TEST_LOCATION ); + DALI_TEST_CHECK( NULL != model->GetLines() ); + + // Configures the text controller similarly to the text-label. + ConfigureTextLabel( controller ); + + // Relais-out for the text-label configuration. + controller->Relayout( Size( 100.f, 100.f) ); // Change the size to force a relayout. + controller->Relayout( CONTROL_SIZE ); + + DALI_TEST_EQUALS( LOREM_NUMBER_OF_LINES_ELIDED, model->GetNumberOfLines(), TEST_LOCATION ); + DALI_TEST_CHECK( NULL != model->GetLines() ); + + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliTextViewModelGetGlyphsLayout(void) +{ + tet_infoline(" UtcDaliTextViewModelGetGlyphsLayout"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + // Tests the rendering controller has been created. + TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() ); + DALI_TEST_CHECK( typesetter ); + + // Tests the view model has been created. + ViewModel* model = typesetter->GetViewModel(); + DALI_TEST_CHECK( NULL != model ); + + // Configures the text controller similarly to the text-editor. + ConfigureTextEditor( controller ); + + // The number of glyphs should be zero. + DALI_TEST_EQUALS( 0u, model->GetNumberOfGlyphs(), TEST_LOCATION ); + DALI_TEST_CHECK( NULL == model->GetGlyphs() ); + DALI_TEST_CHECK( NULL == model->GetLayout() ); + + // Sets a text and relais-out. + controller->SetText( LOREM_IPSUM ); + controller->Relayout( CONTROL_SIZE ); + + DALI_TEST_EQUALS( LOREM_NUMBER_OF_GLYPHS, model->GetNumberOfGlyphs(), TEST_LOCATION ); + DALI_TEST_CHECK( NULL != model->GetGlyphs() ); + DALI_TEST_CHECK( NULL != model->GetLayout() ); + + // Configures the text controller similarly to the text-label. + ConfigureTextLabel( controller ); + + // Relais-out for the text-label configuration. + controller->Relayout( Size( 100.f, 100.f) ); // Change the size to force a relayout. + controller->Relayout( CONTROL_SIZE ); + + // Elide the glyphs. + model->ElideGlyphs(); + + DALI_TEST_EQUALS( LOREM_NUMBER_OF_GLYPHS_ELIDED, model->GetNumberOfGlyphs(), TEST_LOCATION ); + DALI_TEST_CHECK( NULL != model->GetGlyphs() ); + DALI_TEST_CHECK( NULL != model->GetLayout() ); + + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliTextViewModelGetColors(void) +{ + tet_infoline(" UtcDaliTextViewModelGetColors"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + // Tests the rendering controller has been created. + TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() ); + DALI_TEST_CHECK( typesetter ); + + // Tests the view model has been created. + ViewModel* model = typesetter->GetViewModel(); + DALI_TEST_CHECK( NULL != model ); + + // Configures the text controller similarly to the text-label. + ConfigureTextLabel( controller ); + + // Sets a text and relais-out. + controller->SetMarkupProcessorEnabled( true ); + controller->SetText( "Lorem ipsum dolor sit amet." ); + controller->Relayout( CONTROL_SIZE ); + + DALI_TEST_EQUALS( Color::BLACK, model->GetDefaultColor(), TEST_LOCATION ); + + const ColorIndex* const colorIndicesBuffer = model->GetColorIndices(); + + const Length numberOfGlyphs = model->GetNumberOfGlyphs(); + for( ColorIndex index = 0u; index < numberOfGlyphs; ++index ) + { + DALI_TEST_EQUALS( COLOR_INDICES[index], *( colorIndicesBuffer + index ), TEST_LOCATION ); + } + + const Vector4* const colors = model->GetColors(); + for( unsigned int index = 0u; index < NUMBER_OF_COLORS; ++index ) + { + DALI_TEST_EQUALS( COLORS[index], *( colors + index ), TEST_LOCATION ); + } + + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliTextViewModelElideText01(void) +{ + tet_infoline(" UtcDaliTextViewModelElideText01"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + // Tests the rendering controller has been created. + TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() ); + DALI_TEST_CHECK( typesetter ); + + // Tests the view model has been created. + ViewModel* model = typesetter->GetViewModel(); + DALI_TEST_CHECK( NULL != model ); + + // Configures the text controller similarly to the text-editor. + ConfigureTextEditor( controller ); + + // The number of glyphs should be zero. + DALI_TEST_EQUALS( 0u, model->GetNumberOfGlyphs(), TEST_LOCATION ); + DALI_TEST_EQUALS( 0u, model->GetNumberOfLines(), TEST_LOCATION ); + DALI_TEST_CHECK( NULL == model->GetGlyphs() ); + DALI_TEST_CHECK( NULL == model->GetLayout() ); + + // Sets a text and relais-out. + controller->SetText( LOREM_IPSUM ); + controller->Relayout( CONTROL_SIZE ); + + // Keep the pointers to the glyphs and layout. + // As the text is not elided with this configuration, the pointers shoud be the same after calling the ElideGlyphs() method. + const GlyphInfo* const glyphsModel = model->GetGlyphs(); + const Vector2* layoutsModel = model->GetLayout(); + + // Elide the glyphs. Text shouldn't be elided with this configuration. + model->ElideGlyphs(); + + DALI_TEST_CHECK( glyphsModel == model->GetGlyphs() ); + DALI_TEST_CHECK( layoutsModel == model->GetLayout() ); + + DALI_TEST_EQUALS( LOREM_NUMBER_OF_GLYPHS, model->GetNumberOfGlyphs(), TEST_LOCATION ); + DALI_TEST_EQUALS( LOREM_NUMBER_OF_LINES, model->GetNumberOfLines(), TEST_LOCATION ); + + // Configures the text controller similarly to the text-label. + ConfigureTextLabel( controller ); + + // Clear the text and relais-out. + controller->SetText( "" ); + controller->Relayout( CONTROL_SIZE ); + + DALI_TEST_EQUALS( 0u, model->GetNumberOfGlyphs(), TEST_LOCATION ); + DALI_TEST_EQUALS( 0u, model->GetNumberOfLines(), TEST_LOCATION ); + + // Elide the glyphs. Should not add the ellipsis glyph. + model->ElideGlyphs(); + + DALI_TEST_EQUALS( 0u, model->GetNumberOfGlyphs(), TEST_LOCATION ); + + // Sets a text that doesn't need to be elided. + controller->SetText( "Hello\n" ); + controller->Relayout( CONTROL_SIZE ); + + // Elide the glyphs. + model->ElideGlyphs(); + + DALI_TEST_EQUALS( 6u, model->GetNumberOfGlyphs(), TEST_LOCATION ); + DALI_TEST_EQUALS( 2u, model->GetNumberOfLines(), TEST_LOCATION ); + + // Sets a text and relais-out. + controller->SetText( LOREM_IPSUM ); + controller->Relayout( CONTROL_SIZE ); + + // Elide the glyphs. + model->ElideGlyphs(); + + DALI_TEST_EQUALS( LOREM_NUMBER_OF_GLYPHS_ELIDED, model->GetNumberOfGlyphs(), TEST_LOCATION ); + DALI_TEST_EQUALS( LOREM_NUMBER_OF_LINES_ELIDED, model->GetNumberOfLines(), TEST_LOCATION ); + const GlyphInfo* const glyphs = model->GetGlyphs(); + const Vector2* layouts = model->GetLayout(); + DALI_TEST_CHECK( NULL != glyphs ); + DALI_TEST_CHECK( NULL != layouts ); + + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliTextViewModelElideText02(void) +{ + tet_infoline(" UtcDaliTextViewModelElideText02"); + + Size textSize00( 100.f, 100.f ); + + Size textSize01( 80.f, 100.f ); + float positions01[] = { 0.f, 10.f, 16.f, 26.f, 35.f, 38.f, 46.f, 56.f }; + + Size textSize02( 80.f, 100.f ); + float positions02[] = { 72.f, 63.f, 54.f, 50.f, 43.f, 38.f, 30.f, 11.f }; + + Size textSize03( 80.f, 100.f ); + float positions03[] = { 77.f, 76.f, 71.f, 62.f, 60.f, 52.f, 47.f, 42.f, 39.f, 35.f, 32.f, 13.f }; + + Size textSize04( 80.f, 10.f ); + float positions04[] = { 2.f }; + + struct ElideData data[] = + { + { + "void text", + "", + textSize00, + 0u, + 0u, + NULL + }, + { + "Latin script", + "Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.", + textSize01, + 5u, + 42u, + positions01 + }, + { + "Hebrew script", + "צעד על לשון המלצת לאחרונה, אם לכאן שנורו סרבול מדע, קרן דת שפות להפוך.", + textSize02, + 5u, + 49u, + positions02 + }, + { + "Arabic script", + "عل النفط ديسمبر الإمداد بال, بين وترك شعار هو. لمّ من المبرمة النفط بالسيطرة, أم يتم تحرّك وبغطاء, عدم في لإعادة وإقامة رجوعهم.", + textSize03, + 5u, + 79u, + positions03 + }, + { + "Small control size, no line fits.", + "Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.", + textSize04, + 1u, + 1u, + positions04 + } + }; + const unsigned int numberOfTests = 5u; + + for( unsigned int index = 0u; index < numberOfTests; ++index ) + { + ToolkitTestApplication application; + if( !ElideTest( data[index] ) ) + { + tet_result(TET_FAIL); + } + } + + tet_result(TET_PASS); + END_TEST; +} diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-VisualModel.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-VisualModel.cpp index 11b09f1..a13b4d8 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-VisualModel.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-VisualModel.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include using namespace Dali; diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Visuals.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Visuals.cpp index a4bfbcb..b8ccf57 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Visuals.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Visuals.cpp @@ -21,8 +21,11 @@ #include #include +#include +#include #include #include +#include using namespace Dali::Toolkit::Internal; @@ -70,3 +73,51 @@ int UtcDaliWireframeVisual(void) tet_result(TET_PASS); END_TEST; } + +int UtcDaliTextVisual(void) +{ + tet_infoline(" UtcDaliTextVisual"); + ToolkitTestApplication application; + + Stage stage = Stage::GetCurrent(); + + Dali::Toolkit::Control control = Dali::Toolkit::Control::New(); + control.SetParentOrigin( ParentOrigin::CENTER ); + + Dali::Property::Map map; + map[ Dali::Toolkit::Visual::Property::TYPE ] = Dali::Toolkit::DevelVisual::TEXT; + map[ Dali::Toolkit::TextVisual::Property::ENABLE_MARKUP ] = true; + std::string markupText( "Hello world" ); + map[ Dali::Toolkit::TextVisual::Property::TEXT ] = markupText; + map[ Dali::Toolkit::TextVisual::Property::TEXT_COLOR ] = Dali::Vector4( 0.25f, 0.25f, 0.5f, 1.f ); + map[ Dali::Toolkit::TextVisual::Property::FONT_FAMILY ] = "TizenSansRegular"; + map[ Dali::Toolkit::TextVisual::Property::POINT_SIZE ] = 30.f; + map[ Dali::Toolkit::TextVisual::Property::HORIZONTAL_ALIGNMENT ] = "CENTER"; + map[ Dali::Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT ] = "CENTER"; + + control.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map ); + + stage.Add( control ); + + try + { + application.SendNotification(); + application.Render(); + } + catch( ... ) + { + tet_result(TET_FAIL); + } + + // The renderer should be removed. + control.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); + control.SetSize( 1.f, 0.f ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( 0u, control.GetRendererCount(), TEST_LOCATION ); + + tet_result(TET_PASS); + END_TEST; +} diff --git a/automated-tests/src/dali-toolkit-styling/CMakeLists.txt b/automated-tests/src/dali-toolkit-styling/CMakeLists.txt index d8d55f8..caa901e 100644 --- a/automated-tests/src/dali-toolkit-styling/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit-styling/CMakeLists.txt @@ -54,6 +54,7 @@ LIST(APPEND TC_SOURCES PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED dali-core dali-toolkit + dali-adaptor ) PKG_CHECK_MODULES(DALI_ADAPTOR REQUIRED 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 6fcc10d..ae4132b 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 @@ -19,6 +19,8 @@ #include #include +#include +#include namespace Dali { @@ -88,11 +90,23 @@ DummyControlImpl::~DummyControlImpl() void DummyControlImpl::RegisterVisual( Property::Index index, Toolkit::Visual::Base visual ) { Control::RegisterVisual( index, visual ); + + VisualIndices::iterator iter = std::find( mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index ); + if( iter == mRegisteredVisualIndices.end() ) + { + mRegisteredVisualIndices.push_back(index); + } } void DummyControlImpl::RegisterVisual( Property::Index index, Toolkit::Visual::Base visual, bool enabled ) { Control::RegisterVisual( index, visual, enabled ); + + VisualIndices::iterator iter = std::find( mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index ); + if( iter == mRegisteredVisualIndices.end() ) + { + mRegisteredVisualIndices.push_back(index); + } } void DummyControlImpl::UnregisterVisual( Property::Index index ) @@ -115,6 +129,7 @@ bool DummyControlImpl::IsVisualEnabled( Property::Index index ) return Control::IsVisualEnabled( index ); } + Animation DummyControlImpl::CreateTransition( const Toolkit::TransitionData& transition ) { return Control::CreateTransition( transition ); @@ -189,6 +204,24 @@ bool DummyControlImplOverride::OnKeyEvent(const KeyEvent& event) { keyEventCalle void DummyControlImplOverride::OnKeyInputFocusGained() { keyInputFocusGained = true; } void DummyControlImplOverride::OnKeyInputFocusLost() { keyInputFocusLost = true; } +void DummyControlImplOverride::OnRelayout( const Vector2& size, RelayoutContainer& container ) +{ + Property::Map transformMap; + transformMap + .Add( Toolkit::VisualProperty::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) ) + .Add( Toolkit::VisualProperty::Transform::Property::SIZE, Vector2(1.0f, 1.0f) ) + .Add( Toolkit::VisualProperty::Transform::Property::ORIGIN, Toolkit::Align::CENTER ) + .Add( Toolkit::VisualProperty::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER ) + .Add( Toolkit::VisualProperty::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO ); + + for( VisualIndices::iterator iter = mRegisteredVisualIndices.begin(); iter != mRegisteredVisualIndices.end() ; ++iter ) + { + Visual::Base visual = GetVisual(*iter); + visual.SetTransformAndSize( transformMap, size ); + } +} + + DummyControl DummyControl::New( bool override ) { DummyControl control; 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 04847d1..95b4126 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 @@ -84,6 +84,8 @@ public: void CustomSlot1( Actor actor ); bool mCustomSlot1Called; + typedef std::vector VisualIndices; + VisualIndices mRegisteredVisualIndices; protected: @@ -135,6 +137,7 @@ private: // From CustomActorImpl virtual bool OnKeyEvent(const KeyEvent& event); virtual void OnKeyInputFocusGained(); virtual void OnKeyInputFocusLost(); + virtual void OnRelayout( const Vector2& size, RelayoutContainer& container ); public: diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-harness.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-harness.cpp index 332ddaa..76b391b 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-harness.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-harness.cpp @@ -329,8 +329,9 @@ void Usage(const char* program) printf("Usage: \n" " %s \t\t Execute a test case\n" " %s \t\t Execute all test cases in parallel\n" - " %s -r\t\t Execute all test cases in parallel, rerunning failed test cases\n", - program, program, program); + " %s -r\t\t Execute all test cases in parallel, rerunning failed test cases\n" + " %s -s\t\t Execute all test cases serially\n", + program, program, program, program); } } // namespace diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-event-thread-callback.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-event-thread-callback.cpp index f77cdde..b809b87 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-event-thread-callback.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-event-thread-callback.cpp @@ -21,7 +21,10 @@ #include #include #include +#include #include +#include +#include namespace Dali { @@ -63,14 +66,18 @@ void EventThreadCallback::Trigger() } } -void EventThreadCallback::WaitingForTrigger(unsigned int count) +bool EventThreadCallback::WaitingForTrigger(unsigned int count, unsigned int seconds) { if( mImpl->triggeredCount >= count ) { - return; + return true; } + struct timespec now; + clock_gettime( CLOCK_REALTIME, &now ); + now.tv_sec += seconds; mImpl->expectedCount = count; - sem_wait( &(mImpl->mySemaphore) ); + int error = sem_timedwait( &(mImpl->mySemaphore), &now ); + return error != 0; } CallbackBase* EventThreadCallback::GetCallback() @@ -84,3 +91,46 @@ EventThreadCallback* EventThreadCallback::Get() } } + +namespace Test +{ + +bool WaitForEventThreadTrigger( int triggerCount ) +{ + bool success = true; + const int TEST_TIMEOUT(30); + + struct timespec startTime; + struct timespec now; + clock_gettime( CLOCK_REALTIME, &startTime ); + now.tv_sec = startTime.tv_sec; + now.tv_nsec = startTime.tv_nsec; + + Dali::EventThreadCallback* eventTrigger = NULL; + while( eventTrigger == NULL ) + { + eventTrigger = Dali::EventThreadCallback::Get(); + clock_gettime( CLOCK_REALTIME, &now ); + if( now.tv_sec - startTime.tv_sec > TEST_TIMEOUT ) + { + success = false; + break; + } + usleep(10); + } + if( eventTrigger != NULL ) + { + Dali::CallbackBase* callback = eventTrigger->GetCallback(); + eventTrigger->WaitingForTrigger( triggerCount, TEST_TIMEOUT - (now.tv_sec - startTime.tv_sec) ); + Dali::CallbackBase::Execute( *callback ); + } + + clock_gettime( CLOCK_REALTIME, &now ); + if( now.tv_sec > startTime.tv_sec + 1 ) + { + fprintf(stderr, "WaitForEventThreadTrigger took %ld seconds\n", now.tv_sec - startTime.tv_sec ); + } + return success; +} + +} diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-event-thread-callback.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-event-thread-callback.h index d67ca24..a0303be 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-event-thread-callback.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-event-thread-callback.h @@ -36,7 +36,7 @@ public: void Trigger(); - void WaitingForTrigger(unsigned int count); + bool WaitingForTrigger(unsigned int count, unsigned int seconds ); CallbackBase* GetCallback(); @@ -58,4 +58,19 @@ private: } +namespace Test +{ + +/** + * Wait for the tested code to create an event trigger, then + * wait for triggerCount Trigger calls to occur, and execute the trigger + * callback afterwards. + * + * Will wait for a maximum of 30s before failing the test and returning. + */ +bool WaitForEventThreadTrigger( int triggerCount ); + +} + + #endif /* __DALI_TOOLKIT_EVENT_THREAD_CALLBACK_H__ */ diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-text-abstraction.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-text-abstraction.cpp index d06ba71..df25aaa 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-text-abstraction.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-text-abstraction.cpp @@ -152,6 +152,7 @@ public: void GetFontMetrics( FontId fontId, FontMetrics& metrics ){} GlyphIndex GetGlyphIndex( FontId fontId, Character charcode ){return 0;} bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, bool horizontal ){return true;} + void CreateBitmap( FontId fontId, GlyphIndex glyphIndex, Dali::TextAbstraction::FontClient::GlyphBufferData& data ){} PixelData CreateBitmap( FontId fontId, GlyphIndex glyphIndex ){return PixelData();} void CreateVectorBlob( FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight ) @@ -159,6 +160,7 @@ public: blobLength = 0; } const GlyphInfo& GetEllipsisGlyph( PointSize26Dot6 pointSize ){return mGlyphInfo;} + bool IsColorGlyph( FontId fontId, GlyphIndex glyphIndex ){return false;} private: unsigned int mDpiHorizontal; unsigned int mDpiVertical; @@ -356,6 +358,14 @@ FontClient::FontClient( const FontClient& handle ) { } +FontClient::GlyphBufferData::GlyphBufferData() +{ +} + +FontClient::GlyphBufferData::~GlyphBufferData() +{ +} + FontClient& FontClient::operator=( const FontClient& handle ) { BaseHandle::operator=( handle ); @@ -462,12 +472,16 @@ bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType typ return GetImplementation(*this).GetGlyphMetrics( array, size, horizontal ); } +void FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, Dali::TextAbstraction::FontClient::GlyphBufferData& data ) +{ + GetImplementation(*this).CreateBitmap( fontId, glyphIndex, data ); +} + PixelData FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex ) { return GetImplementation(*this).CreateBitmap( fontId, glyphIndex ); } - void FontClient::CreateVectorBlob( FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, @@ -483,6 +497,11 @@ const GlyphInfo& FontClient::GetEllipsisGlyph( PointSize26Dot6 pointSize ) return GetImplementation(*this).GetEllipsisGlyph( pointSize ); } +bool FontClient::IsColorGlyph( FontId fontId, GlyphIndex glyphIndex ) +{ + return GetImplementation(*this).IsColorGlyph( fontId, glyphIndex ); +} + FontClient::FontClient( Internal::FontClient* internal ) : BaseHandle( internal ) { diff --git a/automated-tests/src/dali-toolkit/utc-Dali-AsyncImageLoader.cpp b/automated-tests/src/dali-toolkit/utc-Dali-AsyncImageLoader.cpp index 74dcc73..6e99e48 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-AsyncImageLoader.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-AsyncImageLoader.cpp @@ -174,12 +174,7 @@ int UtcDaliAsyncImageLoaderLoadAndLoadedSignal(void) uint32_t id02 = loader.Load( gImage_50_RGBA, ImageDimensions( 25, 25 ) ); uint32_t id03 = loader.Load( gImage_128_RGB, ImageDimensions( 100, 100 ), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, true ); - EventThreadCallback* eventTrigger = EventThreadCallback::Get(); - CallbackBase* callback = eventTrigger->GetCallback(); - - eventTrigger->WaitingForTrigger( 3 );// waiting until all three images are loaded - - CallbackBase::Execute( *callback ); + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION ); application.SendNotification(); application.Render(); @@ -205,12 +200,7 @@ int UtcDaliAsyncImageLoaderCancel(void) uint32_t id02 = loader.Load( gImage_50_RGBA, ImageDimensions( 25, 25 ) ); uint32_t id03 = loader.Load( gImage_128_RGB, ImageDimensions( 100, 100 ), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, true ); - EventThreadCallback* eventTrigger = EventThreadCallback::Get(); - CallbackBase* callback = eventTrigger->GetCallback(); - - eventTrigger->WaitingForTrigger( 3 ); // waiting until images are loaded - - CallbackBase::Execute( *callback ); + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION ); application.SendNotification(); application.Render(); @@ -248,4 +238,3 @@ int UtcDaliAsyncImageLoaderCancelAll(void) END_TEST; } - diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ImageAtlas.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ImageAtlas.cpp index 5fe744f..0bee5e5 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ImageAtlas.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ImageAtlas.cpp @@ -207,12 +207,7 @@ int UtcDaliImageAtlasUploadP(void) Vector4 textureRect3; atlas.Upload( textureRect3, gImage_128_RGB, ImageDimensions(128, 128) ); - EventThreadCallback* eventTrigger = EventThreadCallback::Get(); - CallbackBase* callback = eventTrigger->GetCallback(); - - eventTrigger->WaitingForTrigger( 3 );// waiting until all three images are loaded - - CallbackBase::Execute( *callback ); + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION ); application.SendNotification(); application.Render(RENDER_FRAME_INTERVAL); @@ -262,8 +257,6 @@ int UtcDaliImageAtlasUploadWithObserver01(void) TestApplication application; ImageAtlas atlas = ImageAtlas::New( 200, 200 ); - EventThreadCallback* eventTrigger = EventThreadCallback::Get(); - CallbackBase* callback = eventTrigger->GetCallback(); gCountOfTestFuncCall = 0; TestUploadObserver uploadObserver; @@ -276,8 +269,7 @@ int UtcDaliImageAtlasUploadWithObserver01(void) atlas.Upload( textureRect3, gImage_128_RGB, ImageDimensions(128, 128), FittingMode::DEFAULT, true, &uploadObserver ); // waiting until all three images are loaded and uploaded to atlas - eventTrigger->WaitingForTrigger( 3 ); - CallbackBase::Execute( *callback ); + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION ); application.SendNotification(); application.Render(RENDER_FRAME_INTERVAL); @@ -292,9 +284,6 @@ int UtcDaliImageAtlasUploadWithObserver02(void) TestApplication application; ImageAtlas atlas = ImageAtlas::New( 200, 200 ); - EventThreadCallback* eventTrigger = EventThreadCallback::Get(); - CallbackBase* callback = eventTrigger->GetCallback(); - gCountOfTestFuncCall = 0; TestUploadObserver* uploadObserver = new TestUploadObserver; @@ -309,8 +298,8 @@ int UtcDaliImageAtlasUploadWithObserver02(void) delete uploadObserver; // waiting until all three images are loaded and uploaded to atlas - eventTrigger->WaitingForTrigger( 3 ); - CallbackBase::Execute( *callback ); + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION ); + application.Render(RENDER_FRAME_INTERVAL); application.SendNotification(); @@ -382,20 +371,19 @@ int UtcDaliImageAtlasImageView(void) ImageView imageView1 = ImageView::New( gImage_34_RGBA, ImageDimensions(34, 34) ); ImageView imageView2 = ImageView::New( gImage_50_RGBA, ImageDimensions(50, 50) ); - Stage::GetCurrent().Add( imageView1 ); - Stage::GetCurrent().Add( imageView2 ); - EventThreadCallback* eventTrigger = EventThreadCallback::Get(); - while( eventTrigger == NULL) // waiting uintil the ImageAtlas is created by ImageAtlasManager - { - usleep(10); - eventTrigger = EventThreadCallback::Get(); - } - CallbackBase* callback = eventTrigger->GetCallback(); + // ImageView doesn't do size negotiation properly: it only listens to OnSizeSet: + imageView1.SetSize( 100, 100 ); + imageView2.SetSize( 100, 100 ); + imageView1.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + imageView2.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - eventTrigger->WaitingForTrigger( 2 );// waiting until both images are loaded + application.GetPlatform().SetClosestImageSize( Vector2(34, 34) ); + Stage::GetCurrent().Add( imageView1 ); + application.GetPlatform().SetClosestImageSize( Vector2(50, 50) ); + Stage::GetCurrent().Add( imageView2 ); - CallbackBase::Execute( *callback ); + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION ); application.SendNotification(); application.Render(RENDER_FRAME_INTERVAL); @@ -426,10 +414,10 @@ int UtcDaliImageAtlasImageView(void) application.SendNotification(); application.Render(RENDER_FRAME_INTERVAL); ImageView imageView3 = ImageView::New( gImage_128_RGB, ImageDimensions(100, 100) ); + application.GetPlatform().SetClosestImageSize( Vector2(100, 100) ); Stage::GetCurrent().Add( imageView3 ); - eventTrigger->WaitingForTrigger( 3 ); // waiting for the third image loaded - CallbackBase::Execute( *callback ); + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION ); application.SendNotification(); application.Render(RENDER_FRAME_INTERVAL); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp index 12c3f17..2ff700b 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp @@ -384,7 +384,7 @@ int UtcDaliImageViewAsyncLoadingWithoutAltasing(void) END_TEST; } -int UtcDaliImageViewAsyncLoadingWithAltasing(void) +int UtcDaliImageViewAsyncLoadingWithAtlasing(void) { ToolkitTestApplication application; @@ -393,13 +393,10 @@ int UtcDaliImageViewAsyncLoadingWithAltasing(void) callStack.Reset(); callStack.Enable(true); - BitmapLoader::ResetLatestCreated(); ImageView imageView = ImageView::New( gImage_34_RGBA, ImageDimensions( 34, 34 ) ); // By default, Aysnc loading is used // loading is not started if the actor is offStage - BitmapLoader loader = BitmapLoader::GetLatestCreated(); - DALI_TEST_CHECK( !loader ); Stage::GetCurrent().Add( imageView ); application.SendNotification(); @@ -407,20 +404,8 @@ int UtcDaliImageViewAsyncLoadingWithAltasing(void) application.Render(16); application.SendNotification(); - // loading started - loader = BitmapLoader::GetLatestCreated(); - DALI_TEST_CHECK( loader ); - - // worker thread is created - EventThreadCallback* eventTrigger = EventThreadCallback::Get(); - DALI_TEST_CHECK( eventTrigger ); - - loader.WaitForLoading();// waiting until the image to be loaded - DALI_TEST_CHECK( loader.IsLoaded() ); - - eventTrigger->WaitingForTrigger( 1 ); - CallbackBase* callback = eventTrigger->GetCallback(); - CallbackBase::Execute( *callback ); + // loading started, this waits for the loader thread for max 30 seconds + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); application.SendNotification(); application.Render(16); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp b/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp index 95a6eb5..6ef6e9e 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. @@ -175,8 +175,19 @@ public: Actor mActivatedActor; }; -} // namespace +// Used to connect to signals via the ConnectSignal Handle method +struct CallbackFunctor +{ + CallbackFunctor() + { + } + void operator()() + { + } +}; + +} // namespace int UtcDaliKeyboardFocusManagerGet(void) { @@ -668,3 +679,19 @@ int UtcDaliKeyboardFocusManagerSignalFocusGroupChanged(void) focusGroupChangedCallback.Reset(); END_TEST; } + +int UtcDaliKeyboardFocusManagerSignals(void) +{ + ToolkitTestApplication application; + + KeyboardFocusManager manager = KeyboardFocusManager::Get(); + DALI_TEST_CHECK( manager ); + + ConnectionTracker* testTracker = new ConnectionTracker(); + DALI_TEST_EQUALS( true, manager.ConnectSignal( testTracker, "keyboardPreFocusChange", CallbackFunctor() ), TEST_LOCATION ); + DALI_TEST_EQUALS( true, manager.ConnectSignal( testTracker, "keyboardFocusChanged", CallbackFunctor() ), TEST_LOCATION ); + DALI_TEST_EQUALS( true, manager.ConnectSignal( testTracker, "keyboardFocusGroupChanged", CallbackFunctor() ), TEST_LOCATION ); + DALI_TEST_EQUALS( true, manager.ConnectSignal( testTracker, "keyboardFocusedActorEnterKey", CallbackFunctor() ), TEST_LOCATION ); + + END_TEST; +} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp index 022695d..dd9a805 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp @@ -1442,3 +1442,93 @@ int utcDaliTextEditorEvent03(void) END_TEST; } + +int utcDaliTextEditorEvent04(void) +{ + ToolkitTestApplication application; + tet_infoline(" utcDaliTextEditorEvent04"); + + // Checks if the highlight actor is created. + + TextEditor editor = TextEditor::New(); + DALI_TEST_CHECK( editor ); + + Stage::GetCurrent().Add( editor ); + + editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" ); + editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f ); + editor.SetSize( 100.f, 50.f ); + editor.SetParentOrigin( ParentOrigin::TOP_LEFT ); + editor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + + // Avoid a crash when core load gl resources. + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Tap on the text editor + application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); + application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Move at the end of the text. + application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down ) ); + + // Render and notify + application.SendNotification(); + application.Render(); + + for( unsigned int index = 0u; index < 10u; ++index ) + { + application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) ); + + // Render and notify + application.SendNotification(); + application.Render(); + } + + // Add a character + application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down ) ); + + // Render and notify + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty( TextEditor::Property::TEXT ), TEST_LOCATION ); + + // Add some key events + application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down ) ); + + // Render and notify + application.SendNotification(); + application.Render(); + + for( unsigned int index = 0u; index < 10u; ++index ) + { + application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) ); + + // Render and notify + application.SendNotification(); + application.Render(); + } + + // Add a character + application.ProcessEvent( GenerateKey( " ", " ", 0, 0, 0, Integration::KeyEvent::Down ) ); + + // Render and notify + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty( TextEditor::Property::TEXT ), 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 1045ad4..6f04d64 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp @@ -17,6 +17,8 @@ #include #include +#include + #include #include @@ -63,6 +65,8 @@ const char* const PROPERTY_NAME_EMBOSS = "emboss"; const char* const PROPERTY_NAME_OUTLINE = "outline"; const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND; +const std::string DEFAULT_FONT_DIR( "/resources/fonts" ); +const unsigned int EMOJI_FONT_SIZE = 3968u; bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet ) { @@ -471,46 +475,21 @@ int UtcDaliToolkitTextLabelLanguagesP(void) application.SendNotification(); application.Render(); - END_TEST; -} + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); -int UtcDaliToolkitTextLabelVectorBasedP(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliToolkitTextLabelVectorBasedP"); + char* pathNamePtr = get_current_dir_name(); + const std::string pathName( pathNamePtr ); + free( pathNamePtr ); - TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - glAbstraction.EnableTextureCallTrace( true ); + fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenColorEmoji.ttf", EMOJI_FONT_SIZE ); - TextLabel label = TextLabel::New(); - label.SetParentOrigin( ParentOrigin::CENTER ); - label.SetSize( Stage::GetCurrent().GetSize() ); - label.SetProperty( TextLabel::Property::TEXT, "Hello World" ); - label.SetProperty( TextLabel::Property::POINT_SIZE, 10.0f ); - label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Toolkit::Text::RENDERING_VECTOR_BASED ); - Stage::GetCurrent().Add( label ); - - application.SendNotification(); - application.Render(); - - // Test that the vector data is uploaded to atlas - DALI_TEST_CHECK( glAbstraction.GetTextureTrace().FindMethod("TexSubImage2D") ); - glAbstraction.GetTextureTrace().Reset(); - - // Add another label with the same text in a different point-size - TextLabel label2 = TextLabel::New(); - label2.SetProperty( TextLabel::Property::TEXT, "Hello World" ); - label2.SetProperty( TextLabel::Property::POINT_SIZE, 13.0f ); - label2.SetProperty( TextLabel::Property::RENDERING_BACKEND, Toolkit::Text::RENDERING_VECTOR_BASED ); - Stage::GetCurrent().Add( label2 ); + const std::string emojis = "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84"; + label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true ); + label.SetProperty( TextLabel::Property::TEXT, emojis ); application.SendNotification(); application.Render(); - // Test that no additional vector data was uploaded to atlas - // i.e. the same vector data can be used to render any point-size - DALI_TEST_CHECK( ! glAbstraction.GetTextureTrace().FindMethod("TexSubImage2D") ); - END_TEST; } diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp index c0bb0b1..14e8a19 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include #include #include "dummy-control.h" @@ -42,6 +44,18 @@ const char* TEST_RESOURCE_LOCATION = TEST_RESOURCE_DIR "/"; const std::string DEFAULT_FONT_DIR( "/resources/fonts" ); +Property::Map DefaultTransform() +{ + Property::Map transformMap; + transformMap + .Add( Toolkit::VisualProperty::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) ) + .Add( Toolkit::VisualProperty::Transform::Property::SIZE, Vector2(1.0f, 1.0f) ) + .Add( Toolkit::VisualProperty::Transform::Property::ORIGIN, Toolkit::Align::CENTER ) + .Add( Toolkit::VisualProperty::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER ) + .Add( Toolkit::VisualProperty::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO ); + return transformMap; +} + bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet ) { if( fontStyleMapGet.Count() == fontStyleMapSet.Count() ) @@ -173,24 +187,25 @@ int UtcDaliVisualSize(void) tet_infoline( "UtcDaliVisualGetNaturalSize" ); VisualFactory factory = VisualFactory::Get(); - Vector2 visualSize( 20.f, 30.f ); + Vector2 controlSize( 20.f, 30.f ); Vector2 naturalSize; // color colorVisual Dali::Property::Map map; map[ Visual::Property::TYPE ] = Visual::COLOR; map[ ColorVisual::Property::MIX_COLOR ] = Color::MAGENTA; + Visual::Base colorVisual = factory.CreateVisual( map ); - colorVisual.SetSize( visualSize ); - DALI_TEST_EQUALS( colorVisual.GetSize(), visualSize, TEST_LOCATION ); + colorVisual.SetTransformAndSize(DefaultTransform(), controlSize ); + colorVisual.GetNaturalSize(naturalSize); DALI_TEST_EQUALS( naturalSize, Vector2::ZERO, TEST_LOCATION ); // image visual Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200)); Visual::Base imageVisual = factory.CreateVisual( image ); - imageVisual.SetSize( visualSize ); - DALI_TEST_EQUALS( imageVisual.GetSize(), visualSize, TEST_LOCATION ); + imageVisual.SetTransformAndSize(DefaultTransform(), controlSize ); + imageVisual.GetNaturalSize(naturalSize); DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 200.f), TEST_LOCATION ); @@ -203,8 +218,7 @@ int UtcDaliVisualSize(void) map[ BorderVisual::Property::COLOR ] = Color::RED; map[ BorderVisual::Property::SIZE ] = borderSize; Visual::Base borderVisual = factory.CreateVisual( map ); - borderVisual.SetSize( visualSize ); - DALI_TEST_EQUALS( borderVisual.GetSize(), visualSize, TEST_LOCATION ); + borderVisual.SetTransformAndSize(DefaultTransform(), controlSize ); borderVisual.GetNaturalSize(naturalSize); DALI_TEST_EQUALS( naturalSize, Vector2::ZERO, TEST_LOCATION ); @@ -221,15 +235,13 @@ int UtcDaliVisualSize(void) stopColors.PushBack( Color::GREEN ); propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors); Visual::Base gradientVisual = factory.CreateVisual(propertyMap); - gradientVisual.SetSize( visualSize ); - DALI_TEST_EQUALS( gradientVisual.GetSize(), visualSize, TEST_LOCATION ); + gradientVisual.SetTransformAndSize(DefaultTransform(), controlSize ); gradientVisual.GetNaturalSize(naturalSize); DALI_TEST_EQUALS( naturalSize, Vector2::ZERO,TEST_LOCATION ); // svg visual Visual::Base svgVisual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() ); - svgVisual.SetSize( visualSize ); - DALI_TEST_EQUALS( svgVisual.GetSize(), visualSize, TEST_LOCATION ); + svgVisual.SetTransformAndSize(DefaultTransform(), controlSize ); svgVisual.GetNaturalSize(naturalSize); // TEST_SVG_FILE: // @@ -239,7 +251,6 @@ int UtcDaliVisualSize(void) // svg visual with a size Visual::Base svgVisual2 = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions(200, 200) ); - DALI_TEST_EQUALS( svgVisual2.GetSize(), Vector2( 200.f, 200.f ), TEST_LOCATION ); svgVisual2.GetNaturalSize(naturalSize); DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 100.f), TEST_LOCATION ); // Natural size should still be 100, 100 @@ -252,8 +263,7 @@ int UtcDaliVisualSize(void) propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true ); Visual::Base batchImageVisual = factory.CreateVisual( propertyMap ); - batchImageVisual.SetSize( visualSize ); - DALI_TEST_EQUALS( batchImageVisual.GetSize(), visualSize, TEST_LOCATION ); + batchImageVisual.SetTransformAndSize(DefaultTransform(), controlSize ); batchImageVisual.GetNaturalSize( naturalSize ); DALI_TEST_EQUALS( naturalSize, Vector2( 80.0f, 160.0f ), TEST_LOCATION ); @@ -270,7 +280,7 @@ int UtcDaliVisualSize(void) fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf" ); propertyMap.Clear(); - propertyMap.Insert( Visual::Property::TYPE, Visual::TEXT ); + propertyMap.Insert( Visual::Property::TYPE, DevelVisual::TEXT ); propertyMap.Insert( TextVisual::Property::ENABLE_MARKUP, true ); propertyMap.Insert( TextVisual::Property::TEXT, "Hello world" ); propertyMap.Insert( TextVisual::Property::MULTI_LINE, true ); @@ -940,7 +950,7 @@ int UtcDaliVisualGetPropertyMap10(void) VisualFactory factory = VisualFactory::Get(); Property::Map propertyMap; - propertyMap.Insert( Visual::Property::TYPE, Visual::TEXT ); + propertyMap.Insert( Visual::Property::TYPE, DevelVisual::TEXT ); propertyMap.Insert( "renderingBackend", static_cast( Toolkit::Text::DEFAULT_RENDERING_BACKEND ) ); propertyMap.Insert( "text", "Hello world" ); propertyMap.Insert( "fontFamily", "TizenSans" ); @@ -955,9 +965,6 @@ int UtcDaliVisualGetPropertyMap10(void) propertyMap.Insert( "verticalAlignment", "CENTER" ); propertyMap.Insert( "textColor", Color::RED ); propertyMap.Insert( "enableMarkup", false ); - propertyMap.Insert( "enableAutoScroll", false ); - propertyMap.Insert( "lineSpacing", 0.f ); - propertyMap.Insert( "batchingEnabled", false ); Visual::Base textVisual = factory.CreateVisual( propertyMap ); Property::Map resultMap; @@ -966,11 +973,7 @@ int UtcDaliVisualGetPropertyMap10(void) //Check values in the result map are identical to the initial map's values. Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER ); DALI_TEST_CHECK( value ); - DALI_TEST_EQUALS( value->Get(), (int)Visual::TEXT, TEST_LOCATION ); - - value = resultMap.Find( TextVisual::Property::RENDERING_BACKEND, Property::INTEGER ); - DALI_TEST_CHECK( value ); - DALI_TEST_EQUALS( value->Get(), Toolkit::Text::DEFAULT_RENDERING_BACKEND, TEST_LOCATION ); + DALI_TEST_EQUALS( value->Get(), (int)DevelVisual::TEXT, TEST_LOCATION ); value = resultMap.Find( TextVisual::Property::TEXT, Property::STRING ); DALI_TEST_CHECK( value ); @@ -1011,17 +1014,6 @@ int UtcDaliVisualGetPropertyMap10(void) DALI_TEST_CHECK( value ); DALI_TEST_CHECK( !value->Get() ); - value = resultMap.Find( TextVisual::Property::ENABLE_AUTO_SCROLL, Property::BOOLEAN ); - DALI_TEST_CHECK( !value ); - - value = resultMap.Find( TextVisual::Property::LINE_SPACING, Property::FLOAT ); - DALI_TEST_CHECK( value ); - DALI_TEST_EQUALS( value->Get(), 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - value = resultMap.Find( TextVisual::Property::BATCHING_ENABLED, Property::BOOLEAN ); - DALI_TEST_CHECK( value ); - DALI_TEST_CHECK( !value->Get() ); - END_TEST; } @@ -1677,3 +1669,44 @@ int UtcDaliVisualRendererRemovalAndReAddition(void) END_TEST; } + + + +int UtcDaliVisualTextVisualRender(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliVisualTextVisualRender" ); + + VisualFactory factory = VisualFactory::Get(); + Property::Map propertyMap; + propertyMap.Insert( Visual::Property::TYPE, DevelVisual::TEXT ); + propertyMap.Insert( "renderingBackend", static_cast( Toolkit::Text::DEFAULT_RENDERING_BACKEND ) ); + propertyMap.Insert( "text", "Hello world" ); + propertyMap.Insert( "fontFamily", "TizenSans" ); + + Property::Map fontStyleMapSet; + fontStyleMapSet.Insert( "weight", "bold" ); + propertyMap.Insert( "fontStyle", fontStyleMapSet ); + + propertyMap.Insert( "pointSize", 12.f ); + propertyMap.Insert( "multiLine", true ); + propertyMap.Insert( "horizontalAlignment", "CENTER" ); + propertyMap.Insert( "verticalAlignment", "CENTER" ); + propertyMap.Insert( "textColor", Color::RED ); + propertyMap.Insert( "enableMarkup", false ); + Visual::Base textVisual = factory.CreateVisual( propertyMap ); + textVisual.SetDepthIndex( 1.f ); + + DummyControl dummyControl = DummyControl::New(true); + DummyControlImpl& dummyImpl = static_cast(dummyControl.GetImplementation()); + dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, textVisual ); + DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION ); + + dummyControl.SetSize(200.f, 200.f); + + Stage::GetCurrent().Add( dummyControl ); + application.SendNotification(); + application.Render(); + + END_TEST; +} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp b/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp index 7d36ae6..ae8761f 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include #include "dummy-control.h" @@ -47,6 +49,18 @@ static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png"; // resolution: 600*600, pixel format: RGB888 static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg"; +Property::Map DefaultTransform() +{ + Property::Map transformMap; + transformMap + .Add( Toolkit::VisualProperty::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) ) + .Add( Toolkit::VisualProperty::Transform::Property::SIZE, Vector2(1.0f, 1.0f) ) + .Add( Toolkit::VisualProperty::Transform::Property::ORIGIN, Toolkit::Align::CENTER ) + .Add( Toolkit::VisualProperty::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER ) + .Add( Toolkit::VisualProperty::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO ); + return transformMap; +} + Integration::Bitmap* CreateBitmap( unsigned int imageWidth, unsigned int imageHeight, unsigned int initialColor, Pixel::Format pixelFormat ) { Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN ); @@ -372,7 +386,7 @@ int UtcDaliVisualFactoryGetBorderVisual1(void) dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual ); actor.SetSize(200.f, 200.f); Stage::GetCurrent().Add( actor ); - visual.SetSize(Vector2(200.f, 200.f)); + visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f)); DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); int blendMode = actor.GetRendererAt(0u).GetProperty( Renderer::Property::BLEND_MODE ); @@ -420,7 +434,7 @@ int UtcDaliVisualFactoryGetBorderVisual2(void) dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual ); actor.SetSize(200.f, 200.f); Stage::GetCurrent().Add( actor ); - visual.SetSize(Vector2(200.f, 200.f)); + visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f)); DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); @@ -971,9 +985,8 @@ int UtcDaliVisualFactoryGetNPatchVisual3(void) ResourceImage image = ResourceImage::New(TEST_NPATCH_FILE_NAME); Visual::Base nPatchVisual = factory.CreateVisual( image ); - Vector2 visualSize( 20.f, 30.f ), naturalSize(0,0); - nPatchVisual.SetSize( visualSize ); - DALI_TEST_EQUALS( nPatchVisual.GetSize(), visualSize, TEST_LOCATION ); + Vector2 controlSize( 20.f, 30.f ), naturalSize(0,0); + nPatchVisual.SetTransformAndSize(DefaultTransform(), controlSize ); nPatchVisual.GetNaturalSize( naturalSize ); DALI_TEST_EQUALS( naturalSize, Vector2( ninePatchImageWidth-2, ninePatchImageHeight-2 ), TEST_LOCATION ); @@ -1124,7 +1137,7 @@ int UtcDaliVisualFactoryGetSvgVisual(void) dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual ); actor.SetSize( 200.f, 200.f ); Stage::GetCurrent().Add( actor ); - visual.SetSize( Vector2(200.f, 200.f) ); + visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f) ); application.SendNotification(); application.Render(); @@ -1132,11 +1145,7 @@ int UtcDaliVisualFactoryGetSvgVisual(void) // renderer is not added to actor until the rasterization is completed. DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); - EventThreadCallback* eventTrigger = EventThreadCallback::Get(); - CallbackBase* callback = eventTrigger->GetCallback(); - - eventTrigger->WaitingForTrigger( 1 );// waiting until the svg image is rasterized. - CallbackBase::Execute( *callback ); + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); // renderer is added to actor DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); @@ -1163,8 +1172,9 @@ int UtcDaliVisualFactoryGetSvgVisualLarge(void) TraceCallStack& textureTrace = gl.GetTextureTrace(); textureTrace.Enable(true); - DummyControl actor = DummyControl::New(); + DummyControl actor = DummyControl::New(true); DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); + actor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); // Only rasterizes when it knows control size. dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual ); Stage::GetCurrent().Add( actor ); @@ -1174,11 +1184,7 @@ int UtcDaliVisualFactoryGetSvgVisualLarge(void) // renderer is not added to actor until the rasterization is completed. DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); - EventThreadCallback* eventTrigger = EventThreadCallback::Get(); - CallbackBase* callback = eventTrigger->GetCallback(); - - eventTrigger->WaitingForTrigger( 1 );// waiting until the svg image is rasterized. - CallbackBase::Execute( *callback ); + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); // renderer is added to actor DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); @@ -1209,7 +1215,7 @@ void MeshVisualLoadsCorrectlyTest( Property::Map& propertyMap, ToolkitTestApplic dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual ); actor.SetSize( 200.f, 200.f ); Stage::GetCurrent().Add( actor ); - visual.SetSize( Vector2( 200.f, 200.f ) ); + visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) ); //Ensure set on stage. DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); @@ -1256,7 +1262,7 @@ void MeshVisualDoesNotLoadCorrectlyTest( Property::Map& propertyMap, ToolkitTest dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual ); actor.SetSize( 200.f, 200.f ); Stage::GetCurrent().Add( actor ); - visual.SetSize( Vector2( 200.f, 200.f ) ); + visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) ); //Ensure set on stage. DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); @@ -1538,7 +1544,7 @@ void TestPrimitiveVisualWithProperties( Property::Map& propertyMap, ToolkitTestA actor.SetSize( 200.f, 200.f ); Stage::GetCurrent().Add( actor ); - visual.SetSize( Vector2( 200.f, 200.f ) ); + visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) ); //Ensure set on stage. DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); @@ -1959,7 +1965,7 @@ int UtcDaliVisualFactoryGetBatchImageVisual1(void) actor.SetSize( 200.0f, 200.0f ); Stage::GetCurrent().Add( actor ); - visual.SetSize( Vector2( 200.0f, 200.0f ) ); + visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.0f, 200.0f ) ); // Test SetOnStage(). DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); @@ -2008,7 +2014,7 @@ int UtcDaliVisualFactoryGetBatchImageVisual2(void) actor.SetSize( 200.0f, 200.0f ); Stage::GetCurrent().Add( actor ); - visual.SetSize( Vector2( 200.0f, 200.0f ) ); + visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.0f, 200.0f ) ); // Test SetOnStage(). DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); diff --git a/build/tizen/dali-toolkit/Makefile.am b/build/tizen/dali-toolkit/Makefile.am index 166feb4..38f4c89 100644 --- a/build/tizen/dali-toolkit/Makefile.am +++ b/build/tizen/dali-toolkit/Makefile.am @@ -118,6 +118,7 @@ develapitransitioneffectsdir = $(develapidir)/transition-effects develapitoolbardir = $(develapicontrolsdir)/tool-bar develapitextselectionpopupdir = $(develapicontrolsdir)/text-controls develapivisualfactorydir = $(develapidir)/visual-factory +develapivisualsdir = $(develapidir)/visuals # devel headers develapi_HEADERS = $(devel_api_header_files) @@ -135,6 +136,7 @@ develapipageturnview_HEADERS = $(devel_api_page_turn_view_header_files) develapipopup_HEADERS = $(devel_api_popup_header_files) develapiprogressbar_HEADERS = $(devel_api_progress_bar_header_files) develapivisualfactory_HEADERS = $(devel_api_visual_factory_header_files) +develapivisuals_HEADERS = $(devel_api_visuals_header_files) develapiscripting_HEADERS = $(devel_api_scripting_header_files) develapishadowview_HEADERS = $(devel_api_shadow_view_header_files) develapishadereffects_HEADERS = $(devel_api_shader_effects_header_files) diff --git a/build/tizen/docs-internal/dali-internal.doxy.in b/build/tizen/docs-internal/dali-internal.doxy.in index b4c92ce..fce6213 100644 --- a/build/tizen/docs-internal/dali-internal.doxy.in +++ b/build/tizen/docs-internal/dali-internal.doxy.in @@ -351,28 +351,55 @@ ALIASES += clip{3}="\dontinclude \1 \n \skip \2 \n \until \3" # For Open Source DALi API Reference ALIASES += SINCE_1_0="@since 1.0" ALIASES += SINCE_1_1="@since 1.1" +ALIASES += SINCE_1_2="@since 1.2" + +# Extra tags for Tizen 3.0 +ALIASES += SINCE_1_2_2="@since 1.2.2" +ALIASES += SINCE_1_2_4="@since 1.2.4" +ALIASES += SINCE_1_2_5="@since 1.2.5" +ALIASES += SINCE_1_2_10="@since 1.2.10" +ALIASES += SINCE_1_2_14="@since 1.2.14" ALIASES += DEPRECATED_1_0="@deprecated Deprecated since 1.0" ALIASES += DEPRECATED_1_1="@deprecated Deprecated since 1.1" +ALIASES += DEPRECATED_1_2_10="@deprecated Deprecated since 1.2.10" +ALIASES += DEPRECATED_1_2="@deprecated Deprecated since 1.2" ALIASES += PLATFORM="" ALIASES += PRIVLEVEL_PLATFORM="" +ALIASES += PRIVLEVEL_PUBLIC="" ALIASES += PRIVILEGE_KEYGRAB="" +ALIASES += PRIVILEGE_DISPLAY="" +ALIASES += REMARK_INTERNET="" +ALIASES += REMARK_STORAGE="" ############################################ ## For Tizen Native API Reference #ALIASES += SINCE_1_0="\par Since:\n 2.4, DALi version 1.0" #ALIASES += SINCE_1_1="\par Since:\n 3.0, DALi version 1.1" +#ALIASES += SINCE_1_2="\par Since:\n 4.0, DALi version 1.2" + +## Extra tags for Tizen 3.0 +#ALIASES += SINCE_1_2_2="\par Since:\n 3.0, DALi version 1.2.2" +#ALIASES += SINCE_1_2_4="\par Since:\n 3.0, DALi version 1.2.4" +#ALIASES += SINCE_1_2_5="\par Since:\n 3.0, DALi version 1.2.5" +#ALIASES += SINCE_1_2_10="\par Since:\n 3.0, DALi version 1.2.10" +#ALIASES += SINCE_1_2_14="\par Since:\n 3.0, DALi version 1.2.14" ## DALi has no deprecated API in Tizen 2.4 because it's DALi's first release. ## Thus deprecated APIs in DALi 1.0.xx will be deprecated in Tizen 3.0. #ALIASES += DEPRECATED_1_0="@deprecated Deprecated since 3.0, DALi version 1.0" #ALIASES += DEPRECATED_1_1="@deprecated Deprecated since 3.0, DALi version 1.1" +#ALIASES += DEPRECATED_1_2_10="@deprecated Deprecated since 3.0, DALi version 1.2.10" +#ALIASES += DEPRECATED_1_2="@deprecated Deprecated since 4.0, DALi version 1.2" #ALIASES += PLATFORM="@platform" #ALIASES += PRIVLEVEL_PLATFORM="\par Privilege Level:\n platform" +#ALIASES += PRIVLEVEL_PUBLIC="\par Privilege Level:\n public" #ALIASES += PRIVILEGE_KEYGRAB="\par Privilege:\n http://tizen.org/privilege/keygrab" - +#ALIASES += PRIVILEGE_DISPLAY="\par Privilege:\n http://tizen.org/privilege/display" +#ALIASES += REMARK_INTERNET="@remarks %http://tizen.org/privilege/internet is needed if @a url is a http or https address." +#ALIASES += REMARK_STORAGE="@remarks %http://tizen.org/privilege/mediastorage is needed if @a url is relevant to media storage. @remarks %http://tizen.org/privilege/externalstorage is needed if @a url is relevant to external storage." # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding "class=itcl::class" diff --git a/build/tizen/docs/dali.doxy.in b/build/tizen/docs/dali.doxy.in index 6007065..69e8acb 100644 --- a/build/tizen/docs/dali.doxy.in +++ b/build/tizen/docs/dali.doxy.in @@ -364,6 +364,7 @@ ALIASES += PRIVLEVEL_PUBLIC="" ALIASES += PRIVILEGE_KEYGRAB="" ALIASES += PRIVILEGE_DISPLAY="" ALIASES += REMARK_INTERNET="" +ALIASES += REMARK_STORAGE="" ############################################ ## For Tizen Native API Reference @@ -391,7 +392,7 @@ ALIASES += REMARK_INTERNET="" #ALIASES += PRIVILEGE_KEYGRAB="\par Privilege:\n http://tizen.org/privilege/keygrab" #ALIASES += PRIVILEGE_DISPLAY="\par Privilege:\n http://tizen.org/privilege/display" #ALIASES += REMARK_INTERNET="@remarks %http://tizen.org/privilege/internet is needed if @a url is a http or https address." - +#ALIASES += REMARK_STORAGE="@remarks %http://tizen.org/privilege/mediastorage is needed if @a url is relevant to media storage. @remarks %http://tizen.org/privilege/externalstorage is needed if @a url is relevant to external storage." # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding "class=itcl::class" diff --git a/build/tizen/plugins/csharp/Makefile.am b/build/tizen/plugins/csharp/Makefile.am index 8aa499a..0e32717 100755 --- a/build/tizen/plugins/csharp/Makefile.am +++ b/build/tizen/plugins/csharp/Makefile.am @@ -18,13 +18,14 @@ BUILT_SOURCES = \ $(dali_swig_dir)/automatic/cpp/dali_wrap.cpp \ $(dali_swig_dir)/automatic/cpp/dali_wrap.h \ $(dali_swig_dir)/manual/cpp/keyboard_focus_manager_wrap.cpp \ - $(dali_swig_dir)/manual/cpp/view-wrapper-impl-wrap.cpp + $(dali_swig_dir)/manual/cpp/view-wrapper-impl-wrap.cpp \ + $(dali_swig_dir)/manual/cpp/callbackbase_wrap.cpp all-local: gbs-local: libNDalic.so NDali.dll -libNDalic.so: $(dali_swig_dir)/automatic/cpp/dali_wrap.o $(dali_swig_dir)/manual/cpp/keyboard_focus_manager_wrap.o $(dali_swig_dir)/manual/cpp/view-wrapper-impl-wrap.o - $(CXX) -shared $(dali_swig_dir)/automatic/cpp/dali_wrap.o $(dali_swig_dir)/manual/cpp/keyboard_focus_manager_wrap.o $(dali_swig_dir)/manual/cpp/view-wrapper-impl-wrap.o -o $(dali_swig_dir)/libNDalic.so $(DALICORE_LIBS) $(DALIADAPTOR_LIBS) $(DALITOOLKIT_LIBS) +libNDalic.so: $(dali_swig_dir)/automatic/cpp/dali_wrap.o $(dali_swig_dir)/manual/cpp/keyboard_focus_manager_wrap.o $(dali_swig_dir)/manual/cpp/view-wrapper-impl-wrap.o $(dali_swig_dir)/manual/cpp/callbackbase_wrap.o + $(CXX) -shared $(dali_swig_dir)/automatic/cpp/dali_wrap.o $(dali_swig_dir)/manual/cpp/keyboard_focus_manager_wrap.o $(dali_swig_dir)/manual/cpp/view-wrapper-impl-wrap.o $(dali_swig_dir)/manual/cpp/callbackbase_wrap.o -o $(dali_swig_dir)/libNDalic.so $(DALICORE_LIBS) $(DALIADAPTOR_LIBS) $(DALITOOLKIT_LIBS) $(dali_swig_dir)/automatic/cpp/dali_wrap.o: $(BUILT_SOURCES) $(CXX) -c -fpic $(CXXFLAGS) $(DALICORE_CFLAGS) $(DALIADAPTOR_CFLAGS) $(DALITOOLKIT_CFLAGS) $(dali_swig_dir)/automatic/cpp/dali_wrap.cpp -o $(dali_swig_dir)/automatic/cpp/dali_wrap.o @@ -35,6 +36,9 @@ $(dali_swig_dir)/manual/cpp/keyboard_focus_manager_wrap.o: $(BUILT_SOURCES) $(dali_swig_dir)/manual/cpp/view-wrapper-impl-wrap.o: $(BUILT_SOURCES) $(CXX) -c -fpic $(CXXFLAGS) $(DALICORE_CFLAGS) $(DALIADAPTOR_CFLAGS) $(DALITOOLKIT_CFLAGS) $(dali_swig_dir)/manual/cpp/view-wrapper-impl-wrap.cpp -o $(dali_swig_dir)/manual/cpp/view-wrapper-impl-wrap.o +$(dali_swig_dir)/manual/cpp/callbackbase_wrap.cpp.o: $(BUILT_SOURCES) + $(CXX) -c -fpic $(CXXFLAGS) $(DALICORE_CFLAGS) $(DALIADAPTOR_CFLAGS) $(DALITOOLKIT_CFLAGS) $(dali_swig_dir)/manual/cpp/callbackbase_wrap.cpp -o $(dali_swig_dir)/manual/cpp/callbackbase_wrap.o + NDali.dll: $(BUILT_SOURCES) # mcs -nologo -target:library -out:$(dali_swig_dir)/NDali.dll $(dali_swig_dir)/automatic/csharp/*.cs $(dali_swig_dir)/manual/csharp/*.cs diff --git a/dali-toolkit/dali-toolkit.h b/dali-toolkit/dali-toolkit.h index ba7e85b..c155cc2 100644 --- a/dali-toolkit/dali-toolkit.h +++ b/dali-toolkit/dali-toolkit.h @@ -64,7 +64,6 @@ #include #include #include -#include #include #include diff --git a/dali-toolkit/devel-api/file.list b/dali-toolkit/devel-api/file.list index a0cd28a..26846a0 100755 --- a/dali-toolkit/devel-api/file.list +++ b/dali-toolkit/devel-api/file.list @@ -84,6 +84,10 @@ devel_api_visual_factory_header_files = \ $(devel_api_src_dir)/visual-factory/visual-factory.h \ $(devel_api_src_dir)/visual-factory/visual-base.h +devel_api_visuals_header_files = \ + $(devel_api_src_dir)/visuals/text-visual-properties.h \ + $(devel_api_src_dir)/visuals/visual-properties-devel.h + devel_api_shadow_view_header_files = \ $(devel_api_src_dir)/controls/shadow-view/shadow-view.h diff --git a/dali-toolkit/devel-api/visual-factory/visual-base.cpp b/dali-toolkit/devel-api/visual-factory/visual-base.cpp index c5b822d..790a3e7 100644 --- a/dali-toolkit/devel-api/visual-factory/visual-base.cpp +++ b/dali-toolkit/devel-api/visual-factory/visual-base.cpp @@ -61,14 +61,9 @@ const std::string& Visual::Base::GetName() return GetImplementation( *this ).GetName(); } -void Visual::Base::SetSize( const Vector2& size ) +void Visual::Base::SetTransformAndSize( const Property::Map& transform, Size controlSize ) { - GetImplementation( *this ).SetSize( size ); -} - -const Vector2& Visual::Base::GetSize() const -{ - return GetImplementation( *this ).GetSize(); + GetImplementation( *this ).SetTransformAndSize( transform, controlSize ); } float Visual::Base::GetHeightForWidth( float width ) const diff --git a/dali-toolkit/devel-api/visual-factory/visual-base.h b/dali-toolkit/devel-api/visual-factory/visual-base.h index 7cfadbf..8b0f576 100644 --- a/dali-toolkit/devel-api/visual-factory/visual-base.h +++ b/dali-toolkit/devel-api/visual-factory/visual-base.h @@ -128,18 +128,12 @@ public: const std::string& GetName(); /** - * @brief Set the size of the painting area. + * @brief Sets the transform and the control size * - * @param[in] size The size of the painting area. + * @param[in] transform A property map describing the transform + * @param[in] controlSize The size of the parent control for visuals that need to scale internally. */ - void SetSize( const Vector2& size ); - - /** - * @brief Get the size of the painting area. - * - * @return The size of the visual's painting area. - */ - const Vector2& GetSize() const; + void SetTransformAndSize( const Dali::Property::Map& transform, Size controlSize ); /** * @brief Returns the height for a given width. @@ -153,7 +147,11 @@ public: /** * @brief Return the natural size of the visual. * - * Deriving classes stipulate the natural size and by default a visual has a ZERO natural size. + * Deriving classes stipulate the natural size and by default a + * visual has a ZERO natural size. + * + * @note A visual may not actually have a natural size until it has + * been placed on stage and acquired all it's resources. * * @param[out] naturalSize The visual's natural size */ diff --git a/dali-toolkit/devel-api/visuals/text-visual-properties.h b/dali-toolkit/devel-api/visuals/text-visual-properties.h new file mode 100644 index 0000000..dfb91ec --- /dev/null +++ b/dali-toolkit/devel-api/visuals/text-visual-properties.h @@ -0,0 +1,101 @@ +#ifndef DALI_TOOLKIT_TEXT_VISUAL_PROPERTIES_H +#define DALI_TOOLKIT_TEXT_VISUAL_PROPERTIES_H + +/* + * Copyright (c) 2016 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 + +namespace Dali +{ + +namespace Toolkit +{ + +namespace TextVisual +{ + +namespace Property +{ + +enum +{ + /** + * @brief The text to display in UTF-8 format, + * @details name "text", type STRING + */ + TEXT = VISUAL_PROPERTY_START_INDEX, + + /** + * @brief The requested font family to use, + * @details name "fontFamily", type STRING + */ + FONT_FAMILY, + + /** + * @brief The requested font style to use, + * @details name "fontStyle", type MAP + */ + FONT_STYLE, + + /** + * @brief The size of font in points + * @details name "pointSize", type FLOAT + */ + POINT_SIZE, + + /** + * @brief The single-line or multi-line layout option + * @details name "multiLine", type BOOLEAN, default false + */ + MULTI_LINE, + + /** + * @brief The line horizontal alignment + * @details name "horizontalAlignment", type STRING, values "BEGIN", "CENTER", "END", default BEGIN + */ + HORIZONTAL_ALIGNMENT, + + /** + * @brief The line vertical alignment + * @details name "verticalAlignment", type STRING, values "TOP", "CENTER", "BOTTOM", default TOP + */ + VERTICAL_ALIGNMENT, + + /** + * @brief The color of the text + * @details name "textColor", type VECTOR4 + */ + TEXT_COLOR, + + /** + * @brief Whether the mark-up processing is enabled + * @details name "enableMarkup", type BOOLEAN + */ + ENABLE_MARKUP, +}; + +} // namespace Property + +} // namespace TextVisual + +} // namespace Toolkit + +} // namespace Dali + +#endif // DALI_TOOLKIT_TEXT_VISUAL_PROPERTIES_H diff --git a/dali-toolkit/devel-api/visuals/visual-properties-devel.h b/dali-toolkit/devel-api/visuals/visual-properties-devel.h new file mode 100644 index 0000000..08f5c3a --- /dev/null +++ b/dali-toolkit/devel-api/visuals/visual-properties-devel.h @@ -0,0 +1,54 @@ +#ifndef DALI_TOOLKIT_VISUAL_PROPERTIES_DEVEL_H +#define DALI_TOOLKIT_VISUAL_PROPERTIES_DEVEL_H + +/* + * Copyright (c) 2016 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 + +namespace Dali +{ + +namespace Toolkit +{ + +namespace DevelVisual +{ + +/** + * @brief All the visual types. + */ +enum Type +{ + BORDER = Dali::Toolkit::Visual::BORDER, + COLOR = Dali::Toolkit::Visual::COLOR, + GRADIENT = Dali::Toolkit::Visual::GRADIENT, + IMAGE = Dali::Toolkit::Visual::IMAGE, + MESH = Dali::Toolkit::Visual::MESH, + PRIMITIVE = Dali::Toolkit::Visual::PRIMITIVE, + WIREFRAME = Dali::Toolkit::Visual::WIREFRAME, + TEXT = Dali::Toolkit::Visual::WIREFRAME + 1, ///< Renders text. +}; + +} // namespace DevelVisual + +} // namespace Toolkit + +} // namespace Dali + +#endif // DALI_TOOLKIT_VISUAL_PROPERTIES_DEVEL_H diff --git a/dali-toolkit/internal/controls/image-view/image-view-impl.cpp b/dali-toolkit/internal/controls/image-view/image-view-impl.cpp index 3c19992..f19f390 100644 --- a/dali-toolkit/internal/controls/image-view/image-view-impl.cpp +++ b/dali-toolkit/internal/controls/image-view/image-view-impl.cpp @@ -15,6 +15,7 @@ #include #include #include +#include namespace Dali { @@ -42,6 +43,19 @@ DALI_PROPERTY_REGISTRATION( Toolkit, ImageView, "preMultipliedAlpha", BOOLEAN, P DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT( Toolkit, ImageView, "pixelArea", Vector4(0.f, 0.f, 1.f, 1.f), PIXEL_AREA ) DALI_TYPE_REGISTRATION_END() + +void SetDefaultTransformMap( Property::Map& transformMap ) +{ + transformMap.Clear(); + transformMap + .Add( Toolkit::Visual::DevelProperty::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) ) + .Add( Toolkit::Visual::DevelProperty::Transform::Property::SIZE, Vector2(1.0f, 1.0f) ) + .Add( Toolkit::Visual::DevelProperty::Transform::Property::ORIGIN, Toolkit::Align::CENTER ) + .Add( Toolkit::Visual::DevelProperty::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER ) + .Add( Toolkit::Visual::DevelProperty::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO ); + +} + } // anonymous namespace using namespace Dali; @@ -138,9 +152,13 @@ void ImageView::SetImage( const std::string& url, ImageDimensions size ) } mVisual = Toolkit::VisualFactory::Get().CreateVisual( url, size ); - RegisterVisual( Toolkit::ImageView::Property::IMAGE, mVisual ); + RegisterVisual( Toolkit::ImageView::Property::IMAGE, mVisual ); - mVisual.SetSize( mSizeSet ); + // This transform fills the control + // Should provide a transform that handles aspect ratio according to image size + Property::Map transformMap; + SetDefaultTransformMap( transformMap ); + mVisual.SetTransformAndSize( transformMap, mSizeSet ); RelayoutRequest(); } @@ -239,7 +257,12 @@ void ImageView::OnSizeSet( const Vector3& targetSize ) if( mVisual ) { Vector2 size( targetSize ); - mVisual.SetSize( size ); + + // This transform fills the control + // Should provide a transform that handles aspect ratio according to image size + Property::Map transformMap; + SetDefaultTransformMap( transformMap ); + mVisual.SetTransformAndSize( transformMap, size ); } } 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 299ef5d..81696b7 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -65,9 +65,9 @@ namespace const Scripting::StringEnum 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 }, + { "BEGIN", Toolkit::Text::Layout::HORIZONTAL_ALIGN_BEGIN }, + { "CENTER", Toolkit::Text::Layout::HORIZONTAL_ALIGN_CENTER }, + { "END", Toolkit::Text::Layout::HORIZONTAL_ALIGN_END }, }; const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] ); @@ -173,7 +173,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P { if( impl.mController ) { - const std::string text = value.Get< std::string >(); + const std::string& text = value.Get< std::string >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p TEXT %s\n", impl.mController.Get(), text.c_str() ); impl.mController->SetText( text ); @@ -184,12 +184,12 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P { if( impl.mController ) { - const Vector4 textColor = value.Get< Vector4 >(); + const Vector4& textColor = value.Get< Vector4 >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a ); - if( impl.mController->GetTextColor() != textColor ) + if( impl.mController->GetDefaultColor() != textColor ) { - impl.mController->SetTextColor( textColor ); + impl.mController->SetDefaultColor( textColor ); impl.mController->SetInputColor( textColor ); impl.mRenderer.Reset(); } @@ -200,7 +200,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P { if( impl.mController ) { - const std::string fontFamily = value.Get< std::string >(); + const std::string& fontFamily = value.Get< std::string >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() ); impl.mController->SetDefaultFontFamily( fontFamily ); } @@ -229,14 +229,14 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P { if( impl.mController ) { - const std::string alignStr = value.Get< std::string >(); + const std::string& alignStr = value.Get< std::string >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p HORIZONTAL_ALIGNMENT %s\n", impl.mController.Get(), alignStr.c_str() ); - LayoutEngine::HorizontalAlignment alignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN ); - if( Scripting::GetEnumeration< LayoutEngine::HorizontalAlignment >( alignStr.c_str(), - HORIZONTAL_ALIGNMENT_STRING_TABLE, - HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT, - alignment ) ) + Layout::HorizontalAlignment alignment( Layout::HORIZONTAL_ALIGN_BEGIN ); + if( Scripting::GetEnumeration< Layout::HorizontalAlignment >( alignStr.c_str(), + HORIZONTAL_ALIGNMENT_STRING_TABLE, + HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT, + alignment ) ) { impl.mController->SetHorizontalAlignment( alignment ); } @@ -269,7 +269,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P { if( impl.mDecorator ) { - const Vector4 color = value.Get< Vector4 >(); + const Vector4& color = value.Get< Vector4 >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p PRIMARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a ); impl.mDecorator->SetCursorColor( PRIMARY_CURSOR, color ); @@ -281,7 +281,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P { if( impl.mDecorator ) { - const Vector4 color = value.Get< Vector4 >(); + const Vector4& color = value.Get< Vector4 >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p SECONDARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a ); impl.mDecorator->SetCursorColor( SECONDARY_CURSOR, color ); @@ -441,7 +441,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P { if( impl.mDecorator ) { - const Rect box = value.Get< Rect >(); + const Rect& box = value.Get< Rect >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p DECORATION_BOUNDING_BOX %d,%d %dx%d\n", impl.mController.Get(), box.x, box.y, box.width, box.height ); impl.mDecorator->SetBoundingBox( box ); @@ -464,7 +464,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P { if( impl.mController ) { - const Vector4 inputColor = value.Get< Vector4 >(); + const Vector4& inputColor = value.Get< Vector4 >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p INPUT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), inputColor.r, inputColor.g, inputColor.b, inputColor.a ); impl.mController->SetInputColor( inputColor ); @@ -475,7 +475,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P { if( impl.mController ) { - const std::string fontFamily = value.Get< std::string >(); + const std::string& fontFamily = value.Get< std::string >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p INPUT_FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() ); impl.mController->SetInputFontFamily( fontFamily ); } @@ -624,7 +624,7 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind { if ( impl.mController ) { - value = impl.mController->GetTextColor(); + value = impl.mController->GetDefaultColor(); } break; } @@ -653,9 +653,9 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind { if( impl.mController ) { - const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetLayoutEngine().GetHorizontalAlignment(), - HORIZONTAL_ALIGNMENT_STRING_TABLE, - HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT ); + const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::HorizontalAlignment >( impl.mController->GetHorizontalAlignment(), + HORIZONTAL_ALIGNMENT_STRING_TABLE, + HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT ); if( name ) { value = std::string( name ); @@ -938,7 +938,7 @@ void TextEditor::OnInitialize() mDecorator = Text::Decorator::New( *mController, *mController ); - mController->GetLayoutEngine().SetLayout( LayoutEngine::MULTI_LINE_BOX ); + mController->GetLayoutEngine().SetLayout( Layout::Engine::MULTI_LINE_BOX ); // Enables the text input. mController->EnableTextInput( mDecorator ); @@ -1088,7 +1088,7 @@ void TextEditor::RenderText( Text::Controller::UpdateTextType updateTextType ) if( mRenderableActor ) { - const Vector2& scrollOffset = mController->GetScrollPosition(); + const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition(); mRenderableActor.SetPosition( scrollOffset.x, scrollOffset.y ); diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index 4723b33..e95ac99 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -63,17 +63,17 @@ namespace const Scripting::StringEnum 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 }, + { "BEGIN", Toolkit::Text::Layout::HORIZONTAL_ALIGN_BEGIN }, + { "CENTER", Toolkit::Text::Layout::HORIZONTAL_ALIGN_CENTER }, + { "END", Toolkit::Text::Layout::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 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 }, + { "TOP", Toolkit::Text::Layout::VERTICAL_ALIGN_TOP }, + { "CENTER", Toolkit::Text::Layout::VERTICAL_ALIGN_CENTER }, + { "BOTTOM", Toolkit::Text::Layout::VERTICAL_ALIGN_BOTTOM }, }; const unsigned int VERTICAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( VERTICAL_ALIGNMENT_STRING_TABLE ) / sizeof( VERTICAL_ALIGNMENT_STRING_TABLE[0] ); @@ -199,7 +199,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { if( impl.mController ) { - const std::string text = value.Get< std::string >(); + const std::string& text = value.Get< std::string >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p TEXT %s\n", impl.mController.Get(), text.c_str() ); impl.mController->SetText( text ); @@ -210,7 +210,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { if( impl.mController ) { - const std::string text = value.Get< std::string >(); + const std::string& text = value.Get< std::string >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str() ); impl.mController->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text ); @@ -221,7 +221,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { if( impl.mController ) { - const std::string text = value.Get< std::string >(); + const std::string& text = value.Get< std::string >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_FOCUSED %s\n", impl.mController.Get(), text.c_str() ); impl.mController->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_ACTIVE, text ); @@ -232,7 +232,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { if( impl.mController ) { - const std::string fontFamily = value.Get< std::string >(); + const std::string& fontFamily = value.Get< std::string >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() ); impl.mController->SetDefaultFontFamily( fontFamily ); } @@ -277,14 +277,14 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { if( impl.mController ) { - const std::string alignStr = value.Get< std::string >(); + const std::string& alignStr = value.Get< std::string >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p HORIZONTAL_ALIGNMENT %s\n", impl.mController.Get(), alignStr.c_str() ); - LayoutEngine::HorizontalAlignment alignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN ); - if( Scripting::GetEnumeration< LayoutEngine::HorizontalAlignment >( alignStr.c_str(), - HORIZONTAL_ALIGNMENT_STRING_TABLE, - HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT, - alignment ) ) + Layout::HorizontalAlignment alignment( Layout::HORIZONTAL_ALIGN_BEGIN ); + if( Scripting::GetEnumeration< Layout::HorizontalAlignment >( alignStr.c_str(), + HORIZONTAL_ALIGNMENT_STRING_TABLE, + HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT, + alignment ) ) { impl.mController->SetHorizontalAlignment( alignment ); } @@ -295,14 +295,14 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { if( impl.mController ) { - const std::string alignStr = value.Get< std::string >(); + const std::string& alignStr = value.Get< std::string >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p VERTICAL_ALIGNMENT %s\n", impl.mController.Get(), alignStr.c_str() ); - LayoutEngine::VerticalAlignment alignment( LayoutEngine::VERTICAL_ALIGN_BOTTOM ); - if( Scripting::GetEnumeration< LayoutEngine::VerticalAlignment >( alignStr.c_str(), - VERTICAL_ALIGNMENT_STRING_TABLE, - VERTICAL_ALIGNMENT_STRING_TABLE_COUNT, - alignment ) ) + Layout::VerticalAlignment alignment( Layout::VERTICAL_ALIGN_BOTTOM ); + if( Scripting::GetEnumeration< Layout::VerticalAlignment >( alignStr.c_str(), + VERTICAL_ALIGNMENT_STRING_TABLE, + VERTICAL_ALIGNMENT_STRING_TABLE_COUNT, + alignment ) ) { impl.mController->SetVerticalAlignment( alignment ); } @@ -313,12 +313,12 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { if( impl.mController ) { - const Vector4 textColor = value.Get< Vector4 >(); + const Vector4& textColor = value.Get< Vector4 >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a ); - if( impl.mController->GetTextColor() != textColor ) + if( impl.mController->GetDefaultColor() != textColor ) { - impl.mController->SetTextColor( textColor ); + impl.mController->SetDefaultColor( textColor ); impl.mController->SetInputColor( textColor ); impl.mRenderer.Reset(); } @@ -329,7 +329,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { if( impl.mController ) { - const Vector4 textColor = value.Get< Vector4 >(); + const Vector4& textColor = value.Get< Vector4 >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %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 ) @@ -344,7 +344,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { if( impl.mController ) { - const Vector2 shadowOffset = value.Get< Vector2 >(); + const Vector2& shadowOffset = value.Get< Vector2 >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SHADOW_OFFSET %f,%f\n", impl.mController.Get(), shadowOffset.x, shadowOffset.y ); if ( impl.mController->GetShadowOffset() != shadowOffset ) @@ -359,7 +359,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { if( impl.mController ) { - const Vector4 shadowColor = value.Get< Vector4 >(); + const Vector4& shadowColor = value.Get< Vector4 >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SHADOW_COLOR %f,%f,%f,%f\n", impl.mController.Get(), shadowColor.r, shadowColor.g, shadowColor.b, shadowColor.a ); if ( impl.mController->GetShadowColor() != shadowColor ) @@ -374,7 +374,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { if( impl.mDecorator ) { - const Vector4 color = value.Get< Vector4 >(); + const Vector4& color = value.Get< Vector4 >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PRIMARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a ); impl.mDecorator->SetCursorColor( PRIMARY_CURSOR, color ); @@ -386,7 +386,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { if( impl.mDecorator ) { - const Vector4 color = value.Get< Vector4 >(); + const Vector4& color = value.Get< Vector4 >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SECONDARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a ); impl.mDecorator->SetCursorColor( SECONDARY_CURSOR, color ); @@ -608,7 +608,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { if( impl.mController ) { - const std::string fontFamily = value.Get< std::string >(); + const std::string& fontFamily = value.Get< std::string >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p INPUT_FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() ); impl.mController->SetInputFontFamily( fontFamily ); } @@ -791,9 +791,9 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde { if( impl.mController ) { - const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetLayoutEngine().GetHorizontalAlignment(), - HORIZONTAL_ALIGNMENT_STRING_TABLE, - HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT ); + const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::HorizontalAlignment >( impl.mController->GetHorizontalAlignment(), + HORIZONTAL_ALIGNMENT_STRING_TABLE, + HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT ); if( name ) { value = std::string( name ); @@ -803,11 +803,11 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde } case Toolkit::TextField::Property::VERTICAL_ALIGNMENT: { - if( impl.mController ) + if( impl.mController ) { - const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( impl.mController->GetLayoutEngine().GetVerticalAlignment(), - VERTICAL_ALIGNMENT_STRING_TABLE, - VERTICAL_ALIGNMENT_STRING_TABLE_COUNT ); + const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::VerticalAlignment >( impl.mController->GetVerticalAlignment(), + VERTICAL_ALIGNMENT_STRING_TABLE, + VERTICAL_ALIGNMENT_STRING_TABLE_COUNT ); if( name ) { value = std::string( name ); @@ -819,7 +819,7 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde { if ( impl.mController ) { - value = impl.mController->GetTextColor(); + value = impl.mController->GetDefaultColor(); } break; } @@ -1123,7 +1123,7 @@ void TextField::OnInitialize() mDecorator = Text::Decorator::New( *mController, *mController ); - mController->GetLayoutEngine().SetLayout( LayoutEngine::SINGLE_LINE_BOX ); + mController->GetLayoutEngine().SetLayout( Layout::Engine::SINGLE_LINE_BOX ); // Enables the text input. mController->EnableTextInput( mDecorator ); @@ -1267,7 +1267,7 @@ void TextField::RenderText( Text::Controller::UpdateTextType updateTextType ) if( mRenderableActor ) { - const Vector2& scrollOffset = mController->GetScrollPosition(); + const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition(); mRenderableActor.SetPosition( scrollOffset.x, scrollOffset.y ); 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 094e755..0129388 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -33,7 +33,7 @@ #include #include -using Dali::Toolkit::Text::LayoutEngine; +using namespace Dali::Toolkit::Text; namespace Dali { @@ -58,17 +58,17 @@ namespace const Scripting::StringEnum 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 }, + { "BEGIN", Toolkit::Text::Layout::HORIZONTAL_ALIGN_BEGIN }, + { "CENTER", Toolkit::Text::Layout::HORIZONTAL_ALIGN_CENTER }, + { "END", Toolkit::Text::Layout::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 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 }, + { "TOP", Toolkit::Text::Layout::VERTICAL_ALIGN_TOP }, + { "CENTER", Toolkit::Text::Layout::VERTICAL_ALIGN_CENTER }, + { "BOTTOM", Toolkit::Text::Layout::VERTICAL_ALIGN_BOTTOM }, }; const unsigned int VERTICAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( VERTICAL_ALIGNMENT_STRING_TABLE ) / sizeof( VERTICAL_ALIGNMENT_STRING_TABLE[0] ); @@ -170,7 +170,7 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr { if( impl.mController ) { - const std::string fontFamily = value.Get< std::string >(); + const std::string& fontFamily = value.Get< std::string >(); DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextLabel::SetProperty Property::FONT_FAMILY newFont(%s)\n", fontFamily.c_str() ); impl.mController->SetDefaultFontFamily( fontFamily ); @@ -207,11 +207,11 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr { if( impl.mController ) { - LayoutEngine::HorizontalAlignment alignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN ); - if( Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::HorizontalAlignment >( value.Get< std::string >().c_str(), - HORIZONTAL_ALIGNMENT_STRING_TABLE, - HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT, - alignment ) ) + Layout::HorizontalAlignment alignment( Layout::HORIZONTAL_ALIGN_BEGIN ); + if( Scripting::GetEnumeration< Toolkit::Text::Layout::HorizontalAlignment >( value.Get< std::string >().c_str(), + HORIZONTAL_ALIGNMENT_STRING_TABLE, + HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT, + alignment ) ) { impl.mController->SetHorizontalAlignment( alignment ); } @@ -222,11 +222,11 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr { if( impl.mController ) { - LayoutEngine::VerticalAlignment alignment( LayoutEngine::VERTICAL_ALIGN_BOTTOM ); - if( Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::VerticalAlignment >( value.Get< std::string >().c_str(), - VERTICAL_ALIGNMENT_STRING_TABLE, - VERTICAL_ALIGNMENT_STRING_TABLE_COUNT, - alignment ) ) + Layout::VerticalAlignment alignment( Layout::VERTICAL_ALIGN_BOTTOM ); + if( Scripting::GetEnumeration< Toolkit::Text::Layout::VerticalAlignment >( value.Get< std::string >().c_str(), + VERTICAL_ALIGNMENT_STRING_TABLE, + VERTICAL_ALIGNMENT_STRING_TABLE_COUNT, + alignment ) ) { impl.mController->SetVerticalAlignment( alignment ); } @@ -238,10 +238,10 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr { if( impl.mController ) { - const Vector4 textColor = value.Get< Vector4 >(); - if( impl.mController->GetTextColor() != textColor ) + const Vector4& textColor = value.Get< Vector4 >(); + if( impl.mController->GetDefaultColor() != textColor ) { - impl.mController->SetTextColor( textColor ); + impl.mController->SetDefaultColor( textColor ); impl.mRenderer.Reset(); } } @@ -252,7 +252,7 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr { if( impl.mController ) { - const Vector2 shadowOffset = value.Get< Vector2 >(); + const Vector2& shadowOffset = value.Get< Vector2 >(); if ( impl.mController->GetShadowOffset() != shadowOffset ) { impl.mController->SetShadowOffset( shadowOffset ); @@ -265,7 +265,7 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr { if( impl.mController ) { - const Vector4 shadowColor = value.Get< Vector4 >(); + const Vector4& shadowColor = value.Get< Vector4 >(); if ( impl.mController->GetShadowColor() != shadowColor ) { impl.mController->SetShadowColor( shadowColor ); @@ -278,7 +278,7 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr { if( impl.mController ) { - const Vector4 color = value.Get< Vector4 >(); + const Vector4& color = value.Get< Vector4 >(); if ( impl.mController->GetUnderlineColor() != color ) { impl.mController->SetUnderlineColor( color ); @@ -342,7 +342,7 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr // If request is enable (true) then start autoscroll as not already running else { - impl.mController->GetLayoutEngine().SetTextEllipsisEnabled( false ); + impl.mController->SetTextElideEnabled( false ); impl.mController->SetAutoScrollEnabled( enableAutoScroll ); } } @@ -485,9 +485,9 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde { if( impl.mController ) { - const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetHorizontalAlignment(), - HORIZONTAL_ALIGNMENT_STRING_TABLE, - HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT ); + const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::HorizontalAlignment >( impl.mController->GetHorizontalAlignment(), + HORIZONTAL_ALIGNMENT_STRING_TABLE, + HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT ); if( name ) { value = std::string( name ); @@ -499,9 +499,9 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde { if( impl.mController ) { - const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( impl.mController->GetVerticalAlignment(), - VERTICAL_ALIGNMENT_STRING_TABLE, - VERTICAL_ALIGNMENT_STRING_TABLE_COUNT ); + const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::VerticalAlignment >( impl.mController->GetVerticalAlignment(), + VERTICAL_ALIGNMENT_STRING_TABLE, + VERTICAL_ALIGNMENT_STRING_TABLE_COUNT ); if( name ) { value = std::string( name ); @@ -513,7 +513,7 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde { if ( impl.mController ) { - value = impl.mController->GetTextColor(); + value = impl.mController->GetDefaultColor(); } break; } @@ -652,9 +652,9 @@ void TextLabel::OnInitialize() self.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); // Enable the text ellipsis. - LayoutEngine& engine = mController->GetLayoutEngine(); + mController->SetTextElideEnabled( true ); // If false then text larger than control will overflow - engine.SetTextEllipsisEnabled( true ); // If false then text larger than control will overflow + Layout::Engine& engine = mController->GetLayoutEngine(); engine.SetCursorWidth( 0u ); // Do not layout space for the cursor. self.OnStageSignal().Connect( this, &TextLabel::OnStageConnect ); @@ -737,7 +737,7 @@ void TextLabel::RenderText() if( renderableActor ) { - const Vector2& scrollOffset = mController->GetScrollPosition(); + const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition(); renderableActor.SetPosition( scrollOffset.x, scrollOffset.y ); self.Add( renderableActor ); @@ -800,7 +800,7 @@ void TextLabel::ScrollingFinished() // Pure Virtual from TextScroller Interface DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel::ScrollingFinished\n"); mController->SetAutoScrollEnabled( false ); - mController->GetLayoutEngine().SetTextEllipsisEnabled( true ); + mController->SetTextElideEnabled( true ); RequestTextRelayout(); } diff --git a/dali-toolkit/internal/file.list b/dali-toolkit/internal/file.list index 1e78bf6..994faaf 100644 --- a/dali-toolkit/internal/file.list +++ b/dali-toolkit/internal/file.list @@ -114,8 +114,8 @@ toolkit_src_files = \ $(toolkit_src_dir)/text/text-effects-style.cpp \ $(toolkit_src_dir)/text/text-font-style.cpp \ $(toolkit_src_dir)/text/text-io.cpp \ + $(toolkit_src_dir)/text/text-model.cpp \ $(toolkit_src_dir)/text/text-scroller.cpp \ - $(toolkit_src_dir)/text/text-scroller-interface.cpp \ $(toolkit_src_dir)/text/text-view.cpp \ $(toolkit_src_dir)/text/text-view-interface.cpp \ $(toolkit_src_dir)/text/visual-model-impl.cpp \ @@ -132,6 +132,8 @@ toolkit_src_files = \ $(toolkit_src_dir)/text/rendering/atlas/atlas-manager-impl.cpp \ $(toolkit_src_dir)/text/rendering/atlas/atlas-mesh-factory.cpp \ $(toolkit_src_dir)/text/rendering/text-backend-impl.cpp \ + $(toolkit_src_dir)/text/rendering/text-typesetter.cpp \ + $(toolkit_src_dir)/text/rendering/view-model.cpp \ $(toolkit_src_dir)/transition-effects/cube-transition-effect-impl.cpp \ $(toolkit_src_dir)/transition-effects/cube-transition-cross-effect-impl.cpp \ $(toolkit_src_dir)/transition-effects/cube-transition-fold-effect-impl.cpp \ diff --git a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp index 3f9a81d..54d8afa 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp @@ -707,17 +707,17 @@ bool KeyboardFocusManager::DoConnectSignal( BaseObject* object, ConnectionTracke Dali::BaseHandle handle( object ); bool connected( true ); - KeyboardFocusManager* manager = dynamic_cast( object ); + KeyboardFocusManager* manager = static_cast< KeyboardFocusManager* >( object ); // TypeRegistry guarantees that this is the correct type. if( 0 == strcmp( signalName.c_str(), SIGNAL_PRE_FOCUS_CHANGE ) ) { manager->PreFocusChangeSignal().Connect( tracker, functor ); } - if( 0 == strcmp( signalName.c_str(), SIGNAL_FOCUS_CHANGED ) ) + else if( 0 == strcmp( signalName.c_str(), SIGNAL_FOCUS_CHANGED ) ) { manager->FocusChangedSignal().Connect( tracker, functor ); } - if( 0 == strcmp( signalName.c_str(), SIGNAL_FOCUS_GROUP_CHANGED ) ) + else if( 0 == strcmp( signalName.c_str(), SIGNAL_FOCUS_GROUP_CHANGED ) ) { manager->FocusGroupChangedSignal().Connect( tracker, functor ); } diff --git a/dali-toolkit/internal/image-loader/async-image-loader-impl.cpp b/dali-toolkit/internal/image-loader/async-image-loader-impl.cpp index 06065b7..1fbef38 100644 --- a/dali-toolkit/internal/image-loader/async-image-loader-impl.cpp +++ b/dali-toolkit/internal/image-loader/async-image-loader-impl.cpp @@ -19,7 +19,6 @@ #include "async-image-loader-impl.h" // EXTERNAL INCLUDES -#include #include namespace Dali @@ -62,9 +61,7 @@ uint32_t AsyncImageLoader::Load( const std::string& url, mIsLoadThreadStarted = true; } - BitmapLoader loader = BitmapLoader::New( url, dimensions, fittingMode, samplingMode, orientationCorrection ); - - mLoadThread.AddTask( new LoadingTask( ++mLoadTaskId, loader ) ); + mLoadThread.AddTask( new LoadingTask( ++mLoadTaskId, url, dimensions, fittingMode, samplingMode, orientationCorrection ) ); return mLoadTaskId; } @@ -88,7 +85,7 @@ void AsyncImageLoader::ProcessLoadedImage() { while( LoadingTask *next = mLoadThread.NextCompletedTask() ) { - mLoadedSignal.Emit( next->id, next->loader.GetPixelData() ); + mLoadedSignal.Emit( next->id, next->pixelData ); delete next; } } diff --git a/dali-toolkit/internal/image-loader/image-load-thread.cpp b/dali-toolkit/internal/image-loader/image-load-thread.cpp index 11e251a..d0b504d 100644 --- a/dali-toolkit/internal/image-loader/image-load-thread.cpp +++ b/dali-toolkit/internal/image-loader/image-load-thread.cpp @@ -18,6 +18,9 @@ // CLASS HEADER #include "image-load-thread.h" +// EXTERNAL INCLUDES +#include + namespace Dali { @@ -27,12 +30,24 @@ namespace Toolkit namespace Internal { -LoadingTask::LoadingTask(uint32_t id, BitmapLoader loader ) -: loader( loader ), - id( id ) +LoadingTask::LoadingTask( uint32_t id, const std::string& url, ImageDimensions dimensions, + FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection ) +: pixelData(), + url( url ), + id( id ), + dimensions( dimensions ), + fittingMode( fittingMode ), + samplingMode( samplingMode ), + orientationCorrection( orientationCorrection ) +{ +} + +void LoadingTask::Load() { + pixelData = Dali::LoadImageFromFile( url, dimensions, fittingMode, samplingMode, orientationCorrection ); } + ImageLoadThread::ImageLoadThread( EventThreadCallback* trigger ) : mTrigger( trigger ) { @@ -52,7 +67,7 @@ void ImageLoadThread::Run() { while( LoadingTask* task = NextTaskToProcess() ) { - task->loader.Load(); + task->Load(); AddCompletedTask( task ); } } @@ -150,8 +165,6 @@ void ImageLoadThread::AddCompletedTask( LoadingTask* task ) mTrigger->Trigger(); } - - } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/image-loader/image-load-thread.h b/dali-toolkit/internal/image-loader/image-load-thread.h index 85ea419..f46d435 100644 --- a/dali-toolkit/internal/image-loader/image-load-thread.h +++ b/dali-toolkit/internal/image-loader/image-load-thread.h @@ -20,12 +20,14 @@ // EXTERNAL INCLUDES #include #include +#include +#include #include #include #include -#include #include + namespace Dali { @@ -42,8 +44,20 @@ struct LoadingTask { /** * Constructor. + * @param [in] id of the task + * @param [in] url The URL of the image file to load. + * @param [in] size The width and height to fit the loaded image to, 0.0 means whole image + * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter. + * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size. + * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header. */ - LoadingTask( uint32_t id, BitmapLoader loader ); + LoadingTask( uint32_t id, const std::string& url, ImageDimensions dimensions, + FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection ); + + /** + * Load the image + */ + void Load(); private: @@ -55,8 +69,14 @@ private: public: - BitmapLoader loader; ///< The loader used to load the bitmap from URL - uint32_t id; ///< The id associated with this task. + PixelData pixelData; ///< pixelData handle after successfull load + std::string url; ///< url of the image to load + uint32_t id; ///< The unique id associated with this task. + ImageDimensions dimensions; ///< dimensions to load + FittingMode::Type fittingMode; ///< fitting options + SamplingMode::Type samplingMode; ///< sampling options + bool orientationCorrection:1; ///< if orientation correction is needed + }; diff --git a/dali-toolkit/internal/text/text-scroller-interface.cpp b/dali-toolkit/internal/text/layouts/layout-alignment.h similarity index 52% rename from dali-toolkit/internal/text/text-scroller-interface.cpp rename to dali-toolkit/internal/text/layouts/layout-alignment.h index ee85ef9..df61ff2 100644 --- a/dali-toolkit/internal/text/text-scroller-interface.cpp +++ b/dali-toolkit/internal/text/layouts/layout-alignment.h @@ -1,3 +1,6 @@ +#ifndef DALI_TOOLKIT_TEXT_LAYOUT_ALIGNMENT_H +#define DALI_TOOLKIT_TEXT_LAYOUT_ALIGNMENT_H + /* * Copyright (c) 2016 Samsung Electronics Co., Ltd. * @@ -15,9 +18,6 @@ * */ -// CLASS HEADER -#include - namespace Dali { @@ -27,16 +27,38 @@ namespace Toolkit namespace Text { -ScrollerInterface::ScrollerInterface() +namespace Layout { -} -ScrollerInterface::~ScrollerInterface() +/** + * @brief Speficies the horizontal alignment. + * + * BEGIN is on the left for Left To Right languages whereas is right for Right To Left. + * Similarly, END is on the right for Left To Right languages and left for Right To Left. + */ +enum HorizontalAlignment { -} + HORIZONTAL_ALIGN_BEGIN, + HORIZONTAL_ALIGN_CENTER, + HORIZONTAL_ALIGN_END +}; + +/** + * @brief Speficies the vertical alignment. + */ +enum VerticalAlignment +{ + VERTICAL_ALIGN_TOP, + VERTICAL_ALIGN_CENTER, + VERTICAL_ALIGN_BOTTOM +}; + +} // namespace Layout } // namespace Text } // namespace Toolkit } // namespace Dali + +#endif // DALI_TOOLKIT_TEXT_LAYOUT_ALIGNMENT_H diff --git a/dali-toolkit/internal/text/layouts/layout-engine.cpp b/dali-toolkit/internal/text/layouts/layout-engine.cpp index 717c752..148ff58 100644 --- a/dali-toolkit/internal/text/layouts/layout-engine.cpp +++ b/dali-toolkit/internal/text/layouts/layout-engine.cpp @@ -38,6 +38,9 @@ namespace Toolkit namespace Text { +namespace Layout +{ + namespace { @@ -99,15 +102,12 @@ struct LineLayout float descender; ///< The minimum descender of all fonts in the line. }; -struct LayoutEngine::Impl +struct Engine::Impl { Impl() - : mLayout( LayoutEngine::SINGLE_LINE_BOX ), - mHorizontalAlignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN ), - mVerticalAlignment( LayoutEngine::VERTICAL_ALIGN_TOP ), + : mLayout( Layout::Engine::SINGLE_LINE_BOX ), mCursorWidth( CURSOR_WIDTH ), - mDefaultLineSpacing( LINE_SPACING ), - mEllipsisEnabled( false ) + mDefaultLineSpacing( LINE_SPACING ) { } @@ -187,7 +187,7 @@ struct LayoutEngine::Impl * @param[in,out] paragraphDirection in: the current paragraph's direction, out: the next paragraph's direction. Is set after a must break. * @param[in] completelyFill Whether to completely fill the line ( even if the last word exceeds the boundaries ). */ - void GetLineLayoutForBox( const LayoutParameters& parameters, + void GetLineLayoutForBox( const Parameters& parameters, LineLayout& lineLayout, CharacterDirection& paragraphDirection, bool completelyFill ) @@ -538,7 +538,7 @@ struct LayoutEngine::Impl * * return Whether the line is ellipsized. */ - bool EllipsisLine( const LayoutParameters& layoutParameters, + bool EllipsisLine( const Parameters& layoutParameters, const LineLayout& layout, Size& layoutSize, LineRun* linesBuffer, @@ -620,7 +620,7 @@ struct LayoutEngine::Impl * @param[in,out] numberOfLines The number of laid-out lines. * @param[in] isLastLine Whether the laid-out line is the last one. */ - void UpdateTextLayout( const LayoutParameters& layoutParameters, + void UpdateTextLayout( const Parameters& layoutParameters, const LineLayout& layout, Size& layoutSize, LineRun* linesBuffer, @@ -678,7 +678,7 @@ struct LayoutEngine::Impl * @param[in,out] linesBuffer Pointer to the line's buffer. * @param[in,out] numberOfLines The number of laid-out lines. */ - void UpdateTextLayout( const LayoutParameters& layoutParameters, + void UpdateTextLayout( const Parameters& layoutParameters, CharacterIndex characterIndex, GlyphIndex glyphIndex, Size& layoutSize, @@ -742,7 +742,7 @@ struct LayoutEngine::Impl * @param[in] characterOffset The offset to be added to the runs of characters. * @param[in] glyphOffset The offset to be added to the runs of glyphs. */ - void UpdateLineIndexOffsets( const LayoutParameters& layoutParameters, + void UpdateLineIndexOffsets( const Parameters& layoutParameters, Vector& lines, Length characterOffset, Length glyphOffset ) @@ -763,10 +763,11 @@ struct LayoutEngine::Impl } } - bool LayoutText( const LayoutParameters& layoutParameters, + bool LayoutText( const Parameters& layoutParameters, Vector& glyphPositions, Vector& lines, - Size& layoutSize ) + Size& layoutSize, + bool elideTextEnabled ) { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->LayoutText\n" ); DALI_LOG_INFO( gLogFilter, Debug::Verbose, " box size %f, %f\n", layoutParameters.boundingBox.width, layoutParameters.boundingBox.height ); @@ -890,7 +891,7 @@ struct LayoutEngine::Impl DALI_LOG_INFO( gLogFilter, Debug::Verbose, " pen y %f\n", penY ); bool ellipsis = false; - if( mEllipsisEnabled ) + if( elideTextEnabled ) { // Does the ellipsis of the last line. ellipsis = EllipsisLine( layoutParameters, @@ -1014,7 +1015,7 @@ struct LayoutEngine::Impl return true; } - void ReLayoutRightToLeftLines( const LayoutParameters& layoutParameters, + void ReLayoutRightToLeftLines( const Parameters& layoutParameters, CharacterIndex startIndex, Length numberOfCharacters, Vector& glyphPositions ) @@ -1076,6 +1077,7 @@ struct LayoutEngine::Impl void Align( const Size& size, CharacterIndex startIndex, Length numberOfCharacters, + HorizontalAlignment horizontalAlignment, Vector& lines ) { const CharacterIndex lastCharacterPlusOne = startIndex + numberOfCharacters; @@ -1102,18 +1104,20 @@ struct LayoutEngine::Impl // Calculate the line's alignment offset accordingly with the align option, // the box width, line length, and the paragraph's direction. CalculateHorizontalAlignment( size.width, + horizontalAlignment, line ); } } void CalculateHorizontalAlignment( float boxWidth, + HorizontalAlignment horizontalAlignment, LineRun& line ) { line.alignmentOffset = 0.f; const bool isRTL = RTL == line.direction; float lineLength = line.width; - HorizontalAlignment alignment = mHorizontalAlignment; + HorizontalAlignment alignment = horizontalAlignment; if( isRTL ) { // Swap the alignment type if the line is right to left. @@ -1191,100 +1195,67 @@ struct LayoutEngine::Impl line.ellipsis = false; } - LayoutEngine::Layout mLayout; - LayoutEngine::HorizontalAlignment mHorizontalAlignment; - LayoutEngine::VerticalAlignment mVerticalAlignment; + Type mLayout; float mCursorWidth; float mDefaultLineSpacing; IntrusivePtr mMetrics; - - bool mEllipsisEnabled:1; }; -LayoutEngine::LayoutEngine() +Engine::Engine() : mImpl( NULL ) { - mImpl = new LayoutEngine::Impl(); + mImpl = new Engine::Impl(); } -LayoutEngine::~LayoutEngine() +Engine::~Engine() { delete mImpl; } -void LayoutEngine::SetMetrics( MetricsPtr& metrics ) +void Engine::SetMetrics( MetricsPtr& metrics ) { mImpl->mMetrics = metrics; } -void LayoutEngine::SetLayout( Layout layout ) +void Engine::SetLayout( Type layout ) { mImpl->mLayout = layout; } -LayoutEngine::Layout LayoutEngine::GetLayout() const +Engine::Type Engine::GetLayout() const { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "GetLayout[%d]\n", mImpl->mLayout); return mImpl->mLayout; } -void LayoutEngine::SetTextEllipsisEnabled( bool enabled ) -{ - DALI_LOG_INFO( gLogFilter, Debug::General, "-->LayoutEngine::SetTextEllipsisEnabled[%s]\n", (enabled)?"true":"false" ); - mImpl->mEllipsisEnabled = enabled; -} - -bool LayoutEngine::GetTextEllipsisEnabled() const -{ - return mImpl->mEllipsisEnabled; -} - -void LayoutEngine::SetHorizontalAlignment( HorizontalAlignment alignment ) -{ - mImpl->mHorizontalAlignment = alignment; -} - -LayoutEngine::HorizontalAlignment LayoutEngine::GetHorizontalAlignment() const -{ - return mImpl->mHorizontalAlignment; -} - -void LayoutEngine::SetVerticalAlignment( VerticalAlignment alignment ) -{ - mImpl->mVerticalAlignment = alignment; -} - -LayoutEngine::VerticalAlignment LayoutEngine::GetVerticalAlignment() const -{ - return mImpl->mVerticalAlignment; -} - -void LayoutEngine::SetCursorWidth( int width ) +void Engine::SetCursorWidth( int width ) { mImpl->mCursorWidth = static_cast( width ); } -int LayoutEngine::GetCursorWidth() const +int Engine::GetCursorWidth() const { return static_cast( mImpl->mCursorWidth ); } -bool LayoutEngine::LayoutText( const LayoutParameters& layoutParameters, - Vector& glyphPositions, - Vector& lines, - Size& layoutSize ) +bool Engine::LayoutText( const Parameters& layoutParameters, + Vector& glyphPositions, + Vector& lines, + Size& layoutSize, + bool elideTextEnabled ) { return mImpl->LayoutText( layoutParameters, glyphPositions, lines, - layoutSize ); + layoutSize, + elideTextEnabled ); } -void LayoutEngine::ReLayoutRightToLeftLines( const LayoutParameters& layoutParameters, - CharacterIndex startIndex, - Length numberOfCharacters, - Vector& glyphPositions ) +void Engine::ReLayoutRightToLeftLines( const Parameters& layoutParameters, + CharacterIndex startIndex, + Length numberOfCharacters, + Vector& glyphPositions ) { mImpl->ReLayoutRightToLeftLines( layoutParameters, startIndex, @@ -1292,27 +1263,31 @@ void LayoutEngine::ReLayoutRightToLeftLines( const LayoutParameters& layoutParam glyphPositions ); } -void LayoutEngine::Align( const Size& size, - CharacterIndex startIndex, - Length numberOfCharacters, - Vector& lines ) +void Engine::Align( const Size& size, + CharacterIndex startIndex, + Length numberOfCharacters, + Layout::HorizontalAlignment horizontalAlignment, + Vector& lines ) { mImpl->Align( size, startIndex, numberOfCharacters, + horizontalAlignment, lines ); } -void LayoutEngine::SetDefaultLineSpacing( float lineSpacing ) +void Engine::SetDefaultLineSpacing( float lineSpacing ) { mImpl->mDefaultLineSpacing = lineSpacing; } -float LayoutEngine::GetDefaultLineSpacing() const +float Engine::GetDefaultLineSpacing() const { return mImpl->mDefaultLineSpacing; } +} // namespace Layout + } // namespace Text } // namespace Toolkit diff --git a/dali-toolkit/internal/text/layouts/layout-engine.h b/dali-toolkit/internal/text/layouts/layout-engine.h index 79daa23..71768ee 100644 --- a/dali-toolkit/internal/text/layouts/layout-engine.h +++ b/dali-toolkit/internal/text/layouts/layout-engine.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H__ -#define __DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H__ +#ifndef DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H +#define DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. @@ -23,6 +23,7 @@ #include // INTERNAL INCLUDE +#include #include #include @@ -35,44 +36,33 @@ namespace Toolkit namespace Text { -struct LayoutParameters; +namespace Layout +{ + +struct Parameters; /** * @brief LayoutEngine is responsible for calculating the visual position of glyphs in layout. */ -class LayoutEngine +class Engine { public: - enum Layout + enum Type { SINGLE_LINE_BOX, MULTI_LINE_BOX }; - enum HorizontalAlignment - { - HORIZONTAL_ALIGN_BEGIN, - HORIZONTAL_ALIGN_CENTER, - HORIZONTAL_ALIGN_END - }; - - enum VerticalAlignment - { - VERTICAL_ALIGN_TOP, - VERTICAL_ALIGN_CENTER, - VERTICAL_ALIGN_BOTTOM - }; - /** * @brief Create a new instance of a LayoutEngine. */ - LayoutEngine(); + Engine(); /** * @brief Virtual destructor. */ - ~LayoutEngine(); + ~Engine(); /** * @brief Provide the wrapper around FontClient used to get metrics @@ -86,54 +76,14 @@ public: * * @param[in] layout The required layout. */ - void SetLayout( Layout layout ); + void SetLayout( Type layout ); /** * @brief Query the required layout. * * @return The required layout. */ - Layout GetLayout() const; - - /** - * @brief Enable or disable the text ellipsis. - * - * @param[in] enabled Whether to enable the text ellipsis. - */ - void SetTextEllipsisEnabled( bool enabled ); - - /** - * @return Whether the text ellipsis is enabled. - */ - bool GetTextEllipsisEnabled() const; - - /** - * @brief Choose the required text horizontal alignment. - * - * @param[in] alignment The required alignment. - */ - void SetHorizontalAlignment( HorizontalAlignment alignment ); - - /** - * @brief Query the required text horizontal alignment. - * - * @return The required alignment. - */ - HorizontalAlignment GetHorizontalAlignment() const; - - /** - * @brief Choose the required text vertical alignment. - * - * @param[in] alignment The required alignment. - */ - void SetVerticalAlignment( VerticalAlignment alignment ); - - /** - * @brief Query the required text vertical alignment. - * - * @return The required alignment. - */ - VerticalAlignment GetVerticalAlignment() const; + Type GetLayout() const; /** * @brief Sets the width of the cursor. @@ -156,13 +106,15 @@ public: * @param[out] glyphPositions The positions of all the glyphs. * @param[out] lines The laid-out lines. * @param[out] layoutSize The size of the text after it has been laid-out. + * @param[in] elideTextEnabled Whether the text elide is enabled. * * @return \e true if the text has been re-laid-out. \e false means the given width is too small to layout even a single character. */ - bool LayoutText( const LayoutParameters& layoutParameters, + bool LayoutText( const Parameters& layoutParameters, Vector& glyphPositions, Vector& lines, - Size& layoutSize ); + Size& layoutSize, + bool elideTextEnabled ); /** * @brief Re-lays out those lines with right to left characters. @@ -174,7 +126,7 @@ public: * @param[in] numberOfCharacters The number of characters. * @param[in,out] glyphPositions The positions of all the glyphs. */ - void ReLayoutRightToLeftLines( const LayoutParameters& layoutParameters, + void ReLayoutRightToLeftLines( const Parameters& layoutParameters, CharacterIndex startIndex, Length numberOfCharacters, Vector& glyphPositions ); @@ -185,11 +137,13 @@ public: * @param[in] size The size of the container where the text is laid-out. * @param[in] startIndex Character index of the line from where the lines are aligned. * @param[in] numberOfCharacters The number of characters. + * @param[in] horizontalAlignment The horizontal alignment. * @param[in,out] lines The laid-out lines. */ void Align( const Size& size, CharacterIndex startIndex, Length numberOfCharacters, + Layout::HorizontalAlignment horizontalAlignment, Vector& lines ); /** @@ -209,20 +163,23 @@ public: private: // Undefined - LayoutEngine( const LayoutEngine& handle ); + Engine( const Engine& handle ); // Undefined - LayoutEngine& operator=( const LayoutEngine& handle ); + Engine& operator=( const Engine& handle ); private: struct Impl; Impl* mImpl; }; + +} // namespace Layout + } // namespace Text } // namespace Toolkit } // namespace Dali -#endif // __DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H__ +#endif // DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H diff --git a/dali-toolkit/internal/text/layouts/layout-parameters.h b/dali-toolkit/internal/text/layouts/layout-parameters.h index 8d875bf..f62191f 100644 --- a/dali-toolkit/internal/text/layouts/layout-parameters.h +++ b/dali-toolkit/internal/text/layouts/layout-parameters.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TOOLKIT_TEXT_LAYOUT_PARAMETERS_H__ -#define __DALI_TOOLKIT_TEXT_LAYOUT_PARAMETERS_H__ +#ifndef DALI_TOOLKIT_TEXT_LAYOUT_PARAMETERS_H +#define DALI_TOOLKIT_TEXT_LAYOUT_PARAMETERS_H /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. @@ -35,10 +35,13 @@ namespace Text struct BidirectionalLineInfoRun; +namespace Layout +{ + /** * @brief Struct used to pass parameters. */ -struct LayoutParameters +struct Parameters { /** * Constructor with the needed parameters to layout the text. @@ -54,18 +57,20 @@ struct LayoutParameters * @param[in] charactersToGlyphsBuffer Vector with indices pointing the first glyph of each character. * @param[in] glyphsPerCharacterBuffer Vector with the number of glyphs shaped from the character. * @param[in] totalNumberOfGlyphs The number of glyphs. + * @param[in] horizontalAlignment The horizontal alignment. */ - LayoutParameters( const Vector2& boundingBox, - const Character* const textBuffer, - const LineBreakInfo* const lineBreakInfoBuffer, - const WordBreakInfo* const wordBreakInfoBuffer, - const CharacterDirection* const characterDirectionBuffer, - const GlyphInfo* const glyphsBuffer, - const CharacterIndex* const glyphsToCharactersBuffer, - const Length* const charactersPerGlyphBuffer, - const GlyphIndex* const charactersToGlyphsBuffer, - const Length* const glyphsPerCharacterBuffer, - Length totalNumberOfGlyphs ) + Parameters( const Vector2& boundingBox, + const Character* const textBuffer, + const LineBreakInfo* const lineBreakInfoBuffer, + const WordBreakInfo* const wordBreakInfoBuffer, + const CharacterDirection* const characterDirectionBuffer, + const GlyphInfo* const glyphsBuffer, + const CharacterIndex* const glyphsToCharactersBuffer, + const Length* const charactersPerGlyphBuffer, + const GlyphIndex* const charactersToGlyphsBuffer, + const Length* const glyphsPerCharacterBuffer, + Length totalNumberOfGlyphs, + HorizontalAlignment horizontalAlignment ) : boundingBox( boundingBox ), textBuffer( textBuffer ), lineBreakInfoBuffer( lineBreakInfoBuffer ), @@ -81,6 +86,7 @@ struct LayoutParameters startGlyphIndex( 0u ), numberOfGlyphs( 0u ), totalNumberOfGlyphs( totalNumberOfGlyphs ), + horizontalAlignment( horizontalAlignment ), startLineIndex( 0u ), estimatedNumberOfLines( 0u ), isLastNewParagraph( false ) @@ -101,15 +107,18 @@ struct LayoutParameters GlyphIndex startGlyphIndex; ///< Index to the first glyph to layout. Length numberOfGlyphs; ///< The number of glyphs to layout. Length totalNumberOfGlyphs; ///< The number of glyphs. + HorizontalAlignment horizontalAlignment; ///< The horizontal alignment. LineIndex startLineIndex; ///< The line index where to insert the new lines. Length estimatedNumberOfLines; ///< The estimated number of lines. bool isLastNewParagraph; ///< Whether the last character is a new paragraph character. }; +} // namespace Layout + } // namespace Text } // namespace Toolkit } // namespace Dali -#endif // __DALI_TOOLKIT_TEXT_LAYOUT_PARAMETERS_H__ +#endif // DALI_TOOLKIT_TEXT_LAYOUT_PARAMETERS_H diff --git a/dali-toolkit/internal/text/multi-language-support-impl.cpp b/dali-toolkit/internal/text/multi-language-support-impl.cpp index 32e7c38..260bd5a 100644 --- a/dali-toolkit/internal/text/multi-language-support-impl.cpp +++ b/dali-toolkit/internal/text/multi-language-support-impl.cpp @@ -589,10 +589,8 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, if( isValidFont && isEmojiScript ) { - const PixelData bitmap = fontClient.CreateBitmap( fontId, glyphIndex ); - - // For color emojis, the font is valid if the bitmap is RGBA. - isValidFont = bitmap && ( Pixel::BGRA8888 == bitmap.GetPixelFormat() ); + // For color emojis, the font is valid if the glyph is a color glyph (the bitmap is RGBA). + isValidFont = fontClient.IsColorGlyph( fontId, glyphIndex ); } // If there is a valid font, cache it. diff --git a/dali-toolkit/internal/text/rendering/text-typesetter.cpp b/dali-toolkit/internal/text/rendering/text-typesetter.cpp new file mode 100644 index 0000000..62e3b14 --- /dev/null +++ b/dali-toolkit/internal/text/rendering/text-typesetter.cpp @@ -0,0 +1,285 @@ +/* + * Copyright (c) 2016 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 + +// INTERNAL INCLUDES +#include + +namespace Dali +{ + +namespace Toolkit +{ + +namespace Text +{ + +namespace +{ + +/** + * @brief Data struct used to set the buffer of the glyph's bitmap into the final bitmap's buffer. + */ +struct GlyphData +{ + uint32_t* bitmapBuffer; ///< The buffer of the whole bitmap. The format is RGBA8888. + Vector2* position; ///< The position of the glyph. + TextAbstraction::FontClient::GlyphBufferData glyphBitmap; ///< The glyph's bitmap. + unsigned int width; ///< The bitmap's width. + unsigned int height; ///< The bitmap's height. + int horizontalOffset; ///< The horizontal offset to be added to the 'x' glyph's position. + int verticalOffset; ///< The vertical offset to be added to the 'y' glyph's position. +}; + +/** + * @brief Sets the glyph's buffer into the bitmap's buffer. + * + * @param[in] data Struct which contains the glyph's data and the bitmap's data. + * @param[in] position The position of the glyph. + * @param[in] color The color of the glyph. + */ +void TypesetGlyph( const GlyphData& data, + const Vector2* const position, + const Vector4* const color ) +{ + if( ( 0u == data.glyphBitmap.width ) || ( 0u == data.glyphBitmap.height ) ) + { + // Nothing to do if the width or height of the buffer is zero. + return; + } + + const int widthMinusOne = static_cast( data.width - 1u ); + const int heightMinusOne = static_cast( data.height - 1u ); + + // Whether the given glyph is a color one. + const bool isColorGlyph = Pixel::BGRA8888 == data.glyphBitmap.format; + + // Pointer to the color glyph if there is one. + const uint32_t* const colorGlyphBuffer = isColorGlyph ? reinterpret_cast( data.glyphBitmap.buffer ) : NULL; + + // Pack the given color into a 32bit buffer. The alpha channel will be updated later for each pixel. + // The format is RGBA8888. + uint32_t packedColor = 0u; + uint8_t* packedColorBuffer = reinterpret_cast( &packedColor ); + *( packedColorBuffer + 2 ) = static_cast( color->b * 255.f ); + *( packedColorBuffer + 1 ) = static_cast( color->g * 255.f ); + *packedColorBuffer = static_cast( color->r * 255.f ); + + // Initial vertical offset. + const int yOffset = data.verticalOffset + position->y; + + // Traverse the pixels of the glyph line per line. + for( int lineIndex = 0, glyphHeight = static_cast( data.glyphBitmap.height ); lineIndex < glyphHeight; ++lineIndex ) + { + const int yOffsetIndex = yOffset + lineIndex; + if( ( 0 > yOffsetIndex ) || ( yOffsetIndex > heightMinusOne ) ) + { + // Do not write out of bounds. + break; + } + + const int verticalOffset = yOffsetIndex * data.width; + const int xOffset = data.horizontalOffset + position->x; + const int glyphBufferOffset = lineIndex * static_cast( data.glyphBitmap.width ); + for( int index = 0, glyphWidth = static_cast( data.glyphBitmap.width ); index < glyphWidth; ++index ) + { + const int xOffsetIndex = xOffset + index; + if( ( 0 > xOffsetIndex ) || ( xOffsetIndex > widthMinusOne ) ) + { + // Don't write out of bounds. + break; + } + + if( isColorGlyph ) + { + // Retrieves the color from the glyph. The format is BGRA8888. + uint32_t packedColorGlyph = *( colorGlyphBuffer + glyphBufferOffset + index ); + + // Update the alpha channel. + uint8_t* packedColorGlyphBuffer = reinterpret_cast( &packedColorGlyph ); + std::swap( *packedColorGlyphBuffer, *( packedColorGlyphBuffer + 2u ) ); // Swap B and R. + *( packedColorGlyphBuffer + 3u ) = static_cast( color->a * static_cast( *( packedColorGlyphBuffer + 3u ) ) ); + + // Set the color into the final pixel buffer. + *( data.bitmapBuffer + verticalOffset + xOffsetIndex ) = packedColorGlyph; + } + else + { + // Update the alpha channel. + const uint8_t alpha = *( data.glyphBitmap.buffer + glyphBufferOffset + index ); + *( packedColorBuffer + 3u ) = static_cast( color->a * static_cast( alpha ) ); + + // Set the color into the final pixel buffer. + *( data.bitmapBuffer + verticalOffset + xOffsetIndex ) = packedColor; + } + } + } +} + +} // namespace + +TypesetterPtr Typesetter::New( const ModelInterface* const model ) +{ + return TypesetterPtr( new Typesetter( model ) ); +} + +ViewModel* Typesetter::GetViewModel() +{ + return mModel; +} + +PixelData Typesetter::Render( const Vector2& size ) +{ + // @todo. This initial implementation for a TextLabel has only one visible page. + + // Elides the text if needed. + mModel->ElideGlyphs(); + + // Retrieves the layout size. + const Size& layoutSize = mModel->GetLayoutSize(); + + // Set the offset for the vertical alignment. + int penY = 0u; + + switch( mModel->GetVerticalAlignment() ) + { + case Layout::VERTICAL_ALIGN_TOP: + { + // No offset to add. + break; + } + case Layout::VERTICAL_ALIGN_CENTER: + { + penY = static_cast( 0.5f * ( size.height - layoutSize.height ) ); + break; + } + case Layout::VERTICAL_ALIGN_BOTTOM: + { + penY = static_cast( size.height - layoutSize.height ); + break; + } + } + + // Retrieve lines, glyphs, positions and colors from the view model. + const Length modelNumberOfLines = mModel->GetNumberOfLines(); + const LineRun* const modelLinesBuffer = mModel->GetLines(); + const Length numberOfGlyphs = mModel->GetNumberOfGlyphs(); + const GlyphInfo* const glyphsBuffer = mModel->GetGlyphs(); + const Vector2* const positionBuffer = mModel->GetLayout(); + const Vector4* const colorsBuffer = mModel->GetColors(); + const ColorIndex* const colorIndexBuffer = mModel->GetColorIndices(); + + // Whether to use the default color. + const bool useDefaultColor = NULL == colorsBuffer; + const Vector4& defaultColor = mModel->GetDefaultColor(); + + // Create and initialize the pixel buffer. + GlyphData glyphData; + glyphData.verticalOffset = penY; + + glyphData.width = static_cast( size.width ); + glyphData.height = static_cast( size.height ); + const unsigned int bufferSizeInt = glyphData.width * glyphData.height; + const unsigned int bufferSizeChar = 4u * bufferSizeInt; + glyphData.bitmapBuffer = new uint32_t[ bufferSizeInt ]; // This array will get deleted by PixelData because of the DELETE_ARRAY parameter. + memset( glyphData.bitmapBuffer, 0u, bufferSizeChar ); + + PixelData pixelData = PixelData::New( reinterpret_cast( glyphData.bitmapBuffer ), + bufferSizeChar, + glyphData.width, + glyphData.height, + Pixel::RGBA8888, // The format is RGBA8888 because is the format accepted by the image atlas manager. + PixelData::DELETE_ARRAY ); + + // Get a handle of the font client. Used to retrieve the bitmaps of the glyphs. + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); + + // Traverses the lines of the text. + for( LineIndex lineIndex = 0u; lineIndex < modelNumberOfLines; ++lineIndex ) + { + const LineRun& line = *( modelLinesBuffer + lineIndex ); + + // Sets the horizontal offset of the line. + glyphData.horizontalOffset = static_cast( line.alignmentOffset ); + + // Increases the vertical offset with the line's ascender. + glyphData.verticalOffset += static_cast( line.ascender ); + + // Traverses the glyphs of the line. + const GlyphIndex endGlyphIndex = std::min( numberOfGlyphs, line.glyphRun.glyphIndex + line.glyphRun.numberOfGlyphs ); + for( GlyphIndex glyphIndex = line.glyphRun.glyphIndex; glyphIndex < endGlyphIndex; ++glyphIndex ) + { + // Retrieve the glyph's info. + const GlyphInfo* const glyphInfo = glyphsBuffer + glyphIndex; + + if( ( glyphInfo->width < Math::MACHINE_EPSILON_1000 ) || + ( glyphInfo->height < Math::MACHINE_EPSILON_1000 ) ) + { + // Nothing to do if the glyph's width or height is zero. + continue; + } + + // Retrieves the glyph's position. + const Vector2* const position = positionBuffer + glyphIndex; + + // Retrieves the glyph's color. + const ColorIndex colorIndex = *( colorIndexBuffer + glyphIndex ); + const Vector4* const color = ( useDefaultColor || ( 0u == colorIndex ) ) ? &defaultColor : colorsBuffer + ( colorIndex - 1u ); + + // Retrieves the glyph's bitmap. + glyphData.glyphBitmap.buffer = NULL; + fontClient.CreateBitmap( glyphInfo->fontId, + glyphInfo->index, + glyphData.glyphBitmap ); + + // Sets the glyph's bitmap into the bitmap of the whole text. + if( NULL != glyphData.glyphBitmap.buffer ) + { + TypesetGlyph( glyphData, + position, + color ); + } + } + + // Increases the vertical offset with the line's descender. + glyphData.verticalOffset += static_cast( -line.descender ); + } + + return pixelData; +} + +Typesetter::Typesetter( const ModelInterface* const model ) +: mModel( new ViewModel( model ) ) +{ +} + +Typesetter::~Typesetter() +{ + delete mModel; +} + +} // namespace Text + +} // namespace Toolkit + +} // namespace Dali diff --git a/dali-toolkit/internal/text/rendering/text-typesetter.h b/dali-toolkit/internal/text/rendering/text-typesetter.h new file mode 100644 index 0000000..62d9d94 --- /dev/null +++ b/dali-toolkit/internal/text/rendering/text-typesetter.h @@ -0,0 +1,114 @@ +#ifndef DALI_TOOLKIT_TEXT_TYPESETTER_H +#define DALI_TOOLKIT_TEXT_TYPESETTER_H + +/* + * Copyright (c) 2016 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 + +namespace Dali +{ + +namespace Toolkit +{ + +namespace Text +{ + +class ModelInterface; +class ViewModel; +class Typesetter; + +typedef IntrusivePtr TypesetterPtr; + +/** + * @brief This class is responsible of controlling the data flow of the text's rendering process. + */ +class Typesetter : public RefObject +{ +public: // Constructor. + /** + * @brief Creates a Typesetter instance. + * + * The typesetter composes the final text retrieving the glyphs and the + * styles from the text's model. + * + * @param[in] model Pointer to the text's data model. + */ + static TypesetterPtr New( const ModelInterface* const model ); + +public: + /** + * @brief Retrieves the pointer to the view model. + * + * @return A pointer to the view model. + */ + ViewModel* GetViewModel(); + + /** + * @brief Renders the text. + * + * Does the following operations: + * - Finds the visible pages needed to be rendered. + * - Elide glyphs if needed. + * - Retrieves the data buffers from the text model. + * - Creates the pixel data used to generate the final image with the given size. + * - Traverse the visible glyphs, retrieve their bitmaps and compose the final pixel data. + * + * @param[in] size The renderer size. + * + * @return A pixel data with the text rendered. + */ + PixelData Render( const Vector2& size ); + +private: + /** + * @brief Private constructor. + * + * @param[in] model Pointer to the text's data model. + */ + Typesetter( const ModelInterface* const model ); + + // Declared private and left undefined to avoid copies. + Typesetter( const Typesetter& handle ); + + // Declared private and left undefined to avoid copies. + Typesetter& operator=( const Typesetter& handle ); + +protected: + + /** + * @brief A reference counted object may only be deleted by calling Unreference(). + * + * Destroys the visual model. + */ + virtual ~Typesetter(); + +private: + ViewModel* mModel; +}; + +} // namespace Text + +} // namespace Toolkit + +} // namespace Dali + +#endif // DALI_TOOLKIT_TEXT_TYPESETTER_H diff --git a/dali-toolkit/internal/text/rendering/view-model.cpp b/dali-toolkit/internal/text/rendering/view-model.cpp new file mode 100644 index 0000000..5636506 --- /dev/null +++ b/dali-toolkit/internal/text/rendering/view-model.cpp @@ -0,0 +1,301 @@ +/* + * Copyright (c) 2016 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 + +// INTERNAL INCLUDES +#include + +namespace Dali +{ + +namespace Toolkit +{ + +namespace Text +{ + +ViewModel::ViewModel( const ModelInterface* const model ) +: mModel( model ), + mElidedGlyphs(), + mElidedLayout(), + mIsTextElided( false ) +{ +} + +ViewModel::~ViewModel() +{ +} + +const Size& ViewModel::GetControlSize() const +{ + return mModel->GetControlSize(); +} + +const Size& ViewModel::GetLayoutSize() const +{ + return mModel->GetLayoutSize(); +} + +const Vector2& ViewModel::GetScrollPosition() const +{ + return mModel->GetScrollPosition(); +} + +Layout::HorizontalAlignment ViewModel::GetHorizontalAlignment() const +{ + return mModel->GetHorizontalAlignment(); +} + +Layout::VerticalAlignment ViewModel::GetVerticalAlignment() const +{ + return mModel->GetVerticalAlignment(); +} + +bool ViewModel::IsTextElideEnabled() const +{ + return mModel->IsTextElideEnabled(); +} + +Length ViewModel::GetNumberOfLines() const +{ + return mModel->GetNumberOfLines(); +} + +const LineRun* const ViewModel::GetLines() const +{ + return mModel->GetLines(); +} + +Length ViewModel::GetNumberOfGlyphs() const +{ + if( mIsTextElided && mModel->IsTextElideEnabled() ) + { + return mElidedGlyphs.Count(); + } + else + { + return mModel->GetNumberOfGlyphs(); + } + + return 0u; +} + +const GlyphInfo* const ViewModel::GetGlyphs() const +{ + if( mIsTextElided && mModel->IsTextElideEnabled() ) + { + return mElidedGlyphs.Begin(); + } + else + { + return mModel->GetGlyphs(); + } + + return NULL; +} + +const Vector2* const ViewModel::GetLayout() const +{ + if( mIsTextElided && mModel->IsTextElideEnabled() ) + { + return mElidedLayout.Begin(); + } + else + { + return mModel->GetLayout(); + } + + return NULL; +} + +const Vector4* const ViewModel::GetColors() const +{ + return mModel->GetColors(); +} + +const ColorIndex* const ViewModel::GetColorIndices() const +{ + return mModel->GetColorIndices(); +} + +const Vector4& ViewModel::GetDefaultColor() const +{ + return mModel->GetDefaultColor(); +} + +void ViewModel::ElideGlyphs() +{ + mIsTextElided = false; + + if( mModel->IsTextElideEnabled() ) + { + const Length numberOfLines = mModel->GetNumberOfLines(); + if( 0u != numberOfLines ) + { + const LineRun* const lines = mModel->GetLines(); + + const LineRun& lastLine = *( lines + ( numberOfLines - 1u ) ); + const Length numberOfLaidOutGlyphs = lastLine.glyphRun.glyphIndex + lastLine.glyphRun.numberOfGlyphs; + + if( lastLine.ellipsis && ( 0u != numberOfLaidOutGlyphs ) ) + { + mIsTextElided = true; + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); + + const GlyphInfo* const glyphs = mModel->GetGlyphs(); + const Vector2* const positions = mModel->GetLayout(); + + // Copy the glyphs to be elided. + mElidedGlyphs.Resize( numberOfLaidOutGlyphs ); + mElidedLayout.Resize( numberOfLaidOutGlyphs ); + + GlyphInfo* elidedGlyphsBuffer = mElidedGlyphs.Begin(); + Vector2* elidedPositionsBuffer = mElidedLayout.Begin(); + + memcpy( elidedGlyphsBuffer, glyphs, numberOfLaidOutGlyphs * sizeof( GlyphInfo ) ); + memcpy( elidedPositionsBuffer, positions, numberOfLaidOutGlyphs * sizeof( Vector2 ) ); + + const Size& controlSize = mModel->GetControlSize(); + + if( ( 1u == numberOfLines ) && + ( lastLine.ascender - lastLine.descender > controlSize.height ) ) + { + // Get the first glyph which is going to be replaced and the ellipsis glyph. + GlyphInfo& glyphToRemove = *elidedGlyphsBuffer; + const GlyphInfo& ellipsisGlyph = fontClient.GetEllipsisGlyph( fontClient.GetPointSize( glyphToRemove.fontId ) ); + + // Change the 'x' and 'y' position of the ellipsis glyph. + Vector2& position = *elidedPositionsBuffer; + + position.x = ellipsisGlyph.xBearing; + position.y = -lastLine.ascender + controlSize.height - ellipsisGlyph.yBearing; + + // Replace the glyph by the ellipsis glyph and resize the buffers. + glyphToRemove = ellipsisGlyph; + + mElidedGlyphs.Resize( 1u ); + mElidedLayout.Resize( 1u ); + + return; + } + + // firstPenX, penY and firstPenSet are used to position the ellipsis glyph if needed. + float firstPenX = 0.f; // Used if rtl text is elided. + float penY = 0.f; + bool firstPenSet = false; + + // Add the ellipsis glyph. + bool inserted = false; + float removedGlypsWidth = 0.f; + Length numberOfRemovedGlyphs = 0u; + GlyphIndex index = numberOfLaidOutGlyphs - 1u; + + // The ellipsis glyph has to fit in the place where the last glyph(s) is(are) removed. + while( !inserted ) + { + const GlyphInfo& glyphToRemove = *( elidedGlyphsBuffer + index ); + + if( 0u != glyphToRemove.fontId ) + { + // i.e. The font id of the glyph shaped from the '\n' character is zero. + + // Need to reshape the glyph as the font may be different in size. + const GlyphInfo& ellipsisGlyph = fontClient.GetEllipsisGlyph( fontClient.GetPointSize( glyphToRemove.fontId ) ); + + if( !firstPenSet ) + { + const Vector2& position = *( elidedPositionsBuffer + index ); + + // Calculates the penY of the current line. It will be used to position the ellipsis glyph. + penY = position.y + glyphToRemove.yBearing; + + // Calculates the first penX which will be used if rtl text is elided. + firstPenX = position.x - glyphToRemove.xBearing; + if( firstPenX < -ellipsisGlyph.xBearing ) + { + // Avoids to exceed the bounding box when rtl text is elided. + firstPenX = -ellipsisGlyph.xBearing; + } + + removedGlypsWidth = -ellipsisGlyph.xBearing; + + firstPenSet = true; + } + + removedGlypsWidth += std::min( glyphToRemove.advance, ( glyphToRemove.xBearing + glyphToRemove.width ) ); + + // Calculate the width of the ellipsis glyph and check if it fits. + const float ellipsisGlyphWidth = ellipsisGlyph.width + ellipsisGlyph.xBearing; + + if( ellipsisGlyphWidth < removedGlypsWidth ) + { + GlyphInfo& glyphInfo = *( elidedGlyphsBuffer + index ); + Vector2& position = *( elidedPositionsBuffer + index ); + position.x -= ( 0.f > glyphInfo.xBearing ) ? glyphInfo.xBearing : 0.f; + + // Replace the glyph by the ellipsis glyph. + glyphInfo = ellipsisGlyph; + + // Change the 'x' and 'y' position of the ellipsis glyph. + + if( position.x > firstPenX ) + { + position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth; + } + + position.x += ellipsisGlyph.xBearing; + position.y = penY - ellipsisGlyph.yBearing; + + inserted = true; + } + } + + if( !inserted ) + { + if( index > 0u ) + { + --index; + } + else + { + // No space for the ellipsis. + inserted = true; + } + ++numberOfRemovedGlyphs; + } + } // while( !inserted ) + + // 'Removes' all the glyphs after the ellipsis glyph. + const Length numberOfGlyphs = numberOfLaidOutGlyphs - numberOfRemovedGlyphs; + mElidedGlyphs.Resize( numberOfGlyphs ); + mElidedLayout.Resize( numberOfGlyphs ); + } + } + } +} + +} // namespace Text + +} // namespace Toolkit + +} // namespace Dali diff --git a/dali-toolkit/internal/text/rendering/view-model.h b/dali-toolkit/internal/text/rendering/view-model.h new file mode 100644 index 0000000..8038820 --- /dev/null +++ b/dali-toolkit/internal/text/rendering/view-model.h @@ -0,0 +1,152 @@ +#ifndef DALI_TOOLKIT_TEXT_VIEW_MODEL_H +#define DALI_TOOLKIT_TEXT_VIEW_MODEL_H + +/* + * Copyright (c) 2016 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 + +namespace Dali +{ + +namespace Toolkit +{ + +namespace Text +{ + +/** + * @brief Responsible of creating and store temporary modifications of the text model. + * i.e. The elide of text. + */ +class ViewModel : public ModelInterface +{ +public: + /** + * @brief Constructor. + * + * Keeps the pointer to the text's model. It initializes all the members of the class to their defaults. + * + * @param[in] model Pointer to the text's model interface. + */ + ViewModel( const ModelInterface* const model ); + + /** + * @brief Virtual destructor. + * + * It's a default destructor. + */ + virtual ~ViewModel(); + + /** + * @copydoc ModelInterface::GetControlSize() + */ + virtual const Size& GetControlSize() const; + + /** + * @copydoc ModelInterface::GetLayoutSize() + */ + virtual const Size& GetLayoutSize() const; + + /** + * @copydoc ModelInterface::GetScrollPosition() + */ + virtual const Vector2& GetScrollPosition() const; + + /** + * @copydoc ModelInterface::GetHorizontalAlignment() + */ + virtual Layout::HorizontalAlignment GetHorizontalAlignment() const; + + /** + * @copydoc ModelInterface::GetVerticalAlignment() + */ + virtual Layout::VerticalAlignment GetVerticalAlignment() const; + + /** + * @copydoc ModelInterface::IsTextElideEnabled() + */ + virtual bool IsTextElideEnabled() const; + + /** + * @copydoc ModelInterface::GetNumberOfLines() + */ + virtual Length GetNumberOfLines() const; + + /** + * @copydoc ModelInterface::GetLines() + */ + virtual const LineRun* const GetLines() const; + + /** + * @copydoc ModelInterface::GetNumberOfGlyphs() + */ + virtual Length GetNumberOfGlyphs() const; + + /** + * @copydoc ModelInterface::GetGlyphs() + */ + virtual const GlyphInfo* const GetGlyphs() const; + + /** + * @copydoc ModelInterface::GetLayout() + */ + virtual const Vector2* const GetLayout() const; + + /** + * @copydoc ModelInterface::GetColors() + */ + virtual const Vector4* const GetColors() const; + + /** + * @copydoc ModelInterface::GetColorIndices() + */ + virtual const ColorIndex* const GetColorIndices() const; + + /** + * @copydoc ModelInterface::GetDefaultColor() + */ + virtual const Vector4& GetDefaultColor() const; + + /** + * @brief Does the text elide. + * + * It stores a copy of the visible glyphs and removes as many glyphs as needed + * from the last visible line to add the ellipsis glyph. + * + * It stores as well a copy of the positions for each visible glyph. + */ + void ElideGlyphs(); + +private: + const ModelInterface* const mModel; ///< Pointer to the text's model. + Vector mElidedGlyphs; ///< Stores the glyphs of the elided text. + Vector mElidedLayout; ///< Stores the positions of each glyph of the elided text. + bool mIsTextElided : 1; ///< Whether the text has been elided. +}; + +} // namespace Text + +} // namespace Toolkit + +} // namespace Dali + +#endif // DALI_TOOLKIT_TEXT_VIEW_MODEL_H diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index ee7c4ac..85f48ec 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -277,7 +277,7 @@ bool Controller::Impl::ProcessInputEvents() const CharacterIndex styleIndex = ( mEventData->mPrimaryCursorPosition > 0u ) ? mEventData->mPrimaryCursorPosition - 1u : 0u; // Retrieve the style from the style runs stored in the logical model. - mLogicalModel->RetrieveStyle( styleIndex, mEventData->mInputStyle ); + mModel->mLogicalModel->RetrieveStyle( styleIndex, mEventData->mInputStyle ); // Compare if the input style has changed. const bool hasInputStyleChanged = !currentInputStyle.Equal( mEventData->mInputStyle ); @@ -329,8 +329,8 @@ void Controller::Impl::NotifyImfMultiLineStatus() { if ( mEventData ) { - LayoutEngine::Layout layout = mLayoutEngine.GetLayout(); - mEventData->mImfManager.NotifyTextInputMultiLine( layout == LayoutEngine::MULTI_LINE_BOX ); + Text::Layout::Engine::Type layout = mLayoutEngine.GetLayout(); + mEventData->mImfManager.NotifyTextInputMultiLine( layout == Text::Layout::Engine::MULTI_LINE_BOX ); } } @@ -359,9 +359,9 @@ Length Controller::Impl::GetNumberOfWhiteSpaces( CharacterIndex index ) const Length numberOfWhiteSpaces = 0u; // Get the buffer to the text. - Character* utf32CharacterBuffer = mLogicalModel->mText.Begin(); + Character* utf32CharacterBuffer = mModel->mLogicalModel->mText.Begin(); - const Length totalNumberOfCharacters = mLogicalModel->mText.Count(); + const Length totalNumberOfCharacters = mModel->mLogicalModel->mText.Count(); for( ; index < totalNumberOfCharacters; ++index, ++numberOfWhiteSpaces ) { if( !TextAbstraction::IsWhiteSpace( *( utf32CharacterBuffer + index ) ) ) @@ -376,12 +376,12 @@ Length Controller::Impl::GetNumberOfWhiteSpaces( CharacterIndex index ) const void Controller::Impl::GetText( CharacterIndex index, std::string& text ) const { // Get the total number of characters. - Length numberOfCharacters = mLogicalModel->mText.Count(); + Length numberOfCharacters = mModel->mLogicalModel->mText.Count(); // Retrieve the text. if( 0u != numberOfCharacters ) { - Utf32ToUtf8( mLogicalModel->mText.Begin() + index, numberOfCharacters - index, text ); + Utf32ToUtf8( mModel->mLogicalModel->mText.Begin() + index, numberOfCharacters - index, text ); } } @@ -392,7 +392,7 @@ void Controller::Impl::CalculateTextUpdateIndices( Length& numberOfCharacters ) mTextUpdateInfo.mStartLineIndex = 0u; numberOfCharacters = 0u; - const Length numberOfParagraphs = mLogicalModel->mParagraphInfo.Count(); + const Length numberOfParagraphs = mModel->mLogicalModel->mParagraphInfo.Count(); if( 0u == numberOfParagraphs ) { mTextUpdateInfo.mParagraphCharacterIndex = 0u; @@ -416,8 +416,8 @@ void Controller::Impl::CalculateTextUpdateIndices( Length& numberOfCharacters ) numberOfCharacters = 0u; mTextUpdateInfo.mRequestedNumberOfCharacters = mTextUpdateInfo.mNumberOfCharactersToAdd - mTextUpdateInfo.mNumberOfCharactersToRemove; - mTextUpdateInfo.mStartGlyphIndex = mVisualModel->mGlyphs.Count(); - mTextUpdateInfo.mStartLineIndex = mVisualModel->mLines.Count() - 1u; + mTextUpdateInfo.mStartGlyphIndex = mModel->mVisualModel->mGlyphs.Count(); + mTextUpdateInfo.mStartLineIndex = mModel->mVisualModel->mLines.Count() - 1u; // Nothing else to do; return; @@ -436,19 +436,19 @@ void Controller::Impl::CalculateTextUpdateIndices( Length& numberOfCharacters ) { numberOfCharactersToUpdate = ( mTextUpdateInfo.mNumberOfCharactersToRemove > 0u ) ? mTextUpdateInfo.mNumberOfCharactersToRemove : 1u; } - mLogicalModel->FindParagraphs( mTextUpdateInfo.mCharacterIndex, - numberOfCharactersToUpdate, - paragraphsToBeUpdated ); + mModel->mLogicalModel->FindParagraphs( mTextUpdateInfo.mCharacterIndex, + numberOfCharactersToUpdate, + paragraphsToBeUpdated ); } if( 0u != paragraphsToBeUpdated.Count() ) { const ParagraphRunIndex firstParagraphIndex = *( paragraphsToBeUpdated.Begin() ); - const ParagraphRun& firstParagraph = *( mLogicalModel->mParagraphInfo.Begin() + firstParagraphIndex ); + const ParagraphRun& firstParagraph = *( mModel->mLogicalModel->mParagraphInfo.Begin() + firstParagraphIndex ); mTextUpdateInfo.mParagraphCharacterIndex = firstParagraph.characterRun.characterIndex; ParagraphRunIndex lastParagraphIndex = *( paragraphsToBeUpdated.End() - 1u ); - const ParagraphRun& lastParagraph = *( mLogicalModel->mParagraphInfo.Begin() + lastParagraphIndex ); + const ParagraphRun& lastParagraph = *( mModel->mLogicalModel->mParagraphInfo.Begin() + lastParagraphIndex ); if( ( mTextUpdateInfo.mNumberOfCharactersToRemove > 0u ) && // Some character are removed. ( lastParagraphIndex < numberOfParagraphs - 1u ) && // There is a next paragraph. @@ -456,7 +456,7 @@ void Controller::Impl::CalculateTextUpdateIndices( Length& numberOfCharacters ) ( mTextUpdateInfo.mCharacterIndex + mTextUpdateInfo.mNumberOfCharactersToRemove ) ) ) { // The new paragraph character of the last updated paragraph has been removed so is going to be merged with the next one. - const ParagraphRun& lastParagraph = *( mLogicalModel->mParagraphInfo.Begin() + lastParagraphIndex + 1u ); + const ParagraphRun& lastParagraph = *( mModel->mLogicalModel->mParagraphInfo.Begin() + lastParagraphIndex + 1u ); numberOfCharacters = lastParagraph.characterRun.characterIndex + lastParagraph.characterRun.numberOfCharacters - mTextUpdateInfo.mParagraphCharacterIndex; } @@ -467,45 +467,45 @@ void Controller::Impl::CalculateTextUpdateIndices( Length& numberOfCharacters ) } mTextUpdateInfo.mRequestedNumberOfCharacters = numberOfCharacters + mTextUpdateInfo.mNumberOfCharactersToAdd - mTextUpdateInfo.mNumberOfCharactersToRemove; - mTextUpdateInfo.mStartGlyphIndex = *( mVisualModel->mCharactersToGlyph.Begin() + mTextUpdateInfo.mParagraphCharacterIndex ); + mTextUpdateInfo.mStartGlyphIndex = *( mModel->mVisualModel->mCharactersToGlyph.Begin() + mTextUpdateInfo.mParagraphCharacterIndex ); } void Controller::Impl::ClearFullModelData( OperationsMask operations ) { if( NO_OPERATION != ( GET_LINE_BREAKS & operations ) ) { - mLogicalModel->mLineBreakInfo.Clear(); - mLogicalModel->mParagraphInfo.Clear(); + mModel->mLogicalModel->mLineBreakInfo.Clear(); + mModel->mLogicalModel->mParagraphInfo.Clear(); } if( NO_OPERATION != ( GET_WORD_BREAKS & operations ) ) { - mLogicalModel->mLineBreakInfo.Clear(); + mModel->mLogicalModel->mLineBreakInfo.Clear(); } if( NO_OPERATION != ( GET_SCRIPTS & operations ) ) { - mLogicalModel->mScriptRuns.Clear(); + mModel->mLogicalModel->mScriptRuns.Clear(); } if( NO_OPERATION != ( VALIDATE_FONTS & operations ) ) { - mLogicalModel->mFontRuns.Clear(); + mModel->mLogicalModel->mFontRuns.Clear(); } - if( 0u != mLogicalModel->mBidirectionalParagraphInfo.Count() ) + if( 0u != mModel->mLogicalModel->mBidirectionalParagraphInfo.Count() ) { if( NO_OPERATION != ( BIDI_INFO & operations ) ) { - mLogicalModel->mBidirectionalParagraphInfo.Clear(); - mLogicalModel->mCharacterDirections.Clear(); + mModel->mLogicalModel->mBidirectionalParagraphInfo.Clear(); + mModel->mLogicalModel->mCharacterDirections.Clear(); } if( NO_OPERATION != ( REORDER & operations ) ) { // Free the allocated memory used to store the conversion table in the bidirectional line info run. - for( Vector::Iterator it = mLogicalModel->mBidirectionalLineInfo.Begin(), - endIt = mLogicalModel->mBidirectionalLineInfo.End(); + for( Vector::Iterator it = mModel->mLogicalModel->mBidirectionalLineInfo.Begin(), + endIt = mModel->mLogicalModel->mBidirectionalLineInfo.End(); it != endIt; ++it ) { @@ -514,28 +514,28 @@ void Controller::Impl::ClearFullModelData( OperationsMask operations ) free( bidiLineInfo.visualToLogicalMap ); bidiLineInfo.visualToLogicalMap = NULL; } - mLogicalModel->mBidirectionalLineInfo.Clear(); + mModel->mLogicalModel->mBidirectionalLineInfo.Clear(); } } if( NO_OPERATION != ( SHAPE_TEXT & operations ) ) { - mVisualModel->mGlyphs.Clear(); - mVisualModel->mGlyphsToCharacters.Clear(); - mVisualModel->mCharactersToGlyph.Clear(); - mVisualModel->mCharactersPerGlyph.Clear(); - mVisualModel->mGlyphsPerCharacter.Clear(); - mVisualModel->mGlyphPositions.Clear(); + mModel->mVisualModel->mGlyphs.Clear(); + mModel->mVisualModel->mGlyphsToCharacters.Clear(); + mModel->mVisualModel->mCharactersToGlyph.Clear(); + mModel->mVisualModel->mCharactersPerGlyph.Clear(); + mModel->mVisualModel->mGlyphsPerCharacter.Clear(); + mModel->mVisualModel->mGlyphPositions.Clear(); } if( NO_OPERATION != ( LAYOUT & operations ) ) { - mVisualModel->mLines.Clear(); + mModel->mVisualModel->mLines.Clear(); } if( NO_OPERATION != ( COLOR & operations ) ) { - mVisualModel->mColorIndices.Clear(); + mModel->mVisualModel->mColorIndices.Clear(); } } @@ -546,23 +546,23 @@ void Controller::Impl::ClearCharacterModelData( CharacterIndex startIndex, Chara if( NO_OPERATION != ( GET_LINE_BREAKS & operations ) ) { // Clear the line break info. - LineBreakInfo* lineBreakInfoBuffer = mLogicalModel->mLineBreakInfo.Begin(); + LineBreakInfo* lineBreakInfoBuffer = mModel->mLogicalModel->mLineBreakInfo.Begin(); - mLogicalModel->mLineBreakInfo.Erase( lineBreakInfoBuffer + startIndex, - lineBreakInfoBuffer + endIndexPlusOne ); + mModel->mLogicalModel->mLineBreakInfo.Erase( lineBreakInfoBuffer + startIndex, + lineBreakInfoBuffer + endIndexPlusOne ); // Clear the paragraphs. ClearCharacterRuns( startIndex, endIndex, - mLogicalModel->mParagraphInfo ); + mModel->mLogicalModel->mParagraphInfo ); } if( NO_OPERATION != ( GET_WORD_BREAKS & operations ) ) { // Clear the word break info. - WordBreakInfo* wordBreakInfoBuffer = mLogicalModel->mWordBreakInfo.Begin(); + WordBreakInfo* wordBreakInfoBuffer = mModel->mLogicalModel->mWordBreakInfo.Begin(); - mLogicalModel->mWordBreakInfo.Erase( wordBreakInfoBuffer + startIndex, + mModel->mLogicalModel->mWordBreakInfo.Erase( wordBreakInfoBuffer + startIndex, wordBreakInfoBuffer + endIndexPlusOne ); } @@ -571,7 +571,7 @@ void Controller::Impl::ClearCharacterModelData( CharacterIndex startIndex, Chara // Clear the scripts. ClearCharacterRuns( startIndex, endIndex, - mLogicalModel->mScriptRuns ); + mModel->mLogicalModel->mScriptRuns ); } if( NO_OPERATION != ( VALIDATE_FONTS & operations ) ) @@ -579,36 +579,36 @@ void Controller::Impl::ClearCharacterModelData( CharacterIndex startIndex, Chara // Clear the fonts. ClearCharacterRuns( startIndex, endIndex, - mLogicalModel->mFontRuns ); + mModel->mLogicalModel->mFontRuns ); } - if( 0u != mLogicalModel->mBidirectionalParagraphInfo.Count() ) + if( 0u != mModel->mLogicalModel->mBidirectionalParagraphInfo.Count() ) { if( NO_OPERATION != ( BIDI_INFO & operations ) ) { // Clear the bidirectional paragraph info. ClearCharacterRuns( startIndex, endIndex, - mLogicalModel->mBidirectionalParagraphInfo ); + mModel->mLogicalModel->mBidirectionalParagraphInfo ); // Clear the character's directions. - CharacterDirection* characterDirectionsBuffer = mLogicalModel->mCharacterDirections.Begin(); + CharacterDirection* characterDirectionsBuffer = mModel->mLogicalModel->mCharacterDirections.Begin(); - mLogicalModel->mCharacterDirections.Erase( characterDirectionsBuffer + startIndex, - characterDirectionsBuffer + endIndexPlusOne ); + mModel->mLogicalModel->mCharacterDirections.Erase( characterDirectionsBuffer + startIndex, + characterDirectionsBuffer + endIndexPlusOne ); } if( NO_OPERATION != ( REORDER & operations ) ) { - uint32_t startRemoveIndex = mLogicalModel->mBidirectionalLineInfo.Count(); + uint32_t startRemoveIndex = mModel->mLogicalModel->mBidirectionalLineInfo.Count(); uint32_t endRemoveIndex = startRemoveIndex; ClearCharacterRuns( startIndex, endIndex, - mLogicalModel->mBidirectionalLineInfo, + mModel->mLogicalModel->mBidirectionalLineInfo, startRemoveIndex, endRemoveIndex ); - BidirectionalLineInfoRun* bidirectionalLineInfoBuffer = mLogicalModel->mBidirectionalLineInfo.Begin(); + BidirectionalLineInfoRun* bidirectionalLineInfoBuffer = mModel->mLogicalModel->mBidirectionalLineInfo.Begin(); // Free the allocated memory used to store the conversion table in the bidirectional line info run. for( Vector::Iterator it = bidirectionalLineInfoBuffer + startRemoveIndex, @@ -622,8 +622,8 @@ void Controller::Impl::ClearCharacterModelData( CharacterIndex startIndex, Chara bidiLineInfo.visualToLogicalMap = NULL; } - mLogicalModel->mBidirectionalLineInfo.Erase( bidirectionalLineInfoBuffer + startRemoveIndex, - bidirectionalLineInfoBuffer + endRemoveIndex ); + mModel->mLogicalModel->mBidirectionalLineInfo.Erase( bidirectionalLineInfoBuffer + startRemoveIndex, + bidirectionalLineInfoBuffer + endRemoveIndex ); } } } @@ -634,8 +634,8 @@ void Controller::Impl::ClearGlyphModelData( CharacterIndex startIndex, Character const Length numberOfCharactersRemoved = endIndexPlusOne - startIndex; // Convert the character index to glyph index before deleting the character to glyph and the glyphs per character buffers. - GlyphIndex* charactersToGlyphBuffer = mVisualModel->mCharactersToGlyph.Begin(); - Length* glyphsPerCharacterBuffer = mVisualModel->mGlyphsPerCharacter.Begin(); + GlyphIndex* charactersToGlyphBuffer = mModel->mVisualModel->mCharactersToGlyph.Begin(); + Length* glyphsPerCharacterBuffer = mModel->mVisualModel->mGlyphsPerCharacter.Begin(); const GlyphIndex endGlyphIndexPlusOne = *( charactersToGlyphBuffer + endIndex ) + *( glyphsPerCharacterBuffer + endIndex ); const Length numberOfGlyphsRemoved = endGlyphIndexPlusOne - mTextUpdateInfo.mStartGlyphIndex; @@ -644,7 +644,7 @@ void Controller::Impl::ClearGlyphModelData( CharacterIndex startIndex, Character { // Update the character to glyph indices. for( Vector::Iterator it = charactersToGlyphBuffer + endIndexPlusOne, - endIt = charactersToGlyphBuffer + mVisualModel->mCharactersToGlyph.Count(); + endIt = charactersToGlyphBuffer + mModel->mVisualModel->mCharactersToGlyph.Count(); it != endIt; ++it ) { @@ -653,23 +653,23 @@ void Controller::Impl::ClearGlyphModelData( CharacterIndex startIndex, Character } // Clear the character to glyph conversion table. - mVisualModel->mCharactersToGlyph.Erase( charactersToGlyphBuffer + startIndex, - charactersToGlyphBuffer + endIndexPlusOne ); + mModel->mVisualModel->mCharactersToGlyph.Erase( charactersToGlyphBuffer + startIndex, + charactersToGlyphBuffer + endIndexPlusOne ); // Clear the glyphs per character table. - mVisualModel->mGlyphsPerCharacter.Erase( glyphsPerCharacterBuffer + startIndex, - glyphsPerCharacterBuffer + endIndexPlusOne ); + mModel->mVisualModel->mGlyphsPerCharacter.Erase( glyphsPerCharacterBuffer + startIndex, + glyphsPerCharacterBuffer + endIndexPlusOne ); // Clear the glyphs buffer. - GlyphInfo* glyphsBuffer = mVisualModel->mGlyphs.Begin(); - mVisualModel->mGlyphs.Erase( glyphsBuffer + mTextUpdateInfo.mStartGlyphIndex, - glyphsBuffer + endGlyphIndexPlusOne ); + GlyphInfo* glyphsBuffer = mModel->mVisualModel->mGlyphs.Begin(); + mModel->mVisualModel->mGlyphs.Erase( glyphsBuffer + mTextUpdateInfo.mStartGlyphIndex, + glyphsBuffer + endGlyphIndexPlusOne ); - CharacterIndex* glyphsToCharactersBuffer = mVisualModel->mGlyphsToCharacters.Begin(); + CharacterIndex* glyphsToCharactersBuffer = mModel->mVisualModel->mGlyphsToCharacters.Begin(); // Update the glyph to character indices. for( Vector::Iterator it = glyphsToCharactersBuffer + endGlyphIndexPlusOne, - endIt = glyphsToCharactersBuffer + mVisualModel->mGlyphsToCharacters.Count(); + endIt = glyphsToCharactersBuffer + mModel->mVisualModel->mGlyphsToCharacters.Count(); it != endIt; ++it ) { @@ -678,55 +678,55 @@ void Controller::Impl::ClearGlyphModelData( CharacterIndex startIndex, Character } // Clear the glyphs to characters buffer. - mVisualModel->mGlyphsToCharacters.Erase( glyphsToCharactersBuffer + mTextUpdateInfo.mStartGlyphIndex, - glyphsToCharactersBuffer + endGlyphIndexPlusOne ); + mModel->mVisualModel->mGlyphsToCharacters.Erase( glyphsToCharactersBuffer + mTextUpdateInfo.mStartGlyphIndex, + glyphsToCharactersBuffer + endGlyphIndexPlusOne ); // Clear the characters per glyph buffer. - Length* charactersPerGlyphBuffer = mVisualModel->mCharactersPerGlyph.Begin(); - mVisualModel->mCharactersPerGlyph.Erase( charactersPerGlyphBuffer + mTextUpdateInfo.mStartGlyphIndex, - charactersPerGlyphBuffer + endGlyphIndexPlusOne ); + Length* charactersPerGlyphBuffer = mModel->mVisualModel->mCharactersPerGlyph.Begin(); + mModel->mVisualModel->mCharactersPerGlyph.Erase( charactersPerGlyphBuffer + mTextUpdateInfo.mStartGlyphIndex, + charactersPerGlyphBuffer + endGlyphIndexPlusOne ); // Clear the positions buffer. - Vector2* positionsBuffer = mVisualModel->mGlyphPositions.Begin(); - mVisualModel->mGlyphPositions.Erase( positionsBuffer + mTextUpdateInfo.mStartGlyphIndex, - positionsBuffer + endGlyphIndexPlusOne ); + Vector2* positionsBuffer = mModel->mVisualModel->mGlyphPositions.Begin(); + mModel->mVisualModel->mGlyphPositions.Erase( positionsBuffer + mTextUpdateInfo.mStartGlyphIndex, + positionsBuffer + endGlyphIndexPlusOne ); } if( NO_OPERATION != ( LAYOUT & operations ) ) { // Clear the lines. - uint32_t startRemoveIndex = mVisualModel->mLines.Count(); + uint32_t startRemoveIndex = mModel->mVisualModel->mLines.Count(); uint32_t endRemoveIndex = startRemoveIndex; ClearCharacterRuns( startIndex, endIndex, - mVisualModel->mLines, + mModel->mVisualModel->mLines, startRemoveIndex, endRemoveIndex ); // Will update the glyph runs. - startRemoveIndex = mVisualModel->mLines.Count(); + startRemoveIndex = mModel->mVisualModel->mLines.Count(); endRemoveIndex = startRemoveIndex; ClearGlyphRuns( mTextUpdateInfo.mStartGlyphIndex, endGlyphIndexPlusOne - 1u, - mVisualModel->mLines, + mModel->mVisualModel->mLines, startRemoveIndex, endRemoveIndex ); // Set the line index from where to insert the new laid-out lines. mTextUpdateInfo.mStartLineIndex = startRemoveIndex; - LineRun* linesBuffer = mVisualModel->mLines.Begin(); - mVisualModel->mLines.Erase( linesBuffer + startRemoveIndex, - linesBuffer + endRemoveIndex ); + LineRun* linesBuffer = mModel->mVisualModel->mLines.Begin(); + mModel->mVisualModel->mLines.Erase( linesBuffer + startRemoveIndex, + linesBuffer + endRemoveIndex ); } if( NO_OPERATION != ( COLOR & operations ) ) { - if( 0u != mVisualModel->mColorIndices.Count() ) + if( 0u != mModel->mVisualModel->mColorIndices.Count() ) { - ColorIndex* colorIndexBuffer = mVisualModel->mColorIndices.Begin(); - mVisualModel->mColorIndices.Erase( colorIndexBuffer + mTextUpdateInfo.mStartGlyphIndex, - colorIndexBuffer + endGlyphIndexPlusOne ); + ColorIndex* colorIndexBuffer = mModel->mVisualModel->mColorIndices.Begin(); + mModel->mVisualModel->mColorIndices.Erase( colorIndexBuffer + mTextUpdateInfo.mStartGlyphIndex, + colorIndexBuffer + endGlyphIndexPlusOne ); } } } @@ -749,9 +749,9 @@ void Controller::Impl::ClearModelData( CharacterIndex startIndex, CharacterIndex } // The estimated number of lines. Used to avoid reallocations when layouting. - mTextUpdateInfo.mEstimatedNumberOfLines = std::max( mVisualModel->mLines.Count(), mLogicalModel->mParagraphInfo.Count() ); + mTextUpdateInfo.mEstimatedNumberOfLines = std::max( mModel->mVisualModel->mLines.Count(), mModel->mLogicalModel->mParagraphInfo.Count() ); - mVisualModel->ClearCaches(); + mModel->mVisualModel->ClearCaches(); } bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) @@ -767,7 +767,7 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) return false; } - Vector& utf32Characters = mLogicalModel->mText; + Vector& utf32Characters = mModel->mLogicalModel->mText; const Length numberOfCharacters = utf32Characters.Count(); @@ -790,7 +790,7 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) // Whether the model is updated. bool updated = false; - Vector& lineBreakInfo = mLogicalModel->mLineBreakInfo; + Vector& lineBreakInfo = mModel->mLogicalModel->mLineBreakInfo; const Length requestedNumberOfCharacters = mTextUpdateInfo.mRequestedNumberOfCharacters; if( NO_OPERATION != ( GET_LINE_BREAKS & operations ) ) @@ -807,12 +807,12 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) lineBreakInfo ); // Create the paragraph info. - mLogicalModel->CreateParagraphInfo( startIndex, - requestedNumberOfCharacters ); + mModel->mLogicalModel->CreateParagraphInfo( startIndex, + requestedNumberOfCharacters ); updated = true; } - Vector& wordBreakInfo = mLogicalModel->mWordBreakInfo; + Vector& wordBreakInfo = mModel->mLogicalModel->mWordBreakInfo; if( NO_OPERATION != ( GET_WORD_BREAKS & operations ) ) { // Retrieves the word break info. The word break info is used to layout the text (where to wrap the text in lines). @@ -828,8 +828,8 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) const bool getScripts = NO_OPERATION != ( GET_SCRIPTS & operations ); const bool validateFonts = NO_OPERATION != ( VALIDATE_FONTS & operations ); - Vector& scripts = mLogicalModel->mScriptRuns; - Vector& validFonts = mLogicalModel->mFontRuns; + Vector& scripts = mModel->mLogicalModel->mScriptRuns; + Vector& validFonts = mModel->mLogicalModel->mFontRuns; if( getScripts || validateFonts ) { @@ -849,7 +849,7 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) if( validateFonts ) { // Validate the fonts set through the mark-up string. - Vector& fontDescriptionRuns = mLogicalModel->mFontDescriptionRuns; + Vector& fontDescriptionRuns = mModel->mLogicalModel->mFontDescriptionRuns; // Get the default font's description. TextAbstraction::FontDescription defaultFontDescription; @@ -876,10 +876,10 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) Vector mirroredUtf32Characters; bool textMirrored = false; - const Length numberOfParagraphs = mLogicalModel->mParagraphInfo.Count(); + const Length numberOfParagraphs = mModel->mLogicalModel->mParagraphInfo.Count(); if( NO_OPERATION != ( BIDI_INFO & operations ) ) { - Vector& bidirectionalInfo = mLogicalModel->mBidirectionalParagraphInfo; + Vector& bidirectionalInfo = mModel->mLogicalModel->mBidirectionalParagraphInfo; bidirectionalInfo.Reserve( numberOfParagraphs ); // Calculates the bidirectional info for the whole paragraph if it contains right to left scripts. @@ -893,7 +893,7 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) if( 0u != bidirectionalInfo.Count() ) { // Only set the character directions if there is right to left characters. - Vector& directions = mLogicalModel->mCharacterDirections; + Vector& directions = mModel->mLogicalModel->mCharacterDirections; GetCharactersDirection( bidirectionalInfo, numberOfCharacters, startIndex, @@ -913,14 +913,14 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) else { // There is no right to left characters. Clear the directions vector. - mLogicalModel->mCharacterDirections.Clear(); + mModel->mLogicalModel->mCharacterDirections.Clear(); } updated = true; } - Vector& glyphs = mVisualModel->mGlyphs; - Vector& glyphsToCharactersMap = mVisualModel->mGlyphsToCharacters; - Vector& charactersPerGlyph = mVisualModel->mCharactersPerGlyph; + Vector& glyphs = mModel->mVisualModel->mGlyphs; + Vector& glyphsToCharactersMap = mModel->mVisualModel->mGlyphsToCharacters; + Vector& charactersPerGlyph = mModel->mVisualModel->mCharactersPerGlyph; Vector newParagraphGlyphs; newParagraphGlyphs.Reserve( numberOfParagraphs ); @@ -942,8 +942,8 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) newParagraphGlyphs ); // Create the 'number of glyphs' per character and the glyph to character conversion tables. - mVisualModel->CreateGlyphsPerCharacterTable( startIndex, mTextUpdateInfo.mStartGlyphIndex, requestedNumberOfCharacters ); - mVisualModel->CreateCharacterToGlyphTable( startIndex, mTextUpdateInfo.mStartGlyphIndex, requestedNumberOfCharacters ); + mModel->mVisualModel->CreateGlyphsPerCharacterTable( startIndex, mTextUpdateInfo.mStartGlyphIndex, requestedNumberOfCharacters ); + mModel->mVisualModel->CreateCharacterToGlyphTable( startIndex, mTextUpdateInfo.mStartGlyphIndex, requestedNumberOfCharacters ); updated = true; } @@ -970,25 +970,25 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) if( NO_OPERATION != ( COLOR & operations ) ) { // Set the color runs in glyphs. - SetColorSegmentationInfo( mLogicalModel->mColorRuns, - mVisualModel->mCharactersToGlyph, - mVisualModel->mGlyphsPerCharacter, + SetColorSegmentationInfo( mModel->mLogicalModel->mColorRuns, + mModel->mVisualModel->mCharactersToGlyph, + mModel->mVisualModel->mGlyphsPerCharacter, startIndex, mTextUpdateInfo.mStartGlyphIndex, requestedNumberOfCharacters, - mVisualModel->mColors, - mVisualModel->mColorIndices ); + mModel->mVisualModel->mColors, + mModel->mVisualModel->mColorIndices ); updated = true; } if( ( NULL != mEventData ) && mEventData->mPreEditFlag && - ( 0u != mVisualModel->mCharactersToGlyph.Count() ) ) + ( 0u != mModel->mVisualModel->mCharactersToGlyph.Count() ) ) { // Add the underline for the pre-edit text. - const GlyphIndex* const charactersToGlyphBuffer = mVisualModel->mCharactersToGlyph.Begin(); - const Length* const glyphsPerCharacterBuffer = mVisualModel->mGlyphsPerCharacter.Begin(); + const GlyphIndex* const charactersToGlyphBuffer = mModel->mVisualModel->mCharactersToGlyph.Begin(); + const Length* const glyphsPerCharacterBuffer = mModel->mVisualModel->mGlyphsPerCharacter.Begin(); const GlyphIndex glyphStart = *( charactersToGlyphBuffer + mEventData->mPreEditStartPosition ); const CharacterIndex lastPreEditCharacter = mEventData->mPreEditStartPosition + ( ( mEventData->mPreEditLength > 0u ) ? mEventData->mPreEditLength - 1u : 0u ); @@ -1000,11 +1000,11 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) underlineRun.numberOfGlyphs = 1u + glyphEnd - glyphStart; // TODO: At the moment the underline runs are only for pre-edit. - mVisualModel->mUnderlineRuns.PushBack( underlineRun ); + mModel->mVisualModel->mUnderlineRuns.PushBack( underlineRun ); } // The estimated number of lines. Used to avoid reallocations when layouting. - mTextUpdateInfo.mEstimatedNumberOfLines = std::max( mVisualModel->mLines.Count(), mLogicalModel->mParagraphInfo.Count() ); + mTextUpdateInfo.mEstimatedNumberOfLines = std::max( mModel->mVisualModel->mLines.Count(), mModel->mLogicalModel->mParagraphInfo.Count() ); // Set the previous number of characters for the next time the text is updated. mTextUpdateInfo.mPreviousNumberOfCharacters = numberOfCharacters; @@ -1117,7 +1117,7 @@ void Controller::Impl::OnCursorKeyEvent( const Event& event ) } else if( Dali::DALI_KEY_CURSOR_RIGHT == keyCode ) { - if( mLogicalModel->mText.Count() > mEventData->mPrimaryCursorPosition ) + if( mModel->mLogicalModel->mText.Count() > mEventData->mPrimaryCursorPosition ) { mEventData->mPrimaryCursorPosition = CalculateNewCursorIndex( mEventData->mPrimaryCursorPosition ); } @@ -1132,7 +1132,7 @@ void Controller::Impl::OnCursorKeyEvent( const Event& event ) characterIndex = mEventData->mPrimaryCursorPosition - 1u; } - const LineIndex lineIndex = mVisualModel->GetLineOfCharacter( characterIndex ); + const LineIndex lineIndex = mModel->mVisualModel->GetLineOfCharacter( characterIndex ); if( lineIndex > 0u ) { @@ -1142,14 +1142,14 @@ void Controller::Impl::OnCursorKeyEvent( const Event& event ) cursorInfo ); // Get the line above. - const LineRun& line = *( mVisualModel->mLines.Begin() + ( lineIndex - 1u ) ); + const LineRun& line = *( mModel->mVisualModel->mLines.Begin() + ( lineIndex - 1u ) ); // Get the next hit 'y' point. const float hitPointY = cursorInfo.lineOffset - 0.5f * ( line.ascender - line.descender ); // Use the cursor hook position 'x' and the next hit 'y' position to calculate the new cursor index. - mEventData->mPrimaryCursorPosition = Text::GetClosestCursorIndex( mVisualModel, - mLogicalModel, + mEventData->mPrimaryCursorPosition = Text::GetClosestCursorIndex( mModel->mVisualModel, + mModel->mLogicalModel, mMetrics, mEventData->mCursorHookPositionX, hitPointY ); @@ -1165,9 +1165,9 @@ void Controller::Impl::OnCursorKeyEvent( const Event& event ) characterIndex = mEventData->mPrimaryCursorPosition - 1u; } - const LineIndex lineIndex = mVisualModel->GetLineOfCharacter( characterIndex ); + const LineIndex lineIndex = mModel->mVisualModel->GetLineOfCharacter( characterIndex ); - if( lineIndex + 1u < mVisualModel->mLines.Count() ) + if( lineIndex + 1u < mModel->mVisualModel->mLines.Count() ) { // Retrieve the cursor position info. CursorInfo cursorInfo; @@ -1175,14 +1175,14 @@ void Controller::Impl::OnCursorKeyEvent( const Event& event ) cursorInfo ); // Get the line below. - const LineRun& line = *( mVisualModel->mLines.Begin() + lineIndex + 1u ); + const LineRun& line = *( mModel->mVisualModel->mLines.Begin() + lineIndex + 1u ); // Get the next hit 'y' point. const float hitPointY = cursorInfo.lineOffset + cursorInfo.lineHeight + 0.5f * ( line.ascender - line.descender ); // Use the cursor hook position 'x' and the next hit 'y' position to calculate the new cursor index. - mEventData->mPrimaryCursorPosition = Text::GetClosestCursorIndex( mVisualModel, - mLogicalModel, + mEventData->mPrimaryCursorPosition = Text::GetClosestCursorIndex( mModel->mVisualModel, + mModel->mLogicalModel, mMetrics, mEventData->mCursorHookPositionX, hitPointY ); @@ -1205,14 +1205,14 @@ void Controller::Impl::OnTapEvent( const Event& event ) if( IsShowingRealText() ) { // Convert from control's coords to text's coords. - const float xPosition = event.p2.mFloat - mScrollPosition.x; - const float yPosition = event.p3.mFloat - mScrollPosition.y; + const float xPosition = event.p2.mFloat - mModel->mScrollPosition.x; + const float yPosition = event.p3.mFloat - mModel->mScrollPosition.y; // Keep the tap 'x' position. Used to move the cursor. mEventData->mCursorHookPositionX = xPosition; - mEventData->mPrimaryCursorPosition = Text::GetClosestCursorIndex( mVisualModel, - mLogicalModel, + mEventData->mPrimaryCursorPosition = Text::GetClosestCursorIndex( mModel->mVisualModel, + mModel->mLogicalModel, mMetrics, xPosition, yPosition ); @@ -1269,13 +1269,13 @@ void Controller::Impl::OnPanEvent( const Event& event ) } case Gesture::Continuing: { - const Vector2& layoutSize = mVisualModel->GetLayoutSize(); - const Vector2 currentScroll = mScrollPosition; + const Vector2& layoutSize = mModel->mVisualModel->GetLayoutSize(); + const Vector2 currentScroll = mModel->mScrollPosition; if( isHorizontalScrollEnabled ) { const float displacementX = event.p2.mFloat; - mScrollPosition.x += displacementX; + mModel->mScrollPosition.x += displacementX; ClampHorizontalScroll( layoutSize ); } @@ -1283,12 +1283,12 @@ void Controller::Impl::OnPanEvent( const Event& event ) if( isVerticalScrollEnabled ) { const float displacementY = event.p3.mFloat; - mScrollPosition.y += displacementY; + mModel->mScrollPosition.y += displacementY; ClampVerticalScroll( layoutSize ); } - mEventData->mDecorator->UpdatePositions( mScrollPosition - currentScroll ); + mEventData->mDecorator->UpdatePositions( mModel->mScrollPosition - currentScroll ); break; } case Gesture::Finished: @@ -1311,6 +1311,7 @@ void Controller::Impl::OnLongPressEvent( const Event& event ) { ChangeState ( EventData::EDITING_WITH_POPUP ); mEventData->mDecoratorUpdated = true; + mEventData->mUpdateInputStyle = true; } } @@ -1329,12 +1330,12 @@ void Controller::Impl::OnHandleEvent( const Event& event ) if( HANDLE_PRESSED == state ) { // Convert from decorator's coords to text's coords. - const float xPosition = event.p2.mFloat - mScrollPosition.x; - const float yPosition = event.p3.mFloat - mScrollPosition.y; + const float xPosition = event.p2.mFloat - mModel->mScrollPosition.x; + const float yPosition = event.p3.mFloat - mModel->mScrollPosition.y; // Need to calculate the handle's new position. - const CharacterIndex handleNewPosition = Text::GetClosestCursorIndex( mVisualModel, - mLogicalModel, + const CharacterIndex handleNewPosition = Text::GetClosestCursorIndex( mModel->mVisualModel, + mModel->mLogicalModel, mMetrics, xPosition, yPosition ); @@ -1403,11 +1404,11 @@ void Controller::Impl::OnHandleEvent( const Event& event ) if( handleStopScrolling || isSmoothHandlePanEnabled ) { // Convert from decorator's coords to text's coords. - const float xPosition = event.p2.mFloat - mScrollPosition.x; - const float yPosition = event.p3.mFloat - mScrollPosition.y; + const float xPosition = event.p2.mFloat - mModel->mScrollPosition.x; + const float yPosition = event.p3.mFloat - mModel->mScrollPosition.y; - handlePosition = Text::GetClosestCursorIndex( mVisualModel, - mLogicalModel, + handlePosition = Text::GetClosestCursorIndex( mModel->mVisualModel, + mModel->mLogicalModel, mMetrics, xPosition, yPosition ); @@ -1474,17 +1475,17 @@ void Controller::Impl::OnHandleEvent( const Event& event ) { const float xSpeed = event.p2.mFloat; const float ySpeed = event.p3.mFloat; - const Vector2& layoutSize = mVisualModel->GetLayoutSize(); - const Vector2 currentScrollPosition = mScrollPosition; + const Vector2& layoutSize = mModel->mVisualModel->GetLayoutSize(); + const Vector2 currentScrollPosition = mModel->mScrollPosition; - mScrollPosition.x += xSpeed; - mScrollPosition.y += ySpeed; + mModel->mScrollPosition.x += xSpeed; + mModel->mScrollPosition.y += ySpeed; ClampHorizontalScroll( layoutSize ); ClampVerticalScroll( layoutSize ); bool endOfScroll = false; - if( Vector2::ZERO == ( currentScrollPosition - mScrollPosition ) ) + if( Vector2::ZERO == ( currentScrollPosition - mModel->mScrollPosition ) ) { // Notify the decorator there is no more text to scroll. // The decorator won't send more scroll events. @@ -1509,7 +1510,7 @@ void Controller::Impl::OnHandleEvent( const Event& event ) if( mEventData->mDecorator->IsHorizontalScrollEnabled() ) { // Position the grag handle close to either the left or right edge. - position.x = scrollRightDirection ? 0.f : mVisualModel->mControlSize.width; + position.x = scrollRightDirection ? 0.f : mModel->mVisualModel->mControlSize.width; } if( mEventData->mDecorator->IsVerticalScrollEnabled() ) @@ -1517,16 +1518,16 @@ void Controller::Impl::OnHandleEvent( const Event& event ) position.x = mEventData->mCursorHookPositionX; // Position the grag handle close to either the top or bottom edge. - position.y = scrollBottomDirection ? 0.f : mVisualModel->mControlSize.height; + position.y = scrollBottomDirection ? 0.f : mModel->mVisualModel->mControlSize.height; } // Get the new handle position. // The grab handle's position is in decorator's coords. Need to transforms to text's coords. - const CharacterIndex handlePosition = Text::GetClosestCursorIndex( mVisualModel, - mLogicalModel, + const CharacterIndex handlePosition = Text::GetClosestCursorIndex( mModel->mVisualModel, + mModel->mLogicalModel, mMetrics, - position.x - mScrollPosition.x, - position.y - mScrollPosition.y ); + position.x - mModel->mScrollPosition.x, + position.y - mModel->mScrollPosition.y ); if( mEventData->mPrimaryCursorPosition != handlePosition ) { @@ -1550,7 +1551,7 @@ void Controller::Impl::OnHandleEvent( const Event& event ) if( mEventData->mDecorator->IsHorizontalScrollEnabled() ) { // Position the selection handle close to either the left or right edge. - position.x = scrollRightDirection ? 0.f : mVisualModel->mControlSize.width; + position.x = scrollRightDirection ? 0.f : mModel->mVisualModel->mControlSize.width; } if( mEventData->mDecorator->IsVerticalScrollEnabled() ) @@ -1558,16 +1559,16 @@ void Controller::Impl::OnHandleEvent( const Event& event ) position.x = mEventData->mCursorHookPositionX; // Position the grag handle close to either the top or bottom edge. - position.y = scrollBottomDirection ? 0.f : mVisualModel->mControlSize.height; + position.y = scrollBottomDirection ? 0.f : mModel->mVisualModel->mControlSize.height; } // Get the new handle position. // The selection handle's position is in decorator's coords. Need to transform to text's coords. - const CharacterIndex handlePosition = Text::GetClosestCursorIndex( mVisualModel, - mLogicalModel, + const CharacterIndex handlePosition = Text::GetClosestCursorIndex( mModel->mVisualModel, + mModel->mLogicalModel, mMetrics, - position.x - mScrollPosition.x, - position.y - mScrollPosition.y ); + position.x - mModel->mScrollPosition.x, + position.y - mModel->mScrollPosition.y ); if( leftSelectionHandleEvent ) { @@ -1615,8 +1616,8 @@ void Controller::Impl::OnSelectEvent( const Event& event ) if( mEventData->mSelectionEnabled ) { // Convert from control's coords to text's coords. - const float xPosition = event.p2.mFloat - mScrollPosition.x; - const float yPosition = event.p3.mFloat - mScrollPosition.y; + const float xPosition = event.p2.mFloat - mModel->mScrollPosition.x; + const float yPosition = event.p3.mFloat - mModel->mScrollPosition.y; // Calculates the logical position from the x,y coords. RepositionSelectionHandles( xPosition, @@ -1639,7 +1640,7 @@ void Controller::Impl::OnSelectAllEvent() ChangeState( EventData::SELECTING ); mEventData->mLeftSelectionPosition = 0u; - mEventData->mRightSelectionPosition = mLogicalModel->mText.Count(); + mEventData->mRightSelectionPosition = mModel->mLogicalModel->mText.Count(); mEventData->mScrollAfterUpdatePosition = true; mEventData->mUpdateLeftSelectionPosition = true; @@ -1663,7 +1664,7 @@ void Controller::Impl::RetrieveSelection( std::string& selectedText, bool delete const CharacterIndex startOfSelectedText = handlesCrossed ? mEventData->mRightSelectionPosition : mEventData->mLeftSelectionPosition; const Length lengthOfSelectedText = ( handlesCrossed ? mEventData->mLeftSelectionPosition : mEventData->mRightSelectionPosition ) - startOfSelectedText; - Vector& utf32Characters = mLogicalModel->mText; + Vector& utf32Characters = mModel->mLogicalModel->mText; const Length numberOfCharacters = utf32Characters.Count(); // Validate the start and end selection points @@ -1679,7 +1680,7 @@ void Controller::Impl::RetrieveSelection( std::string& selectedText, bool delete currentInputStyle.Copy( mEventData->mInputStyle ); // Set as input style the style of the first deleted character. - mLogicalModel->RetrieveStyle( startOfSelectedText, mEventData->mInputStyle ); + mModel->mLogicalModel->RetrieveStyle( startOfSelectedText, mEventData->mInputStyle ); // Compare if the input style has changed. const bool hasInputStyleChanged = !currentInputStyle.Equal( mEventData->mInputStyle ); @@ -1691,7 +1692,7 @@ void Controller::Impl::RetrieveSelection( std::string& selectedText, bool delete mEventData->mInputStyleChangedQueue.PushBack( styleChangedMask ); } - mLogicalModel->UpdateTextStyleRuns( startOfSelectedText, -static_cast( lengthOfSelectedText ) ); + mModel->mLogicalModel->UpdateTextStyleRuns( startOfSelectedText, -static_cast( lengthOfSelectedText ) ); // Mark the paragraphs to be updated. mTextUpdateInfo.mCharacterIndex = startOfSelectedText; @@ -1771,15 +1772,15 @@ void Controller::Impl::RepositionSelectionHandles() mEventData->mDecorator->ClearHighlights(); - const GlyphIndex* const charactersToGlyphBuffer = mVisualModel->mCharactersToGlyph.Begin(); - const Length* const glyphsPerCharacterBuffer = mVisualModel->mGlyphsPerCharacter.Begin(); - const GlyphInfo* const glyphsBuffer = mVisualModel->mGlyphs.Begin(); - const Vector2* const positionsBuffer = mVisualModel->mGlyphPositions.Begin(); - const Length* const charactersPerGlyphBuffer = mVisualModel->mCharactersPerGlyph.Begin(); - const CharacterIndex* const glyphToCharacterBuffer = mVisualModel->mGlyphsToCharacters.Begin(); - const CharacterDirection* const modelCharacterDirectionsBuffer = ( 0u != mLogicalModel->mCharacterDirections.Count() ) ? mLogicalModel->mCharacterDirections.Begin() : NULL; + const GlyphIndex* const charactersToGlyphBuffer = mModel->mVisualModel->mCharactersToGlyph.Begin(); + const Length* const glyphsPerCharacterBuffer = mModel->mVisualModel->mGlyphsPerCharacter.Begin(); + const GlyphInfo* const glyphsBuffer = mModel->mVisualModel->mGlyphs.Begin(); + const Vector2* const positionsBuffer = mModel->mVisualModel->mGlyphPositions.Begin(); + const Length* const charactersPerGlyphBuffer = mModel->mVisualModel->mCharactersPerGlyph.Begin(); + const CharacterIndex* const glyphToCharacterBuffer = mModel->mVisualModel->mGlyphsToCharacters.Begin(); + const CharacterDirection* const modelCharacterDirectionsBuffer = ( 0u != mModel->mLogicalModel->mCharacterDirections.Count() ) ? mModel->mLogicalModel->mCharacterDirections.Begin() : NULL; - const bool isLastCharacter = selectionEnd >= mLogicalModel->mText.Count(); + const bool isLastCharacter = selectionEnd >= mModel->mLogicalModel->mText.Count(); const CharacterDirection startDirection = ( ( NULL == modelCharacterDirectionsBuffer ) ? false : *( modelCharacterDirectionsBuffer + selectionStart ) ); const CharacterDirection endDirection = ( ( NULL == modelCharacterDirectionsBuffer ) ? false : *( modelCharacterDirectionsBuffer + ( selectionEnd - ( isLastCharacter ? 1u : 0u ) ) ) ); @@ -1801,14 +1802,14 @@ void Controller::Impl::RepositionSelectionHandles() const GlyphIndex glyphEnd = *( charactersToGlyphBuffer + selectionEndMinusOne ) + ( ( numberOfGlyphs > 0 ) ? numberOfGlyphs - 1u : 0u ); // Get the lines where the glyphs are laid-out. - const LineRun* lineRun = mVisualModel->mLines.Begin(); + const LineRun* lineRun = mModel->mVisualModel->mLines.Begin(); LineIndex lineIndex = 0u; Length numberOfLines = 0u; - mVisualModel->GetNumberOfLines( glyphStart, - 1u + glyphEnd - glyphStart, - lineIndex, - numberOfLines ); + mModel->mVisualModel->GetNumberOfLines( glyphStart, + 1u + glyphEnd - glyphStart, + lineIndex, + numberOfLines ); const LineIndex firstLineIndex = lineIndex; // Create the structure to store some selection box info. @@ -1828,11 +1829,11 @@ void Controller::Impl::RepositionSelectionHandles() // Retrieve the first line and get the line's vertical offset, the line's height and the index to the last glyph. // The line's vertical offset of all the lines before the line where the first glyph is laid-out. - selectionBoxInfo->lineOffset = CalculateLineOffset( mVisualModel->mLines, + selectionBoxInfo->lineOffset = CalculateLineOffset( mModel->mVisualModel->mLines, firstLineIndex ); // Transform to decorator's (control) coords. - selectionBoxInfo->lineOffset += mScrollPosition.y; + selectionBoxInfo->lineOffset += mModel->mScrollPosition.y; lineRun += firstLineIndex; @@ -1844,11 +1845,11 @@ void Controller::Impl::RepositionSelectionHandles() // Check if the first glyph is a ligature that must be broken like Latin ff, fi, or Arabic ﻻ, etc which needs special code. const Length numberOfCharactersStart = *( charactersPerGlyphBuffer + glyphStart ); - bool splitStartGlyph = ( numberOfCharactersStart > 1u ) && HasLigatureMustBreak( mLogicalModel->GetScript( selectionStart ) ); + bool splitStartGlyph = ( numberOfCharactersStart > 1u ) && HasLigatureMustBreak( mModel->mLogicalModel->GetScript( selectionStart ) ); // Check if the last glyph is a ligature that must be broken like Latin ff, fi, or Arabic ﻻ, etc which needs special code. const Length numberOfCharactersEnd = *( charactersPerGlyphBuffer + glyphEnd ); - bool splitEndGlyph = ( glyphStart != glyphEnd ) && ( numberOfCharactersEnd > 1u ) && HasLigatureMustBreak( mLogicalModel->GetScript( selectionEndMinusOne ) ); + bool splitEndGlyph = ( glyphStart != glyphEnd ) && ( numberOfCharactersEnd > 1u ) && HasLigatureMustBreak( mModel->mLogicalModel->GetScript( selectionEndMinusOne ) ); // The number of quads of the selection box. const unsigned int numberOfQuads = 1u + ( glyphEnd - glyphStart ) + ( ( numberOfLines > 1u ) ? 2u * numberOfLines : 0u ); @@ -1881,7 +1882,7 @@ void Controller::Impl::RepositionSelectionHandles() // Calculate the number of characters selected. const Length numberOfCharacters = ( glyphStart == glyphEnd ) ? ( selectionEnd - selectionStart ) : ( numberOfCharactersStart - interGlyphIndex ); - quad.x = lineRun->alignmentOffset + position.x - glyph.xBearing + mScrollPosition.x + glyphAdvance * static_cast( isCurrentRightToLeft ? ( numberOfCharactersStart - interGlyphIndex - numberOfCharacters ) : interGlyphIndex ); + quad.x = lineRun->alignmentOffset + position.x - glyph.xBearing + mModel->mScrollPosition.x + glyphAdvance * static_cast( isCurrentRightToLeft ? ( numberOfCharactersStart - interGlyphIndex - numberOfCharacters ) : interGlyphIndex ); quad.y = selectionBoxInfo->lineOffset; quad.z = quad.x + static_cast( numberOfCharacters ) * glyphAdvance; quad.w = selectionBoxInfo->lineOffset + selectionBoxInfo->lineHeight; @@ -1912,7 +1913,7 @@ void Controller::Impl::RepositionSelectionHandles() const Length numberOfCharacters = numberOfCharactersEnd - interGlyphIndex; - quad.x = lineRun->alignmentOffset + position.x - glyph.xBearing + mScrollPosition.x + ( isCurrentRightToLeft ? ( glyphAdvance * static_cast( numberOfCharacters ) ) : 0.f ); + quad.x = lineRun->alignmentOffset + position.x - glyph.xBearing + mModel->mScrollPosition.x + ( isCurrentRightToLeft ? ( glyphAdvance * static_cast( numberOfCharacters ) ) : 0.f ); quad.y = selectionBoxInfo->lineOffset; quad.z = quad.x + static_cast( interGlyphIndex ) * glyphAdvance; quad.w = quad.y + selectionBoxInfo->lineHeight; @@ -1929,7 +1930,7 @@ void Controller::Impl::RepositionSelectionHandles() continue; } - quad.x = lineRun->alignmentOffset + position.x - glyph.xBearing + mScrollPosition.x; + quad.x = lineRun->alignmentOffset + position.x - glyph.xBearing + mModel->mScrollPosition.x; quad.y = selectionBoxInfo->lineOffset; quad.z = quad.x + glyph.advance; quad.w = quad.y + selectionBoxInfo->lineHeight; @@ -1994,7 +1995,7 @@ void Controller::Impl::RepositionSelectionHandles() if( 1u < numberOfLines ) { // Boxify the first line. - lineRun = mVisualModel->mLines.Begin() + firstLineIndex; + lineRun = mModel->mVisualModel->mLines.Begin() + firstLineIndex; const SelectionBoxInfo& firstSelectionBoxLineInfo = *( selectionBoxLinesInfo.Begin() ); bool boxifyBegin = ( LTR != lineRun->direction ) && ( LTR != startDirection ); @@ -2020,7 +2021,7 @@ void Controller::Impl::RepositionSelectionHandles() { quad.x = firstSelectionBoxLineInfo.maxX; quad.y = firstSelectionBoxLineInfo.lineOffset; - quad.z = mVisualModel->mControlSize.width; + quad.z = mModel->mVisualModel->mControlSize.width; quad.w = firstSelectionBoxLineInfo.lineOffset + firstSelectionBoxLineInfo.lineHeight; // Boxify at the end of the line. @@ -2029,7 +2030,7 @@ void Controller::Impl::RepositionSelectionHandles() ++actualNumberOfQuads; // Update the size of the highlighted text. - maxHighlightX = mVisualModel->mControlSize.width; + maxHighlightX = mModel->mVisualModel->mControlSize.width; } // Boxify the central lines. @@ -2053,7 +2054,7 @@ void Controller::Impl::RepositionSelectionHandles() quad.x = info.maxX; quad.y = info.lineOffset; - quad.z = mVisualModel->mControlSize.width; + quad.z = mModel->mVisualModel->mControlSize.width; quad.w = info.lineOffset + info.lineHeight; mEventData->mDecorator->AddHighlight( actualNumberOfQuads, @@ -2063,11 +2064,11 @@ void Controller::Impl::RepositionSelectionHandles() // Update the size of the highlighted text. minHighlightX = 0.f; - maxHighlightX = mVisualModel->mControlSize.width; + maxHighlightX = mModel->mVisualModel->mControlSize.width; } // Boxify the last line. - lineRun = mVisualModel->mLines.Begin() + firstLineIndex + numberOfLines - 1u; + lineRun = mModel->mVisualModel->mLines.Begin() + firstLineIndex + numberOfLines - 1u; const SelectionBoxInfo& lastSelectionBoxLineInfo = *( selectionBoxLinesInfo.End() - 1u ); boxifyBegin = ( LTR == lineRun->direction ) && ( LTR == endDirection ); @@ -2093,7 +2094,7 @@ void Controller::Impl::RepositionSelectionHandles() { quad.x = lastSelectionBoxLineInfo.maxX; quad.y = lastSelectionBoxLineInfo.lineOffset; - quad.z = mVisualModel->mControlSize.width; + quad.z = mModel->mVisualModel->mControlSize.width; quad.w = lastSelectionBoxLineInfo.lineOffset + lastSelectionBoxLineInfo.lineHeight; // Boxify at the end of the line. @@ -2102,7 +2103,7 @@ void Controller::Impl::RepositionSelectionHandles() ++actualNumberOfQuads; // Update the size of the highlighted text. - maxHighlightX = mVisualModel->mControlSize.width; + maxHighlightX = mModel->mVisualModel->mControlSize.width; } } @@ -2125,22 +2126,22 @@ void Controller::Impl::RepositionSelectionHandles() GetCursorPosition( mEventData->mLeftSelectionPosition, primaryCursorInfo ); - const Vector2 primaryPosition = primaryCursorInfo.primaryPosition + mScrollPosition; + const Vector2 primaryPosition = primaryCursorInfo.primaryPosition + mModel->mScrollPosition; mEventData->mDecorator->SetPosition( LEFT_SELECTION_HANDLE, primaryPosition.x, - primaryCursorInfo.lineOffset + mScrollPosition.y, + primaryCursorInfo.lineOffset + mModel->mScrollPosition.y, primaryCursorInfo.lineHeight ); CursorInfo secondaryCursorInfo; GetCursorPosition( mEventData->mRightSelectionPosition, secondaryCursorInfo ); - const Vector2 secondaryPosition = secondaryCursorInfo.primaryPosition + mScrollPosition; + const Vector2 secondaryPosition = secondaryCursorInfo.primaryPosition + mModel->mScrollPosition; mEventData->mDecorator->SetPosition( RIGHT_SELECTION_HANDLE, secondaryPosition.x, - secondaryCursorInfo.lineOffset + mScrollPosition.y, + secondaryCursorInfo.lineOffset + mModel->mScrollPosition.y, secondaryCursorInfo.lineHeight ); } @@ -2165,8 +2166,8 @@ void Controller::Impl::RepositionSelectionHandles( float visualX, float visualY return; } - const Length numberOfGlyphs = mVisualModel->mGlyphs.Count(); - const Length numberOfLines = mVisualModel->mLines.Count(); + const Length numberOfGlyphs = mModel->mVisualModel->mGlyphs.Count(); + const Length numberOfLines = mModel->mVisualModel->mLines.Count(); if( ( 0 == numberOfGlyphs ) || ( 0 == numberOfLines ) ) { @@ -2177,8 +2178,8 @@ void Controller::Impl::RepositionSelectionHandles( float visualX, float visualY // Find which word was selected CharacterIndex selectionStart( 0 ); CharacterIndex selectionEnd( 0 ); - const bool indicesFound = FindSelectionIndices( mVisualModel, - mLogicalModel, + const bool indicesFound = FindSelectionIndices( mModel->mVisualModel, + mModel->mLogicalModel, mMetrics, visualX, visualY, @@ -2242,7 +2243,7 @@ void Controller::Impl::SetPopupButtons() } else if( EventData::EDITING_WITH_POPUP == mEventData->mState ) { - if( mLogicalModel->mText.Count() && !IsShowingPlaceholderText() ) + if( mModel->mLogicalModel->mText.Count() && !IsShowingPlaceholderText() ) { buttonsToShow = TextSelectionPopup::Buttons( TextSelectionPopup::SELECT | TextSelectionPopup::SELECT_ALL ); } @@ -2485,21 +2486,21 @@ void Controller::Impl::GetCursorPosition( CharacterIndex logical, cursorInfo.lineHeight = GetDefaultFontLineHeight(); cursorInfo.primaryCursorHeight = cursorInfo.lineHeight; - switch( mLayoutEngine.GetHorizontalAlignment() ) + switch( mModel->mHorizontalAlignment ) { - case LayoutEngine::HORIZONTAL_ALIGN_BEGIN: + case Layout::HORIZONTAL_ALIGN_BEGIN: { cursorInfo.primaryPosition.x = 0.f; break; } - case LayoutEngine::HORIZONTAL_ALIGN_CENTER: + case Layout::HORIZONTAL_ALIGN_CENTER: { - cursorInfo.primaryPosition.x = floorf( 0.5f * mVisualModel->mControlSize.width ); + cursorInfo.primaryPosition.x = floorf( 0.5f * mModel->mVisualModel->mControlSize.width ); break; } - case LayoutEngine::HORIZONTAL_ALIGN_END: + case Layout::HORIZONTAL_ALIGN_END: { - cursorInfo.primaryPosition.x = mVisualModel->mControlSize.width - mEventData->mDecorator->GetCursorWidth(); + cursorInfo.primaryPosition.x = mModel->mVisualModel->mControlSize.width - mEventData->mDecorator->GetCursorWidth(); break; } } @@ -2508,13 +2509,13 @@ void Controller::Impl::GetCursorPosition( CharacterIndex logical, return; } - Text::GetCursorPosition( mVisualModel, - mLogicalModel, + Text::GetCursorPosition( mModel->mVisualModel, + mModel->mLogicalModel, mMetrics, logical, cursorInfo ); - if( LayoutEngine::MULTI_LINE_BOX == mLayoutEngine.GetLayout() ) + if( Layout::Engine::MULTI_LINE_BOX == mLayoutEngine.GetLayout() ) { // If the text is editable and multi-line, the cursor position after a white space shouldn't exceed the boundaries of the text control. @@ -2526,7 +2527,7 @@ void Controller::Impl::GetCursorPosition( CharacterIndex logical, cursorInfo.primaryPosition.x = 0.f; } - const float edgeWidth = mVisualModel->mControlSize.width - static_cast( mEventData->mDecorator->GetCursorWidth() ); + const float edgeWidth = mModel->mVisualModel->mControlSize.width - static_cast( mEventData->mDecorator->GetCursorWidth() ); if( cursorInfo.primaryPosition.x > edgeWidth ) { cursorInfo.primaryPosition.x = edgeWidth; @@ -2544,15 +2545,15 @@ CharacterIndex Controller::Impl::CalculateNewCursorIndex( CharacterIndex index ) CharacterIndex cursorIndex = mEventData->mPrimaryCursorPosition; - const GlyphIndex* const charactersToGlyphBuffer = mVisualModel->mCharactersToGlyph.Begin(); - const Length* const charactersPerGlyphBuffer = mVisualModel->mCharactersPerGlyph.Begin(); + const GlyphIndex* const charactersToGlyphBuffer = mModel->mVisualModel->mCharactersToGlyph.Begin(); + const Length* const charactersPerGlyphBuffer = mModel->mVisualModel->mCharactersPerGlyph.Begin(); GlyphIndex glyphIndex = *( charactersToGlyphBuffer + index ); Length numberOfCharacters = *( charactersPerGlyphBuffer + glyphIndex ); if( numberOfCharacters > 1u ) { - const Script script = mLogicalModel->GetScript( index ); + const Script script = mModel->mLogicalModel->GetScript( index ); if( HasLigatureMustBreak( script ) ) { // Prevents to jump the whole Latin ligatures like fi, ff, or Arabic ﻻ, ... @@ -2593,7 +2594,7 @@ void Controller::Impl::UpdateCursorPosition( const CursorInfo& cursorInfo ) return; } - const Vector2 cursorPosition = cursorInfo.primaryPosition + mScrollPosition; + const Vector2 cursorPosition = cursorInfo.primaryPosition + mModel->mScrollPosition; // Sets the cursor position. mEventData->mDecorator->SetPosition( PRIMARY_CURSOR, @@ -2608,18 +2609,18 @@ void Controller::Impl::UpdateCursorPosition( const CursorInfo& cursorInfo ) // Sets the grab handle position. mEventData->mDecorator->SetPosition( GRAB_HANDLE, cursorPosition.x, - cursorInfo.lineOffset + mScrollPosition.y, + cursorInfo.lineOffset + mModel->mScrollPosition.y, cursorInfo.lineHeight ); } if( cursorInfo.isSecondaryCursor ) { mEventData->mDecorator->SetPosition( SECONDARY_CURSOR, - cursorInfo.secondaryPosition.x + mScrollPosition.x, - cursorInfo.secondaryPosition.y + mScrollPosition.y, + cursorInfo.secondaryPosition.x + mModel->mScrollPosition.x, + cursorInfo.secondaryPosition.y + mModel->mScrollPosition.y, cursorInfo.secondaryCursorHeight, cursorInfo.lineHeight ); - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Secondary cursor position: %f,%f\n", cursorInfo.secondaryPosition.x + mScrollPosition.x, cursorInfo.secondaryPosition.y + mScrollPosition.y ); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Secondary cursor position: %f,%f\n", cursorInfo.secondaryPosition.x + mModel->mScrollPosition.x, cursorInfo.secondaryPosition.y + mModel->mScrollPosition.y ); } // Set which cursors are active according the state. @@ -2651,58 +2652,58 @@ void Controller::Impl::UpdateSelectionHandle( HandleType handleType, return; } - const Vector2 cursorPosition = cursorInfo.primaryPosition + mScrollPosition; + const Vector2 cursorPosition = cursorInfo.primaryPosition + mModel->mScrollPosition; // Sets the handle's position. mEventData->mDecorator->SetPosition( handleType, cursorPosition.x, - cursorInfo.lineOffset + mScrollPosition.y, + cursorInfo.lineOffset + mModel->mScrollPosition.y, cursorInfo.lineHeight ); // If selection handle at start of the text and other at end of the text then all text is selected. const CharacterIndex startOfSelection = std::min( mEventData->mLeftSelectionPosition, mEventData->mRightSelectionPosition ); const CharacterIndex endOfSelection = std::max ( mEventData->mLeftSelectionPosition, mEventData->mRightSelectionPosition ); - mEventData->mAllTextSelected = ( startOfSelection == 0 ) && ( endOfSelection == mLogicalModel->mText.Count() ); + mEventData->mAllTextSelected = ( startOfSelection == 0 ) && ( endOfSelection == mModel->mLogicalModel->mText.Count() ); } void Controller::Impl::ClampHorizontalScroll( const Vector2& layoutSize ) { // Clamp between -space & 0. - if( layoutSize.width > mVisualModel->mControlSize.width ) + if( layoutSize.width > mModel->mVisualModel->mControlSize.width ) { - const float space = ( layoutSize.width - mVisualModel->mControlSize.width ); - mScrollPosition.x = ( mScrollPosition.x < -space ) ? -space : mScrollPosition.x; - mScrollPosition.x = ( mScrollPosition.x > 0.f ) ? 0.f : mScrollPosition.x; + const float space = ( layoutSize.width - mModel->mVisualModel->mControlSize.width ); + mModel->mScrollPosition.x = ( mModel->mScrollPosition.x < -space ) ? -space : mModel->mScrollPosition.x; + mModel->mScrollPosition.x = ( mModel->mScrollPosition.x > 0.f ) ? 0.f : mModel->mScrollPosition.x; mEventData->mDecoratorUpdated = true; } else { - mScrollPosition.x = 0.f; + mModel->mScrollPosition.x = 0.f; } } void Controller::Impl::ClampVerticalScroll( const Vector2& layoutSize ) { - if( LayoutEngine::SINGLE_LINE_BOX == mLayoutEngine.GetLayout() ) + if( Layout::Engine::SINGLE_LINE_BOX == mLayoutEngine.GetLayout() ) { // Nothing to do if the text is single line. return; } // Clamp between -space & 0. - if( layoutSize.height > mVisualModel->mControlSize.height ) + if( layoutSize.height > mModel->mVisualModel->mControlSize.height ) { - const float space = ( layoutSize.height - mVisualModel->mControlSize.height ); - mScrollPosition.y = ( mScrollPosition.y < -space ) ? -space : mScrollPosition.y; - mScrollPosition.y = ( mScrollPosition.y > 0.f ) ? 0.f : mScrollPosition.y; + const float space = ( layoutSize.height - mModel->mVisualModel->mControlSize.height ); + mModel->mScrollPosition.y = ( mModel->mScrollPosition.y < -space ) ? -space : mModel->mScrollPosition.y; + mModel->mScrollPosition.y = ( mModel->mScrollPosition.y > 0.f ) ? 0.f : mModel->mScrollPosition.y; mEventData->mDecoratorUpdated = true; } else { - mScrollPosition.y = 0.f; + mModel->mScrollPosition.y = 0.f; } } @@ -2715,28 +2716,28 @@ void Controller::Impl::ScrollToMakePositionVisible( const Vector2& position, flo const float positionEndY = position.y + lineHeight; // Transform the position to decorator coords. - const float decoratorPositionBeginX = position.x + mScrollPosition.x; - const float decoratorPositionEndX = positionEndX + mScrollPosition.x; + const float decoratorPositionBeginX = position.x + mModel->mScrollPosition.x; + const float decoratorPositionEndX = positionEndX + mModel->mScrollPosition.x; - const float decoratorPositionBeginY = position.y + mScrollPosition.y; - const float decoratorPositionEndY = positionEndY + mScrollPosition.y; + const float decoratorPositionBeginY = position.y + mModel->mScrollPosition.y; + const float decoratorPositionEndY = positionEndY + mModel->mScrollPosition.y; if( decoratorPositionBeginX < 0.f ) { - mScrollPosition.x = -position.x; + mModel->mScrollPosition.x = -position.x; } - else if( decoratorPositionEndX > mVisualModel->mControlSize.width ) + else if( decoratorPositionEndX > mModel->mVisualModel->mControlSize.width ) { - mScrollPosition.x = mVisualModel->mControlSize.width - positionEndX; + mModel->mScrollPosition.x = mModel->mVisualModel->mControlSize.width - positionEndX; } if( decoratorPositionBeginY < 0.f ) { - mScrollPosition.y = -position.y; + mModel->mScrollPosition.y = -position.y; } - else if( decoratorPositionEndY > mVisualModel->mControlSize.height ) + else if( decoratorPositionEndY > mModel->mVisualModel->mControlSize.height ) { - mScrollPosition.y = mVisualModel->mControlSize.height - positionEndY; + mModel->mScrollPosition.y = mModel->mVisualModel->mControlSize.height - positionEndY; } } @@ -2746,11 +2747,11 @@ void Controller::Impl::ScrollTextToMatchCursor( const CursorInfo& cursorInfo ) const Vector2& currentCursorPosition = mEventData->mDecorator->GetPosition( PRIMARY_CURSOR ); // Calculate the offset to match the cursor position before the character was deleted. - mScrollPosition.x = currentCursorPosition.x - cursorInfo.primaryPosition.x; - mScrollPosition.y = currentCursorPosition.y - cursorInfo.lineOffset; + mModel->mScrollPosition.x = currentCursorPosition.x - cursorInfo.primaryPosition.x; + mModel->mScrollPosition.y = currentCursorPosition.y - cursorInfo.lineOffset; - ClampHorizontalScroll( mVisualModel->GetLayoutSize() ); - ClampVerticalScroll( mVisualModel->GetLayoutSize() ); + ClampHorizontalScroll( mModel->mVisualModel->GetLayoutSize() ); + ClampVerticalScroll( mModel->mVisualModel->GetLayoutSize() ); // Makes the new cursor position visible if needed. ScrollToMakePositionVisible( cursorInfo.primaryPosition, cursorInfo.lineHeight ); diff --git a/dali-toolkit/internal/text/text-controller-impl.h b/dali-toolkit/internal/text/text-controller-impl.h index 3a89308..81b6554 100644 --- a/dali-toolkit/internal/text/text-controller-impl.h +++ b/dali-toolkit/internal/text/text-controller-impl.h @@ -24,11 +24,9 @@ // INTERNAL INCLUDES #include -#include -#include #include +#include #include -#include namespace Dali { @@ -289,8 +287,7 @@ struct Controller::Impl EditableControlInterface* editableControlInterface ) : mControlInterface( controlInterface ), mEditableControlInterface( editableControlInterface ), - mLogicalModel(), - mVisualModel(), + mModel(), mFontDefaults( NULL ), mUnderlineDefaults( NULL ), mShadowDefaults( NULL ), @@ -301,10 +298,8 @@ struct Controller::Impl mClipboard(), mView(), mMetrics(), - mLayoutEngine(), mModifyEvents(), mTextColor( Color::BLACK ), - mScrollPosition(), mTextUpdateInfo(), mOperationsPending( NO_OPERATION ), mMaximumNumberOfCharacters( 50u ), @@ -314,21 +309,20 @@ struct Controller::Impl mIsAutoScrollEnabled( false ), mAutoScrollDirectionRTL( false ) { - mLogicalModel = LogicalModel::New(); - mVisualModel = VisualModel::New(); + mModel = Model::New(); mFontClient = TextAbstraction::FontClient::Get(); mClipboard = Clipboard::Get(); - mView.SetVisualModel( mVisualModel ); + mView.SetVisualModel( mModel->mVisualModel ); // Use this to access FontClient i.e. to get down-scaled Emoji metrics. mMetrics = Metrics::New( mFontClient ); mLayoutEngine.SetMetrics( mMetrics ); // Set the text properties to default - mVisualModel->SetUnderlineEnabled( false ); - mVisualModel->SetUnderlineHeight( 0.0f ); + mModel->mVisualModel->SetUnderlineEnabled( false ); + mModel->mVisualModel->SetUnderlineHeight( 0.0f ); } ~Impl() @@ -399,7 +393,7 @@ struct Controller::Impl bool IsShowingRealText() const { return ( !IsShowingPlaceholderText() && - 0u != mLogicalModel->mText.Count() ); + 0u != mModel->mLogicalModel->mText.Count() ); } /** @@ -412,7 +406,7 @@ struct Controller::Impl mEventData->mIsShowingPlaceholderText = false; // Remove mPlaceholderTextColor - mVisualModel->SetTextColor( mTextColor ); + mModel->mVisualModel->SetTextColor( mTextColor ); } } @@ -693,8 +687,7 @@ public: ControlInterface* mControlInterface; ///< Reference to the text controller. EditableControlInterface* mEditableControlInterface; ///< Reference to the editable text controller. - LogicalModelPtr mLogicalModel; ///< Pointer to the logical model. - VisualModelPtr mVisualModel; ///< Pointer to the visual model. + ModelPtr mModel; ///< Pointer to the text's model. FontDefaults* mFontDefaults; ///< Avoid allocating this when the user does not specify a font. UnderlineDefaults* mUnderlineDefaults; ///< Avoid allocating this when the user does not specify underline parameters. ShadowDefaults* mShadowDefaults; ///< Avoid allocating this when the user does not specify shadow parameters. @@ -705,14 +698,9 @@ public: Clipboard mClipboard; ///< Handle to the system clipboard View mView; ///< The view interface to the rendering back-end. MetricsPtr mMetrics; ///< A wrapper around FontClient used to get metrics & potentially down-scaled Emoji metrics. - LayoutEngine mLayoutEngine; ///< The layout engine. + Layout::Engine mLayoutEngine; ///< The layout engine. Vector mModifyEvents; ///< Temporary stores the text set until the next relayout. Vector4 mTextColor; ///< The regular text color - /** - * 0,0 means that the top-left corner of the layout matches the top-left corner of the UI control. - * Typically this will have a negative value with scrolling occurs. - */ - Vector2 mScrollPosition; ///< The text is offset by this position when scrolling. TextUpdateInfo mTextUpdateInfo; ///< Info of the characters updated. OperationsMask mOperationsPending; ///< Operations pending to be done to layout the text. Length mMaximumNumberOfCharacters; ///< Maximum number of characters that can be inserted. diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 11a9161..5a82cc9 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -122,6 +122,15 @@ ControllerPtr Controller::New( ControlInterface* controlInterface, void Controller::EnableTextInput( DecoratorPtr decorator ) { + if( !decorator ) + { + delete mImpl->mEventData; + mImpl->mEventData = NULL; + + // Nothing else to do. + return; + } + if( NULL == mImpl->mEventData ) { mImpl->mEventData = new EventData( decorator ); @@ -151,9 +160,9 @@ bool Controller::IsMarkupProcessorEnabled() const void Controller::SetAutoScrollEnabled( bool enable ) { - DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetAutoScrollEnabled[%s] SingleBox[%s]-> [%p]\n", (enable)?"true":"false", ( mImpl->mLayoutEngine.GetLayout() == LayoutEngine::SINGLE_LINE_BOX)?"true":"false", this ); + DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetAutoScrollEnabled[%s] SingleBox[%s]-> [%p]\n", (enable)?"true":"false", ( mImpl->mLayoutEngine.GetLayout() == Layout::Engine::SINGLE_LINE_BOX)?"true":"false", this ); - if( mImpl->mLayoutEngine.GetLayout() == LayoutEngine::SINGLE_LINE_BOX ) + if( mImpl->mLayoutEngine.GetLayout() == Layout::Engine::SINGLE_LINE_BOX ) { if( enable ) { @@ -202,10 +211,10 @@ float Controller::GetAutoScrollLineAlignment() const { float offset = 0.f; - if( mImpl->mVisualModel && - ( 0u != mImpl->mVisualModel->mLines.Count() ) ) + if( mImpl->mModel->mVisualModel && + ( 0u != mImpl->mModel->mVisualModel->mLines.Count() ) ) { - offset = ( *mImpl->mVisualModel->mLines.Begin() ).alignmentOffset; + offset = ( *mImpl->mModel->mVisualModel->mLines.Begin() ).alignmentOffset; } return offset; @@ -219,7 +228,6 @@ void Controller::SetHorizontalScrollEnabled( bool enable ) mImpl->mEventData->mDecorator->SetHorizontalScrollEnabled( enable ); } } - bool Controller::IsHorizontalScrollEnabled() const { if( ( NULL != mImpl->mEventData ) && @@ -312,7 +320,7 @@ bool Controller::GetEnableCursorBlink() const void Controller::SetMultiLineEnabled( bool enable ) { - const LayoutEngine::Layout layout = enable ? LayoutEngine::MULTI_LINE_BOX : LayoutEngine::SINGLE_LINE_BOX; + const Layout::Engine::Type layout = enable ? Layout::Engine::MULTI_LINE_BOX : Layout::Engine::SINGLE_LINE_BOX; if( layout != mImpl->mLayoutEngine.GetLayout() ) { @@ -333,15 +341,15 @@ void Controller::SetMultiLineEnabled( bool enable ) bool Controller::IsMultiLineEnabled() const { - return LayoutEngine::MULTI_LINE_BOX == mImpl->mLayoutEngine.GetLayout(); + return Layout::Engine::MULTI_LINE_BOX == mImpl->mLayoutEngine.GetLayout(); } -void Controller::SetHorizontalAlignment( LayoutEngine::HorizontalAlignment alignment ) +void Controller::SetHorizontalAlignment( Layout::HorizontalAlignment alignment ) { - if( alignment != mImpl->mLayoutEngine.GetHorizontalAlignment() ) + if( alignment != mImpl->mModel->mHorizontalAlignment ) { // Set the alignment. - mImpl->mLayoutEngine.SetHorizontalAlignment( alignment ); + mImpl->mModel->mHorizontalAlignment = alignment; // Set the flag to redo the alignment operation. mImpl->mOperationsPending = static_cast( mImpl->mOperationsPending | ALIGN ); @@ -350,17 +358,17 @@ void Controller::SetHorizontalAlignment( LayoutEngine::HorizontalAlignment align } } -LayoutEngine::HorizontalAlignment Controller::GetHorizontalAlignment() const +Layout::HorizontalAlignment Controller::GetHorizontalAlignment() const { - return mImpl->mLayoutEngine.GetHorizontalAlignment(); + return mImpl->mModel->mHorizontalAlignment; } -void Controller::SetVerticalAlignment( LayoutEngine::VerticalAlignment alignment ) +void Controller::SetVerticalAlignment( Layout::VerticalAlignment alignment ) { - if( alignment != mImpl->mLayoutEngine.GetVerticalAlignment() ) + if( alignment != mImpl->mModel->mVerticalAlignment ) { // Set the alignment. - mImpl->mLayoutEngine.SetVerticalAlignment( alignment ); + mImpl->mModel->mVerticalAlignment = alignment; mImpl->mOperationsPending = static_cast( mImpl->mOperationsPending | ALIGN ); @@ -368,9 +376,19 @@ void Controller::SetVerticalAlignment( LayoutEngine::VerticalAlignment alignment } } -LayoutEngine::VerticalAlignment Controller::GetVerticalAlignment() const +Layout::VerticalAlignment Controller::GetVerticalAlignment() const +{ + return mImpl->mModel->mVerticalAlignment; +} + +void Controller::SetTextElideEnabled( bool enabled ) { - return mImpl->mLayoutEngine.GetVerticalAlignment(); + mImpl->mModel->mElideEnabled = enabled; +} + +bool Controller::IsTextElideEnabled() const +{ + return mImpl->mModel->mElideEnabled; } // public : Update @@ -404,10 +422,10 @@ void Controller::SetText( const std::string& text ) if( !text.empty() ) { - mImpl->mVisualModel->SetTextColor( mImpl->mTextColor ); + mImpl->mModel->mVisualModel->SetTextColor( mImpl->mTextColor ); - MarkupProcessData markupProcessData( mImpl->mLogicalModel->mColorRuns, - mImpl->mLogicalModel->mFontDescriptionRuns ); + MarkupProcessData markupProcessData( mImpl->mModel->mLogicalModel->mColorRuns, + mImpl->mModel->mLogicalModel->mFontDescriptionRuns ); Length textSize = 0u; const uint8_t* utf8 = NULL; @@ -428,7 +446,7 @@ void Controller::SetText( const std::string& text ) } // Convert text into UTF-32 - Vector& utf32Characters = mImpl->mLogicalModel->mText; + Vector& utf32Characters = mImpl->mModel->mLogicalModel->mText; utf32Characters.Resize( textSize ); // Transform a text array encoded in utf8 into an array encoded in utf32. @@ -437,10 +455,10 @@ void Controller::SetText( const std::string& text ) utf32Characters.Resize( characterCount ); DALI_ASSERT_DEBUG( textSize >= characterCount && "Invalid UTF32 conversion length" ); - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SetText %p UTF8 size %d, UTF32 size %d\n", this, textSize, mImpl->mLogicalModel->mText.Count() ); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SetText %p UTF8 size %d, UTF32 size %d\n", this, textSize, mImpl->mModel->mLogicalModel->mText.Count() ); // The characters to be added. - mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mLogicalModel->mText.Count(); + mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count(); // To reset the cursor position lastCursorIndex = characterCount; @@ -508,7 +526,7 @@ void Controller::SetPlaceholderText( PlaceholderType type, const std::string& te // Update placeholder if there is no text if( mImpl->IsShowingPlaceholderText() || - ( 0u == mImpl->mLogicalModel->mText.Count() ) ) + ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) ) { ShowPlaceholderText(); } @@ -693,19 +711,19 @@ float Controller::GetDefaultPointSize() const return 0.0f; } -void Controller::SetTextColor( const Vector4& textColor ) +void Controller::SetDefaultColor( const Vector4& color ) { - mImpl->mTextColor = textColor; + mImpl->mTextColor = color; if( !mImpl->IsShowingPlaceholderText() ) { - mImpl->mVisualModel->SetTextColor( textColor ); + mImpl->mModel->mVisualModel->SetTextColor( color ); mImpl->RequestRelayout(); } } -const Vector4& Controller::GetTextColor() const +const Vector4& Controller::GetDefaultColor() const { return mImpl->mTextColor; } @@ -719,7 +737,7 @@ void Controller::SetPlaceholderTextColor( const Vector4& textColor ) if( mImpl->IsShowingPlaceholderText() ) { - mImpl->mVisualModel->SetTextColor( textColor ); + mImpl->mModel->mVisualModel->SetTextColor( textColor ); mImpl->RequestRelayout(); } } @@ -736,62 +754,62 @@ const Vector4& Controller::GetPlaceholderTextColor() const void Controller::SetShadowOffset( const Vector2& shadowOffset ) { - mImpl->mVisualModel->SetShadowOffset( shadowOffset ); + mImpl->mModel->mVisualModel->SetShadowOffset( shadowOffset ); mImpl->RequestRelayout(); } const Vector2& Controller::GetShadowOffset() const { - return mImpl->mVisualModel->GetShadowOffset(); + return mImpl->mModel->mVisualModel->GetShadowOffset(); } void Controller::SetShadowColor( const Vector4& shadowColor ) { - mImpl->mVisualModel->SetShadowColor( shadowColor ); + mImpl->mModel->mVisualModel->SetShadowColor( shadowColor ); mImpl->RequestRelayout(); } const Vector4& Controller::GetShadowColor() const { - return mImpl->mVisualModel->GetShadowColor(); + return mImpl->mModel->mVisualModel->GetShadowColor(); } void Controller::SetUnderlineColor( const Vector4& color ) { - mImpl->mVisualModel->SetUnderlineColor( color ); + mImpl->mModel->mVisualModel->SetUnderlineColor( color ); mImpl->RequestRelayout(); } const Vector4& Controller::GetUnderlineColor() const { - return mImpl->mVisualModel->GetUnderlineColor(); + return mImpl->mModel->mVisualModel->GetUnderlineColor(); } void Controller::SetUnderlineEnabled( bool enabled ) { - mImpl->mVisualModel->SetUnderlineEnabled( enabled ); + mImpl->mModel->mVisualModel->SetUnderlineEnabled( enabled ); mImpl->RequestRelayout(); } bool Controller::IsUnderlineEnabled() const { - return mImpl->mVisualModel->IsUnderlineEnabled(); + return mImpl->mModel->mVisualModel->IsUnderlineEnabled(); } void Controller::SetUnderlineHeight( float height ) { - mImpl->mVisualModel->SetUnderlineHeight( height ); + mImpl->mModel->mVisualModel->SetUnderlineHeight( height ); mImpl->RequestRelayout(); } float Controller::GetUnderlineHeight() const { - return mImpl->mVisualModel->GetUnderlineHeight(); + return mImpl->mModel->mVisualModel->GetUnderlineHeight(); } void Controller::SetDefaultEmbossProperties( const std::string& embossProperties ) @@ -861,10 +879,10 @@ void Controller::SetInputColor( const Vector4& color ) const Length lengthOfSelectedText = ( handlesCrossed ? mImpl->mEventData->mLeftSelectionPosition : mImpl->mEventData->mRightSelectionPosition ) - startOfSelectedText; // Add the color run. - const VectorBase::SizeType numberOfRuns = mImpl->mLogicalModel->mColorRuns.Count(); - mImpl->mLogicalModel->mColorRuns.Resize( numberOfRuns + 1u ); + const VectorBase::SizeType numberOfRuns = mImpl->mModel->mLogicalModel->mColorRuns.Count(); + mImpl->mModel->mLogicalModel->mColorRuns.Resize( numberOfRuns + 1u ); - ColorRun& colorRun = *( mImpl->mLogicalModel->mColorRuns.Begin() + numberOfRuns ); + ColorRun& colorRun = *( mImpl->mModel->mLogicalModel->mColorRuns.Begin() + numberOfRuns ); colorRun.color = color; colorRun.characterRun.characterIndex = startOfSelectedText; colorRun.characterRun.numberOfCharacters = lengthOfSelectedText; @@ -904,7 +922,7 @@ void Controller::SetInputFontFamily( const std::string& fontFamily ) CharacterIndex startOfSelectedText = 0u; Length lengthOfSelectedText = 0u; FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData, - mImpl->mLogicalModel, + mImpl->mModel->mLogicalModel, startOfSelectedText, lengthOfSelectedText ); @@ -963,7 +981,7 @@ void Controller::SetInputFontWeight( FontWeight weight ) CharacterIndex startOfSelectedText = 0u; Length lengthOfSelectedText = 0u; FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData, - mImpl->mLogicalModel, + mImpl->mModel->mLogicalModel, startOfSelectedText, lengthOfSelectedText ); @@ -1029,7 +1047,7 @@ void Controller::SetInputFontWidth( FontWidth width ) CharacterIndex startOfSelectedText = 0u; Length lengthOfSelectedText = 0u; FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData, - mImpl->mLogicalModel, + mImpl->mModel->mLogicalModel, startOfSelectedText, lengthOfSelectedText ); @@ -1095,7 +1113,7 @@ void Controller::SetInputFontSlant( FontSlant slant ) CharacterIndex startOfSelectedText = 0u; Length lengthOfSelectedText = 0u; FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData, - mImpl->mLogicalModel, + mImpl->mModel->mLogicalModel, startOfSelectedText, lengthOfSelectedText ); @@ -1161,7 +1179,7 @@ void Controller::SetInputFontPointSize( float size ) CharacterIndex startOfSelectedText = 0u; Length lengthOfSelectedText = 0u; FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData, - mImpl->mLogicalModel, + mImpl->mModel->mLogicalModel, startOfSelectedText, lengthOfSelectedText ); @@ -1297,7 +1315,7 @@ const std::string& Controller::GetInputOutlineProperties() const // public : Queries & retrieves. -LayoutEngine& Controller::GetLayoutEngine() +Layout::Engine& Controller::GetLayoutEngine() { return mImpl->mLayoutEngine; } @@ -1307,11 +1325,6 @@ View& Controller::GetView() return mImpl->mView; } -const Vector2& Controller::GetScrollPosition() const -{ - return mImpl->mScrollPosition; -} - Vector3 Controller::GetNaturalSize() { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::GetNaturalSize\n" ); @@ -1339,10 +1352,10 @@ Vector3 Controller::GetNaturalSize() // Set the update info to relayout the whole text. mImpl->mTextUpdateInfo.mParagraphCharacterIndex = 0u; - mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mLogicalModel->mText.Count(); + mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mModel->mLogicalModel->mText.Count(); // Store the actual control's size to restore later. - const Size actualControlSize = mImpl->mVisualModel->mControlSize; + const Size actualControlSize = mImpl->mModel->mVisualModel->mControlSize; DoRelayout( Size( MAX_FLOAT, MAX_FLOAT ), static_cast( onlyOnceOperations | @@ -1360,7 +1373,7 @@ Vector3 Controller::GetNaturalSize() // Stores the natural size to avoid recalculate it again // unless the text/style changes. - mImpl->mVisualModel->SetNaturalSize( naturalSize.GetVectorXY() ); + mImpl->mModel->mVisualModel->SetNaturalSize( naturalSize.GetVectorXY() ); mImpl->mRecalculateNaturalSize = false; @@ -1368,13 +1381,13 @@ Vector3 Controller::GetNaturalSize() mImpl->mTextUpdateInfo.Clear(); // Restore the actual control's size. - mImpl->mVisualModel->mControlSize = actualControlSize; + mImpl->mModel->mVisualModel->mControlSize = actualControlSize; DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize calculated %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z ); } else { - naturalSize = mImpl->mVisualModel->GetNaturalSize(); + naturalSize = mImpl->mModel->mVisualModel->GetNaturalSize(); DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize cached %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z ); } @@ -1392,7 +1405,7 @@ float Controller::GetHeightForWidth( float width ) ProcessModifyEvents(); Size layoutSize; - if( fabsf( width - mImpl->mVisualModel->mControlSize.width ) > Math::MACHINE_EPSILON_1000 ) + if( fabsf( width - mImpl->mModel->mVisualModel->mControlSize.width ) > Math::MACHINE_EPSILON_1000 ) { // Operations that can be done only once until the text changes. const OperationsMask onlyOnceOperations = static_cast( CONVERT_TO_UTF32 | @@ -1412,10 +1425,10 @@ float Controller::GetHeightForWidth( float width ) // Set the update info to relayout the whole text. mImpl->mTextUpdateInfo.mParagraphCharacterIndex = 0u; - mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mLogicalModel->mText.Count(); + mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mModel->mLogicalModel->mText.Count(); // Store the actual control's width. - const float actualControlWidth = mImpl->mVisualModel->mControlSize.width; + const float actualControlWidth = mImpl->mModel->mVisualModel->mControlSize.width; DoRelayout( Size( width, MAX_FLOAT ), static_cast( onlyOnceOperations | @@ -1436,19 +1449,24 @@ float Controller::GetHeightForWidth( float width ) mImpl->mTextUpdateInfo.Clear(); // Restore the actual control's width. - mImpl->mVisualModel->mControlSize.width = actualControlWidth; + mImpl->mModel->mVisualModel->mControlSize.width = actualControlWidth; DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth calculated %f\n", layoutSize.height ); } else { - layoutSize = mImpl->mVisualModel->GetLayoutSize(); + layoutSize = mImpl->mModel->mVisualModel->GetLayoutSize(); DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth cached %f\n", layoutSize.height ); } return layoutSize.height; } +const ModelInterface* const Controller::GetTextModel() const +{ + return mImpl->mModel.Get(); +} + // public : Relayout. Controller::UpdateTextType Controller::Relayout( const Size& size ) @@ -1459,9 +1477,9 @@ Controller::UpdateTextType Controller::Relayout( const Size& size ) if( ( size.width < Math::MACHINE_EPSILON_1000 ) || ( size.height < Math::MACHINE_EPSILON_1000 ) ) { - if( 0u != mImpl->mVisualModel->mGlyphPositions.Count() ) + if( 0u != mImpl->mModel->mVisualModel->mGlyphPositions.Count() ) { - mImpl->mVisualModel->mGlyphPositions.Clear(); + mImpl->mModel->mVisualModel->mGlyphPositions.Clear(); updateTextType = MODEL_UPDATED; } @@ -1475,11 +1493,11 @@ Controller::UpdateTextType Controller::Relayout( const Size& size ) } // Whether a new size has been set. - const bool newSize = ( size != mImpl->mVisualModel->mControlSize ); + const bool newSize = ( size != mImpl->mModel->mVisualModel->mControlSize ); if( newSize ) { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "new size (previous size %f,%f)\n", mImpl->mVisualModel->mControlSize.width, mImpl->mVisualModel->mControlSize.height ); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "new size (previous size %f,%f)\n", mImpl->mModel->mVisualModel->mControlSize.width, mImpl->mModel->mVisualModel->mControlSize.height ); // Layout operations that need to be done if the size changes. mImpl->mOperationsPending = static_cast( mImpl->mOperationsPending | @@ -1525,7 +1543,7 @@ Controller::UpdateTextType Controller::Relayout( const Size& size ) Vector2 offset; if( newSize && isEditable ) { - offset = mImpl->mScrollPosition; + offset = mImpl->mModel->mScrollPosition; } if( !isEditable || !IsMultiLineEnabled() ) @@ -1542,7 +1560,7 @@ Controller::UpdateTextType Controller::Relayout( const Size& size ) mImpl->ClampHorizontalScroll( layoutSize ); // Update the decorator's positions is needed if there is a new size. - mImpl->mEventData->mDecorator->UpdatePositions( mImpl->mScrollPosition - offset ); + mImpl->mEventData->mDecorator->UpdatePositions( mImpl->mModel->mScrollPosition - offset ); } // Move the cursor, grab handle etc. @@ -1609,6 +1627,7 @@ void Controller::KeyboardFocusGainEvent() { mImpl->ChangeState( EventData::EDITING ); mImpl->mEventData->mUpdateCursorPosition = true; //If editing started without tap event, cursor update must be triggered. + mImpl->mEventData->mUpdateInputStyle = true; } mImpl->NotifyImfMultiLineStatus(); if( mImpl->IsShowingPlaceholderText() ) @@ -1888,7 +1907,7 @@ ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, cons if( textDeleted ) { - if( ( 0u != mImpl->mLogicalModel->mText.Count() ) || + if( ( 0u != mImpl->mModel->mLogicalModel->mText.Count() ) || !mImpl->IsPlaceholderAvailable() ) { mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED ); @@ -1982,7 +2001,7 @@ void Controller::PasteClipboardItemEvent() void Controller::GetTargetSize( Vector2& targetSize ) { - targetSize = mImpl->mVisualModel->mControlSize; + targetSize = mImpl->mModel->mVisualModel->mControlSize; } void Controller::AddDecoration( Actor& actor, bool needsClipping ) @@ -2063,7 +2082,7 @@ void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Butt mImpl->SendSelectionToClipboard( true ); // Synchronous call to modify text mImpl->mOperationsPending = ALL_OPERATIONS; - if( ( 0u != mImpl->mLogicalModel->mText.Count() ) || + if( ( 0u != mImpl->mModel->mLogicalModel->mText.Count() ) || !mImpl->IsPlaceholderAvailable() ) { mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED ); @@ -2147,10 +2166,10 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ mImpl->mEventData->mPrimaryCursorPosition, mImpl->mEventData->mPreEditFlag, mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength ); // TODO: At the moment the underline runs are only for pre-edit. - mImpl->mVisualModel->mUnderlineRuns.Clear(); + mImpl->mModel->mVisualModel->mUnderlineRuns.Clear(); // Keep the current number of characters. - const Length currentNumberOfCharacters = mImpl->IsShowingRealText() ? mImpl->mLogicalModel->mText.Count() : 0u; + const Length currentNumberOfCharacters = mImpl->IsShowingRealText() ? mImpl->mModel->mLogicalModel->mText.Count() : 0u; // Remove the previous IMF pre-edit. if( mImpl->mEventData->mPreEditFlag && ( 0u != mImpl->mEventData->mPreEditLength ) ) @@ -2220,7 +2239,7 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "mPreEditStartPosition %d mPreEditLength %d\n", mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength ); } - const Length numberOfCharactersInModel = mImpl->mLogicalModel->mText.Count(); + const Length numberOfCharactersInModel = mImpl->mModel->mLogicalModel->mText.Count(); // Restrict new text to fit within Maximum characters setting. Length maxSizeOfNewText = std::min( ( mImpl->mMaximumNumberOfCharacters - numberOfCharactersInModel ), characterCount ); @@ -2232,7 +2251,7 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ // Update the text's style. // Updates the text style runs by adding characters. - mImpl->mLogicalModel->UpdateTextStyleRuns( cursorIndex, maxSizeOfNewText ); + mImpl->mModel->mLogicalModel->UpdateTextStyleRuns( cursorIndex, maxSizeOfNewText ); // Get the character index from the cursor index. const CharacterIndex styleIndex = ( cursorIndex > 0u ) ? cursorIndex - 1u : 0u; @@ -2240,7 +2259,7 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ // Retrieve the text's style for the given index. InputStyle style; mImpl->RetrieveDefaultInputStyle( style ); - mImpl->mLogicalModel->RetrieveStyle( styleIndex, style ); + mImpl->mModel->mLogicalModel->RetrieveStyle( styleIndex, style ); // Whether to add a new text color run. const bool addColorRun = ( style.textColor != mImpl->mEventData->mInputStyle.textColor ); @@ -2255,10 +2274,10 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ // Add style runs. if( addColorRun ) { - const VectorBase::SizeType numberOfRuns = mImpl->mLogicalModel->mColorRuns.Count(); - mImpl->mLogicalModel->mColorRuns.Resize( numberOfRuns + 1u ); + const VectorBase::SizeType numberOfRuns = mImpl->mModel->mLogicalModel->mColorRuns.Count(); + mImpl->mModel->mLogicalModel->mColorRuns.Resize( numberOfRuns + 1u ); - ColorRun& colorRun = *( mImpl->mLogicalModel->mColorRuns.Begin() + numberOfRuns ); + ColorRun& colorRun = *( mImpl->mModel->mLogicalModel->mColorRuns.Begin() + numberOfRuns ); colorRun.color = mImpl->mEventData->mInputStyle.textColor; colorRun.characterRun.characterIndex = cursorIndex; colorRun.characterRun.numberOfCharacters = maxSizeOfNewText; @@ -2270,10 +2289,10 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ addFontSlantRun || addFontSizeRun ) { - const VectorBase::SizeType numberOfRuns = mImpl->mLogicalModel->mFontDescriptionRuns.Count(); - mImpl->mLogicalModel->mFontDescriptionRuns.Resize( numberOfRuns + 1u ); + const VectorBase::SizeType numberOfRuns = mImpl->mModel->mLogicalModel->mFontDescriptionRuns.Count(); + mImpl->mModel->mLogicalModel->mFontDescriptionRuns.Resize( numberOfRuns + 1u ); - FontDescriptionRun& fontDescriptionRun = *( mImpl->mLogicalModel->mFontDescriptionRuns.Begin() + numberOfRuns ); + FontDescriptionRun& fontDescriptionRun = *( mImpl->mModel->mLogicalModel->mFontDescriptionRuns.Begin() + numberOfRuns ); if( addFontNameRun ) { @@ -2314,7 +2333,7 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ } // Insert at current cursor position. - Vector& modifyText = mImpl->mLogicalModel->mText; + Vector& modifyText = mImpl->mModel->mLogicalModel->mText; if( cursorIndex < numberOfCharactersInModel ) { @@ -2332,12 +2351,12 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ // Update the cursor index. cursorIndex += maxSizeOfNewText; - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Inserted %d characters, new size %d new cursor %d\n", maxSizeOfNewText, mImpl->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition ); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Inserted %d characters, new size %d new cursor %d\n", maxSizeOfNewText, mImpl->mModel->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition ); } - const Length numberOfCharacters = mImpl->IsShowingRealText() ? mImpl->mLogicalModel->mText.Count() : 0u; + const Length numberOfCharacters = mImpl->IsShowingRealText() ? mImpl->mModel->mLogicalModel->mText.Count() : 0u; - if( ( 0u == mImpl->mLogicalModel->mText.Count() ) && + if( ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) && mImpl->IsPlaceholderAvailable() ) { // Show place-holder if empty after removing the pre-edit text @@ -2364,7 +2383,7 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ if( maxLengthReached ) { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "MaxLengthReached (%d)\n", mImpl->mLogicalModel->mText.Count() ); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "MaxLengthReached (%d)\n", mImpl->mModel->mLogicalModel->mText.Count() ); mImpl->ResetImfManager(); @@ -2401,12 +2420,12 @@ bool Controller::RemoveText( int cursorOffset, } DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p mText.Count() %d cursor %d cursorOffset %d numberOfCharacters %d\n", - this, mImpl->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition, cursorOffset, numberOfCharacters ); + this, mImpl->mModel->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition, cursorOffset, numberOfCharacters ); if( !mImpl->IsShowingPlaceholderText() ) { // Delete at current cursor position - Vector& currentText = mImpl->mLogicalModel->mText; + Vector& currentText = mImpl->mModel->mLogicalModel->mText; CharacterIndex& oldCursorIndex = mImpl->mEventData->mPrimaryCursorPosition; CharacterIndex cursorIndex = oldCursorIndex; @@ -2440,7 +2459,7 @@ bool Controller::RemoveText( int cursorOffset, mImpl->RetrieveDefaultInputStyle( mImpl->mEventData->mInputStyle ); // Update the input style. - mImpl->mLogicalModel->RetrieveStyle( cursorIndex, mImpl->mEventData->mInputStyle ); + mImpl->mModel->mLogicalModel->RetrieveStyle( cursorIndex, mImpl->mEventData->mInputStyle ); // Compare if the input style has changed. const bool hasInputStyleChanged = !currentInputStyle.Equal( mImpl->mEventData->mInputStyle ); @@ -2454,7 +2473,7 @@ bool Controller::RemoveText( int cursorOffset, } // Updates the text style runs by removing characters. Runs with no characters are removed. - mImpl->mLogicalModel->UpdateTextStyleRuns( cursorIndex, -numberOfCharacters ); + mImpl->mModel->mLogicalModel->UpdateTextStyleRuns( cursorIndex, -numberOfCharacters ); // Remove the characters. Vector::Iterator first = currentText.Begin() + cursorIndex; @@ -2510,7 +2529,7 @@ bool Controller::DoRelayout( const Size& size, const Length requestedNumberOfCharacters = mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters; // Get the current layout size. - layoutSize = mImpl->mVisualModel->GetLayoutSize(); + layoutSize = mImpl->mModel->mVisualModel->GetLayoutSize(); if( NO_OPERATION != ( LAYOUT & operations ) ) { @@ -2521,21 +2540,21 @@ bool Controller::DoRelayout( const Size& size, // Fill the vectors again. // Calculate the number of glyphs to layout. - const Vector& charactersToGlyph = mImpl->mVisualModel->mCharactersToGlyph; - const Vector& glyphsPerCharacter = mImpl->mVisualModel->mGlyphsPerCharacter; + const Vector& charactersToGlyph = mImpl->mModel->mVisualModel->mCharactersToGlyph; + const Vector& glyphsPerCharacter = mImpl->mModel->mVisualModel->mGlyphsPerCharacter; const GlyphIndex* const charactersToGlyphBuffer = charactersToGlyph.Begin(); const Length* const glyphsPerCharacterBuffer = glyphsPerCharacter.Begin(); const CharacterIndex lastIndex = startIndex + ( ( requestedNumberOfCharacters > 0u ) ? requestedNumberOfCharacters - 1u : 0u ); const GlyphIndex startGlyphIndex = mImpl->mTextUpdateInfo.mStartGlyphIndex; const Length numberOfGlyphs = ( requestedNumberOfCharacters > 0u ) ? *( charactersToGlyphBuffer + lastIndex ) + *( glyphsPerCharacterBuffer + lastIndex ) - startGlyphIndex : 0u; - const Length totalNumberOfGlyphs = mImpl->mVisualModel->mGlyphs.Count(); + const Length totalNumberOfGlyphs = mImpl->mModel->mVisualModel->mGlyphs.Count(); if( 0u == totalNumberOfGlyphs ) { if( NO_OPERATION != ( UPDATE_LAYOUT_SIZE & operations ) ) { - mImpl->mVisualModel->SetLayoutSize( Size::ZERO ); + mImpl->mModel->mVisualModel->SetLayoutSize( Size::ZERO ); } // Nothing else to do if there is no glyphs. @@ -2543,33 +2562,34 @@ bool Controller::DoRelayout( const Size& size, return true; } - const Vector& lineBreakInfo = mImpl->mLogicalModel->mLineBreakInfo; - const Vector& wordBreakInfo = mImpl->mLogicalModel->mWordBreakInfo; - const Vector& characterDirection = mImpl->mLogicalModel->mCharacterDirections; - const Vector& glyphs = mImpl->mVisualModel->mGlyphs; - const Vector& glyphsToCharactersMap = mImpl->mVisualModel->mGlyphsToCharacters; - const Vector& charactersPerGlyph = mImpl->mVisualModel->mCharactersPerGlyph; - const Character* const textBuffer = mImpl->mLogicalModel->mText.Begin(); + const Vector& lineBreakInfo = mImpl->mModel->mLogicalModel->mLineBreakInfo; + const Vector& wordBreakInfo = mImpl->mModel->mLogicalModel->mWordBreakInfo; + const Vector& characterDirection = mImpl->mModel->mLogicalModel->mCharacterDirections; + const Vector& glyphs = mImpl->mModel->mVisualModel->mGlyphs; + const Vector& glyphsToCharactersMap = mImpl->mModel->mVisualModel->mGlyphsToCharacters; + const Vector& charactersPerGlyph = mImpl->mModel->mVisualModel->mCharactersPerGlyph; + const Character* const textBuffer = mImpl->mModel->mLogicalModel->mText.Begin(); // Set the layout parameters. - LayoutParameters layoutParameters( size, - textBuffer, - lineBreakInfo.Begin(), - wordBreakInfo.Begin(), - ( 0u != characterDirection.Count() ) ? characterDirection.Begin() : NULL, - glyphs.Begin(), - glyphsToCharactersMap.Begin(), - charactersPerGlyph.Begin(), - charactersToGlyphBuffer, - glyphsPerCharacterBuffer, - totalNumberOfGlyphs ); + Layout::Parameters layoutParameters( size, + textBuffer, + lineBreakInfo.Begin(), + wordBreakInfo.Begin(), + ( 0u != characterDirection.Count() ) ? characterDirection.Begin() : NULL, + glyphs.Begin(), + glyphsToCharactersMap.Begin(), + charactersPerGlyph.Begin(), + charactersToGlyphBuffer, + glyphsPerCharacterBuffer, + totalNumberOfGlyphs, + mImpl->mModel->mHorizontalAlignment ); // Resize the vector of positions to have the same size than the vector of glyphs. - Vector& glyphPositions = mImpl->mVisualModel->mGlyphPositions; + Vector& glyphPositions = mImpl->mModel->mVisualModel->mGlyphPositions; glyphPositions.Resize( totalNumberOfGlyphs ); // Whether the last character is a new paragraph character. - mImpl->mTextUpdateInfo.mIsLastCharacterNewParagraph = TextAbstraction::IsNewParagraph( *( textBuffer + ( mImpl->mLogicalModel->mText.Count() - 1u ) ) ); + mImpl->mTextUpdateInfo.mIsLastCharacterNewParagraph = TextAbstraction::IsNewParagraph( *( textBuffer + ( mImpl->mModel->mLogicalModel->mText.Count() - 1u ) ) ); layoutParameters.isLastNewParagraph = mImpl->mTextUpdateInfo.mIsLastCharacterNewParagraph; // The initial glyph and the number of glyphs to layout. @@ -2582,8 +2602,9 @@ bool Controller::DoRelayout( const Size& size, Size newLayoutSize; viewUpdated = mImpl->mLayoutEngine.LayoutText( layoutParameters, glyphPositions, - mImpl->mVisualModel->mLines, - newLayoutSize ); + mImpl->mModel->mVisualModel->mLines, + newLayoutSize, + mImpl->mModel->mElideEnabled ); viewUpdated = viewUpdated || ( newLayoutSize != layoutSize ); @@ -2591,7 +2612,7 @@ bool Controller::DoRelayout( const Size& size, { layoutSize = newLayoutSize; - if ( NO_OPERATION != ( UPDATE_DIRECTION & operations ) ) + if( NO_OPERATION != ( UPDATE_DIRECTION & operations ) ) { mImpl->mAutoScrollDirectionRTL = false; } @@ -2599,21 +2620,21 @@ bool Controller::DoRelayout( const Size& size, // Reorder the lines if( NO_OPERATION != ( REORDER & operations ) ) { - Vector& bidirectionalInfo = mImpl->mLogicalModel->mBidirectionalParagraphInfo; - Vector& bidirectionalLineInfo = mImpl->mLogicalModel->mBidirectionalLineInfo; + Vector& bidirectionalInfo = mImpl->mModel->mLogicalModel->mBidirectionalParagraphInfo; + Vector& bidirectionalLineInfo = mImpl->mModel->mLogicalModel->mBidirectionalLineInfo; // Check first if there are paragraphs with bidirectional info. if( 0u != bidirectionalInfo.Count() ) { // Get the lines - const Length numberOfLines = mImpl->mVisualModel->mLines.Count(); + const Length numberOfLines = mImpl->mModel->mVisualModel->mLines.Count(); // Reorder the lines. bidirectionalLineInfo.Reserve( numberOfLines ); // Reserve because is not known yet how many lines have right to left characters. ReorderLines( bidirectionalInfo, startIndex, requestedNumberOfCharacters, - mImpl->mVisualModel->mLines, + mImpl->mModel->mVisualModel->mLines, bidirectionalLineInfo ); // Set the bidirectional info per line into the layout parameters. @@ -2628,7 +2649,7 @@ bool Controller::DoRelayout( const Size& size, if ( ( NO_OPERATION != ( UPDATE_DIRECTION & operations ) ) && ( numberOfLines > 0 ) ) { - const LineRun* const firstline = mImpl->mVisualModel->mLines.Begin(); + const LineRun* const firstline = mImpl->mModel->mVisualModel->mLines.Begin(); if ( firstline ) { mImpl->mAutoScrollDirectionRTL = firstline->direction; @@ -2640,22 +2661,23 @@ bool Controller::DoRelayout( const Size& size, // Sets the layout size. if( NO_OPERATION != ( UPDATE_LAYOUT_SIZE & operations ) ) { - mImpl->mVisualModel->SetLayoutSize( layoutSize ); + mImpl->mModel->mVisualModel->SetLayoutSize( layoutSize ); } } // view updated // Store the size used to layout the text. - mImpl->mVisualModel->mControlSize = size; + mImpl->mModel->mVisualModel->mControlSize = size; } if( NO_OPERATION != ( ALIGN & operations ) ) { // The laid-out lines. - Vector& lines = mImpl->mVisualModel->mLines; + Vector& lines = mImpl->mModel->mVisualModel->mLines; mImpl->mLayoutEngine.Align( size, startIndex, requestedNumberOfCharacters, + mImpl->mModel->mHorizontalAlignment, lines ); viewUpdated = true; @@ -2671,7 +2693,7 @@ bool Controller::DoRelayout( const Size& size, void Controller::CalculateVerticalOffset( const Size& controlSize ) { - Size layoutSize = mImpl->mVisualModel->GetLayoutSize(); + Size layoutSize = mImpl->mModel->mVisualModel->GetLayoutSize(); if( fabsf( layoutSize.height ) < Math::MACHINE_EPSILON_1000 ) { @@ -2679,21 +2701,21 @@ void Controller::CalculateVerticalOffset( const Size& controlSize ) layoutSize.height = mImpl->GetDefaultFontLineHeight(); } - switch( mImpl->mLayoutEngine.GetVerticalAlignment() ) + switch( mImpl->mModel->mVerticalAlignment ) { - case LayoutEngine::VERTICAL_ALIGN_TOP: + case Layout::VERTICAL_ALIGN_TOP: { - mImpl->mScrollPosition.y = 0.f; + mImpl->mModel->mScrollPosition.y = 0.f; break; } - case LayoutEngine::VERTICAL_ALIGN_CENTER: + case Layout::VERTICAL_ALIGN_CENTER: { - mImpl->mScrollPosition.y = floorf( 0.5f * ( controlSize.height - layoutSize.height ) ); // try to avoid pixel alignment. + mImpl->mModel->mScrollPosition.y = floorf( 0.5f * ( controlSize.height - layoutSize.height ) ); // try to avoid pixel alignment. break; } - case LayoutEngine::VERTICAL_ALIGN_BOTTOM: + case Layout::VERTICAL_ALIGN_BOTTOM: { - mImpl->mScrollPosition.y = controlSize.height - layoutSize.height; + mImpl->mModel->mScrollPosition.y = controlSize.height - layoutSize.height; break; } } @@ -2841,7 +2863,7 @@ bool Controller::BackspaceKeyEvent() if( removed ) { - if( ( 0u != mImpl->mLogicalModel->mText.Count() ) || + if( ( 0u != mImpl->mModel->mLogicalModel->mText.Count() ) || !mImpl->IsPlaceholderAvailable() ) { mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED ); @@ -2862,7 +2884,7 @@ bool Controller::BackspaceKeyEvent() void Controller::ResetText() { // Reset buffers. - mImpl->mLogicalModel->mText.Clear(); + mImpl->mModel->mLogicalModel->mText.Clear(); // We have cleared everything including the placeholder-text mImpl->PlaceholderCleared(); @@ -2919,11 +2941,11 @@ void Controller::ShowPlaceholderText() mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters; // Reset model for showing placeholder. - mImpl->mLogicalModel->mText.Clear(); - mImpl->mVisualModel->SetTextColor( mImpl->mEventData->mPlaceholderTextColor ); + mImpl->mModel->mLogicalModel->mText.Clear(); + mImpl->mModel->mVisualModel->SetTextColor( mImpl->mEventData->mPlaceholderTextColor ); // Convert text into UTF-32 - Vector& utf32Characters = mImpl->mLogicalModel->mText; + Vector& utf32Characters = mImpl->mModel->mLogicalModel->mText; utf32Characters.Resize( size ); // This is a bit horrible but std::string returns a (signed) char* @@ -2961,7 +2983,7 @@ void Controller::ClearFontData() // Set flags to update the model. mImpl->mTextUpdateInfo.mCharacterIndex = 0u; mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters; - mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mLogicalModel->mText.Count(); + mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count(); mImpl->mTextUpdateInfo.mClearAll = true; mImpl->mTextUpdateInfo.mFullRelayoutNeeded = true; @@ -2979,8 +3001,8 @@ void Controller::ClearFontData() void Controller::ClearStyleData() { - mImpl->mLogicalModel->mColorRuns.Clear(); - mImpl->mLogicalModel->ClearFontDescriptionRuns(); + mImpl->mModel->mLogicalModel->mColorRuns.Clear(); + mImpl->mModel->mLogicalModel->ClearFontDescriptionRuns(); } void Controller::ResetCursorPosition( CharacterIndex cursorIndex ) @@ -3003,7 +3025,7 @@ void Controller::ResetScrollPosition() if( NULL != mImpl->mEventData ) { // Reset the scroll position. - mImpl->mScrollPosition = Vector2::ZERO; + mImpl->mModel->mScrollPosition = Vector2::ZERO; mImpl->mEventData->mScrollAfterUpdatePosition = true; } } diff --git a/dali-toolkit/internal/text/text-controller.h b/dali-toolkit/internal/text/text-controller.h index a78d0eb..6f4b864 100644 --- a/dali-toolkit/internal/text/text-controller.h +++ b/dali-toolkit/internal/text/text-controller.h @@ -26,6 +26,7 @@ #include #include #include +#include namespace Dali { @@ -40,6 +41,7 @@ class Controller; class ControlInterface; class EditableControlInterface; class View; +class RenderingController; typedef IntrusivePtr ControllerPtr; @@ -297,24 +299,40 @@ public: // Configure the text controller. bool IsMultiLineEnabled() const; /** - * @copydoc Dali::Toolkit::Text::LayoutEngine::SetHorizontalAlignment() + * @brief Sets the text's horizontal alignment. + * + * @param[in] alignment The horizontal alignment. + */ + void SetHorizontalAlignment( Layout::HorizontalAlignment alignment ); + + /** + * @copydoc ModelInterface::GetHorizontalAlignment() */ - void SetHorizontalAlignment( LayoutEngine::HorizontalAlignment alignment ); + Layout::HorizontalAlignment GetHorizontalAlignment() const; /** - * @copydoc Dali::Toolkit::Text::LayoutEngine::GetHorizontalAlignment() + * @brief Sets the text's vertical alignment. + * + * @param[in] alignment The vertical alignment. */ - LayoutEngine::HorizontalAlignment GetHorizontalAlignment() const; + void SetVerticalAlignment( Layout::VerticalAlignment alignment ); /** - * @copydoc Dali::Toolkit::Text::LayoutEngine::SetVerticalAlignment() + * @copydoc ModelInterface::GetVerticalAlignment() */ - void SetVerticalAlignment( LayoutEngine::VerticalAlignment alignment ); + Layout::VerticalAlignment GetVerticalAlignment() const; /** - * @copydoc Dali::Toolkit::Text::LayoutEngine::GetVerticalAlignment() + * @brief Enable or disable the text elide. + * + * @param[in] enabled Whether to enable the text elide. */ - LayoutEngine::VerticalAlignment GetVerticalAlignment() const; + void SetTextElideEnabled( bool enabled ); + + /** + * @copydoc ModelInterface::IsTextElideEnabled() + */ + bool IsTextElideEnabled() const; public: // Update. @@ -443,18 +461,18 @@ public: // Default style & Input style float GetDefaultPointSize() const; /** - * @brief Set the text color + * @brief Sets the text's default color. * - * @param textColor The text color + * @param color The default color. */ - void SetTextColor( const Vector4& textColor ); + void SetDefaultColor( const Vector4& color ); /** - * @brief Retrieve the text color + * @brief Retrieves the text's default color. * - * @return The text color + * @return The default color. */ - const Vector4& GetTextColor() const; + const Vector4& GetDefaultColor() const; /** * @brief Set the text color @@ -770,7 +788,7 @@ public: // Queries & retrieves. * * @return A reference to the layout engine. */ - LayoutEngine& GetLayoutEngine(); + Layout::Engine& GetLayoutEngine(); /** * @brief Return a view of the text. @@ -780,13 +798,6 @@ public: // Queries & retrieves. View& GetView(); /** - * @brief Query the current scroll position; the UI control is responsible for moving actors to this position. - * - * @return The scroll position. - */ - const Vector2& GetScrollPosition() const; - - /** * @copydoc Control::GetNaturalSize() */ Vector3 GetNaturalSize(); @@ -796,6 +807,13 @@ public: // Queries & retrieves. */ float GetHeightForWidth( float width ); + /** + * @brief Retrieves the text's model. + * + * @return A pointer to the text's model. + */ + const ModelInterface* const GetTextModel() const; + public: // Relayout. /** diff --git a/dali-toolkit/internal/text/text-model-interface.h b/dali-toolkit/internal/text/text-model-interface.h new file mode 100644 index 0000000..e6b50c9 --- /dev/null +++ b/dali-toolkit/internal/text/text-model-interface.h @@ -0,0 +1,155 @@ +#ifndef DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H +#define DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H + +/* + * Copyright (c) 2016 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 + +namespace Dali +{ + +namespace Toolkit +{ + +namespace Text +{ + +/** + * @brief Interface class used to retrieve the text's model from the text-controller. + */ +class ModelInterface +{ +public: + /** + * @brief Virtual destructor. + */ + virtual ~ModelInterface() + {} + + /** + * @brief Retrives the control's size. + * + * @return The control's size. + */ + virtual const Size& GetControlSize() const = 0; + + /** + * @brief Retrives the layout's size. + * + * @return The layout's size. + */ + virtual const Size& GetLayoutSize() const = 0; + + /** + * @brief Retrieves the text's scroll position. + * + * @return The scroll position. + */ + virtual const Vector2& GetScrollPosition() const = 0; + + /** + * @brief Retrieves the text's horizontal alignment. + * + * @return The horizontal alignment. + */ + virtual Layout::HorizontalAlignment GetHorizontalAlignment() const = 0; + + /** + * @brief Retrieves the text's vertical alignment. + * + * @return The vertical alignment. + */ + virtual Layout::VerticalAlignment GetVerticalAlignment() const = 0; + + /** + * @brief Whether the text elide property is enabled. + * + * @return @e true if the text elide property is enabled, @e false otherwise. + */ + virtual bool IsTextElideEnabled() const = 0; + + /** + * @brief Retrieves the number of laid-out lines. + * + * @return The number of laid-out lines. + */ + virtual Length GetNumberOfLines() const = 0; + + /** + * @brief Retrieves the laid-out lines. + * + * @return A pointer to the vector with the laid-out lines. + */ + virtual const LineRun* const GetLines() const = 0; + + /** + * @brief Retrieves the number of laid-out glyphs. + * + * @return The number of laid-out glyphs. + */ + virtual Length GetNumberOfGlyphs() const = 0; + + /** + * @brief Retrieves the laid-out glyphs. + * + * @return A pointer to the vector with the laid-out glyphs. + */ + virtual const GlyphInfo* const GetGlyphs() const = 0; + + /** + * @brief Retrieves the text layout. + * + * @return A pointer to the vector with the positions for each glyph. + */ + virtual const Vector2* const GetLayout() const = 0; + + /** + * @brief Retrieves the vector of colors. + * + * @return Pointer to the vector of colors. + */ + virtual const Vector4* const GetColors() const = 0; + + /** + * @brief Retrieves the vector of indices to the vector of colors. + * + * @return Pointer to a vector which stores for each glyph the index to the vector of colors. + */ + virtual const ColorIndex* const GetColorIndices() const = 0; + + /** + * @brief Retrieves the text's default color. + * + * @return The default color. + */ + virtual const Vector4& GetDefaultColor() const = 0; +}; + +} // namespace Text + +} // namespace Toolkit + +} // namespace Dali + +#endif // DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H diff --git a/dali-toolkit/internal/text/text-model.cpp b/dali-toolkit/internal/text/text-model.cpp new file mode 100644 index 0000000..eca74df --- /dev/null +++ b/dali-toolkit/internal/text/text-model.cpp @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2016 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 + +namespace Dali +{ + +namespace Toolkit +{ + +namespace Text +{ + +ModelPtr Model::New() +{ + return ModelPtr( new Model() ); +} + +const Size& Model::GetControlSize() const +{ + return mVisualModel->mControlSize; +} + +const Size& Model::GetLayoutSize() const +{ + return mVisualModel->GetLayoutSize(); +} + +const Vector2& Model::GetScrollPosition() const +{ + return mScrollPosition; +} + +Layout::HorizontalAlignment Model::GetHorizontalAlignment() const +{ + return mHorizontalAlignment; +} + +Layout::VerticalAlignment Model::GetVerticalAlignment() const +{ + return mVerticalAlignment; +} + +bool Model::IsTextElideEnabled() const +{ + return mElideEnabled; +} + +Length Model::GetNumberOfLines() const +{ + return mVisualModel->mLines.Count(); +} + +const LineRun* const Model::GetLines() const +{ + return mVisualModel->mLines.Begin(); +} + +Length Model::GetNumberOfGlyphs() const +{ + return mVisualModel->mGlyphs.Count(); +} + +const GlyphInfo* const Model::GetGlyphs() const +{ + return mVisualModel->mGlyphs.Begin(); +} + +const Vector2* const Model::GetLayout() const +{ + return mVisualModel->mGlyphPositions.Begin(); +} + +const Vector4* const Model::GetColors() const +{ + return mVisualModel->mColors.Begin(); +} + +const ColorIndex* const Model::GetColorIndices() const +{ + return mVisualModel->mColorIndices.Begin(); +} + +const Vector4& Model::GetDefaultColor() const +{ + return mVisualModel->mTextColor; +} + +Model::Model() +: mLogicalModel(), + mVisualModel(), + mScrollPosition(), + mHorizontalAlignment( Layout::HORIZONTAL_ALIGN_BEGIN ), + mVerticalAlignment( Layout::VERTICAL_ALIGN_TOP ), + mElideEnabled( false ) +{ + mLogicalModel = LogicalModel::New(); + mVisualModel = VisualModel::New(); +} + +Model::~Model() +{ +} + +} // namespace Text + +} // namespace Toolkit + +} // namespace Dali diff --git a/dali-toolkit/internal/text/text-model.h b/dali-toolkit/internal/text/text-model.h new file mode 100644 index 0000000..765dd31 --- /dev/null +++ b/dali-toolkit/internal/text/text-model.h @@ -0,0 +1,170 @@ +#ifndef DALI_TOOLKIT_TEXT_MODEL_H +#define DALI_TOOLKIT_TEXT_MODEL_H + +/* + * Copyright (c) 2016 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 + +namespace Dali +{ + +namespace Toolkit +{ + +namespace Text +{ + +// Forward declarations. +class Model; + +typedef IntrusivePtr ModelPtr; + +/** + * @brief Implementation class used to retrieve the text's model from the text-controller. + */ +class Model : public RefObject, public ModelInterface +{ + +public: // Constructor. + + /** + * @brief Create a new instance of a text Model. + * + * @return A pointer to a new text Model. + */ + static ModelPtr New(); + +public: + + /** + * @copydoc ModelInterface::GetControlSize() + */ + virtual const Size& GetControlSize() const; + + /** + * @copydoc ModelInterface::GetLayoutSize() + */ + virtual const Size& GetLayoutSize() const; + + /** + * @copydoc ModelInterface::GetScrollPosition() + */ + virtual const Vector2& GetScrollPosition() const; + + /** + * @copydoc ModelInterface::GetHorizontalAlignment() + */ + virtual Layout::HorizontalAlignment GetHorizontalAlignment() const; + + /** + * @copydoc ModelInterface::GetVerticalAlignment() + */ + virtual Layout::VerticalAlignment GetVerticalAlignment() const; + + /** + * @copydoc ModelInterface::IsTextElideEnabled() + */ + virtual bool IsTextElideEnabled() const; + + /** + * @copydoc ModelInterface::GetNumberOfLines() + */ + virtual Length GetNumberOfLines() const; + + /** + * @copydoc ModelInterface::GetLines() + */ + virtual const LineRun* const GetLines() const; + + /** + * @copydoc ModelInterface::GetNumberOfGlyphs() + */ + virtual Length GetNumberOfGlyphs() const; + + /** + * @copydoc ModelInterface::GetGlyphs() + */ + virtual const GlyphInfo* const GetGlyphs() const; + + /** + * @copydoc ModelInterface::GetLayout() + */ + virtual const Vector2* const GetLayout() const; + + /** + * @copydoc ModelInterface::GetColors() + */ + virtual const Vector4* const GetColors() const; + + /** + * @copydoc ModelInterface::GetColorIndices() + */ + virtual const ColorIndex* const GetColorIndices() const; + + /** + * @copydoc ModelInterface::GetDefaultColor() + */ + virtual const Vector4& GetDefaultColor() const; + +private: // Private contructors & copy operator. + + /** + * @brief Private constructor. + */ + Model(); + + // Undefined. + Model( const Model& handle ); + + // Undefined. + Model& operator=( const Model& handle ); + +protected: + + /** + * @brief A reference counted object may only be deleted by calling Unreference(). + */ + virtual ~Model(); + +public: + LogicalModelPtr mLogicalModel; ///< Pointer to the logical model. + VisualModelPtr mVisualModel; ///< Pointer to the visual model. + /** + * 0,0 means that the top-left corner of the layout matches the top-left corner of the UI control. + * Typically this will have a negative value with scrolling occurs. + */ + Vector2 mScrollPosition; ///< The text is offset by this position when scrolling. + Layout::HorizontalAlignment mHorizontalAlignment; ///< The layout's horizontal alignment. + Layout::VerticalAlignment mVerticalAlignment; ///< The layout's vertical alignment. + bool mElideEnabled:1; ///< Whether the text's elide is enabled. +}; + +} // namespace Text + +} // namespace Toolkit + +} // namespace Dali + +#endif // DALI_TOOLKIT_TEXT_MODEL_H diff --git a/dali-toolkit/internal/text/text-scroller-interface.h b/dali-toolkit/internal/text/text-scroller-interface.h index 31a0819..08b1153 100644 --- a/dali-toolkit/internal/text/text-scroller-interface.h +++ b/dali-toolkit/internal/text/text-scroller-interface.h @@ -37,14 +37,10 @@ class ScrollerInterface public: /** - * @brief Constructor. - */ - ScrollerInterface(); - - /** * @brief Virtual destructor. */ - virtual ~ScrollerInterface(); + virtual ~ScrollerInterface() + {} /** * @brief Called when the scrolling finishes diff --git a/dali-toolkit/internal/text/visual-model-impl.cpp b/dali-toolkit/internal/text/visual-model-impl.cpp index c1faee7..92bc48d 100644 --- a/dali-toolkit/internal/text/visual-model-impl.cpp +++ b/dali-toolkit/internal/text/visual-model-impl.cpp @@ -410,7 +410,8 @@ VisualModel::VisualModel() mTextColor( Color::BLACK ), mShadowColor( Color::BLACK ), mUnderlineColor( Color::BLACK ), - mShadowOffset( Vector2::ZERO ), + mControlSize(), + mShadowOffset(), mUnderlineHeight( 0.0f ), mNaturalSize(), mLayoutSize(), diff --git a/dali-toolkit/internal/text/visual-model-impl.h b/dali-toolkit/internal/text/visual-model-impl.h index 7c1accb..b024307 100644 --- a/dali-toolkit/internal/text/visual-model-impl.h +++ b/dali-toolkit/internal/text/visual-model-impl.h @@ -313,10 +313,10 @@ public: Vector mColors; ///< Colors of the glyphs. Vector mColorIndices; ///< Indices to the vector of colors for each glyphs. - Vector2 mControlSize; ///< The size of the UI control the decorator is adding it's decorations to. Vector4 mTextColor; ///< The text color Vector4 mShadowColor; ///< Color of drop shadow Vector4 mUnderlineColor; ///< Color of underline + Size mControlSize; ///< The size of the UI control. Vector2 mShadowOffset; ///< Offset for drop shadow, 0 indicates no shadow float mUnderlineHeight; ///< Fixed height for underline to override font metrics. diff --git a/dali-toolkit/internal/visuals/color/color-visual.cpp b/dali-toolkit/internal/visuals/color/color-visual.cpp index 82c6254..0d5ad54 100644 --- a/dali-toolkit/internal/visuals/color/color-visual.cpp +++ b/dali-toolkit/internal/visuals/color/color-visual.cpp @@ -103,13 +103,6 @@ void ColorVisual::DoSetProperties( const Property::Map& propertyMap ) } } -void ColorVisual::SetSize( const Vector2& size ) -{ - Visual::Base::SetSize( size ); - - // ToDo: renderer responds to the size change -} - void ColorVisual::DoSetOnStage( Actor& actor ) { InitializeRenderer(); diff --git a/dali-toolkit/internal/visuals/color/color-visual.h b/dali-toolkit/internal/visuals/color/color-visual.h index d2f3ebe..a8214ea 100644 --- a/dali-toolkit/internal/visuals/color/color-visual.h +++ b/dali-toolkit/internal/visuals/color/color-visual.h @@ -60,11 +60,6 @@ public: public: // from Visual /** - * @copydoc Visual::Base::SetSize - */ - virtual void SetSize( const Vector2& size ); - - /** * @copydoc Visual::Base::CreatePropertyMap */ virtual void DoCreatePropertyMap( Property::Map& map ) const; diff --git a/dali-toolkit/internal/visuals/gradient/gradient-visual.cpp b/dali-toolkit/internal/visuals/gradient/gradient-visual.cpp index bfc9130..bc354e5 100644 --- a/dali-toolkit/internal/visuals/gradient/gradient-visual.cpp +++ b/dali-toolkit/internal/visuals/gradient/gradient-visual.cpp @@ -267,11 +267,6 @@ void GradientVisual::OnSetTransform() } } -void GradientVisual::SetSize( const Vector2& size ) -{ - Visual::Base::SetSize( size ); -} - void GradientVisual::DoSetOnStage( Actor& actor ) { InitializeRenderer(); diff --git a/dali-toolkit/internal/visuals/gradient/gradient-visual.h b/dali-toolkit/internal/visuals/gradient/gradient-visual.h index bc131ae..351e772 100644 --- a/dali-toolkit/internal/visuals/gradient/gradient-visual.h +++ b/dali-toolkit/internal/visuals/gradient/gradient-visual.h @@ -95,11 +95,6 @@ public: public: // from Visual /** - * @copydoc Visual::Base::SetSize - */ - virtual void SetSize( const Vector2& size ); - - /** * @copydoc Visual::Base::CreatePropertyMap */ virtual void DoCreatePropertyMap( Property::Map& map ) const; diff --git a/dali-toolkit/internal/visuals/image/batch-image-visual.cpp b/dali-toolkit/internal/visuals/image/batch-image-visual.cpp index 90d2b53..b46048a 100644 --- a/dali-toolkit/internal/visuals/image/batch-image-visual.cpp +++ b/dali-toolkit/internal/visuals/image/batch-image-visual.cpp @@ -127,11 +127,6 @@ void BatchImageVisual::DoSetProperties( const Property::Map& propertyMap ) mDesiredSize = ImageDimensions( desiredWidth, desiredHeight ); } -void BatchImageVisual::SetSize( const Vector2& size ) -{ - Visual::Base::SetSize( size ); -} - void BatchImageVisual::GetNaturalSize( Vector2& naturalSize ) { if( mDesiredSize.GetWidth() > 0 && mDesiredSize.GetHeight() > 0 ) @@ -275,6 +270,14 @@ void BatchImageVisual::CleanCache(const std::string& url) } } +void BatchImageVisual::OnSetTransform() +{ + if( mImpl->mRenderer ) + { + //Register transform properties + mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT ); + } +} } // namespace Internal diff --git a/dali-toolkit/internal/visuals/image/batch-image-visual.h b/dali-toolkit/internal/visuals/image/batch-image-visual.h index 85ef5b4..60209d3 100644 --- a/dali-toolkit/internal/visuals/image/batch-image-visual.h +++ b/dali-toolkit/internal/visuals/image/batch-image-visual.h @@ -50,11 +50,6 @@ public: public: // from Visual /** - * @copydoc Visual::Base::SetSize - */ - virtual void SetSize( const Vector2& size ); - - /** * @copydoc Visual::Base::GetNaturalSize */ virtual void GetNaturalSize( Vector2& naturalSize ); @@ -103,6 +98,11 @@ protected: */ virtual void DoSetOffStage( Actor& actor ); + /** + * @copydoc Visual::Base::OnSetTransform + */ + virtual void OnSetTransform(); + private: /** diff --git a/dali-toolkit/internal/visuals/image/image-visual.cpp b/dali-toolkit/internal/visuals/image/image-visual.cpp index 084491a..ab6d1b6 100644 --- a/dali-toolkit/internal/visuals/image/image-visual.cpp +++ b/dali-toolkit/internal/visuals/image/image-visual.cpp @@ -122,7 +122,7 @@ const char* VERTEX_SHADER = DALI_COMPOSE_SHADER( void main()\n {\n - mediump vec4 vertexPosition = uMvpMatrix *ComputeVertexPosition();\n + mediump vec4 vertexPosition = uMvpMatrix * ComputeVertexPosition();\n vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );\n gl_Position = vertexPosition;\n }\n @@ -286,6 +286,8 @@ void ImageVisual::DoSetProperties( const Property::Map& propertyMap ) desiredHeightValue->Get( desiredHeight ); } + mDesiredSize = ImageDimensions( desiredWidth, desiredHeight ); + Property::Value* pixelAreaValue = propertyMap.Find( Toolkit::ImageVisual::Property::PIXEL_AREA, PIXEL_AREA_UNIFORM_NAME ); if( pixelAreaValue ) { @@ -308,8 +310,6 @@ void ImageVisual::DoSetProperties( const Property::Map& propertyMap ) mWrapModeV = Dali::WrapMode::Type( value ); } - mDesiredSize = ImageDimensions( desiredWidth, desiredHeight ); - Property::Value* syncLoading = propertyMap.Find( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, SYNCHRONOUS_LOADING ); if( syncLoading ) { diff --git a/dali-toolkit/internal/visuals/mesh/mesh-visual.cpp b/dali-toolkit/internal/visuals/mesh/mesh-visual.cpp index 3384976..f0ba67b 100644 --- a/dali-toolkit/internal/visuals/mesh/mesh-visual.cpp +++ b/dali-toolkit/internal/visuals/mesh/mesh-visual.cpp @@ -429,13 +429,6 @@ void MeshVisual::OnSetTransform() } } -void MeshVisual::SetSize( const Vector2& size ) -{ - Visual::Base::SetSize( size ); - - // ToDo: renderer responds to the size change -} - void MeshVisual::DoSetOnStage( Actor& actor ) { InitializeRenderer(); diff --git a/dali-toolkit/internal/visuals/mesh/mesh-visual.h b/dali-toolkit/internal/visuals/mesh/mesh-visual.h index 2e3772c..75b4a86 100644 --- a/dali-toolkit/internal/visuals/mesh/mesh-visual.h +++ b/dali-toolkit/internal/visuals/mesh/mesh-visual.h @@ -70,11 +70,6 @@ public: public: // from Visual /** - * @copydoc Visual::Base::SetSize - */ - virtual void SetSize( const Vector2& size ); - - /** * @copydoc Visual::Base::CreatePropertyMap */ virtual void DoCreatePropertyMap( Property::Map& map ) const; diff --git a/dali-toolkit/internal/visuals/primitive/primitive-visual.cpp b/dali-toolkit/internal/visuals/primitive/primitive-visual.cpp index 5fbde5a..f4a3fe5 100644 --- a/dali-toolkit/internal/visuals/primitive/primitive-visual.cpp +++ b/dali-toolkit/internal/visuals/primitive/primitive-visual.cpp @@ -387,13 +387,6 @@ void PrimitiveVisual::DoSetProperties( const Property::Map& propertyMap ) } } -void PrimitiveVisual::SetSize( const Vector2& size ) -{ - Visual::Base::SetSize( size ); - - // ToDo: renderer responds to the size change -} - void PrimitiveVisual::GetNaturalSize( Vector2& naturalSize ) { naturalSize.x = mObjectDimensions.x; diff --git a/dali-toolkit/internal/visuals/primitive/primitive-visual.h b/dali-toolkit/internal/visuals/primitive/primitive-visual.h index 5239d3f..deda8d3 100644 --- a/dali-toolkit/internal/visuals/primitive/primitive-visual.h +++ b/dali-toolkit/internal/visuals/primitive/primitive-visual.h @@ -112,11 +112,6 @@ public: public: // from Visual /** - * @copydoc Visual::Base::SetSize - */ - virtual void SetSize( const Vector2& size ); - - /** * @copydoc Visual::Base::GetNaturalSize */ virtual void GetNaturalSize( Vector2& naturalSize ); diff --git a/dali-toolkit/internal/visuals/svg/svg-visual.cpp b/dali-toolkit/internal/visuals/svg/svg-visual.cpp index 8a390d4..df53192 100644 --- a/dali-toolkit/internal/visuals/svg/svg-visual.cpp +++ b/dali-toolkit/internal/visuals/svg/svg-visual.cpp @@ -54,10 +54,10 @@ namespace Toolkit namespace Internal { -SvgVisualPtr SvgVisual::New( VisualFactoryCache& factoryCache, const std::string& imageUrl, ImageDimensions size ) +SvgVisualPtr SvgVisual::New( VisualFactoryCache& factoryCache, const std::string& imageUrl ) { SvgVisual* svgVisual = new SvgVisual( factoryCache ); - svgVisual->ParseFromUrl( imageUrl, size ); + svgVisual->ParseFromUrl( imageUrl ); return svgVisual; } @@ -66,7 +66,8 @@ SvgVisual::SvgVisual( VisualFactoryCache& factoryCache ) mAtlasRect( FULL_TEXTURE_RECT ), mImageUrl(), mParsedImage( NULL ), - mPlacementActor() + mPlacementActor(), + mVisualSize(Vector2::ZERO) { // the rasterized image is with pre-multiplied alpha format mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA; @@ -101,10 +102,7 @@ void SvgVisual::DoSetOnStage( Actor& actor ) // Register transform properties mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT ); - if( mImpl->mSize != Vector2::ZERO && mParsedImage ) - { - AddRasterizationTask( mImpl->mSize ); - } + // Defer the rasterisation task until we get given a size (by Size Negotiation algorithm) // Hold the weak handle of the placement actor and delay the adding of renderer until the svg rasterization is finished. mPlacementActor = actor; @@ -132,15 +130,6 @@ void SvgVisual::GetNaturalSize( Vector2& naturalSize ) } } -void SvgVisual::SetSize( const Vector2& size ) -{ - if(mImpl->mSize != size && mParsedImage && IsOnStage() ) - { - AddRasterizationTask( size ); - } - mImpl->mSize = size; -} - void SvgVisual::DoCreatePropertyMap( Property::Map& map ) const { map.Clear(); @@ -162,19 +151,13 @@ Dali::Property::Value SvgVisual::DoGetProperty( Dali::Property::Index index ) return Dali::Property::Value(); } -void SvgVisual::ParseFromUrl( const std::string& imageUrl, ImageDimensions size ) +void SvgVisual::ParseFromUrl( const std::string& imageUrl ) { mImageUrl = imageUrl; Vector2 dpi = Stage::GetCurrent().GetDpi(); float meanDpi = (dpi.height + dpi.width) * 0.5f; mParsedImage = nsvgParseFromFile( imageUrl.c_str(), UNITS, meanDpi ); - - if( size.GetWidth() != 0u && size.GetHeight() != 0u) - { - mImpl->mSize.x = size.GetWidth(); - mImpl->mSize.y = size.GetHeight(); - } } void SvgVisual::AddRasterizationTask( const Vector2& size ) @@ -248,6 +231,19 @@ void SvgVisual::ApplyRasterizedImage( PixelData rasterizedPixelData ) } } +void SvgVisual::OnSetTransform() +{ + Vector2 visualSize = mImpl->mTransform.GetVisualSize( mImpl->mControlSize ); + + if( mParsedImage && IsOnStage() ) + { + if( visualSize != mVisualSize ) + { + AddRasterizationTask( visualSize ); + mVisualSize = visualSize; + } + } +} } // namespace Internal diff --git a/dali-toolkit/internal/visuals/svg/svg-visual.h b/dali-toolkit/internal/visuals/svg/svg-visual.h index e5a2f8e..43ac1f4 100644 --- a/dali-toolkit/internal/visuals/svg/svg-visual.h +++ b/dali-toolkit/internal/visuals/svg/svg-visual.h @@ -61,9 +61,8 @@ public: * * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object * @param[in] imageUrl The URL to svg resource to use - * @param[in] size The required size for the SVG */ - static SvgVisualPtr New( VisualFactoryCache& factoryCache, const std::string& imageUrl, ImageDimensions size = ImageDimensions() ); + static SvgVisualPtr New( VisualFactoryCache& factoryCache, const std::string& imageUrl ); public: // from Visual @@ -73,11 +72,6 @@ public: // from Visual virtual void GetNaturalSize( Vector2& naturalSize ); /** - * @copydoc Visual::Base::SetSize - */ - virtual void SetSize( const Vector2& size ); - - /** * @copydoc Visual::Base::CreatePropertyMap */ virtual void DoCreatePropertyMap( Property::Map& map ) const; @@ -121,6 +115,11 @@ protected: */ virtual void DoSetOffStage( Actor& actor ); + /** + * @copydoc Visual::Base::OnSetTransform + */ + virtual void OnSetTransform(); + public: /** @@ -136,9 +135,8 @@ private: * @brief Parses the SVG Image from the set URL. * * @param[in] imageUrl The URL of the image to parse the SVG from. - * @param[in] size The required size of the SVG */ - void ParseFromUrl( const std::string& imageUrl, ImageDimensions size = ImageDimensions() ); + void ParseFromUrl( const std::string& imageUrl ); /** * @bried Rasterize the svg with the given size, and add it to the visual. @@ -159,7 +157,7 @@ private: std::string mImageUrl; NSVGimage* mParsedImage; WeakHandle mPlacementActor; - + Vector2 mVisualSize; }; } // namespace Internal diff --git a/dali-toolkit/internal/visuals/text/text-visual.cpp b/dali-toolkit/internal/visuals/text/text-visual.cpp index baba744..b67617a 100644 --- a/dali-toolkit/internal/visuals/text/text-visual.cpp +++ b/dali-toolkit/internal/visuals/text/text-visual.cpp @@ -18,23 +18,16 @@ // CLASS HEADER #include -// EXTERNAL HEADER -#include -// #include - // INTERNAL HEADER -#include -#include #include +#include +#include #include -#include -#include +#include #include #include +#include #include -#include - -using Dali::Toolkit::Text::LayoutEngine; namespace Dali { @@ -49,7 +42,6 @@ namespace { // Property names. -const char * const RENDERING_BACKEND_PROPERTY( "renderingBackend" ); const char * const TEXT_PROPERTY( "text" ); const char * const FONT_FAMILY_PROPERTY( "fontFamily" ); const char * const FONT_STYLE_PROPERTY( "fontStyle" ); @@ -59,46 +51,41 @@ const char * const HORIZONTAL_ALIGNMENT_PROPERTY( "horizontalAlignment" ); const char * const VERTICAL_ALIGNMENT_PROPERTY( "verticalAlignment" ); const char * const TEXT_COLOR_PROPERTY( "textColor" ); const char * const ENABLE_MARKUP_PROPERTY( "enableMarkup" ); -const char * const ENABLE_AUTO_SCROLL_PROPERTY( "enableAutoScroll" ); -const char * const AUTO_SCROLL_SPEED_PROPERTY( "autoScrollSpeed" ); -const char * const AUTO_SCROLL_LOOP_COUNT_PROPERTY( "autoScrollLoopCount" ); -const char * const AUTO_SCROLL_GAP_PROPERTY( "autoScrollGap" ); -const char * const LINE_SPACING_PROPERTY( "lineSpacing" ); -const char * const UNDERLINE_PROPERTY( "underline" ); -const char * const SHADOW_PROPERTY( "shadow" ); -const char * const OUTLINE_PROPERTY( "outline" ); -const char * const BATCHING_ENABLED_PROPERTY( "batchingEnabled" ); + +const std::string PIXEL_AREA_UNIFORM_NAME = "pixelArea"; const Scripting::StringEnum 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 }, + { "BEGIN", Toolkit::Text::Layout::HORIZONTAL_ALIGN_BEGIN }, + { "CENTER", Toolkit::Text::Layout::HORIZONTAL_ALIGN_CENTER }, + { "END", Toolkit::Text::Layout::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 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 }, + { "TOP", Toolkit::Text::Layout::VERTICAL_ALIGN_TOP }, + { "CENTER", Toolkit::Text::Layout::VERTICAL_ALIGN_CENTER }, + { "BOTTOM", Toolkit::Text::Layout::VERTICAL_ALIGN_BOTTOM }, }; const unsigned int VERTICAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( VERTICAL_ALIGNMENT_STRING_TABLE ) / sizeof( VERTICAL_ALIGNMENT_STRING_TABLE[0] ); -std::string GetHorizontalAlignment( LayoutEngine::HorizontalAlignment alignment ) +const Vector4 FULL_TEXTURE_RECT( 0.f, 0.f, 1.f, 1.f ); + +std::string GetHorizontalAlignment( Toolkit::Text::Layout::HorizontalAlignment alignment ) { - const char* name = Scripting::GetEnumerationName( alignment, - HORIZONTAL_ALIGNMENT_STRING_TABLE, - HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT ); + const char* name = Scripting::GetEnumerationName( alignment, + HORIZONTAL_ALIGNMENT_STRING_TABLE, + HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT ); return std::string( name ); } -std::string GetVerticalAlignment( LayoutEngine::VerticalAlignment alignment ) +std::string GetVerticalAlignment( Toolkit::Text::Layout::VerticalAlignment alignment ) { - const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( alignment, - VERTICAL_ALIGNMENT_STRING_TABLE, - VERTICAL_ALIGNMENT_STRING_TABLE_COUNT ); + const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::VerticalAlignment >( alignment, + VERTICAL_ALIGNMENT_STRING_TABLE, + VERTICAL_ALIGNMENT_STRING_TABLE_COUNT ); return std::string( name ); } @@ -110,12 +97,24 @@ const char* VERTEX_SHADER = DALI_COMPOSE_SHADER( uniform mediump vec4 pixelArea; varying mediump vec2 vTexCoord;\n \n + + //Visual size and offset + uniform mediump vec2 offset;\n + uniform mediump vec2 size;\n + uniform mediump vec4 offsetSizeMode;\n + uniform mediump vec2 origin;\n + uniform mediump vec2 anchorPoint;\n + + vec4 ComputeVertexPosition()\n + {\n + vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n + vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n + return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n + }\n + void main()\n {\n - mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n - vertexPosition.xyz *= uSize;\n - vertexPosition = uMvpMatrix * vertexPosition;\n - \n + mediump vec4 vertexPosition = uMvpMatrix *ComputeVertexPosition();\n vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );\n gl_Position = vertexPosition;\n }\n @@ -134,27 +133,6 @@ const char* FRAGMENT_SHADER_ATLAS_CLAMP = DALI_COMPOSE_SHADER( }\n ); -Geometry CreateGeometry( VisualFactoryCache& factoryCache, ImageDimensions gridSize ) -{ - Geometry geometry; - - if( gridSize == ImageDimensions( 1, 1 ) ) - { - geometry = factoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY ); - if( !geometry ) - { - geometry = VisualFactoryCache::CreateQuadGeometry(); - factoryCache.SaveGeometry( VisualFactoryCache::QUAD_GEOMETRY, geometry ); - } - } - else - { - geometry = VisualFactoryCache::CreateGridGeometry( gridSize ); - } - - return geometry; -} - } // unnamed namespace TextVisualPtr TextVisual::New( VisualFactoryCache& factoryCache ) @@ -162,22 +140,6 @@ TextVisualPtr TextVisual::New( VisualFactoryCache& factoryCache ) return new TextVisual( factoryCache ); } -void TextVisual::SetSize( const Vector2& size ) -{ - const Text::Controller::UpdateTextType updateTextType = mController->Relayout( size ); - - if( ( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) ) || - !mRenderer ) - { - if( !mRenderer ) - { - mRenderer = Text::Backend::Get().NewRenderer( mRenderingBackend ); - } - - RenderText(); - } -} - float TextVisual::GetHeightForWidth( float width ) const { return mController->GetHeightForWidth( width ); @@ -193,9 +155,7 @@ void TextVisual::DoCreatePropertyMap( Property::Map& map ) const Property::Value value; map.Clear(); - map.Insert( Toolkit::VisualProperty::TYPE, Toolkit::Visual::TEXT ); - - map.Insert( Toolkit::TextVisual::Property::RENDERING_BACKEND, mRenderingBackend ); + map.Insert( Toolkit::VisualProperty::TYPE, Toolkit::DevelVisual::TEXT ); std::string text; mController->GetText( text ); @@ -214,29 +174,15 @@ void TextVisual::DoCreatePropertyMap( Property::Map& map ) const map.Insert( Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT, GetVerticalAlignment( mController->GetVerticalAlignment() ) ); - map.Insert( Toolkit::TextVisual::Property::TEXT_COLOR, mController->GetTextColor() ); + map.Insert( Toolkit::TextVisual::Property::TEXT_COLOR, mController->GetDefaultColor() ); map.Insert( Toolkit::TextVisual::Property::ENABLE_MARKUP, mController->IsMarkupProcessorEnabled() ); - - map.Insert( Toolkit::TextVisual::Property::LINE_SPACING, mController->GetDefaultLineSpacing() ); - - GetUnderlineProperties( mController, value, Text::EffectStyle::DEFAULT ); - map.Insert( Toolkit::TextVisual::Property::UNDERLINE, value ); - - GetShadowProperties( mController, value, Text::EffectStyle::DEFAULT ); - map.Insert( Toolkit::TextVisual::Property::SHADOW, value ); - - GetOutlineProperties( mController, value, Text::EffectStyle::DEFAULT ); - map.Insert( Toolkit::TextVisual::Property::OUTLINE, value ); - - map.Insert( Toolkit::TextVisual::Property::BATCHING_ENABLED, false ); // TODO } TextVisual::TextVisual( VisualFactoryCache& factoryCache ) : Visual::Base( factoryCache ), mController( Text::Controller::New() ), - mRenderingBackend( Toolkit::Text::DEFAULT_RENDERING_BACKEND ), - mHasBeenStaged( false ) + mTypesetter( Text::Typesetter::New( mController->GetTextModel() ) ) { } @@ -262,11 +208,7 @@ void TextVisual::DoSetProperties( const Property::Map& propertyMap ) } case Property::Key::STRING: { - if( keyValue.first.stringKey == RENDERING_BACKEND_PROPERTY ) - { - DoSetProperty( Toolkit::TextVisual::Property::RENDERING_BACKEND, keyValue.second ); - } - else if( keyValue.first.stringKey == TEXT_PROPERTY ) + if( keyValue.first.stringKey == TEXT_PROPERTY ) { DoSetProperty( Toolkit::TextVisual::Property::TEXT, keyValue.second ); } @@ -302,52 +244,16 @@ void TextVisual::DoSetProperties( const Property::Map& propertyMap ) { DoSetProperty( Toolkit::TextVisual::Property::ENABLE_MARKUP, keyValue.second ); } - else if( keyValue.first.stringKey == ENABLE_AUTO_SCROLL_PROPERTY ) - { - DoSetProperty( Toolkit::TextVisual::Property::ENABLE_AUTO_SCROLL, keyValue.second ); - } - else if( keyValue.first.stringKey == AUTO_SCROLL_SPEED_PROPERTY ) - { - DoSetProperty( Toolkit::TextVisual::Property::AUTO_SCROLL_SPEED, keyValue.second ); - } - else if( keyValue.first.stringKey == AUTO_SCROLL_LOOP_COUNT_PROPERTY ) - { - DoSetProperty( Toolkit::TextVisual::Property::AUTO_SCROLL_LOOP_COUNT, keyValue.second ); - } - else if( keyValue.first.stringKey == AUTO_SCROLL_GAP_PROPERTY ) - { - DoSetProperty( Toolkit::TextVisual::Property::AUTO_SCROLL_GAP, keyValue.second ); - } - else if( keyValue.first.stringKey == LINE_SPACING_PROPERTY ) - { - DoSetProperty( Toolkit::TextVisual::Property::LINE_SPACING, keyValue.second ); - } - else if( keyValue.first.stringKey == UNDERLINE_PROPERTY ) - { - DoSetProperty( Toolkit::TextVisual::Property::UNDERLINE, keyValue.second ); - } - else if( keyValue.first.stringKey == SHADOW_PROPERTY ) - { - DoSetProperty( Toolkit::TextVisual::Property::SHADOW, keyValue.second ); - } - else if( keyValue.first.stringKey == OUTLINE_PROPERTY ) - { - DoSetProperty( Toolkit::TextVisual::Property::OUTLINE, keyValue.second ); - } - else if( keyValue.first.stringKey == BATCHING_ENABLED_PROPERTY ) - { - DoSetProperty( Toolkit::TextVisual::Property::BATCHING_ENABLED, keyValue.second ); - } break; } } } - // Retrieve the layout engine to set whether to elide the text and set the cursor's width. - Text::LayoutEngine& engine = mController->GetLayoutEngine(); - // Elide the text if it exceeds the boundaries. - engine.SetTextEllipsisEnabled( true ); + mController->SetTextElideEnabled( true ); + + // Retrieve the layout engine to set the cursor's width. + Text::Layout::Engine& engine = mController->GetLayoutEngine(); // Sets 0 as cursor's width. engine.SetCursorWidth( 0u ); // Do not layout space for the cursor. @@ -355,64 +261,29 @@ void TextVisual::DoSetProperties( const Property::Map& propertyMap ) void TextVisual::DoSetOnStage( Actor& actor ) { - // TODO Create the actual renderer(s) for the text!!!! - // Will crash if no mImpl->mRenderer is set. - Geometry geometry; - Shader shader; + mControl = actor; - geometry = CreateGeometry( mFactoryCache, ImageDimensions( 1, 1 ) ); + CreateRenderer(); +} - shader = mFactoryCache.GetShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP ); - if( !shader ) +void TextVisual::DoSetOffStage( Actor& actor ) +{ + if( mImpl->mRenderer ) { - shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_ATLAS_CLAMP ); - mFactoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP, shader ); - } - - mImpl->mRenderer = Renderer::New( geometry, shader ); + // Removes the renderer from the actor. + actor.RemoveRenderer( mImpl->mRenderer ); - mSelf = actor; - - if( mHasBeenStaged ) - { - RenderText(); - } - else - { - mHasBeenStaged = true; + DestroyRenderer(); } -} -void TextVisual::DoSetOffStage( Actor& actor ) -{ - mSelf.Reset(); + // Resets the control handle. + mControl.Reset(); } void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue ) { switch( index ) { - case Toolkit::TextVisual::Property::RENDERING_BACKEND: - { - int backend = propertyValue.Get(); - -#ifndef ENABLE_VECTOR_BASED_TEXT_RENDERING - if( Text::RENDERING_VECTOR_BASED == backend ) - { - backend = TextAbstraction::BITMAP_GLYPH; // Fallback to bitmap-based rendering - } -#endif - if( mRenderingBackend != backend ) - { - mRenderingBackend = backend; - mRenderer.Reset(); - - // When using the vector-based rendering, the size of the GLyphs are different - TextAbstraction::GlyphType glyphType = ( Text::RENDERING_VECTOR_BASED == mRenderingBackend ) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH; - mController->SetGlyphType( glyphType ); - } - break; - } case Toolkit::TextVisual::Property::TEXT: { mController->SetText( propertyValue.Get() ); @@ -445,11 +316,11 @@ void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Propert } case Toolkit::TextVisual::Property::HORIZONTAL_ALIGNMENT: { - LayoutEngine::HorizontalAlignment alignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN ); - if( Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::HorizontalAlignment >( propertyValue.Get< std::string >().c_str(), - HORIZONTAL_ALIGNMENT_STRING_TABLE, - HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT, - alignment ) ) + Toolkit::Text::Layout::HorizontalAlignment alignment( Toolkit::Text::Layout::HORIZONTAL_ALIGN_BEGIN ); + if( Scripting::GetEnumeration< Toolkit::Text::Layout::HorizontalAlignment >( propertyValue.Get< std::string >().c_str(), + HORIZONTAL_ALIGNMENT_STRING_TABLE, + HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT, + alignment ) ) { mController->SetHorizontalAlignment( alignment ); } @@ -457,11 +328,11 @@ void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Propert } case Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT: { - LayoutEngine::VerticalAlignment alignment( LayoutEngine::VERTICAL_ALIGN_BOTTOM ); - if( Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::VerticalAlignment >( propertyValue.Get< std::string >().c_str(), - VERTICAL_ALIGNMENT_STRING_TABLE, - VERTICAL_ALIGNMENT_STRING_TABLE_COUNT, - alignment ) ) + Toolkit::Text::Layout::VerticalAlignment alignment( Toolkit::Text::Layout::VERTICAL_ALIGN_BOTTOM ); + if( Scripting::GetEnumeration< Toolkit::Text::Layout::VerticalAlignment >( propertyValue.Get< std::string >().c_str(), + VERTICAL_ALIGNMENT_STRING_TABLE, + VERTICAL_ALIGNMENT_STRING_TABLE_COUNT, + alignment ) ) { mController->SetVerticalAlignment( alignment ); } @@ -469,11 +340,10 @@ void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Propert } case Toolkit::TextVisual::Property::TEXT_COLOR: { - const Vector4 textColor = propertyValue.Get< Vector4 >(); - if( mController->GetTextColor() != textColor ) + const Vector4& textColor = propertyValue.Get< Vector4 >(); + if( mController->GetDefaultColor() != textColor ) { - mController->SetTextColor( textColor ); - mRenderer.Reset(); + mController->SetDefaultColor( textColor ); } break; } @@ -483,153 +353,6 @@ void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Propert mController->SetMarkupProcessorEnabled( enableMarkup ); break; } - case Toolkit::TextVisual::Property::ENABLE_AUTO_SCROLL: - { - // nothing to do. - break; - } - case Toolkit::TextVisual::Property::AUTO_SCROLL_SPEED: - { - // nothing to do. - break; - } - case Toolkit::TextVisual::Property::AUTO_SCROLL_LOOP_COUNT: - { - // nothing to do. - break; - } - case Toolkit::TextVisual::Property::AUTO_SCROLL_GAP: - { - // nothing to do. - break; - } - case Toolkit::TextVisual::Property::LINE_SPACING: - { - const float lineSpacing = propertyValue.Get(); - mController->SetDefaultLineSpacing( lineSpacing ); - mRenderer.Reset(); - break; - } - case Toolkit::TextVisual::Property::UNDERLINE: - { - // TODO : This switch can be removed when the deprecated SHADOW_OFFSET and SHADOW_COLOR properties are finally removed. - // Only the code for the MAP case should be kept. - switch( propertyValue.GetType() ) - { - case Property::VECTOR4: - { - const Vector4 color = propertyValue.Get(); - if( mController->GetUnderlineColor() != color ) - { - mController->SetUnderlineColor( color ); - mRenderer.Reset(); - } - break; - } - case Property::FLOAT: - { - float height = propertyValue.Get(); - if( fabsf( mController->GetUnderlineHeight() - height ) > Math::MACHINE_EPSILON_1000 ) - { - mController->SetUnderlineHeight( height ); - mRenderer.Reset(); - } - break; - } - case Property::BOOLEAN: - { - const bool enabled = propertyValue.Get(); - if( mController->IsUnderlineEnabled() != enabled ) - { - mController->SetUnderlineEnabled( enabled ); - mRenderer.Reset(); - } - break; - } - case Property::MAP: - { - const bool update = SetUnderlineProperties( mController, propertyValue, Text::EffectStyle::DEFAULT ); - if( update ) - { - mRenderer.Reset(); - } - break; - } - default: - { - // Nothing to do. - break; - } - } - - break; - } - case Toolkit::TextVisual::Property::SHADOW: - { - // TODO : This switch can be removed when the deprecated SHADOW_OFFSET and SHADOW_COLOR properties are finally removed. - // Only the code for the MAP case should be kept. - switch( propertyValue.GetType() ) - { - case Property::VECTOR2: - { - const Vector2 shadowOffset = propertyValue.Get(); - if( mController->GetShadowOffset() != shadowOffset ) - { - mController->SetShadowOffset( shadowOffset ); - mRenderer.Reset(); - } - break; - } - case Property::VECTOR4: - { - const Vector4 shadowColor = propertyValue.Get(); - if( mController->GetShadowColor() != shadowColor ) - { - mController->SetShadowColor( shadowColor ); - mRenderer.Reset(); - } - break; - } - case Property::MAP: - { - const bool update = SetShadowProperties( mController, propertyValue, Text::EffectStyle::DEFAULT ); - if( update ) - { - mRenderer.Reset(); - } - break; - } - default: - { - // Nothing to do. - break; - } - } - break; - } - case Toolkit::TextVisual::Property::EMBOSS: - { - const bool update = SetEmbossProperties( mController, propertyValue, Text::EffectStyle::DEFAULT ); - if( update ) - { - mRenderer.Reset(); - } - break; - } - case Toolkit::TextVisual::Property::OUTLINE: - { - const bool update = SetOutlineProperties( mController, propertyValue, Text::EffectStyle::DEFAULT ); - if( update ) - { - mRenderer.Reset(); - } - break; - } - case Toolkit::TextVisual::Property::BATCHING_ENABLED: - { - // TODO - break; - } default: { // Should not arrive here. @@ -644,11 +367,6 @@ Dali::Property::Value TextVisual::DoGetProperty( Dali::Property::Index index ) switch( index ) { - case Toolkit::TextVisual::Property::RENDERING_BACKEND: - { - value = mRenderingBackend; - break; - } case Toolkit::TextVisual::Property::TEXT: { std::string text; @@ -678,9 +396,9 @@ Dali::Property::Value TextVisual::DoGetProperty( Dali::Property::Index index ) } case Toolkit::TextVisual::Property::HORIZONTAL_ALIGNMENT: { - const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( mController->GetHorizontalAlignment(), - HORIZONTAL_ALIGNMENT_STRING_TABLE, - HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT ); + const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::HorizontalAlignment >( mController->GetHorizontalAlignment(), + HORIZONTAL_ALIGNMENT_STRING_TABLE, + HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT ); if( name ) { value = std::string( name ); @@ -689,9 +407,9 @@ Dali::Property::Value TextVisual::DoGetProperty( Dali::Property::Index index ) } case Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT: { - const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( mController->GetVerticalAlignment(), - VERTICAL_ALIGNMENT_STRING_TABLE, - VERTICAL_ALIGNMENT_STRING_TABLE_COUNT ); + const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::VerticalAlignment >( mController->GetVerticalAlignment(), + VERTICAL_ALIGNMENT_STRING_TABLE, + VERTICAL_ALIGNMENT_STRING_TABLE_COUNT ); if( name ) { value = std::string( name ); @@ -700,7 +418,7 @@ Dali::Property::Value TextVisual::DoGetProperty( Dali::Property::Index index ) } case Toolkit::TextVisual::Property::TEXT_COLOR: { - value = mController->GetTextColor(); + value = mController->GetDefaultColor(); break; } case Toolkit::TextVisual::Property::ENABLE_MARKUP: @@ -708,56 +426,6 @@ Dali::Property::Value TextVisual::DoGetProperty( Dali::Property::Index index ) value = mController->IsMarkupProcessorEnabled(); break; } - case Toolkit::TextVisual::Property::ENABLE_AUTO_SCROLL: - { - // nothing to do. - break; - } - case Toolkit::TextVisual::Property::AUTO_SCROLL_SPEED: - { - // nothing to do. - break; - } - case Toolkit::TextVisual::Property::AUTO_SCROLL_LOOP_COUNT: - { - // nothing to do. - break; - } - case Toolkit::TextVisual::Property::AUTO_SCROLL_GAP: - { - // nothing to do. - break; - } - case Toolkit::TextVisual::Property::LINE_SPACING: - { - value = mController->GetDefaultLineSpacing(); - break; - } - case Toolkit::TextVisual::Property::UNDERLINE: - { - GetUnderlineProperties( mController, value, Text::EffectStyle::DEFAULT ); - break; - } - case Toolkit::TextVisual::Property::SHADOW: - { - GetShadowProperties( mController, value, Text::EffectStyle::DEFAULT ); - break; - } - case Toolkit::TextVisual::Property::EMBOSS: - { - GetEmbossProperties( mController, value, Text::EffectStyle::DEFAULT ); - break; - } - case Toolkit::TextVisual::Property::OUTLINE: - { - GetOutlineProperties( mController, value, Text::EffectStyle::DEFAULT ); - break; - } - case Toolkit::TextVisual::Property::BATCHING_ENABLED: - { - // TODO - break; - } default: { // Should not arrive here. @@ -768,37 +436,125 @@ Dali::Property::Value TextVisual::DoGetProperty( Dali::Property::Index index ) return value; } -void TextVisual::RenderText() +void TextVisual::OnSetTransform() { - Actor self = mSelf.GetHandle(); - if( !self ) + CreateRenderer(); +} + +void TextVisual::CreateRenderer() +{ + Actor control = mControl.GetHandle(); + if( !control ) { - // Nothing to do if the handle is not initialized. + // Nothing to do. return; } - Actor renderableActor; + // Calculates the size to be used to relayout. + Vector2 relayoutSize; + + const bool isWidthRelative = fabsf( mImpl->mTransform.mOffsetSizeMode.z ) < Math::MACHINE_EPSILON_1000; + const bool isHeightRelative = fabsf( mImpl->mTransform.mOffsetSizeMode.w ) < Math::MACHINE_EPSILON_1000; - if( mRenderer ) + // Round the size and offset to avoid pixel alignement issues. + relayoutSize.width = floorf( 0.5f + ( isWidthRelative ? mImpl->mControlSize.width * mImpl->mTransform.mSize.x : mImpl->mTransform.mSize.width ) ); + relayoutSize.height = floorf( 0.5f + ( isHeightRelative ? mImpl->mControlSize.height * mImpl->mTransform.mSize.y : mImpl->mTransform.mSize.height ) ); + + if( ( fabsf( relayoutSize.width ) < Math::MACHINE_EPSILON_1000 ) || ( fabsf( relayoutSize.height ) < Math::MACHINE_EPSILON_1000 ) ) { - renderableActor = mRenderer->Render( mController->GetView(), Toolkit::DepthIndex::TEXT ); + // Remove any renderer previously set. + if( mImpl->mRenderer ) + { + control.RemoveRenderer( mImpl->mRenderer ); + + DestroyRenderer(); + } + + // Nothing else to do if the relayout size is zero. + return; } - if( renderableActor != mRenderableActor ) + const Text::Controller::UpdateTextType updateTextType = mController->Relayout( relayoutSize ); + + if( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) ) { - UnparentAndReset( mRenderableActor ); + // Remove any renderer previously set. + if( mImpl->mRenderer ) + { + control.RemoveRenderer( mImpl->mRenderer ); + + DestroyRenderer(); + } - if( renderableActor ) + if( ( relayoutSize.width > Math::MACHINE_EPSILON_1000 ) && + ( relayoutSize.height > Math::MACHINE_EPSILON_1000 ) ) { - const Vector2& scrollOffset = mController->GetScrollPosition(); - renderableActor.SetPosition( scrollOffset.x, scrollOffset.y ); + PixelData data = mTypesetter->Render( relayoutSize ); + + Geometry geometry; + Shader shader; + TextureSet textureSet; + + Vector4 atlasRect; + + textureSet = mFactoryCache.GetAtlasManager()->Add( atlasRect, data ); + mImpl->mFlags |= Impl::IS_ATLASING_APPLIED; + + // Filter mode needs to be set to nearest to avoid blurry text. + Sampler sampler = Sampler::New(); + sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST ); + textureSet.SetSampler( 0u, sampler ); + + geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY ); + if( !geometry ) + { + geometry = VisualFactoryCache::CreateQuadGeometry(); + mFactoryCache.SaveGeometry( VisualFactoryCache::QUAD_GEOMETRY , geometry ); + } + + shader = mFactoryCache.GetShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP ); + if( !shader ) + { + shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_ATLAS_CLAMP ); + mFactoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP, shader ); + } + shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT ); + + mImpl->mRenderer = Renderer::New( geometry, shader ); + mImpl->mRenderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, Toolkit::DepthIndex::TEXT ); + mImpl->mRenderer.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, atlasRect ); + + mImpl->mRenderer.SetTextures( textureSet ); + + control.AddRenderer( mImpl->mRenderer ); - self.Add( renderableActor ); + //Register transform properties + mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT ); + + mImpl->mFlags |= Impl::IS_FROM_CACHE; } - mRenderableActor = renderableActor; } } +void TextVisual::DestroyRenderer() +{ + // Removes the text's image from the texture atlas. + Vector4 atlasRect; + + const Property::Index index = mImpl->mRenderer.GetPropertyIndex( ATLAS_RECT_UNIFORM_NAME ); + if( index != Property::INVALID_INDEX ) + { + const Property::Value& atlasRectValue = mImpl->mRenderer.GetProperty( index ); + atlasRectValue.Get( atlasRect ); + + const TextureSet& textureSet = mImpl->mRenderer.GetTextures(); + mFactoryCache.GetAtlasManager()->Remove( textureSet, atlasRect ); + } + + // Resets the renderer. + mImpl->mRenderer.Reset(); +} + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/visuals/text/text-visual.h b/dali-toolkit/internal/visuals/text/text-visual.h index dd1abf6..777729b 100644 --- a/dali-toolkit/internal/visuals/text/text-visual.h +++ b/dali-toolkit/internal/visuals/text/text-visual.h @@ -18,13 +18,9 @@ * */ -// EXTERNAL INCLUDES -#include -#include - // INTERNAL INCLUDES #include -#include +#include #include namespace Dali @@ -84,12 +80,7 @@ public: // from Visual::Base /** * @copydoc Visual::Base::GetHeightForWidth() */ - float GetHeightForWidth( float width ) const; - - /** - * @copydoc Visual::Base::GetNaturalSize() - */ - virtual void SetSize( const Vector2& size ); + virtual float GetHeightForWidth( float width ) const; /** * @copydoc Visual::Base::GetNaturalSize() @@ -142,23 +133,27 @@ protected: */ virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index ); -private: - /** - * @brief Render view, create and attach actor(s) to this TextView. - * @todo In a next patch a new text render back-end won't add extra actors. + * @copydoc Visual::Base::OnSetTransform */ - void RenderText(); + virtual void OnSetTransform(); private: - Text::ControllerPtr mController; ///< The text's controller. - WeakHandle mSelf; - Text::RendererPtr mRenderer; - Actor mRenderableActor; + /** + * @brief Creates the text's renderer. + */ + void CreateRenderer(); + + /** + * @brief Destroys the text's renderer. + */ + void DestroyRenderer(); - int mRenderingBackend; - bool mHasBeenStaged : 1; +private: + Text::ControllerPtr mController; ///< The text's controller. + Text::TypesetterPtr mTypesetter; ///< The text's typesetter. + WeakHandle mControl; ///< The control where the renderer is added. }; } // namespace Internal diff --git a/dali-toolkit/internal/visuals/transition-data-impl.cpp b/dali-toolkit/internal/visuals/transition-data-impl.cpp index 8ccb354..a91b8ab 100644 --- a/dali-toolkit/internal/visuals/transition-data-impl.cpp +++ b/dali-toolkit/internal/visuals/transition-data-impl.cpp @@ -174,7 +174,7 @@ TransitionData::Animator* TransitionData::ConvertMap( const Property::Map& map) bool valid = true; Vector4 controlPoints; Property::Array *array = value.GetArray(); - if( array->Count() >= 4 ) + if( array && array->Count() >= 4 ) { for( size_t vecIdx = 0; vecIdx < 4; ++vecIdx ) { diff --git a/dali-toolkit/internal/visuals/visual-base-data-impl.cpp b/dali-toolkit/internal/visuals/visual-base-data-impl.cpp index 1826196..158c432 100644 --- a/dali-toolkit/internal/visuals/visual-base-data-impl.cpp +++ b/dali-toolkit/internal/visuals/visual-base-data-impl.cpp @@ -82,8 +82,9 @@ Dali::Vector2 PointToVector2( Toolkit::Align::Type point, Toolkit::Direction::Ty } // unnamed namespace Internal::Visual::Base::Impl::Impl() -: mCustomShader(NULL), +: mCustomShader( NULL ), mTransform(), + mControlSize( Vector2::ZERO ), mDepthIndex( 0.0f ), mFlags( 0 ) { @@ -267,6 +268,13 @@ void Internal::Visual::Base::Impl::Transform::RegisterUniforms( Dali::Renderer r renderer.RegisterProperty( ANCHOR_POINT, Vector2(0.5,0.5) - PointToVector2( mAnchorPoint, direction ) ); } +Vector2 Internal::Visual::Base::Impl::Transform::GetVisualSize( const Vector2& controlSize ) +{ + return Vector2( Lerp( mOffsetSizeMode.x, mSize.x * controlSize.x, mSize.x ), + Lerp( mOffsetSizeMode.y, mSize.y * controlSize.y, mSize.y ) ); +} + + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/visuals/visual-base-data-impl.h b/dali-toolkit/internal/visuals/visual-base-data-impl.h index f8ceabf..e631f43 100644 --- a/dali-toolkit/internal/visuals/visual-base-data-impl.h +++ b/dali-toolkit/internal/visuals/visual-base-data-impl.h @@ -73,13 +73,14 @@ struct Base::Impl void SetPropertyMap( const Property::Map& map ); void GetPropertyMap( Property::Map& map ) const; void RegisterUniforms( Renderer renderer, Toolkit::Direction::Type direction ); + Vector2 GetVisualSize( const Vector2& controlSize ); }; Renderer mRenderer; CustomShader* mCustomShader; std::string mName; Transform mTransform; - Vector2 mSize; + Size mControlSize; float mDepthIndex; int mFlags; diff --git a/dali-toolkit/internal/visuals/visual-base-impl.cpp b/dali-toolkit/internal/visuals/visual-base-impl.cpp index e8ed4a3..12b6b35 100644 --- a/dali-toolkit/internal/visuals/visual-base-impl.cpp +++ b/dali-toolkit/internal/visuals/visual-base-impl.cpp @@ -84,6 +84,13 @@ void Visual::Base::SetProperties( const Property::Map& propertyMap ) DoSetProperties( propertyMap ); } +void Visual::Base::SetTransformAndSize( const Property::Map& transform, Size controlSize ) +{ + mImpl->mControlSize = controlSize; + mImpl->mTransform.SetPropertyMap( transform ); + OnSetTransform(); +} + void Visual::Base::SetName( const std::string& name ) { mImpl->mName = name; @@ -94,16 +101,6 @@ const std::string& Visual::Base::GetName() return mImpl->mName; } -void Visual::Base::SetSize( const Vector2& size ) -{ - mImpl->mSize = size; -} - -const Vector2& Visual::Base::GetSize() const -{ - return mImpl->mSize; -} - float Visual::Base::GetHeightForWidth( float width ) const { return 0.f; @@ -217,11 +214,10 @@ void Visual::Base::SetProperty( Dali::Property::Index index, const Dali::Propert { if( index == Dali::Toolkit::Visual::DevelProperty::TRANSFORM ) { - Property::Map* map = propertyValue.GetMap(); - if( map ) + Property::Map* transformMap = propertyValue.GetMap(); + if( transformMap ) { - mImpl->mTransform.SetPropertyMap( *map ); - OnSetTransform(); + SetTransformAndSize( *transformMap, mImpl->mControlSize ); } } diff --git a/dali-toolkit/internal/visuals/visual-base-impl.h b/dali-toolkit/internal/visuals/visual-base-impl.h index 4028ca4..cb0c7be 100644 --- a/dali-toolkit/internal/visuals/visual-base-impl.h +++ b/dali-toolkit/internal/visuals/visual-base-impl.h @@ -84,12 +84,7 @@ public: /** * @copydoc Toolkit::Visual::Base::SetSize */ - virtual void SetSize( const Vector2& size ); - - /** - * @copydoc Toolkit::Visual::Base::GetSize - */ - const Vector2& GetSize() const; + void SetTransformAndSize( const Property::Map& transform, Size controlSize ); /** * @copydoc Toolkit::Visual::Base::GetHeightForWidth @@ -187,9 +182,10 @@ protected: virtual void DoSetProperties( const Property::Map& propertyMap ) = 0; /** - * @brief Called when transform property changes + * @brief Called when transform or control size changes + * ( Of use to SVG and Text visuals ) */ - virtual void OnSetTransform(){} + virtual void OnSetTransform() = 0; protected: diff --git a/dali-toolkit/internal/visuals/visual-factory-cache.cpp b/dali-toolkit/internal/visuals/visual-factory-cache.cpp index 51c6bc2..bf6814d 100644 --- a/dali-toolkit/internal/visuals/visual-factory-cache.cpp +++ b/dali-toolkit/internal/visuals/visual-factory-cache.cpp @@ -150,16 +150,6 @@ bool VisualFactoryCache::CleanRendererCache( const std::string& key ) return false; } -void VisualFactoryCache::CacheWireframeRenderer( Renderer& renderer ) -{ - mWireframeRenderer = renderer; -} - -Renderer VisualFactoryCache::GetWireframeRenderer() -{ - return mWireframeRenderer; -} - Geometry VisualFactoryCache::CreateQuadGeometry() { const float halfWidth = 0.5f; diff --git a/dali-toolkit/internal/visuals/visual-factory-cache.h b/dali-toolkit/internal/visuals/visual-factory-cache.h index 0b77e53..8bbae5c 100644 --- a/dali-toolkit/internal/visuals/visual-factory-cache.h +++ b/dali-toolkit/internal/visuals/visual-factory-cache.h @@ -69,7 +69,8 @@ public: IMAGE_SHADER_ATLAS_CUSTOM_WRAP, NINE_PATCH_SHADER, SVG_SHADER, - SHADER_TYPE_MAX = SVG_SHADER + WIREFRAME_SHADER, + SHADER_TYPE_MAX = WIREFRAME_SHADER }; /** @@ -81,7 +82,8 @@ public: BORDER_GEOMETRY, NINE_PATCH_GEOMETRY, NINE_PATCH_BORDER_GEOMETRY, - GEOMETRY_TYPE_MAX = NINE_PATCH_BORDER_GEOMETRY + WIREFRAME_GEOMETRY, + GEOMETRY_TYPE_MAX = WIREFRAME_GEOMETRY }; public: @@ -173,16 +175,6 @@ public: bool CleanRendererCache( const std::string& key ); /** - * @brief Cache the wireframe renderer - */ - void CacheWireframeRenderer( Renderer& renderer ); - - /** - * @brief Request the wireframe renderer; - */ - Renderer GetWireframeRenderer(); - - /** * Get the image atlas manager. * @return A pointer to the atlas manager */ diff --git a/dali-toolkit/internal/visuals/visual-factory-impl.cpp b/dali-toolkit/internal/visuals/visual-factory-impl.cpp index 9b77e63..d2e9ee2 100644 --- a/dali-toolkit/internal/visuals/visual-factory-impl.cpp +++ b/dali-toolkit/internal/visuals/visual-factory-impl.cpp @@ -29,6 +29,7 @@ // INTERNAL INCLUDES #include #include +#include #include #include #include @@ -97,103 +98,105 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& property mFactoryCache = new VisualFactoryCache(); } - // Return a new WireframeVisual if we have debug enabled - if( mDebugEnabled ) - { - return Toolkit::Visual::Base( WireframeVisual::New( *( mFactoryCache.Get() ) ).Get() ); - } - Visual::BasePtr visualPtr; - Property::Value* typeValue = propertyMap.Find( Toolkit::VisualProperty::TYPE, VISUAL_TYPE ); - Toolkit::Visual::Type visualType = Toolkit::Visual::IMAGE; // Default to IMAGE type. - if( typeValue ) + if( mDebugEnabled ) { - Scripting::GetEnumerationProperty( *typeValue, VISUAL_TYPE_TABLE, VISUAL_TYPE_TABLE_COUNT, visualType ); + //Create a WireframeVisual if we have debug enabled + visualPtr = WireframeVisual::New( *( mFactoryCache.Get() ) ); } - - switch( visualType ) + else { - case Toolkit::Visual::BORDER: + Property::Value* typeValue = propertyMap.Find( Toolkit::VisualProperty::TYPE, VISUAL_TYPE ); + Toolkit::DevelVisual::Type visualType = Toolkit::DevelVisual::IMAGE; // Default to IMAGE type. + if( typeValue ) { - visualPtr = BorderVisual::New( *( mFactoryCache.Get() ) ); - break; + Scripting::GetEnumerationProperty( *typeValue, VISUAL_TYPE_TABLE, VISUAL_TYPE_TABLE_COUNT, visualType ); } - case Toolkit::Visual::COLOR: + switch( visualType ) { - visualPtr = ColorVisual::New( *( mFactoryCache.Get() ) ); - break; - } + case Toolkit::Visual::BORDER: + { + visualPtr = BorderVisual::New( *( mFactoryCache.Get() ) ); + break; + } - case Toolkit::Visual::GRADIENT: - { - visualPtr = GradientVisual::New( *( mFactoryCache.Get() ) ); - break; - } + case Toolkit::Visual::COLOR: + { + visualPtr = ColorVisual::New( *( mFactoryCache.Get() ) ); + break; + } - case Toolkit::Visual::IMAGE: - { - Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME ); - std::string imageUrl; - if( imageURLValue && imageURLValue->Get( imageUrl ) ) + case Toolkit::Visual::GRADIENT: { - // first resolve url type to know which visual to create - UrlType::Type type = ResolveUrlType( imageUrl ); - if( UrlType::N_PATCH == type ) - { - visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ), imageUrl ); - } - else if( UrlType::SVG == type ) - { - visualPtr = SvgVisual::New( *( mFactoryCache.Get() ), imageUrl ); - } - else // Regular image + visualPtr = GradientVisual::New( *( mFactoryCache.Get() ) ); + break; + } + + case Toolkit::Visual::IMAGE: + { + Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME ); + std::string imageUrl; + if( imageURLValue && imageURLValue->Get( imageUrl ) ) { - bool batchingEnabled( false ); - Property::Value* batchingEnabledValue = propertyMap.Find( Toolkit::ImageVisual::Property::BATCHING_ENABLED, BATCHING_ENABLED ); - if( batchingEnabledValue ) + // first resolve url type to know which visual to create + UrlType::Type type = ResolveUrlType( imageUrl ); + if( UrlType::N_PATCH == type ) { - batchingEnabledValue->Get( batchingEnabled ); + visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ), imageUrl ); } - - if( batchingEnabled ) + else if( UrlType::SVG == type ) { - visualPtr = BatchImageVisual::New( *( mFactoryCache.Get() ), imageUrl ); - break; + visualPtr = SvgVisual::New( *( mFactoryCache.Get() ), imageUrl ); } - else + else // Regular image { - visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), imageUrl ); + bool batchingEnabled( false ); + Property::Value* batchingEnabledValue = propertyMap.Find( Toolkit::ImageVisual::Property::BATCHING_ENABLED, BATCHING_ENABLED ); + if( batchingEnabledValue ) + { + batchingEnabledValue->Get( batchingEnabled ); + } + + if( batchingEnabled ) + { + visualPtr = BatchImageVisual::New( *( mFactoryCache.Get() ), imageUrl ); + break; + } + else + { + visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), imageUrl ); + } } } - } - break; - } + break; + } - case Toolkit::Visual::MESH: - { - visualPtr = MeshVisual::New( *( mFactoryCache.Get() ) ); - break; - } + case Toolkit::Visual::MESH: + { + visualPtr = MeshVisual::New( *( mFactoryCache.Get() ) ); + break; + } - case Toolkit::Visual::PRIMITIVE: - { - visualPtr = PrimitiveVisual::New( *( mFactoryCache.Get() ) ); - break; - } + case Toolkit::Visual::PRIMITIVE: + { + visualPtr = PrimitiveVisual::New( *( mFactoryCache.Get() ) ); + break; + } - case Toolkit::Visual::WIREFRAME: - { - visualPtr = WireframeVisual::New( *( mFactoryCache.Get() ) ); - break; - } + case Toolkit::Visual::WIREFRAME: + { + visualPtr = WireframeVisual::New( *( mFactoryCache.Get() ) ); + break; + } - case Toolkit::Visual::TEXT: - { - visualPtr = TextVisual::New( *( mFactoryCache.Get() ) ); - break; + case Toolkit::DevelVisual::TEXT: + { + visualPtr = TextVisual::New( *( mFactoryCache.Get() ) ); + break; + } } } @@ -258,7 +261,7 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const std::string& url, Image } else if( UrlType::SVG == type ) { - visualPtr = SvgVisual::New( *( mFactoryCache.Get() ), url, size ); + visualPtr = SvgVisual::New( *( mFactoryCache.Get() ), url ); } else // Regular image { diff --git a/dali-toolkit/internal/visuals/wireframe/wireframe-visual.cpp b/dali-toolkit/internal/visuals/wireframe/wireframe-visual.cpp index 2e1e4a3..396f13b 100644 --- a/dali-toolkit/internal/visuals/wireframe/wireframe-visual.cpp +++ b/dali-toolkit/internal/visuals/wireframe/wireframe-visual.cpp @@ -45,11 +45,24 @@ attribute mediump vec2 aPosition;\n uniform mediump mat4 uMvpMatrix;\n uniform mediump vec3 uSize;\n \n + +//Visual size and offset +uniform mediump vec2 offset;\n +uniform mediump vec2 size;\n +uniform mediump vec4 offsetSizeMode;\n +uniform mediump vec2 origin;\n +uniform mediump vec2 anchorPoint;\n + +vec4 ComputeVertexPosition()\n +{\n + vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n + vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n + return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n +}\n + void main()\n {\n - mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n - vertexPosition.xyz *= uSize;\n - gl_Position = uMvpMatrix * vertexPosition;\n + gl_Position = uMvpMatrix * ComputeVertexPosition();\n }\n ); @@ -109,15 +122,25 @@ Dali::Property::Value WireframeVisual::DoGetProperty( Dali::Property::Index inde void WireframeVisual::InitializeRenderer() { - mImpl->mRenderer = mFactoryCache.GetWireframeRenderer(); - if( !mImpl->mRenderer ) + Shader shader = mFactoryCache.GetShader( VisualFactoryCache::WIREFRAME_SHADER ); + if( !shader ) { - Geometry geometry = CreateQuadWireframeGeometry(); - Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER ); + shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER ); + mFactoryCache.SaveShader( VisualFactoryCache::WIREFRAME_SHADER, shader ); + } - mImpl->mRenderer = Renderer::New( geometry, shader); - mFactoryCache.CacheWireframeRenderer( mImpl->mRenderer ); + Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::WIREFRAME_GEOMETRY ); + if( !geometry ) + { + geometry = CreateQuadWireframeGeometry(); + mFactoryCache.SaveGeometry( VisualFactoryCache::WIREFRAME_GEOMETRY, geometry ); } + + //Create the renderer + mImpl->mRenderer = Renderer::New( geometry, shader); + + //Register transform properties + mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT ); } Geometry WireframeVisual::CreateQuadWireframeGeometry() @@ -150,6 +173,15 @@ Geometry WireframeVisual::CreateQuadWireframeGeometry() return geometry; } +void WireframeVisual::OnSetTransform() +{ + if( mImpl->mRenderer ) + { + //Register transform properties + mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT ); + } +} + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/visuals/wireframe/wireframe-visual.h b/dali-toolkit/internal/visuals/wireframe/wireframe-visual.h index 3756e00..19cbc46 100644 --- a/dali-toolkit/internal/visuals/wireframe/wireframe-visual.h +++ b/dali-toolkit/internal/visuals/wireframe/wireframe-visual.h @@ -90,6 +90,11 @@ protected: */ virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index ); + /** + * @copydoc Visual::Base::OnSetTransform + */ + virtual void OnSetTransform(); + private: /** * Create the geometry which presents the quad wireframe. diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index 90b3bb6..d3f4362 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -44,6 +44,7 @@ #include #include #include +#include namespace Dali { @@ -165,6 +166,16 @@ HandleIndex GetVisualProperty( return HandleIndex( handle, Property::INVALID_INDEX ); } +void SetDefaultTransform( Property::Map& propertyMap ) +{ + propertyMap.Clear(); + propertyMap + .Add( Toolkit::Visual::DevelProperty::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) ) + .Add( Toolkit::Visual::DevelProperty::Transform::Property::SIZE, Vector2(1.0f, 1.0f) ) + .Add( Toolkit::Visual::DevelProperty::Transform::Property::ORIGIN, Toolkit::Align::CENTER ) + .Add( Toolkit::Visual::DevelProperty::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER ) + .Add( Toolkit::Visual::DevelProperty::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO ); +} /** * Creates control through type registry @@ -747,22 +758,22 @@ void Control::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visu bool visualReplaced ( false ); Actor self = Self(); - if ( !mImpl->mVisuals.Empty() ) + if( !mImpl->mVisuals.Empty() ) { - RegisteredVisualContainer::Iterator iter; - // Check if visual (index) is already registered. Replace if so. - if ( FindVisual( index, mImpl->mVisuals, iter ) ) + RegisteredVisualContainer::Iterator iter; + // Check if visual (index) is already registered. Replace if so. + if ( FindVisual( index, mImpl->mVisuals, iter ) ) + { + if( (*iter)->visual && self.OnStage() ) { - if( (*iter)->visual && self.OnStage() ) - { - Toolkit::GetImplementation((*iter)->visual).SetOffStage( self ); - } - (*iter)->visual = visual; - visualReplaced = true; + Toolkit::GetImplementation((*iter)->visual).SetOffStage( self ); } + (*iter)->visual = visual; + visualReplaced = true; + } } - if ( !visualReplaced ) // New registration entry + if( !visualReplaced ) // New registration entry { mImpl->mVisuals.PushBack( new RegisteredVisual( index, visual, enabled ) ); } @@ -1142,7 +1153,9 @@ void Control::OnSizeSet(const Vector3& targetSize) if( visual ) { Vector2 size( targetSize ); - visual.SetSize( size ); + Property::Map transformMap; + SetDefaultTransform( transformMap ); + visual.SetTransformAndSize( transformMap, size ); } } @@ -1177,6 +1190,15 @@ void Control::OnRelayout( const Vector2& size, RelayoutContainer& container ) { container.Add( Self().GetChildAt( i ), size ); } + + Toolkit::Visual::Base visual = GetVisual( Toolkit::Control::Property::BACKGROUND ); + if( visual ) + { + Vector2 controlSize( size ); + Property::Map transformMap; + SetDefaultTransform( transformMap ); + visual.SetTransformAndSize( transformMap, controlSize ); + } } void Control::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) diff --git a/dali-toolkit/public-api/controls/image-view/image-view.h b/dali-toolkit/public-api/controls/image-view/image-view.h index d58e239..4585657 100644 --- a/dali-toolkit/public-api/controls/image-view/image-view.h +++ b/dali-toolkit/public-api/controls/image-view/image-view.h @@ -143,6 +143,8 @@ public: * If the string is empty, ImageView will not display anything. * * @SINCE_1_0.0 + * @REMARK_INTERNET + * @REMARK_STORAGE * @param[in] url The url of the image resource to display. * @return A handle to a newly allocated ImageView. */ @@ -154,6 +156,8 @@ public: * If the string is empty, ImageView will not display anything. * * @SINCE_1_1.10 + * @REMARK_INTERNET + * @REMARK_STORAGE * @param[in] url The url of the image resource to display. * @param [in] size The width and height to which to fit the loaded image. * @return A handle to a newly allocated ImageView. @@ -218,6 +222,8 @@ public: * If the URL is empty, ImageView will not display anything. * * @SINCE_1_1.4 + * @REMARK_INTERNET + * @REMARK_STORAGE * @param[in] url The URL to the image resource to display. */ void SetImage( const std::string& url ); @@ -228,6 +234,8 @@ public: * If the URL is empty, ImageView will not display anything. * * @SINCE_1_1.10 + * @REMARK_INTERNET + * @REMARK_STORAGE * @param[in] url The URL to the image resource to display. * @param [in] size The width and height to fit the loaded image to. */ diff --git a/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h b/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h index e013196..e9c5068 100644 --- a/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h +++ b/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h @@ -2,7 +2,7 @@ #define __DALI_TOOLKIT_ITEM_LAYOUT_H__ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. @@ -79,8 +79,11 @@ struct ItemRange */ ItemRange& operator=(const ItemRange& range) { - begin = range.begin; - end = range.end; + if( this != &range ) + { + begin = range.begin; + end = range.end; + } return *this; } diff --git a/dali-toolkit/public-api/controls/video-view/video-view.h b/dali-toolkit/public-api/controls/video-view/video-view.h index 561ca2c..8fa6fcc 100644 --- a/dali-toolkit/public-api/controls/video-view/video-view.h +++ b/dali-toolkit/public-api/controls/video-view/video-view.h @@ -121,6 +121,8 @@ public: * If the string is empty, VideoView will not display anything * * @SINCE_1_1.38 + * @REMARK_INTERNET + * @REMARK_STORAGE * @param[in] url The url of the video resource to display * @return A handle to a newly allocated Dali VideoView */ diff --git a/dali-toolkit/public-api/dali-toolkit-version.cpp b/dali-toolkit/public-api/dali-toolkit-version.cpp index 8cac8e3..bd25c80 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 = 14; +const unsigned int TOOLKIT_MICRO_VERSION = 15; const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__; #ifdef DEBUG_ENABLED diff --git a/dali-toolkit/public-api/file.list b/dali-toolkit/public-api/file.list index a4e4e56..861f2de 100755 --- a/dali-toolkit/public-api/file.list +++ b/dali-toolkit/public-api/file.list @@ -119,5 +119,4 @@ public_api_visuals_header_files = \ $(public_api_src_dir)/visuals/image-visual-properties.h \ $(public_api_src_dir)/visuals/mesh-visual-properties.h \ $(public_api_src_dir)/visuals/primitive-visual-properties.h \ - $(public_api_src_dir)/visuals/text-visual-properties.h \ $(public_api_src_dir)/visuals/visual-properties.h diff --git a/dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h b/dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h index 96bbed0..457f222 100644 --- a/dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h +++ b/dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h @@ -2,7 +2,7 @@ #define __DALI_TOOLKIT_KEYBOARD_FOCUS_MANAGER_H__ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. @@ -46,12 +46,12 @@ class KeyboardFocusManager; * is changed. * * Signals - * | %Signal Name | Method | - * |-------------------------------|------------------------------------| - * | keyboardPreFocusChange | @ref PreFocusChangeSignal() | - * | keyboardFocusChanged | @ref FocusChangedSignal() | - * | keyboardFocusGroupChanged | @ref FocusGroupChangedSignal() | - * | keyboardFocusedActorAenterKey | @ref FocusedActorEnterKeySignal() | + * | %Signal Name | Method | + * |------------------------------|------------------------------------| + * | keyboardPreFocusChange | @ref PreFocusChangeSignal() | + * | keyboardFocusChanged | @ref FocusChangedSignal() | + * | keyboardFocusGroupChanged | @ref FocusGroupChangedSignal() | + * | keyboardFocusedActorEnterKey | @ref FocusedActorEnterKeySignal() | * @SINCE_1_0.0 */ class DALI_IMPORT_API KeyboardFocusManager : public BaseHandle diff --git a/dali-toolkit/public-api/image-loader/async-image-loader.h b/dali-toolkit/public-api/image-loader/async-image-loader.h index 844d758..3472fc0 100644 --- a/dali-toolkit/public-api/image-loader/async-image-loader.h +++ b/dali-toolkit/public-api/image-loader/async-image-loader.h @@ -156,6 +156,8 @@ public: * orientationCorrection = true * * @SINCE_1_2_14 + * @REMARK_INTERNET + * @REMARK_STORAGE * * @param[in] url The URL of the image file to load. * @return The loading task id. @@ -170,6 +172,8 @@ public: * orientationCorrection = true * * @SINCE_1_2_14 + * @REMARK_INTERNET + * @REMARK_STORAGE * * @param[in] url The URL of the image file to load. * @param[in] dimensions The width and height to fit the loaded image to. @@ -180,6 +184,8 @@ public: /** * @brief Start an image loading task. * @SINCE_1_2_14 + * @REMARK_INTERNET + * @REMARK_STORAGE * * @param[in] url The URL of the image file to load. * @param[in] dimensions The width and height to fit the loaded image to. diff --git a/dali-toolkit/public-api/image-loader/sync-image-loader.cpp b/dali-toolkit/public-api/image-loader/sync-image-loader.cpp index de489dc..7a8ab3c 100644 --- a/dali-toolkit/public-api/image-loader/sync-image-loader.cpp +++ b/dali-toolkit/public-api/image-loader/sync-image-loader.cpp @@ -16,7 +16,7 @@ // CLASS HEADER #include "sync-image-loader.h" -#include +#include namespace Dali @@ -45,12 +45,8 @@ PixelData Load( const std::string& url, SamplingMode::Type samplingMode, bool orientationCorrection ) { - BitmapLoader loader = BitmapLoader::New( url, dimensions, fittingMode, samplingMode, orientationCorrection ); - // Load the image synchronously (block the thread here). - loader.Load(); - - return loader.GetPixelData(); + return Dali::LoadImageFromFile( url, dimensions, fittingMode, samplingMode, orientationCorrection ); } diff --git a/dali-toolkit/public-api/image-loader/sync-image-loader.h b/dali-toolkit/public-api/image-loader/sync-image-loader.h index 1586218..c065664 100644 --- a/dali-toolkit/public-api/image-loader/sync-image-loader.h +++ b/dali-toolkit/public-api/image-loader/sync-image-loader.h @@ -56,6 +56,8 @@ namespace SyncImageLoader * orientationCorrection = true * * @SINCE_1_2_14 + * @REMARK_INTERNET + * @REMARK_STORAGE * * @param[in] url The URL of the image file to load. * @return A PixelData object containing the image, or an invalid object on failure. @@ -70,6 +72,8 @@ DALI_IMPORT_API PixelData Load( const std::string& url ); * orientationCorrection = true * * @SINCE_1_2_14 + * @REMARK_INTERNET + * @REMARK_STORAGE * * @param[in] url The URL of the image file to load. * @param[in] dimensions The width and height to fit the loaded image to. @@ -80,6 +84,8 @@ DALI_IMPORT_API PixelData Load( const std::string& url, ImageDimensions dimensio /** * @brief Load an image synchronously by specifying the target dimensions and options. * @SINCE_1_2_14 + * @REMARK_INTERNET + * @REMARK_STORAGE * * @param[in] url The URL of the image file to load. * @param[in] dimensions The width and height to fit the loaded image to. diff --git a/dali-toolkit/public-api/visuals/text-visual-properties.h b/dali-toolkit/public-api/visuals/text-visual-properties.h deleted file mode 100644 index 0e2dd5d..0000000 --- a/dali-toolkit/public-api/visuals/text-visual-properties.h +++ /dev/null @@ -1,188 +0,0 @@ -#ifndef DALI_TOOLKIT_TEXT_VISUAL_PROPERTIES_H -#define DALI_TOOLKIT_TEXT_VISUAL_PROPERTIES_H - -/* - * Copyright (c) 2016 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 - -namespace Dali -{ - -namespace Toolkit -{ - -namespace TextVisual -{ - -namespace Property -{ - -enum -{ - /** - * @brief The type of rendering e.g. bitmap-based - * @details name "renderingBackend", type INTEGER, default RENDERING_SHARED_ATLAS - * @SINCE_1_2.11 - */ - RENDERING_BACKEND = VISUAL_PROPERTY_START_INDEX, - - /** - * @brief The text to display in UTF-8 format, - * @details name "text", type STRING - * @SINCE_1_2.11 - */ - TEXT, - - /** - * @brief The requested font family to use, - * @details name "fontFamily", type STRING - * @SINCE_1_2.11 - */ - FONT_FAMILY, - - /** - * @brief The requested font style to use, - * @details name "fontStyle", type STRING or MAP - * @SINCE_1_2.13 - */ - FONT_STYLE, - - /** - * @brief The size of font in points - * @details name "pointSize", type FLOAT - * @SINCE_1_2.11 - */ - POINT_SIZE, - - /** - * @brief The single-line or multi-line layout option - * @details name "multiLine", type BOOLEAN, default false - * @SINCE_1_2.11 - */ - MULTI_LINE, - - /** - * @brief The line horizontal alignment - * @details name "horizontalAlignment", type STRING, values "BEGIN", "CENTER", "END", default BEGIN - * @SINCE_1_2.11 - */ - HORIZONTAL_ALIGNMENT, - - /** - * @brief The line vertical alignment - * @details name "verticalAlignment", type STRING, values "TOP", "CENTER", "BOTTOM", default TOP - * @SINCE_1_2.11 - */ - VERTICAL_ALIGNMENT, - - /** - * @brief The color of the text - * @details name "textColor", type VECTOR4 - * @SINCE_1_2.11 - */ - TEXT_COLOR, - - /** - * @brief Whether the mark-up processing is enabled - * @details name "enableMarkup", type BOOLEAN - * @SINCE_1_2.11 - */ - ENABLE_MARKUP, - - /** - * @brief Start or stop auto scrolling, - * @details name "enableAutoScroll", type BOOLEAN, default is false - * @SINCE_1_2.11 - */ - ENABLE_AUTO_SCROLL, - - /** - * @brief Sets the speed of scrolling in pixels per second, - * @details name "autoScrollSpeed", type INTEGER, default in style sheet - * @SINCE_1_2.11 - */ - AUTO_SCROLL_SPEED, - - /** - * @brief Number of complete loops when scrolling enabled - * @details name "autoScrollLoopCount", type INTEGER, default in style sheet - * @SINCE_1_2.11 - */ - AUTO_SCROLL_LOOP_COUNT, - - /** - * @brief Gap before before scrolling wraps - * @details name "autoScrollGap", type INTEGER, default in style sheet but can be overridden to prevent same text being show at start and end. - * @SINCE_1_2.11 - */ - AUTO_SCROLL_GAP, - - /** - * @brief The default extra space between lines in points. - * @details name "lineSpacing", type FLOAT. - * @SINCE_1_2.11 - */ - LINE_SPACING, - - /** - * @brief The default underline parameters. - * @details name "underline", type STRING or MAP. - * @SINCE_1_2.13 - */ - UNDERLINE, - - /** - * @brief The default shadow parameters. - * @details name "shadow", type STRING or MAP. - * @SINCE_1_2.13 - */ - SHADOW, - - /** - * @brief The default emboss parameters. - * @details name "emboss", type STRING or MAP. - * @SINCE_1_2.13 - */ - EMBOSS, - - /** - * @brief The default outline parameters. - * @details name "outline", type STRING or MAP. - * @SINCE_1_2.13 - */ - OUTLINE, - - /** - * @brief This enables Text visuals to automatically be converted to Batch-Text visuals. - * @details Name "batchingEnabled", type Property::BOOLEAN. - * @SINCE_1_2.11 - * @note Optional. If not specified, the default is false. - */ - BATCHING_ENABLED, -}; - -} // namespace Property - -} // namespace TextVisual - -} // namespace Toolkit - -} // namespace Dali - -#endif // DALI_TOOLKIT_TEXT_VISUAL_PROPERTIES_H diff --git a/dali-toolkit/public-api/visuals/visual-properties.h b/dali-toolkit/public-api/visuals/visual-properties.h index ef07c89..c4f5cb2 100644 --- a/dali-toolkit/public-api/visuals/visual-properties.h +++ b/dali-toolkit/public-api/visuals/visual-properties.h @@ -42,8 +42,7 @@ enum Type IMAGE, ///< Renders an image into the control's quad. @SINCE_1_1.45 MESH, ///< Renders a mesh using an "obj" file, optionally with textures provided by an "mtl" file. @SINCE_1_1.45 PRIMITIVE, ///< Renders a simple 3D shape, such as a cube or sphere. @SINCE_1_1.45 - WIREFRAME, ///< Renders a simple wire-frame outlining a quad. @SINCE_1_2_2 - TEXT, ///< Renders text. @SINCE_1_2.11 + WIREFRAME ///< Renders a simple wire-frame outlining a quad. @SINCE_1_2_2 }; namespace Property diff --git a/packaging/dali-addon.spec b/packaging/dali-addon.spec index ef9b273..11112dc 100644 --- a/packaging/dali-addon.spec +++ b/packaging/dali-addon.spec @@ -1,6 +1,6 @@ Name: dali-addon Summary: DALi module for Node.JS -Version: 1.2.14 +Version: 1.2.15 Release: 1 Group: Development/Libraries License: Apache License, Version 2.0 diff --git a/packaging/dali-csharp-wrapper.spec b/packaging/dali-csharp-wrapper.spec index b8fb3ce..35c4e7e 100755 --- a/packaging/dali-csharp-wrapper.spec +++ b/packaging/dali-csharp-wrapper.spec @@ -1,6 +1,6 @@ Name: NDalic Summary: dali wrapper -Version: 1.2.14 +Version: 1.2.15 Release: 1 Group: uifw/graphic License: TO_BE_FILLED_IN diff --git a/packaging/dali-toolkit.spec b/packaging/dali-toolkit.spec index 1ccf8e0..7af9db3 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.14 +Version: 1.2.15 Release: 1 Group: System/Libraries License: Apache-2.0 and BSD-2-Clause and MIT diff --git a/plugins/dali-swig/Makefile.am b/plugins/dali-swig/Makefile.am index 9ed6c33..6b6966a 100644 --- a/plugins/dali-swig/Makefile.am +++ b/plugins/dali-swig/Makefile.am @@ -23,8 +23,8 @@ if BUILD_MCS all-local: libNDalic.so NDali.dll -libNDalic.so: automatic/cpp/dali_wrap.o manual/cpp/keyboard_focus_manager_wrap.o manual/cpp/view-wrapper-impl-wrap.o - g++ -shared automatic/cpp/dali_wrap.o manual/cpp/keyboard_focus_manager_wrap.o manual/cpp/view-wrapper-impl-wrap.o -o libNDalic.so $(DALICORE_LIBS) $(DALIADAPTOR_LIBS) $(DALITOOLKIT_LIBS) +libNDalic.so: automatic/cpp/dali_wrap.o manual/cpp/keyboard_focus_manager_wrap.o manual/cpp/view-wrapper-impl-wrap.o manual/cpp/callbackbase_wrap.o + g++ -shared automatic/cpp/dali_wrap.o manual/cpp/keyboard_focus_manager_wrap.o manual/cpp/view-wrapper-impl-wrap.o manual/cpp/callbackbase_wrap.o -o libNDalic.so $(DALICORE_LIBS) $(DALIADAPTOR_LIBS) $(DALITOOLKIT_LIBS) automatic/cpp/dali_wrap.o: $(BUILT_SOURCES) g++ -c -fpic $(CXXFLAGS) $(DALICORE_CFLAGS) $(DALIADAPTOR_CFLAGS) $(DALITOOLKIT_CFLAGS) automatic/cpp/dali_wrap.cpp -o automatic/cpp/dali_wrap.o @@ -35,6 +35,9 @@ manual/cpp/keyboard_focus_manager_wrap.o: $(BUILT_SOURCES) manual/cpp/view-wrapper-impl-wrap.o: $(BUILT_SOURCES) g++ -c -fpic $(CXXFLAGS) $(DALICORE_CFLAGS) $(DALIADAPTOR_CFLAGS) $(DALITOOLKIT_CFLAGS) manual/cpp/view-wrapper-impl-wrap.cpp -o manual/cpp/view-wrapper-impl-wrap.o +manual/cpp/callbackbase_wrap.o: $(BUILT_SOURCES) + g++ -c -fpic $(CXXFLAGS) $(DALICORE_CFLAGS) $(DALIADAPTOR_CFLAGS) $(DALITOOLKIT_CFLAGS) manual/cpp/callbackbase_wrap.cpp -o manual/cpp/callbackbase_wrap.o + NDali.dll: $(BUILT_SOURCES) $(MCS) -nologo -target:library -out:NDali.dll automatic/csharp/*.cs manual/csharp/*.cs diff --git a/plugins/dali-swig/SWIG/dali-gc.i b/plugins/dali-swig/SWIG/dali-gc.i new file mode 100644 index 0000000..ea71121 --- /dev/null +++ b/plugins/dali-swig/SWIG/dali-gc.i @@ -0,0 +1,1491 @@ +/* + * Copyright (c) 2016 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. + * + */ + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_##ClassName(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( NameSpace, ClassName ) +%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_##ClassName(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + base.Dispose(); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~ClassName() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_VIDEOVIEWSIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~VideoViewSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_VIDEOVIEWSIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_VideoViewSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_APPLICATIONSIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~ApplicationSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_APPLICATIONSIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_ApplicationSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_APPLICATIONCONTROLSIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~ApplicationControlSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_APPLICATIONCONTROLSIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_ApplicationControlSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_IMAGESIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~ImageSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_IMAGESIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_ImageSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_RESOURCESIMAGESIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~ResourceImageSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_RESOURCESIMAGESIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_ResourceImageSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_RECTINT( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~RectInteger() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_RECTINT( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_RectInteger(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_RECTDOUBLE( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~RectDouble() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_RECTDOUBLE( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_RectDouble(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_RECTFLOAT( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~RectFloat() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_RECTFLOAT( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_RectFloat(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_RECTUNSIGNEDINT( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~RectUnsignedInteger() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_RECTUNSIGNEDINT( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_RectUnsignedInteger(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_STRINGVALUEPAIR( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~StringValuePair() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_STRINGVALUEPAIR( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_StringValuePair(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_TOUCHCONTAINER( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~TouchPointContainer() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_TOUCHCONTAINER( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_TouchPointContainer(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_BOOLSIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~BoolSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_BOOLSIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_BoolSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_ACCESSIBILITYACTIONSIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~AccessibilityActionSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_ACCESSIBILITYACTIONSIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_AccessibilityActionSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_ACCESSIBILITYACTIONSCROLLSIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~AccessibilityActionScrollSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_ACCESSIBILITYACTIONSCROLLSIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_AccessibilityActionScrollSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_ACCESSIBILITYFOCUSSIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~AccessibilityFocusOvershotSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_ACCESSIBILITYFOCUSSIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_AccessibilityFocusOvershotSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_VECTORINT( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~VectorInteger() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_VECTORINT( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_VectorInteger(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_VECTORFLOAT( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~VectorFloat() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_VECTORFLOAT( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_VectorFloat(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_VECTORUNSIGNEDCHAR( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~VectorUnsignedChar() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_VECTORUNSIGNEDCHAR( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_VectorUnsignedChar(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_VECTORUINT16PAIR( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~VectorUint16Pair() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_VECTORUINT16PAIR( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_VectorUint16Pair(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_TIMERSIGNALTYPE( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~TimerSignalType() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_TIMERSIGNALTYPE( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_TimerSignalType(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_ACTOR( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~ActorSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_ACTOR( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_ActorSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_ANIMATIONSIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~AnimationSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_ANIMATIONSIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_AnimationSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_BUTTON( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~ButtonSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_BUTTON( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_ButtonSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_PAGETURNSIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~PageTurnSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_PAGETURNSIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_PageTurnSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_PAGEVIEWSIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~PagePanSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_PAGEVIEWSIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_PagePanSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_PANGESTURESIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~PanGestureDetectedSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_PANGESTURESIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_PanGestureDetectedSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_PINCHGESTURESIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~PinchGestureDetectedSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_PINCHGESTURESIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_PinchGestureDetectedSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_RENDERTASKSIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~RenderTaskSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_RENDERTASKSIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_RenderTaskSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_SCROLLABLESIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~ScrollableSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_SCROLLABLESIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_ScrollableSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_SCROLLVIEWSIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~ScrollViewSnapStartedSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_SCROLLVIEWSIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_ScrollViewSnapStartedSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_SLIDERVALUECHANGEDSIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~SliderValueChangedSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_SLIDERVALUECHANGEDSIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_SliderValueChangedSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_SLIDERMARKCHANGEDSIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~SliderMarkReachedSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_SLIDERMARKCHANGEDSIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_SliderMarkReachedSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_STAGESIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~StageWheelEventSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_STAGESIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_StageWheelEventSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_STYLECHANGEDSIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~StyleChangedSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_STYLECHANGEDSIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_StyleChangedSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_TAPGESTURESIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~TapGestureDetectedSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_TAPGESTURESIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_TapGestureDetectedSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_TEXTFIELDSIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~TextFieldSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_TEXTFIELDSIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_TextFieldSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_TEXTEDITORSIGNAL( NameSpace, ClassName ) +%typemap(csfinalize) NameSpace::ClassName %{ + ~TextEditorSignal() { + DisposeQueue.Instance.Add(this); + } +%} +%enddef + +%define DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_TEXTEDITORSIGNAL( NameSpace, ClassName ) +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") NameSpace::ClassName %{{ + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + + lock(this) { + if (swigCPtr.Handle != global::System.IntPtr.Zero) { + if (swigCMemOwn) { + swigCMemOwn = false; + NDalicPINVOKE.delete_TextEditorSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + global::System.GC.SuppressFinalize(this); + } + } +%} +%enddef + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Any ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, Any ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Actor ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, Actor ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, AlphaFunction ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, AlphaFunction ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Animation ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, Animation ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, AngleAxis ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, AngleAxis ); + +//DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, BaseObject ); +//DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, BaseObject ); +//DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, RefObject ); +//DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, RefObject ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Handle ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, Handle ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, ObjectRegistry ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, ObjectRegistry ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, BaseHandle ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, BaseHandle ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, BufferImage ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, BufferImage ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, CameraActor ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, CameraActor ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, CustomActor ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, CustomActor ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, CustomActorImpl ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, CustomActorImpl ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, ConnectionTracker ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, ConnectionTracker ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, ConnectionTrackerInterface ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, ConnectionTrackerInterface ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Degree ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, Degree ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, EncodedBufferImage ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, EncodedBufferImage ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, FrameBuffer ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, FrameBuffer ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, FrameBufferImage ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, FrameBufferImage ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Geometry ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, Geometry ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Gesture ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, Gesture ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, GestureDetector ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, GestureDetector ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, TapGesture ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, TapGesture ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, TapGestureDetector ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, TapGestureDetector ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, PanGesture ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, PanGesture ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, PanGestureDetector ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, PanGestureDetector ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, PinchGesture ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, PinchGesture ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, PinchGestureDetector ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, PinchGestureDetector ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, LongPressGesture ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, LongPressGesture ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, LongPressGestureDetector ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, LongPressGestureDetector ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, KeyEvent ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, KeyEvent ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, HoverEvent ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, HoverEvent ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, TouchEvent ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, TouchEvent ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, WheelEvent ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, WheelEvent ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Renderer ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, Renderer ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, RenderTask ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, RenderTask ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, RenderTaskList ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, RenderTaskList ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, RelayoutContainer ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, RelayoutContainer ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Radian ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, Radian ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Quaternion ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, Quaternion ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Matrix ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, Matrix ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Matrix3 ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, Matrix3 ); + +//DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, RulerPtr ); +//DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, RulerPtr ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Layer ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, Layer ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, KeyFrames ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, KeyFrames ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Stage ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, Stage ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Sampler ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, Sampler ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Shader ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, Shader ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Vector2 ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, Vector2 ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Vector3 ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, Vector3 ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Vector4 ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, Vector4 ); +//DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, VectorBase ); +//DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, VectorBase ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Image ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, Image ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, NativeImage ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, NativeImage ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, NinePatchImage ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, NinePatchImage ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, ResourceImage ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, ResourceImage ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Path ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, Path ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Property ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, Property ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, PropertyBuffer ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, PropertyBuffer ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, PropertyCondition ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, PropertyCondition ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, PropertyNotification ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, PropertyNotification ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, PixelData ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, PixelData ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Uint16Pair ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, Uint16Pair ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, TypeInfo ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, TypeInfo ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Texture ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, Texture ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, TextureSet ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, TextureSet ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, TimePeriod ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, TimePeriod ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, LinearConstrainer ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, LinearConstrainer ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, PathConstrainer ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, PathConstrainer ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, TouchPoint ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, TouchPoint ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, TouchData ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, TouchData ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Application ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, Application ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, DragAndDropDetector ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, DragAndDropDetector ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Timer ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, Timer ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, Window ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, Window ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, AccessibilityManager ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, AccessibilityManager ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, Alignment ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, Alignment ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, Button ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, Button ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, CheckBoxButton ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, CheckBoxButton ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, PushButton ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, PushButton ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, RadioButton ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, RadioButton ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, Builder ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, Builder ); + +//DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, View ); +//DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, View ); +//DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, ViewImpl ); +//DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, ViewImpl ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, FlexContainer ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, FlexContainer ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, GaussianBlurView ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, GaussianBlurView ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, ImageView ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, ImageView ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, ItemView ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, ItemView ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, ItemFactory ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali::Toolkit, ItemFactory ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, ItemLayout ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, ItemLayout ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, ItemRange ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali::Toolkit, ItemRange ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, Model3dView ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, Model3dView ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, PageFactory ); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali::Toolkit, PageFactory ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, PageTurnLandscapeView ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, PageTurnLandscapeView ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, PageTurnPortraitView ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, PageTurnPortraitView ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, PageTurnView ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, PageTurnView ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, Popup ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, Popup ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, ProgressBar ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, ProgressBar ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, Scrollable ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, Scrollable ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, ScrollBar ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, ScrollBar ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, ScrollView ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, ScrollView ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, ScrollViewEffect ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, ScrollViewEffect ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, ScrollViewPagePathEffect ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, ScrollViewPagePathEffect ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, StyleManager ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, StyleManager ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, Slider ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, Slider ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, TableView ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, TableView ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, TextEditor ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, TextEditor ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, TextField ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, TextField ); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, TextLabel ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, TextLabel ); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, VideoView ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, VideoView ); +//DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, VisualBase ); +//DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, VisualBase); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali::Toolkit, VisualFactory ); +DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali::Toolkit, VisualFactory ); + +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_APPLICATIONSIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_APPLICATIONSIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_APPLICATIONCONTROLSIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_APPLICATIONCONTROLSIGNAL( Dali, Signal); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_VIDEOVIEWSIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_VIDEOVIEWSIGNAL( Dali, Signal); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_IMAGESIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_IMAGESIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_RESOURCESIMAGESIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_RESOURCESIMAGESIGNAL( Dali, Signal); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_RECTINT( Dali, Rect); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_RECTINT( Dali, Rect); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_RECTDOUBLE( Dali, Rect); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_RECTDOUBLE( Dali, Rect); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_RECTFLOAT( Dali, Rect); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_RECTFLOAT( Dali, Rect); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_RECTUNSIGNEDINT( Dali, Rect); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_RECTUNSIGNEDINT( Dali, Rect); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_TOUCHCONTAINER( std, vector); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_TOUCHCONTAINER( std, vector); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_VECTORINT( Dali, Vector); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_VECTORINT( Dali, Vector); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_VECTORFLOAT( Dali, Vector); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_VECTORFLOAT( Dali, Vector); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_VECTORUNSIGNEDCHAR( Dali, Vector); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_VECTORUNSIGNEDCHAR( Dali, Vector); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_VECTORUINT16PAIR( Dali, Vector); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_VECTORUINT16PAIR( Dali, Vector); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_ACCESSIBILITYACTIONSIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_ACCESSIBILITYACTIONSIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_ACCESSIBILITYACTIONSCROLLSIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_ACCESSIBILITYACTIONSCROLLSIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_ACCESSIBILITYFOCUSSIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_ACCESSIBILITYFOCUSSIGNAL( Dali, Signal); +//DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_STRINGVALUEPAIR( Dali, pair); +//DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_STRINGVALUEPAIR( Dali, pair); +//DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_BOOLSIGNAL( Dali, Signal); +//DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_BOOLSIGNAL( Dali, Signal); +//DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_TIMERSIGNALTYPE( Dali, Signal); +//DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_TIMERSIGNALTYPE( Dali, Signal); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_ACTOR( Dali, Signal); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_ACTOR( Dali, Signal); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_ANIMATIONSIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_ANIMATIONSIGNAL( Dali, Signal); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_BUTTON( Dali, Signal); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_BUTTON( Dali, Signal); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_PAGETURNSIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_PAGETURNSIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_PAGEVIEWSIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_PAGEVIEWSIGNAL( Dali, Signal); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_PANGESTURESIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_PANGESTURESIGNAL( Dali, Signal); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_PINCHGESTURESIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_PINCHGESTURESIGNAL( Dali, Signal); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_RENDERTASKSIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_RENDERTASKSIGNAL( Dali, Signal); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_SCROLLABLESIGNAL( Dali, Signal< void(const Dali::Vector2&)>); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_SCROLLABLESIGNAL( Dali, Signal< void(const Dali::Vector2&)>); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_SCROLLVIEWSIGNAL( Dali, Signal< void(const Dali::Toolkit::ScrollView::SnapEvent&)>); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_SCROLLVIEWSIGNAL( Dali, Signal< void(const Dali::Toolkit::ScrollView::SnapEvent&)>); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_SLIDERVALUECHANGEDSIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_SLIDERVALUECHANGEDSIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_SLIDERMARKCHANGEDSIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_SLIDERMARKCHANGEDSIGNAL( Dali, Signal); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_STAGESIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_STAGESIGNAL( Dali, Signal); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_STYLECHANGEDSIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_STYLECHANGEDSIGNAL( Dali, Signal); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_TAPGESTURESIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_TAPGESTURESIGNAL( Dali, Signal); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_TEXTEDITORSIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_TEXTEDITORSIGNAL( Dali, Signal); + +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_TEXTFIELDSIGNAL( Dali, Signal); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_TEXTFIELDSIGNAL( Dali, Signal); diff --git a/plugins/dali-swig/SWIG/dali.i b/plugins/dali-swig/SWIG/dali.i index 3659b21..fdcd4b2 100755 --- a/plugins/dali-swig/SWIG/dali.i +++ b/plugins/dali-swig/SWIG/dali.i @@ -25,6 +25,7 @@ #endif %include exception.i +%include dali-gc.i %exception { try { diff --git a/plugins/dali-swig/SWIG/events/application-event.i b/plugins/dali-swig/SWIG/events/application-event.i index 69fdb2b..b6acb9d 100644 --- a/plugins/dali-swig/SWIG/events/application-event.i +++ b/plugins/dali-swig/SWIG/events/application-event.i @@ -927,7 +927,7 @@ } } - private static Application instance; // singleton + private static Application _instance; // singleton public delegate void InitDelegate(); @@ -984,6 +984,14 @@ // instance.InitDelegate(); } + public static Application Instance + { + get + { + return _instance; + } + } + public static Application GetApplicationFromPtr(global::System.IntPtr cPtr) { Application ret = new Application(cPtr, false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); @@ -999,11 +1007,13 @@ } public static Application NewApplication() { - return NewApplication("",Application.WINDOW_MODE.OPAQUE); + _instance = NewApplication("", Application.WINDOW_MODE.OPAQUE); + return _instance; } public static Application NewApplication(string stylesheet) { - return NewApplication(stylesheet, Application.WINDOW_MODE.OPAQUE); + _instance = NewApplication(stylesheet, Application.WINDOW_MODE.OPAQUE); + return _instance; } public static Application NewApplication(string stylesheet, Application.WINDOW_MODE windowMode) { @@ -1014,10 +1024,19 @@ // we've got an application now connect the signals ret.SetupDelegates(); // set the singleton - + _instance = ret; return ret; } + public bool AddIdle(System.Delegate func) { + System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func); + System.IntPtr ip2 = NDalicManualPINVOKE.MakeCallback(new System.Runtime.InteropServices.HandleRef(this, ip)); + + bool ret = NDalicPINVOKE.Application_AddIdle(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip2)); + + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } %} %enddef diff --git a/plugins/dali-swig/examples/firstscreen/App.cs b/plugins/dali-swig/examples/firstscreen/App.cs index 5f5819f..6c3b676 100644 --- a/plugins/dali-swig/examples/firstscreen/App.cs +++ b/plugins/dali-swig/examples/firstscreen/App.cs @@ -7,33 +7,33 @@ namespace FirstScreen { public class FirstScreenApp { - private int _currentPostersContainerID; - private int _totalPostersContainers; - - private Application _application; - private Stage _stage; - private Vector2 _stageSize; - - private List _postersContainer; - - private ScrollContainer _menuContainer; - private Vector3 _menuItemSize; - - private Layer _bottomClipLayer; - private Layer _topClipLayer; - private View _topContainer; - private View _bottomContainer; - - private FocusEffect _focusEffect; - private string _imagePath; - - private ImageView _keyboardFocusIndicator; - private ImageView _launcherSeparator; - private ImageView[] launcherIcon; - private Animation _showBottomContainerAnimation; - private Animation _hideBottomContainerAnimation; - - public FirstScreenApp(Application application) + private Application _application; // Reference to Dali Application. + private Stage _stage; // Reference to Dali stage. + private Vector2 _stageSize; // Reference to Dali stage size. + + private View _topContainer; // Top Container added to the Stage will contain Poster ScrollContainers. + private View _bottomContainer; // Bottom Container added to the Stage will contain Menu ScrollContainer. + private int _currentPostersContainerID; // Current Poster Container ID visible on the Top Container / Stage. + private int _totalPostersContainers; // Number of Poster ScrollContainers to be added on Top Container. + private List _postersContainer; // List collection of Poster ScrollContainers used on the Top Container in this demo application. + private ScrollContainer _menuContainer; // Menu ScrollContainer used on the Bottom Container in this demo application. + private Layer _bottomClipLayer; // Clip layer (Dali Clip Layer instance) used for Bottom Container. + private Layer _topClipLayer; // Clip layer (Dali Clip Layer instance) used for Top Container. + + private FocusEffect _focusEffect; // FocusEffect is used to apply Focus animation effect on any supplied item/image. + private string _imagePath; // Contains the physical location of all images used in the demo application. + + private ImageView _keyboardFocusIndicator; // Reference to the ImageView (Keyboard Focus indicator) applied to the focused item on ScrollContainer. + private ImageView _launcherSeparator; // Reference to the ImageView used for launcher separation (Launcher consists of three image icons on left of Menu ScrollContainer). + private ImageView[] launcherIcon; // ImageViews used for launcher Icons. + private Animation _showBottomContainerAnimation; // Animation used to show/unhide Bottom Container (Menu ScrollContainer) when it is focused. + private Animation _hideBottomContainerAnimation; // Animation used to hide Bottom Container (Menu ScrollContainer) when it is focused. + private Animation _showAnimation; // Animation used to move Poster scrollContainer from bottom to top and make it non-transparent. + private Animation _hideAnimation; // Animation used to make the unused specified Poster scrollContainer transparent. + private ScrollContainer _hideScrollContainer; // The unused Poster scrollContainer which needs to be transparent. + KeyboardFocusManager _keyboardFocusManager; // Reference to Dali KeyboardFocusManager. + + private FirstScreenApp(Application application) { _application = application; _application.Initialized += OnInitialize; @@ -45,7 +45,7 @@ namespace FirstScreen tVApp.MainLoop(); } - public void MainLoop() + private void MainLoop() { _application.MainLoop(); } @@ -62,23 +62,23 @@ namespace FirstScreen { View item = new ImageView(_imagePath + "/poster"+j+"/"+ (i % 6)+ ".jpg"); item.SetName ("poster-item-" + _postersContainer[j].ItemCount); - _postersContainer[j].AddItem(item); + _postersContainer[j].Add(item); } else { View item = new ImageView(_imagePath + "/poster"+j+"/"+ (i % 6)+ ".jpg"); item.SetName ("poster-item-" + _postersContainer[j].ItemCount); - _postersContainer[j].AddItem(item); + _postersContainer[j].Add(item); } } if (j == 0) { - _postersContainer[j].Show(); + Show(_postersContainer[j]); } else { - _postersContainer[j].Hide(); + Hide(_postersContainer[j]); } _postersContainer[j].SetFocused(false); @@ -97,13 +97,18 @@ namespace FirstScreen { View menuItem = new ImageView(_imagePath + "/menu/" + i % 7 + ".png"); menuItem.SetName("menu-item-" + _menuContainer.ItemCount); - _menuContainer.AddItem(menuItem); + _menuContainer.Add(menuItem); } } private Actor OnKeyboardPreFocusChangeSignal(object source, KeyboardFocusManager.PreFocusChangeEventArgs e) { - Actor actor = _menuContainer.ItemRoot; + if (!e.Current && !e.Proposed) + { + return _menuContainer; + } + + Actor actor = _menuContainer.Container; if (e.Direction == View.KeyboardFocus.Direction.UP) { @@ -116,7 +121,7 @@ namespace FirstScreen HideBottomContainer(); // Also apply Focus animation on Focused item on Poster ScrollContainer - _postersContainer[_currentPostersContainerID].FocusAnimation(_focusEffect, FocusEffectDirection.BottomToTop); + FocusAnimation(_postersContainer[_currentPostersContainerID], FocusEffectDirection.BottomToTop); } } else if (e.Direction == View.KeyboardFocus.Direction.DOWN) @@ -130,56 +135,100 @@ namespace FirstScreen _menuContainer.SetFocused(true); // Also apply Focus animation on Focused item on Menu ScrollContainer - _menuContainer.FocusAnimation(_focusEffect, FocusEffectDirection.TopToBottom); + FocusAnimation(_menuContainer, FocusEffectDirection.TopToBottom); } } - else if (e.Direction == View.KeyboardFocus.Direction.LEFT) + else + { + actor = e.Proposed; + } + + if (e.Direction == View.KeyboardFocus.Direction.LEFT) { if (_menuContainer.IsFocused) { - // Move the Focus to the left item/image of currently focused item on Menu ScrollContainer - actor = _menuContainer.FocusPrevious(); - int id = _menuContainer.FocusedItemID % _totalPostersContainers; if (id != _currentPostersContainerID) { - _postersContainer[_currentPostersContainerID].Hide(); + Hide(_postersContainer[_currentPostersContainerID]); _currentPostersContainerID = id; - _postersContainer[_currentPostersContainerID].Show(); + Show(_postersContainer[_currentPostersContainerID]); } } - else - { - // Move the Focus to the left item/image of currently focused item on Poster ScrollContainer - actor = _postersContainer[_currentPostersContainerID].FocusPrevious(); - } } else if (e.Direction == View.KeyboardFocus.Direction.RIGHT) { if (_menuContainer.IsFocused) { - // Move the Focus to the right item/image of currently focused item on Menu ScrollContainer - actor = _menuContainer.FocusNext(); - int id = _menuContainer.FocusedItemID % _totalPostersContainers; if (id != _currentPostersContainerID) { - _postersContainer[_currentPostersContainerID].Hide(); + Hide(_postersContainer[_currentPostersContainerID]); _currentPostersContainerID = id; - _postersContainer[_currentPostersContainerID].Show(); + Show(_postersContainer[_currentPostersContainerID]); } } - else - { - // Move the Focus to the right item/image of currently focused item on Poster ScrollContainer - actor = _postersContainer[_currentPostersContainerID].FocusNext(); - } } return actor; } + // Perform Focus animation Effect on the current Focused Item on ScrollContainer. + private void FocusAnimation(ScrollContainer scrollContainer, FocusEffectDirection direction) + { + _focusEffect.FocusAnimation(scrollContainer.GetCurrentFocusedActor(), scrollContainer.ItemSize, 1.0f, direction); + } + + // Perform Show animation on ScrollContainer (used only for Poster Container) + private void Show(ScrollContainer scrollContainer) + { + scrollContainer.Add(scrollContainer.Container); + + _hideScrollContainer = null; + _showAnimation = new Animation (0.35f); + + // This animation will move Poster scrollContainer from bottom to top and make it non-transparent. + _showAnimation.AnimateTo(new Dali.Property(scrollContainer.Container, Actor.Property.COLOR_ALPHA), new Dali.Property.Value(1.0f)); + + scrollContainer.Container.PositionY = scrollContainer.Container.Position.y + 200.0f; + float targetPositionY = scrollContainer.Container.Position.y - 200.0f; + _showAnimation.AnimateTo(new Dali.Property(scrollContainer.Container, Actor.Property.POSITION_Y), new Dali.Property.Value(targetPositionY), + new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR)); + + _showAnimation.Play(); + } + + // Perform Hide animation on ScrollContainer (used only for Poster Container) + private void Hide(ScrollContainer scrollContainer) + { + if (_hideAnimation) + { + _hideAnimation.Clear(); + _hideAnimation.Reset(); + } + + float duration = 0.35f; + _hideAnimation = new Animation(duration); + + _hideAnimation.AnimateTo(new Dali.Property(scrollContainer.Container, Actor.Property.COLOR_ALPHA), new Dali.Property.Value(0.0f), + new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR), new TimePeriod(0.0f, duration * 0.75f)); + + _hideAnimation.Finished += OnHideAnimationFinished; + + _hideScrollContainer = scrollContainer; + _hideAnimation.Play(); + } + + // This removes all the items from the specified unused Poster ScrollContainer (hence Stage) to improve performance. + private void OnHideAnimationFinished(object source, Animation.FinishedEventArgs e) + { + if (_hideScrollContainer) + { + _hideScrollContainer.Remove(_hideScrollContainer.Container); + } + } + // Hide Bottom Container (Menu ScrollContainer) when it is not focused private void HideBottomContainer() { @@ -211,13 +260,14 @@ namespace FirstScreen // First screen demo Application initialisation private void OnInitialize(object source, AUIApplicationInitEventArgs e) { + _hideScrollContainer = null; _stage = Stage.GetCurrent(); _stageSize = _stage.GetSize(); -// _stage.SetBackgroundColor(NDalic.TRANSPARENT); + //_stage.SetBackgroundColor(NDalic.TRANSPARENT); _totalPostersContainers = Constants.TotalPostersContainers; _imagePath = "./images/"; // Desktop -// _imagePath = "/home/owner/apps_rw/org.tizen.firstscreen/res/images/"; // Target + //_imagePath = "/home/owner/apps_rw/org.tizen.firstscreen/res/images/"; // Target _postersContainer = new List (); _menuContainer = new ScrollContainer (); @@ -297,18 +347,18 @@ namespace FirstScreen } else { - _postersContainer[i].ItemSize = new Vector3(_stageSize.width * Constants.Poster1ItemWidthFactor, + _postersContainer[i].ItemSize = new Vector3((_stageSize.width * Constants.Poster1ItemWidthFactor) - Constants.PostersContainerPadding, _stageSize.height * Constants.PostersItemHeightFactor, 0.0f); } - _postersContainer[i].Padding = Constants.PostersContainerPadding; + _postersContainer[i].Gap = Constants.PostersContainerPadding; _postersContainer[i].MarginX = Constants.PostersContainerMargin; - _postersContainer[i].OffsetY = Constants.PostersContainerOffsetYFactor; + _postersContainer[i].OffsetYFator = Constants.PostersContainerOffsetYFactor; _postersContainer[i].Width = _stageSize.width; _postersContainer[i].Height = _stageSize.height * Constants.PostersContainerHeightFactor; _postersContainer[i].ShadowBorder = shadowBorder; _postersContainer[i].ShadowBorder.Position = new Vector3(0.0f, 4.0f, 0.0f); _postersContainer[i].SpotLight = spotLight; - _topClipLayer.Add(_postersContainer[i].Container); + _topClipLayer.Add(_postersContainer[i]); } // Add a clip layer to Bottom Container @@ -347,13 +397,13 @@ namespace FirstScreen _bottomContainer.Add(_launcherSeparator); // Create Menu Container and add it to Bottom Clip Layer - _menuItemSize = new Vector3((_stageSize.width * Constants.MenuItemWidthFactor) - Constants.MenuContainerPadding, + Vector3 menuItemSize = new Vector3((_stageSize.width * Constants.MenuItemWidthFactor) - Constants.MenuContainerPadding, _stageSize.height * Constants.MenuItemHeightFactor, 0.0f); _menuContainer.Container.Name = "menu"; - _menuContainer.ItemSize = _menuItemSize; - _menuContainer.Padding = Constants.MenuContainerPadding; + _menuContainer.ItemSize = menuItemSize; + _menuContainer.Gap = Constants.MenuContainerPadding; _menuContainer.MarginX = Constants.MenuContainerMargin; - _menuContainer.OffsetY = Constants.MenuContainerOffsetYFactor; + _menuContainer.OffsetYFator = Constants.MenuContainerOffsetYFactor; _menuContainer.OffsetX = Constants.LauncherWidth; _menuContainer.Width = _stageSize.width - Constants.LauncherWidth; _menuContainer.Height = _stageSize.height * Constants.MenuContainerHeightFactor; @@ -364,14 +414,14 @@ namespace FirstScreen _menuContainer.ShadowBorder.ParentOrigin = NDalic.ParentOriginCenter; _menuContainer.ShadowBorder.AnchorPoint = NDalic.AnchorPointCenter; _menuContainer.SpotLight = spotLight; - _bottomClipLayer.Add(_menuContainer.Container); + _bottomClipLayer.Add(_menuContainer); CreatePosters(); // Create Items for Poster ScrollContainer CreateMenu(); // Create Items for Menu ScrollContainer // Initialize PreFocusChange event of KeyboardFocusManager - KeyboardFocusManager keyboardFocusManager = KeyboardFocusManager.Get(); - keyboardFocusManager.PreFocusChange += OnKeyboardPreFocusChangeSignal; + _keyboardFocusManager = KeyboardFocusManager.Get(); + _keyboardFocusManager.PreFocusChange += OnKeyboardPreFocusChangeSignal; _keyboardFocusIndicator = new ImageView(_imagePath + "/highlight_stroke.9.png"); _keyboardFocusIndicator.ParentOrigin = NDalic.ParentOriginCenter; @@ -379,7 +429,12 @@ namespace FirstScreen _keyboardFocusIndicator.WidthResizePolicy = "FILL_TO_PARENT"; _keyboardFocusIndicator.HeightResizePolicy = "FILL_TO_PARENT"; - keyboardFocusManager.SetFocusIndicatorActor(_keyboardFocusIndicator); + _keyboardFocusManager.SetFocusIndicatorActor(_keyboardFocusIndicator); + + _keyboardFocusManager.SetAsFocusGroup(_menuContainer, true); + _keyboardFocusManager.SetAsFocusGroup(_postersContainer[0], true); + _keyboardFocusManager.SetAsFocusGroup(_postersContainer[1], true); + _keyboardFocusManager.SetFocusGroupLoop(true); _focusEffect = new FocusEffect(); @@ -390,3 +445,4 @@ namespace FirstScreen } } + diff --git a/plugins/dali-swig/examples/firstscreen/Constants.cs b/plugins/dali-swig/examples/firstscreen/Constants.cs index 7ada417..42e2c97 100644 --- a/plugins/dali-swig/examples/firstscreen/Constants.cs +++ b/plugins/dali-swig/examples/firstscreen/Constants.cs @@ -22,14 +22,14 @@ namespace FirstScreen public const float BottomClipLayerHeightFactor = 0.84f; // Height Factor of stage height used for Bottom Clip layer height public const float MenuContainerPadding = 10.0f; // Padding size used between items / images in Menu ScrollContainer public const float MenuContainerMargin = 25.0f; // Extra margin Padding size used between items / images in Menu ScrollContainer when item / image is focused - public const float MenuContainerOffsetYFactor = 0.35f; // Position Factor of Poster item height used for Menu items / images position + public const float MenuContainerOffsetYFactor = 0.35f; // Position Factor of Menu item height used for Menu items / images position public const float MenuItemWidthFactor = 0.125f; // Width Factor (1/8) of stage Width used for Menu items / images Width public const float MenuItemHeightFactor = 0.10f; // Height Factor of stage height used for Menu items / images Height public const float MenuItemsCount = 14; // Number of Menu items / images used in a Menu ScrollContainer public const float Poster0ItemWidthFactor = 0.25f; // Width Factor (1/4) of stage Width used for Poster items / images Width in a Poster ScrollContainer 0 - public const float Poster1ItemWidthFactor = 0.24f; // Width Factor of stage Width used for Poster items / images Width in a Poster ScrollContainer 1 + public const float Poster1ItemWidthFactor = 0.20f; // Width Factor of stage Width used for Poster items / images Width in a Poster ScrollContainer 1 public const float PostersItemHeightFactor = 0.24f; // Height Factor of stage height used for Poster items / images Height public const float PostersItemsCount = 24; // Number of Menu items / images used in a Poster ScrollContainer @@ -38,6 +38,10 @@ namespace FirstScreen public const float LauncherSeparatorWidth = 20.0f; // Extra area / space to the left of Menu ScrollContainer used for a speration shadow image public const float LauncherItemsCount = 3.0f; // Total number of Launcher items / images public const float LauncherIconWidth = (LauncherWidth - LauncherLeftMargin - LauncherSeparatorWidth) / LauncherItemsCount; // Width of each Launcher item / image + + public const float SpotLightDuration = 5.0f; // Duration of Spot Light Animation. + public const float FocusTransitionDuration = 0.35f; // Duration of Focus Transition Animation. + public const float FocusDuration = 0.35f; // Duration of Focus Animation. + public const float ScrollDuration = 0.35f; // Duration of Scroll Animation. } } - diff --git a/plugins/dali-swig/examples/firstscreen/FocusData.cs b/plugins/dali-swig/examples/firstscreen/FocusData.cs index b1ee188..75a3a96 100644 --- a/plugins/dali-swig/examples/firstscreen/FocusData.cs +++ b/plugins/dali-swig/examples/firstscreen/FocusData.cs @@ -17,7 +17,7 @@ namespace FirstScreen // Initialize FocusData used for key frame animation public FocusData(string name, string imageName, Direction direction, Vector3 parentOrigin, Vector3 initSize, - Vector3 targetSize, float keyFrameStart, float keyFrameEnd) + Vector3 targetSize, float keyFrameStart, float keyFrameEnd) { _name = name; _imageName = imageName; @@ -29,7 +29,7 @@ namespace FirstScreen _direction = direction; _imageFocus = new ImageView("./images/focuseffect/" + _imageName); // Desktop -// _imageFocus = new ImageView("/home/owner/apps_rw/org.tizen.firstscreen/res/images/focuseffect/" + _imageName); // Target + // _imageFocus = new ImageView("/home/owner/apps_rw/org.tizen.firstscreen/res/images/focuseffect/" + _imageName); // Target _imageFocus.ParentOrigin = _parentOrigin; _imageFocus.AnchorPoint = NDalic.AnchorPointCenter; @@ -103,4 +103,3 @@ namespace FirstScreen } } } - diff --git a/plugins/dali-swig/examples/firstscreen/FocusEffect.cs b/plugins/dali-swig/examples/firstscreen/FocusEffect.cs index d02e483..f34986e 100644 --- a/plugins/dali-swig/examples/firstscreen/FocusEffect.cs +++ b/plugins/dali-swig/examples/firstscreen/FocusEffect.cs @@ -1,7 +1,6 @@ using Dali; using System; using System.Collections.Generic; -using System.Collections.Specialized; namespace FirstScreen { @@ -9,14 +8,14 @@ namespace FirstScreen { private float _frameThickness; private FocusData[] _focusData; // Each FocusData is used for one key frame animation (total 6 key frame animations needed for EddenEffect) - private Animation _animation; // Animation used to apply all six key frame animations + private Animation _animation; // Animation used to apply all six key frame animations public FocusEffect() { _frameThickness = 10.0f; float _bottomFrameTime = 0.6f; // complete the halo/bottom animation 60% of the way through - float _sideFrameTime = 0.8f; // Start the side frame animation after the bottom animation and complete at 80% of the way through - float _topFrameTime = 1.0f; // start the top frame animation after the side frame animation and complete at 100% way through + float _sideFrameTime = 0.8f; // Start the side frame animation after the bottom animation and complete at 80% of the way through + float _topFrameTime = 1.0f; // start the top frame animation after the side frame animation and complete at 100% way through // Six key frame animations (FocusData objects) needed for EddenEffect // Two key frame animations for top horizontal effect @@ -25,27 +24,27 @@ namespace FirstScreen _focusData = new FocusData[6]; FocusData focusData = new FocusData("halo", "halo.png", FocusData.Direction.Horizontal, NDalic.ParentOriginTopCenter, - new Vector3(50,20,0), new Vector3(0.0f, 100.0f , 0.0f), 0.0f, _bottomFrameTime); + new Vector3(50,20,0), new Vector3(0.0f, 100.0f , 0.0f), 0.0f, _bottomFrameTime); _focusData[0] = focusData; focusData = new FocusData("bottom", "horizontalFrame.png", FocusData.Direction.Horizontal, NDalic.ParentOriginTopCenter, - new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, _frameThickness, 0.0f), 0.0f, _bottomFrameTime); + new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, _frameThickness, 0.0f), 0.0f, _bottomFrameTime); _focusData[1] = focusData; focusData = new FocusData("left", "verticalFrame.png", FocusData.Direction.Vertical, NDalic.ParentOriginBottomLeft, - new Vector3(0.0f, 0.0f, 0.0f), new Vector3(_frameThickness, 0.0f, 0.0f), _bottomFrameTime, _sideFrameTime); + new Vector3(0.0f, 0.0f, 0.0f), new Vector3(_frameThickness, 0.0f, 0.0f), _bottomFrameTime, _sideFrameTime); _focusData[2] = focusData; focusData = new FocusData("right", "verticalFrame.png", FocusData.Direction.Vertical, NDalic.ParentOriginBottomRight, - new Vector3(0.0f, 0.0f, 0.0f), new Vector3(_frameThickness, 0.0f, 0.0f), _bottomFrameTime, _sideFrameTime); + new Vector3(0.0f, 0.0f, 0.0f), new Vector3(_frameThickness, 0.0f, 0.0f), _bottomFrameTime, _sideFrameTime); _focusData[3] = focusData; focusData = new FocusData("top-left", "horizontalFrame.png", FocusData.Direction.Horizontal, NDalic.ParentOriginBottomLeft, - new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f ,_frameThickness, 0.0f), _sideFrameTime, _topFrameTime); + new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f ,_frameThickness, 0.0f), _sideFrameTime, _topFrameTime); _focusData[4] = focusData; focusData = new FocusData("top-right", "horizontalFrame.png", FocusData.Direction.Horizontal, NDalic.ParentOriginBottomRight, - new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, _frameThickness, 0.0f), _sideFrameTime, _topFrameTime); + new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, _frameThickness, 0.0f), _sideFrameTime, _topFrameTime); _focusData[5] = focusData; } @@ -200,4 +199,3 @@ namespace FirstScreen } } } - diff --git a/plugins/dali-swig/examples/firstscreen/IFocusEffect.cs b/plugins/dali-swig/examples/firstscreen/IFocusEffect.cs index 222c2ed..8e8b9d6 100644 --- a/plugins/dali-swig/examples/firstscreen/IFocusEffect.cs +++ b/plugins/dali-swig/examples/firstscreen/IFocusEffect.cs @@ -14,4 +14,3 @@ namespace FirstScreen void FocusAnimation(View parentItem, Vector3 itemSize, float duration, FocusEffectDirection direction); } } - diff --git a/plugins/dali-swig/examples/firstscreen/Program.cs b/plugins/dali-swig/examples/firstscreen/Program.cs index d33c1f6..1470a4a 100644 --- a/plugins/dali-swig/examples/firstscreen/Program.cs +++ b/plugins/dali-swig/examples/firstscreen/Program.cs @@ -11,4 +11,3 @@ namespace FirstScreen } } } - diff --git a/plugins/dali-swig/examples/firstscreen/ScrollContainer.cs b/plugins/dali-swig/examples/firstscreen/ScrollContainer.cs index 633af05..adaee72 100644 --- a/plugins/dali-swig/examples/firstscreen/ScrollContainer.cs +++ b/plugins/dali-swig/examples/firstscreen/ScrollContainer.cs @@ -6,88 +6,37 @@ using System.Collections.Generic; namespace FirstScreen { - public class ScrollContainer + public class ScrollContainer : CustomView { - private View _container; - private Actor _itemRoot; - private Vector3 _itemSize; - private List _itemList; - private int _itemCount; - private int _focusedItem; - private PanGestureDetector _panGestureDetector; - private float _scrollDisplacement; - private float _currentScrollPosition; - private float _padding; - private float _width; - private float _height; - private bool _isFocused; - private float _marginX; - private float _marginY; - private float _offsetY; - private float _offsetX; - private Stage _stage; - private Vector2 _stageSize; - private ImageView _shadowBorder; - private ImageView _spotLight; - private Animation _spotLightAnimation; - private Animation _showAnimation; - private Animation _hideAnimation; - private Animation _focusAnimation; - private Animation _scrollAnimation; - private Animation _focusTransitionAnimation; - private Path _circularPath; - private bool _shouldHide; - - public ScrollContainer() + private View _container; // View Container will be the first item added to ScrollContainer and parent to all the items added to the ScrollContainer. + private Vector3 _itemSize; // Size of the item / images added to the ScrollContainer. + private List _itemList; // List collection of View items/images added to the ScrollContainer. + private int _itemCount; // Number of items / images added to the ScrollContainer. + private int _focusedItem; // Index of currently focused View item / image on the ScrollContainer. + private float _scrollDisplacement; // Used for horizontal pan displacement. + private float _currentScrollPosition; // Used for horizontal scroll position. + private float _gap; // Used for gap / padding between items / images on the ScrollContainer. + private float _width; // Width of the ScrollContainer. + private float _height; // Height of the ScrollContainer. + private bool _isFocused; // Flag to check if ScrollContainer is enabled or not. + private float _marginX; // Extra horizontal margin is used to add an extra gap between items / images after a focused and scaled item / image. + private float _marginY; // Extra vertical margin (not used at the moment). + private float _offsetYFactor; // Vertical Position offset Factor of item height. + private float _offsetX; // Horizontal Position offset of ScrollContainer. + private Stage _stage; // Reference to Dali stage. + private Vector2 _stageSize; // Reference to Dali stage size. + private ImageView _shadowBorder; // Reference to Shadow border ImageView applied to the focused item on ScrollContainer. + private ImageView _spotLight; // Reference to SpotLight ImageView applied to the focused item on ScrollContainer. + private Animation _spotLightAnimation; // SpotLight Animation applied to the focused item on ScrollContainer. + private Animation _focusAnimation; // Focused position animation on ScrollContainer. + private Animation _scrollAnimation; // Scroll animation on items of ScrollContainer. + private Animation _focusTransitionAnimation; // Focus Transition (scaling /unscaling) animation on items of ScrollContainer. + private Path _circularPath; // Circular path used for SpotLight Animation applied to the focused item on ScrollContainer. + + public ScrollContainer() : base(ViewWrapperImpl.CustomViewBehaviour.DISABLE_STYLE_CHANGE_SIGNALS | + ViewWrapperImpl.CustomViewBehaviour.REQUIRES_KEYBOARD_NAVIGATION_SUPPORT) { - _itemSize = new Vector3(0.0f, 0.0f, 0.0f); - _padding = 0.0f; - _width = 0.0f; - _height = 0.0f; - _currentScrollPosition = 0.0f; - _itemCount = 0; - _focusedItem = -1; - _isFocused = false; - _marginX = 50.0f; - _marginY = 0.0f; - _offsetY = 0.0f; - _offsetX = 0.0f; - - _shouldHide = true; - - _container = new View(); - _itemRoot = new Actor(); - _container.Add(_itemRoot); - - _itemList = new List(); - - if (_panGestureDetector == null) - { - _panGestureDetector = new PanGestureDetector(); - _panGestureDetector.Attach(_container); - _panGestureDetector.Detected += OnPan; - } - - _container.ParentOrigin = NDalic.ParentOriginTopLeft; - _container.AnchorPoint = NDalic.AnchorPointTopLeft; - _itemRoot.ParentOrigin = NDalic.ParentOriginTopLeft; - _itemRoot.AnchorPoint = NDalic.AnchorPointTopLeft; - - _container.WidthResizePolicy = "FILL_TO_PARENT"; - _container.HeightResizePolicy = "FILL_TO_PARENT"; - _itemRoot.WidthResizePolicy = "FILL_TO_PARENT"; - _itemRoot.HeightResizePolicy = "FILL_TO_PARENT"; - - _stage = Stage.GetCurrent(); - _stageSize = _stage.GetSize(); - - _spotLightAnimation = new Animation(5.0f); - _focusTransitionAnimation = new Animation (0.35f); - _focusAnimation = new Animation (0.35f); - _focusAnimation.SetEndAction(Animation.EndAction.BakeFinal); - _scrollAnimation = new Animation (0.35f); - _scrollAnimation.SetEndAction(Animation.EndAction.BakeFinal); } public bool IsFocused @@ -114,14 +63,6 @@ namespace FirstScreen } } - public Actor ItemRoot - { - get - { - return _itemRoot; - } - } - public Vector3 ItemSize { get @@ -148,16 +89,16 @@ namespace FirstScreen } } - public float Padding + public float Gap { get { - return _padding; + return _gap; } set { - _padding = value; + _gap = value; } } @@ -174,16 +115,16 @@ namespace FirstScreen } } - public float OffsetY + public float OffsetYFator { get { - return _offsetY; + return _offsetYFactor; } set { - _offsetY = value; + _offsetYFactor = value; } } @@ -278,161 +219,168 @@ namespace FirstScreen } } - public Actor GetCurrentFocusedActor() + // This override method is called automatically after the Control has been initialized. + // Any second phase initialization is done here. + public override void OnInitialize() { - if (_focusedItem < 0) - { - _focusedItem = 0; - } + _itemSize = new Vector3(0.0f, 0.0f, 0.0f); + _gap = 0.0f; + _width = 0.0f; + _height = 0.0f; + _currentScrollPosition = 0.0f; + _itemCount = 0; + _focusedItem = -1; + _isFocused = false; + _marginX = 50.0f; + _marginY = 0.0f; + _offsetYFactor = 0.0f; + _offsetX = 0.0f; - return _itemList[_focusedItem]; - } + _container = new View(); + this.Add(_container); - public void AddItem(View item) - { - item.AnchorPoint = NDalic.AnchorPointBottomCenter; - item.ParentOrigin = NDalic.ParentOriginBottomCenter; + _itemList = new List(); - item.Size = _itemSize; - item.SetKeyboardFocusable(true); - item.Position = GetItemPosition(_itemCount, _currentScrollPosition); + this.ParentOrigin = NDalic.ParentOriginTopLeft; + this.AnchorPoint = NDalic.AnchorPointTopLeft; + this.WidthResizePolicy = "FILL_TO_PARENT"; + this.HeightResizePolicy = "FILL_TO_PARENT"; + this.SetKeyboardFocusable(true); - item.Name = _itemCount.ToString(); + _container.ParentOrigin = NDalic.ParentOriginTopLeft; + _container.AnchorPoint = NDalic.AnchorPointTopLeft; + _container.WidthResizePolicy = "FILL_TO_PARENT"; + _container.HeightResizePolicy = "FILL_TO_PARENT"; -// item.ClippingMode = "CLIP_CHILDREN"; + _stage = Stage.GetCurrent(); + _stageSize = _stage.GetSize(); + + _spotLightAnimation = new Animation(Constants.SpotLightDuration); + _focusTransitionAnimation = new Animation(Constants.FocusTransitionDuration); + _focusAnimation = new Animation(Constants.FocusDuration); + _focusAnimation.SetEndAction(Animation.EndAction.BakeFinal); + _scrollAnimation = new Animation(Constants.ScrollDuration); + _scrollAnimation.SetEndAction(Animation.EndAction.BakeFinal); - _itemRoot.Add(item); - _itemList.Add(item); - _panGestureDetector.Attach(item); - _itemCount++; + EnableGestureDetection(Gesture.Type.Pan); } - // Perform Show animation on ScrollContainer (used only for Poster Container) - public void Show() + // This will be invoked automatically if an item/image is added to the ScrollContainer + public override void OnChildAdd(Actor actor) { - Container.Add(ItemRoot); + View item = View.DownCast(actor); - _shouldHide = false; - _showAnimation = new Animation (0.35f); + if (item is View && item != _container) + { + item.AnchorPoint = NDalic.AnchorPointBottomCenter; + item.ParentOrigin = NDalic.ParentOriginBottomCenter; - _showAnimation.AnimateTo(new Property(_container, Actor.Property.COLOR_ALPHA), new Property.Value(1.0f)); + item.Size = _itemSize; + item.SetKeyboardFocusable(true); + item.Position = GetItemPosition(_itemCount, _currentScrollPosition); - _container.PositionY = _container.Position.y + 200.0f; - float targetPositionY = _container.Position.y - 200.0f; - _showAnimation.AnimateTo(new Property(_container, Actor.Property.POSITION_Y), new Property.Value(targetPositionY), - new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR)); + item.Name = _itemCount.ToString(); - _showAnimation.Play(); - } + //item.ClippingMode = "CLIP_CHILDREN"; - // Perform Hide animation on ScrollContainer (used only for Poster Container) - public void Hide() - { - if (_hideAnimation) - { - _hideAnimation.Clear(); - _hideAnimation.Reset(); - } + _container.Add(item); + _itemList.Add(item); - float duration = 0.35f; - _hideAnimation = new Animation(duration); + _itemCount++; + item.SetKeyboardFocusable(true); + } + } - _hideAnimation.AnimateTo(new Property(_container, Actor.Property.COLOR_ALPHA), new Property.Value(0.0f), - new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR), new TimePeriod(0.0f, duration * 0.75f)); + // This will be invoked automatically if an item/image is removed from the ScrollContainer + public override void OnChildRemove(Actor actor) + { + View item = View.DownCast(actor); - _hideAnimation.Finished += OnHideAnimationFinished; + if (item is View && item != _container) + { + _container.Remove(item); - _shouldHide = true; - _hideAnimation.Play(); + _itemCount--; + _itemList.Remove(item); + } } - public View Focus(int itemId) + // This override function supports two dimensional keyboard navigation. + // This function returns the next keyboard focusable actor in ScrollContainer control towards the given direction. + public override Actor GetNextKeyboardFocusableActor(Actor currentFocusedActor, View.KeyboardFocus.Direction direction, bool loopEnabled) { - if (itemId < 0) + if (direction == View.KeyboardFocus.Direction.LEFT) { - itemId = 0; + return FocusPrevious(loopEnabled); } - else if (itemId >= _itemList.Count) + else if (direction == View.KeyboardFocus.Direction.RIGHT) { - itemId = _itemList.Count - 1; + return FocusNext(loopEnabled); } - - _itemList[itemId].Add(_shadowBorder); - _itemList[itemId].Add(_spotLight); - - // Perform Spot Light animation - if(_focusedItem != itemId && _spotLight != null) + else { - _spotLightAnimation.Clear(); - _spotLightAnimation.Animate( _spotLight, _circularPath, new Vector3(0.0f, 0.0f, 0.0f) ); - _spotLightAnimation.SetLooping(true); - _spotLightAnimation.Play(); + return currentFocusedActor; } + } - _focusedItem = itemId; + // This override function is invoked before chosen focusable actor will be focused. + // This allows the application to preform any actions (i.e. Scroll and SpotLight animations) before the focus is actually moved to the chosen actor. + public override void OnKeyboardFocusChangeCommitted(Actor commitedFocusableActor) + { + Focus(_focusedItem); + } - Vector3 itemPosition = GetItemPosition(_focusedItem, _currentScrollPosition); + // This override function is invoked whenever a pan gesture is detected on this control. + // Perform Scroll Animation based upon pan gesture velocity / speed. + public override void OnPan(PanGesture pan) + { + switch (pan.state) + { + case Gesture.State.Started: + _scrollDisplacement = 0.0f; + break; - _focusAnimation.Clear(); + case Gesture.State.Continuing: + _scrollDisplacement = pan.displacement.x; + break; - float relativeItemPositionX = itemPosition.x - _itemSize.width * 0.5f + (_stageSize.width * 0.5f) + _offsetX; - if (relativeItemPositionX < _marginX + _offsetX + _padding) - { - float amount = _marginX + _offsetX + _padding - relativeItemPositionX; - Scroll(amount, itemId + 1); // Perform Scroll animation - } - else if (relativeItemPositionX + _itemSize.width + _padding + _marginX > _stageSize.width) - { - float amount = relativeItemPositionX + _marginX + _padding + _itemSize.width - _stageSize.width; - Scroll(-amount, itemId - 1); // Perform Scroll animation - } - else - { - for (int i = 0; i < _itemList.Count; ++i) - { - Vector3 targetPosition = GetItemPosition(i, _currentScrollPosition); - _focusAnimation.AnimateTo(new Property(_itemList[i], Actor.Property.POSITION), - new Property.Value(targetPosition), - new AlphaFunction(AlphaFunction.BuiltinFunction.EASE_OUT_SINE)); - } - } + case Gesture.State.Finished: + case Gesture.State.Cancelled: + float absScrollDistance = _scrollDisplacement; + if (absScrollDistance < 0.0f) + absScrollDistance = 0.0f - absScrollDistance; - for (int i = 0; i < _itemList.Count; ++i) - { - SetupItemRenderer(_itemList[i], false); + float scrollSpeed = pan.velocity.x * pan.velocity.x + pan.velocity.y * pan.velocity.y; + float maxScrollSpeed = 40.0f; // TBD + if (scrollSpeed > maxScrollSpeed) + scrollSpeed = maxScrollSpeed; - // Perform Focus animation - if (i == _focusedItem) - { - _focusAnimation.AnimateTo(new Property(_itemList[i], Actor.Property.SCALE), - new Property.Value(new Vector3(1.2f, 1.2f, 1.2f)), - new AlphaFunction(AlphaFunction.BuiltinFunction.EASE_OUT_SINE)); - } - else + if (absScrollDistance > 1.0f && scrollSpeed > 0.05f) // Threshold TBD { - _focusAnimation.AnimateTo(new Property(_itemList[i], Actor.Property.SCALE), - new Property.Value(new Vector3(1.0f, 1.0f, 1.0f)), - new AlphaFunction(AlphaFunction.BuiltinFunction.EASE_OUT_SINE)); + if (_scrollDisplacement > 0.0f) // scroll constant distance in constant speed. + { + Scroll((_itemSize.x + _gap) * 2, GetFirstVisibleItemId()); + } + else + { + Scroll(-(_itemSize.x + _gap) * 2, GetFirstVisibleItemId()); + } } + break; } + } - _focusAnimation.Play(); - - if (_isFocused && _focusedItem >= 0) + // This function returns current focused actor + public View GetCurrentFocusedActor() + { + if (_focusedItem < 0) { - SetupItemRenderer(_itemList[_focusedItem], true); - SetupSpotLightRenderer(); + _focusedItem = 0; } return _itemList[_focusedItem]; } - // Perform EddenEffect animation on Focused Item specified - public void FocusAnimation(FocusEffect focusEffect, FocusEffectDirection direction) - { - focusEffect.FocusAnimation(_itemList[_focusedItem], _itemSize, 1.0f, direction); - } - public void SetFocused(bool focused) { _isFocused = focused; @@ -459,12 +407,12 @@ namespace FirstScreen SetupItemRenderer(_itemList[i], false); Vector3 targetPosition = GetItemPosition(i, _currentScrollPosition); - _focusTransitionAnimation.AnimateTo(new Property(_itemList[i], Actor.Property.POSITION), - new Property.Value(targetPosition), + _focusTransitionAnimation.AnimateTo(new Dali.Property(_itemList[i], Actor.Property.POSITION), + new Dali.Property.Value(targetPosition), new AlphaFunction(AlphaFunction.BuiltinFunction.EASE_OUT_SINE)); - _focusTransitionAnimation.AnimateTo(new Property(_itemList[i], Actor.Property.SCALE), - new Property.Value(new Vector3(1.0f, 1.0f, 1.0f)), + _focusTransitionAnimation.AnimateTo(new Dali.Property(_itemList[i], Actor.Property.SCALE), + new Dali.Property.Value(new Vector3(1.0f, 1.0f, 1.0f)), new AlphaFunction(AlphaFunction.BuiltinFunction.EASE_OUT_SINE)); } @@ -477,17 +425,17 @@ namespace FirstScreen } // Obtain ID of first visible item/image on the screen of the ScrollContainer - public int GetFirstVisibleItemId() + private int GetFirstVisibleItemId() { int firstItemId = -1; if (_isFocused) { - firstItemId = (int)Math.Floor((-1.0 * _currentScrollPosition + _marginX * 2.0f) / (_itemSize.x + _padding)); + firstItemId = (int)Math.Floor((-1.0 * _currentScrollPosition + _marginX * 2.0f) / (_itemSize.x + _gap)); } else { - firstItemId = (int)Math.Floor(-1.0 * _currentScrollPosition / (_itemSize.x + _padding)); + firstItemId = (int)Math.Floor(-1.0 * _currentScrollPosition / (_itemSize.x + _gap)); } if (firstItemId < 0) @@ -499,7 +447,7 @@ namespace FirstScreen } // Obtain ID of last visible item/image on the screen of the ScrollContainer - public int GetLastVisibleItemId() + private int GetLastVisibleItemId() { int lastItemId = -1; @@ -522,7 +470,7 @@ namespace FirstScreen } // Obtain Next item/image (Right of the currently focused item) of the ScrollContainer - public Actor FocusNext() + private Actor FocusNext(bool loopEnabled) { int nextItem = -1; @@ -535,11 +483,24 @@ namespace FirstScreen nextItem = _focusedItem + 1; } - return Focus(nextItem); + if (nextItem >= _itemList.Count) + { + if (loopEnabled) + { + nextItem = 0; + } + else + { + nextItem = _itemList.Count - 1; + } + } + + _focusedItem = nextItem; + return _itemList[_focusedItem]; } // Obtain Previous item/image (left of the currently focused item) of the ScrollContainer - public Actor FocusPrevious() + private Actor FocusPrevious(bool loopEnabled) { int previousItem = -1; @@ -552,61 +513,27 @@ namespace FirstScreen previousItem = _focusedItem - 1; } - return Focus(previousItem); - } - - private void OnHideAnimationFinished(object source, Animation.FinishedEventArgs e) - { - var currentParent = ItemRoot.GetParent(); - if (_shouldHide && currentParent != null) + if (previousItem < 0) { - Container.Remove(ItemRoot); - } - } - - private void OnPan(object source, PanGestureDetector.DetectedEventArgs e) - { - switch (e.PanGesture.state) - { - case Gesture.State.Started: - _scrollDisplacement = 0.0f; - break; - - case Gesture.State.Continuing: - _scrollDisplacement = e.PanGesture.displacement.x; - break; - - case Gesture.State.Finished: - case Gesture.State.Cancelled: - float absScrollDistance = _scrollDisplacement; - if (absScrollDistance < 0.0f) - absScrollDistance = 0.0f - absScrollDistance; - - float scrollSpeed = e.PanGesture.velocity.x * e.PanGesture.velocity.x + e.PanGesture.velocity.y * e.PanGesture.velocity.y; - float maxScrollSpeed = 40.0f; // TBD - if (scrollSpeed > maxScrollSpeed) - scrollSpeed = maxScrollSpeed; - - if (absScrollDistance > 1.0f && scrollSpeed > 0.05f) // Threshold TBD + if (loopEnabled) { - if (_scrollDisplacement > 0.0f) // scroll constant distance in constant speed. - { - Scroll((_itemSize.x + _padding) * 2, GetFirstVisibleItemId()); - } - else - { - Scroll(-(_itemSize.x + _padding) * 2, GetFirstVisibleItemId()); - } + previousItem = _itemList.Count - 1; + } + else + { + previousItem = 0; } - break; } + + _focusedItem = previousItem; + return _itemList[_focusedItem]; } // Perform ScrollAnimation on each item private void Scroll(float amount, int baseItem) { float tagetScrollPosition = _currentScrollPosition + amount; - float totalItemSize = _itemList.Count * (_itemSize.width + _padding) + _padding + (_marginX * 2.0f); + float totalItemSize = _itemList.Count * (_itemSize.width + _gap) + _gap + (_marginX * 2.0f); float maxScrollPosition = _width - totalItemSize; @@ -618,14 +545,13 @@ namespace FirstScreen { tagetScrollPosition = 0.0f; } - _scrollAnimation.Clear(); for (int i = 0; i < _itemList.Count; ++i) { Vector3 targetPosition = GetItemPosition(i, tagetScrollPosition); - _scrollAnimation.AnimateTo(new Property(_itemList[i], Actor.Property.POSITION), - new Property.Value(targetPosition), + _scrollAnimation.AnimateTo(new Dali.Property(_itemList[i], Actor.Property.POSITION), + new Dali.Property.Value(targetPosition), new AlphaFunction(AlphaFunction.BuiltinFunction.EASE_OUT_SINE)); } @@ -633,6 +559,87 @@ namespace FirstScreen _scrollAnimation.Play(); } + // This function uses ItemId as next FocusedItem and preforms Scroll and SpotLight animations on that item. + private void Focus(int itemId) + { + if (itemId < 0) + { + itemId = 0; + } + else if (itemId >= _itemList.Count) + { + itemId = _itemList.Count - 1; + } + + _itemList[itemId].Add(_shadowBorder); + _itemList[itemId].Add(_spotLight); + + // Perform Spot Light animation + if(_focusedItem != itemId && _spotLight != null) + { + _spotLightAnimation.Clear(); + _spotLightAnimation.Animate( _spotLight, _circularPath, new Vector3(0.0f, 0.0f, 0.0f) ); + _spotLightAnimation.SetLooping(true); + _spotLightAnimation.Play(); + } + + _focusedItem = itemId; + + Vector3 itemPosition = GetItemPosition(_focusedItem, _currentScrollPosition); + + _focusAnimation.Clear(); + + float relativeItemPositionX = itemPosition.x - _itemSize.width * 0.5f + (_stageSize.width * 0.5f) + _offsetX; + if (relativeItemPositionX < _marginX + _offsetX + _gap) + { + float amount = _marginX + _offsetX + _gap - relativeItemPositionX; + Scroll(amount, itemId + 1); // Perform Scroll animation + } + else if (relativeItemPositionX + _itemSize.width + _gap + _marginX > _stageSize.width) + { + float amount = relativeItemPositionX + _marginX + _gap + _itemSize.width - _stageSize.width; + Scroll(-amount, itemId - 1); // Perform Scroll animation + } + else + { + // Perform animation when item is focused + for (int i = 0; i < _itemList.Count; ++i) + { + Vector3 targetPosition = GetItemPosition(i, _currentScrollPosition); + _focusAnimation.AnimateTo(new Dali.Property(_itemList[i], Actor.Property.POSITION), + new Dali.Property.Value(targetPosition), + new AlphaFunction(AlphaFunction.BuiltinFunction.EASE_OUT_SINE)); + } + } + + for (int i = 0; i < _itemList.Count; ++i) + { + SetupItemRenderer(_itemList[i], false); + + // Perform scale animation on Focused item + if (i == _focusedItem) + { + _focusAnimation.AnimateTo(new Dali.Property(_itemList[i], Actor.Property.SCALE), + new Dali.Property.Value(new Vector3(1.2f, 1.2f, 1.2f)), + new AlphaFunction(AlphaFunction.BuiltinFunction.EASE_OUT_SINE)); + } + else + { + _focusAnimation.AnimateTo(new Dali.Property(_itemList[i], Actor.Property.SCALE), + new Dali.Property.Value(new Vector3(1.0f, 1.0f, 1.0f)), + new AlphaFunction(AlphaFunction.BuiltinFunction.EASE_OUT_SINE)); + } + } + + _focusAnimation.Play(); + + if (_isFocused && _focusedItem >= 0) + { + SetupItemRenderer(_itemList[_focusedItem], true); + SetupSpotLightRenderer(); + } + } + // Calculate Position of any item/image of ScrollContainer private Vector3 GetItemPosition(int itemId, float scrollPosition) { @@ -642,24 +649,24 @@ namespace FirstScreen // used (_stageSize.width * 0.5f) because of ParentOriginCenter if (_focusedItem > itemId) { - float positionX = (_itemSize.width * itemId) + (_padding * (itemId + 1)) + scrollPosition + (_itemSize.width * 0.5f) - (_stageSize.width * 0.5f); - return new Vector3(positionX, -_itemSize.height * _offsetY, 0.0f); + float positionX = (_itemSize.width * itemId) + (_gap * (itemId + 1)) + scrollPosition + (_itemSize.width * 0.5f) - (_stageSize.width * 0.5f); + return new Vector3(positionX, -_itemSize.height * _offsetYFactor, 0.0f); } else if (_focusedItem == itemId) { - float positionX = (_itemSize.width * itemId) + (_padding * (itemId + 1)) + scrollPosition + _marginX + (_itemSize.width * 0.5f) - (_stageSize.width * 0.5f); - return new Vector3(positionX, -_itemSize.height * _offsetY, 0.0f); + float positionX = (_itemSize.width * itemId) + (_gap * (itemId + 1)) + scrollPosition + _marginX + (_itemSize.width * 0.5f) - (_stageSize.width * 0.5f); + return new Vector3(positionX, -_itemSize.height * _offsetYFactor, 0.0f); } else { - float positionX = (_itemSize.width * itemId) + (_padding * (itemId + 1)) + scrollPosition + _marginX * 2.0f + (_itemSize.width * 0.5f) - (_stageSize.width * 0.5f); - return new Vector3(positionX, -_itemSize.height * _offsetY, 0.0f); + float positionX = (_itemSize.width * itemId) + (_gap * (itemId + 1)) + scrollPosition + _marginX * 2.0f + (_itemSize.width * 0.5f) - (_stageSize.width * 0.5f); + return new Vector3(positionX, -_itemSize.height * _offsetYFactor, 0.0f); } } else { - float positionX = (_itemSize.width * itemId) + (_padding * (itemId + 1)) + scrollPosition + (_itemSize.width * 0.5f) - (_stageSize.width * 0.5f); - return new Vector3(positionX, -_itemSize.height * _offsetY, 0.0f); + float positionX = (_itemSize.width * itemId) + (_gap * (itemId + 1)) + scrollPosition + (_itemSize.width * 0.5f) - (_stageSize.width * 0.5f); + return new Vector3(positionX, -_itemSize.height * _offsetYFactor, 0.0f); } } diff --git a/plugins/dali-swig/examples/firstscreen/firstscreen.csproj b/plugins/dali-swig/examples/firstscreen/firstscreen.csproj new file mode 100644 index 0000000..148cd79 --- /dev/null +++ b/plugins/dali-swig/examples/firstscreen/firstscreen.csproj @@ -0,0 +1,47 @@ + + + + Debug + x86 + {7606F35D-21C4-48CE-A38F-A24D6BEDB996} + Exe + firstscreen + firstscreen + v4.5 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + false + x86 + + + full + true + bin\Release + prompt + 4 + false + x86 + + + + + + + + + + + + + + ..\..\NDali.dll + + + \ No newline at end of file diff --git a/plugins/dali-swig/examples/firstscreen/firstscreen.sln b/plugins/dali-swig/examples/firstscreen/firstscreen.sln new file mode 100644 index 0000000..cbe800d --- /dev/null +++ b/plugins/dali-swig/examples/firstscreen/firstscreen.sln @@ -0,0 +1,17 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "firstscreen", "firstscreen.csproj", "{7606F35D-21C4-48CE-A38F-A24D6BEDB996}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7606F35D-21C4-48CE-A38F-A24D6BEDB996}.Debug|x86.ActiveCfg = Debug|x86 + {7606F35D-21C4-48CE-A38F-A24D6BEDB996}.Debug|x86.Build.0 = Debug|x86 + {7606F35D-21C4-48CE-A38F-A24D6BEDB996}.Release|x86.ActiveCfg = Release|x86 + {7606F35D-21C4-48CE-A38F-A24D6BEDB996}.Release|x86.Build.0 = Release|x86 + EndGlobalSection +EndGlobal diff --git a/plugins/dali-swig/manual/cpp/callbackbase_wrap.cpp b/plugins/dali-swig/manual/cpp/callbackbase_wrap.cpp new file mode 100644 index 0000000..6b925d4 --- /dev/null +++ b/plugins/dali-swig/manual/cpp/callbackbase_wrap.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2016 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. + * + */ + +#ifndef CSHARP_CALLBACK_BASE +#define CSHARP_CALLBACK_BASE +#endif + +#include "common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_MakeCallback(void * jarg1) { + void * jresult ; + void (*arg1)(void) = (void (*)(void)) 0 ; + Dali::CallbackBase *result = 0 ; + + arg1 = (void (*)(void))jarg1; + { + try { + result = (Dali::CallbackBase *)Dali::MakeCallback(arg1); + } catch (std::out_of_range& e) { + { + SWIG_CSharpException(SWIG_IndexError, const_cast(e.what())); return 0; + }; + } catch (std::exception& e) { + { + SWIG_CSharpException(SWIG_RuntimeError, const_cast(e.what())); return 0; + }; + } catch (...) { + { + SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return 0; + }; + } + } + + jresult = (void *)result; + + return jresult; +} + +#ifdef __cplusplus +} +#endif + diff --git a/plugins/dali-swig/manual/csharp/DisposeQueue.cs b/plugins/dali-swig/manual/csharp/DisposeQueue.cs new file mode 100644 index 0000000..a62843b --- /dev/null +++ b/plugins/dali-swig/manual/csharp/DisposeQueue.cs @@ -0,0 +1,60 @@ +// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved +// PROPRIETARY/CONFIDENTIAL +// This software is the confidential and proprietary +// information of SAMSUNG ELECTRONICS ("Confidential Information"). You shall +// not disclose such Confidential Information and shall use it only in +// accordance with the terms of the license agreement you entered into with +// SAMSUNG ELECTRONICS. +// + +using System; +using System.Collections.Generic; + +namespace Dali +{ + + public class DisposeQueue + { + private static DisposeQueue _disposableQueue = new DisposeQueue(); + private List _disposables = new List(); + private Object _listLock = new object(); + private delegate int ProcessDisposablesDelegate(IntPtr ptr); + private ProcessDisposablesDelegate _disposequeueProcessDisposablesDelegate; + + private DisposeQueue() + { + _disposequeueProcessDisposablesDelegate = new ProcessDisposablesDelegate(ProcessDisposables); + Application.Instance.AddIdle(_disposequeueProcessDisposablesDelegate); + } + + ~DisposeQueue() + { + } + + public static DisposeQueue Instance + { + get { return _disposableQueue; } + } + + public void Add(IDisposable disposable) + { + lock(_listLock) + { + _disposables.Add(disposable); + } + } + + private int ProcessDisposables(IntPtr ptr) + { + lock(_listLock) + { + foreach (IDisposable disposable in _disposables) + { + disposable.Dispose(); + } + _disposables.Clear(); + } + return 0; + } + } +} diff --git a/plugins/dali-swig/manual/csharp/KeyboardFocusManager.cs b/plugins/dali-swig/manual/csharp/KeyboardFocusManager.cs index 6509966..4051b36 100644 --- a/plugins/dali-swig/manual/csharp/KeyboardFocusManager.cs +++ b/plugins/dali-swig/manual/csharp/KeyboardFocusManager.cs @@ -32,10 +32,15 @@ public class KeyboardFocusManager : BaseHandle { } ~KeyboardFocusManager() { - Dispose(); + DisposeQueue.Instance.Add(this); } public override void Dispose() { + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwn) { diff --git a/plugins/dali-swig/manual/csharp/KeyboardPreFocusChangeSignal.cs b/plugins/dali-swig/manual/csharp/KeyboardPreFocusChangeSignal.cs index 5980e96..949dfb8 100644 --- a/plugins/dali-swig/manual/csharp/KeyboardPreFocusChangeSignal.cs +++ b/plugins/dali-swig/manual/csharp/KeyboardPreFocusChangeSignal.cs @@ -35,10 +35,15 @@ public class KeyboardPreFocusChangeSignal : global::System.IDisposable { } ~KeyboardPreFocusChangeSignal() { - Dispose(); + DisposeQueue.Instance.Add(this); } public virtual void Dispose() { + if (!Stage.IsInstalled()) { + DisposeQueue.Instance.Add(this); + return; + } + lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwn) { diff --git a/plugins/dali-swig/manual/csharp/ManualPINVOKE.cs b/plugins/dali-swig/manual/csharp/ManualPINVOKE.cs index 782ad37..d39ebcb 100644 --- a/plugins/dali-swig/manual/csharp/ManualPINVOKE.cs +++ b/plugins/dali-swig/manual/csharp/ManualPINVOKE.cs @@ -183,5 +183,9 @@ namespace Dali [global::System.Runtime.InteropServices.DllImport("NDalic", EntryPoint="CSharp_Dali_ViewWrapperImpl_ApplyThemeStyle")] public static extern void ViewWrapperImpl_ApplyThemeStyle(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport("NDalic", EntryPoint="CSharp_Dali_MakeCallback")] + public static extern global::System.IntPtr MakeCallback(global::System.Runtime.InteropServices.HandleRef jarg1); + } }