From: Adeel Kazmi Date: Tue, 22 Sep 2020 18:12:06 +0000 (+0000) Subject: Merge "Make MeasureCallback signature .NET friendly" into devel/master X-Git-Tag: dali_1.9.31~2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=8bb92d7d1170f2ddf59da60bd3588be601ef8cd2;hp=cabf76b631c0365a1e8f396b91ee54faa4994880 Merge "Make MeasureCallback signature .NET friendly" into devel/master --- diff --git a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt index bbb53b3..851ca00 100755 --- a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt @@ -55,6 +55,7 @@ LIST(APPEND TC_SOURCES ../dali-toolkit/dali-toolkit-test-utils/toolkit-timer.cpp ../dali-toolkit/dali-toolkit-test-utils/toolkit-tts-player.cpp ../dali-toolkit/dali-toolkit-test-utils/toolkit-vector-animation-renderer.cpp + ../dali-toolkit/dali-toolkit-test-utils/toolkit-vector-image-renderer.cpp ../dali-toolkit/dali-toolkit-test-utils/toolkit-window.cpp ../dali-toolkit/dali-toolkit-test-utils/toolkit-scene-holder.cpp ../dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.cpp diff --git a/automated-tests/src/dali-toolkit/CMakeLists.txt b/automated-tests/src/dali-toolkit/CMakeLists.txt index d7b4a5b..d889c6f 100755 --- a/automated-tests/src/dali-toolkit/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit/CMakeLists.txt @@ -95,6 +95,7 @@ LIST(APPEND TC_SOURCES dali-toolkit-test-utils/toolkit-tts-player.cpp dali-toolkit-test-utils/toolkit-native-image-source.cpp dali-toolkit-test-utils/toolkit-vector-animation-renderer.cpp + dali-toolkit-test-utils/toolkit-vector-image-renderer.cpp dali-toolkit-test-utils/toolkit-video-player.cpp dali-toolkit-test-utils/toolkit-web-engine.cpp dali-toolkit-test-utils/toolkit-window.cpp diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-vector-image-renderer.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-vector-image-renderer.cpp new file mode 100644 index 0000000..3513410 --- /dev/null +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-vector-image-renderer.cpp @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2020 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 + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +class VectorImageRenderer: public Dali::BaseObject +{ +public: + + VectorImageRenderer() + : mUrl(), + mRenderer(), + mWidth( 0 ), + mHeight( 0 ) + { + } + + ~VectorImageRenderer() + { + } + + bool Render( float scale ) + { + return true; + } + + void SetBuffer( Dali::Devel::PixelBuffer &buffer ) + { + } + + bool Load( const std::string& url ) + { + struct stat sb; + if ( stat(url.c_str(), &sb) == 0 ) + { + return true; + } + + return false; + } + + bool Load( const char *data, uint32_t size ) + { + return true; + } + + void GetDefaultSize( uint32_t& width, uint32_t& height ) const + { + width = 100; + height = 100; + } + +public: + + std::string mUrl; + Dali::Renderer mRenderer; + uint32_t mWidth; + uint32_t mHeight; +}; + +inline VectorImageRenderer& GetImplementation( Dali::VectorImageRenderer& renderer ) +{ + DALI_ASSERT_ALWAYS( renderer && "VectorImageRenderer handle is empty." ); + BaseObject& handle = renderer.GetBaseObject(); + return static_cast< Internal::Adaptor::VectorImageRenderer& >( handle ); +} + +inline const VectorImageRenderer& GetImplementation( const Dali::VectorImageRenderer& renderer ) +{ + DALI_ASSERT_ALWAYS( renderer && "VectorImageRenderer handle is empty." ); + const BaseObject& handle = renderer.GetBaseObject(); + return static_cast< const Internal::Adaptor::VectorImageRenderer& >( handle ); +} + +} // namespace Adaptor + +} // namespace Internal + + +/********************************************************************************/ +/********************************* PUBLIC CLASS *******************************/ +/********************************************************************************/ + +VectorImageRenderer VectorImageRenderer::New() +{ + Internal::Adaptor::VectorImageRenderer* imageRenderer = new Internal::Adaptor::VectorImageRenderer(); + + return VectorImageRenderer( imageRenderer ); +} + +VectorImageRenderer::VectorImageRenderer() +{ +} + +VectorImageRenderer::~VectorImageRenderer() +{ +} + +VectorImageRenderer::VectorImageRenderer( Internal::Adaptor::VectorImageRenderer* internal ) +: BaseHandle( internal ) +{ +} + +void VectorImageRenderer::SetBuffer( Dali::Devel::PixelBuffer &buffer ) +{ + Internal::Adaptor::GetImplementation( *this ).SetBuffer( buffer ); +} + +bool VectorImageRenderer::Render( float scale ) +{ + return Internal::Adaptor::GetImplementation( *this ).Render( scale ); +} + +bool VectorImageRenderer::Load( const std::string& url ) +{ + return Internal::Adaptor::GetImplementation( *this ).Load( url ); +} + +bool VectorImageRenderer::Load( const char *data, uint32_t size ) +{ + return Internal::Adaptor::GetImplementation( *this ).Load( data, size ); +} + +void VectorImageRenderer::GetDefaultSize( uint32_t& width, uint32_t& height ) const +{ + Internal::Adaptor::GetImplementation( *this ).GetDefaultSize( width, height ); +} + +} // namespace Dali diff --git a/build/tizen/CMakeLists.txt b/build/tizen/CMakeLists.txt index d122fd5..21b7c0f 100644 --- a/build/tizen/CMakeLists.txt +++ b/build/tizen/CMakeLists.txt @@ -154,6 +154,9 @@ IF( ENABLE_TRACE ) ADD_DEFINITIONS("-DTRACE_ENABLED") ENDIF() +# Remove below when thorvg is ready +ADD_DEFINITIONS( "-DNO_THORVG" ) + # Set paths SET( toolkit_images_dir ${ROOT_SRC_DIR}/dali-toolkit/styles/images-common ) SET( toolkit_sounds_dir ${ROOT_SRC_DIR}/dali-toolkit/sounds ) 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 e6a2804..5fac4ba 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -193,6 +194,8 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P if( textEditor ) { TextEditor& impl( GetImpl( textEditor ) ); + DALI_ASSERT_DEBUG( impl.mController && "No text contoller" ); + DALI_ASSERT_DEBUG( impl.mDecorator && "No text decorator" ); switch( index ) { @@ -211,39 +214,30 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P } case Toolkit::TextEditor::Property::TEXT: { - if( impl.mController ) - { - 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() ); + 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 ); - } + impl.mController->SetText( text ); break; } case Toolkit::TextEditor::Property::TEXT_COLOR: { - if( impl.mController ) + 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->GetDefaultColor() != textColor ) { - 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->GetDefaultColor() != textColor ) - { - impl.mController->SetDefaultColor( textColor ); - impl.mController->SetInputColor( textColor ); - impl.mRenderer.Reset(); - } + impl.mController->SetDefaultColor( textColor ); + impl.mController->SetInputColor( textColor ); + impl.mRenderer.Reset(); } break; } case Toolkit::TextEditor::Property::FONT_FAMILY: { - if( impl.mController ) - { - 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 ); - } + 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 ); break; } case Toolkit::TextEditor::Property::FONT_STYLE: @@ -253,28 +247,22 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P } case Toolkit::TextEditor::Property::POINT_SIZE: { - if( impl.mController ) - { - const float pointSize = value.Get< float >(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p POINT_SIZE %f\n", impl.mController.Get(), pointSize ); + const float pointSize = value.Get< float >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p POINT_SIZE %f\n", impl.mController.Get(), pointSize ); - if( !Equals( impl.mController->GetDefaultFontSize( Text::Controller::POINT_SIZE ), pointSize ) ) - { - impl.mController->SetDefaultFontSize( pointSize, Text::Controller::POINT_SIZE ); - } + if( !Equals( impl.mController->GetDefaultFontSize( Text::Controller::POINT_SIZE ), pointSize ) ) + { + impl.mController->SetDefaultFontSize( pointSize, Text::Controller::POINT_SIZE ); } break; } case Toolkit::TextEditor::Property::HORIZONTAL_ALIGNMENT: { - if( impl.mController ) + Text::HorizontalAlignment::Type alignment( static_cast< Text::HorizontalAlignment::Type >( -1 ) ); // Set to invalid value to ensure a valid mode does get set + if( Text::GetHorizontalAlignmentEnumeration( value, alignment ) ) { - Text::HorizontalAlignment::Type alignment( static_cast< Text::HorizontalAlignment::Type >( -1 ) ); // Set to invalid value to ensure a valid mode does get set - if( Text::GetHorizontalAlignmentEnumeration( value, alignment ) ) - { - DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p HORIZONTAL_ALIGNMENT %d\n", impl.mController.Get(), alignment ); - impl.mController->SetHorizontalAlignment( alignment ); - } + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p HORIZONTAL_ALIGNMENT %d\n", impl.mController.Get(), alignment ); + impl.mController->SetHorizontalAlignment( alignment ); } break; } @@ -283,10 +271,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P const float threshold = value.Get< float >(); DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p SCROLL_THRESHOLD %f\n", impl.mController.Get(), threshold ); - if( impl.mDecorator ) - { - impl.mDecorator->SetScrollThreshold( threshold ); - } + impl.mDecorator->SetScrollThreshold( threshold ); break; } case Toolkit::TextEditor::Property::SCROLL_SPEED: @@ -294,80 +279,59 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P const float speed = value.Get< float >(); DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p SCROLL_SPEED %f\n", impl.mController.Get(), speed ); - if( impl.mDecorator ) - { - impl.mDecorator->SetScrollSpeed( speed ); - } + impl.mDecorator->SetScrollSpeed( speed ); break; } case Toolkit::TextEditor::Property::PRIMARY_CURSOR_COLOR: { - if( impl.mDecorator ) - { - 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 ); + 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 ); - impl.RequestTextRelayout(); - } + impl.mDecorator->SetCursorColor( PRIMARY_CURSOR, color ); + impl.RequestTextRelayout(); break; } case Toolkit::TextEditor::Property::SECONDARY_CURSOR_COLOR: { - if( impl.mDecorator ) - { - 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 ); + 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 ); - impl.RequestTextRelayout(); - } + impl.mDecorator->SetCursorColor( SECONDARY_CURSOR, color ); + impl.RequestTextRelayout(); break; } case Toolkit::TextEditor::Property::ENABLE_CURSOR_BLINK: { - if( impl.mController ) - { - const bool enable = value.Get< bool >(); - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p ENABLE_CURSOR_BLINK %d\n", impl.mController.Get(), enable ); + const bool enable = value.Get< bool >(); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p ENABLE_CURSOR_BLINK %d\n", impl.mController.Get(), enable ); - impl.mController->SetEnableCursorBlink( enable ); - impl.RequestTextRelayout(); - } + impl.mController->SetEnableCursorBlink( enable ); + impl.RequestTextRelayout(); break; } case Toolkit::TextEditor::Property::CURSOR_BLINK_INTERVAL: { - if( impl.mDecorator ) - { - const float interval = value.Get< float >(); - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p CURSOR_BLINK_INTERVAL %f\n", impl.mController.Get(), interval ); + const float interval = value.Get< float >(); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p CURSOR_BLINK_INTERVAL %f\n", impl.mController.Get(), interval ); - impl.mDecorator->SetCursorBlinkInterval( interval ); - } + impl.mDecorator->SetCursorBlinkInterval( interval ); break; } case Toolkit::TextEditor::Property::CURSOR_BLINK_DURATION: { - if( impl.mDecorator ) - { - const float duration = value.Get< float >(); - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p CURSOR_BLINK_DURATION %f\n", impl.mController.Get(), duration ); + const float duration = value.Get< float >(); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p CURSOR_BLINK_DURATION %f\n", impl.mController.Get(), duration ); - impl.mDecorator->SetCursorBlinkDuration( duration ); - } + impl.mDecorator->SetCursorBlinkDuration( duration ); break; } case Toolkit::TextEditor::Property::CURSOR_WIDTH: { - if( impl.mDecorator ) - { - const int width = value.Get< int >(); - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p CURSOR_WIDTH %d\n", impl.mController.Get(), width ); + const int width = value.Get< int >(); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p CURSOR_WIDTH %d\n", impl.mController.Get(), width ); - impl.mDecorator->SetCursorWidth( width ); - impl.mController->GetLayoutEngine().SetCursorWidth( width ); - } + impl.mDecorator->SetCursorWidth( width ); + impl.mController->GetLayoutEngine().SetCursorWidth( width ); break; } case Toolkit::TextEditor::Property::GRAB_HANDLE_IMAGE: @@ -375,7 +339,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P const std::string imageFileName = value.Get< std::string >(); DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p GRAB_HANDLE_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str() ); - if( impl.mDecorator && imageFileName.size() ) + if( imageFileName.size() ) { impl.mDecorator->SetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED, imageFileName ); impl.RequestTextRelayout(); @@ -387,7 +351,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P const std::string imageFileName = value.Get< std::string >(); DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p GRAB_HANDLE_PRESSED_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str() ); - if( impl.mDecorator && imageFileName.size() ) + if( imageFileName.size() ) { impl.mDecorator->SetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED, imageFileName ); impl.RequestTextRelayout(); @@ -398,7 +362,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P { const std::string filename = GetImageFileNameFromPropertyValue( value ); - if( impl.mDecorator && filename.size() ) + if( filename.size() ) { impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, filename ); impl.RequestTextRelayout(); @@ -409,7 +373,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P { const std::string filename = GetImageFileNameFromPropertyValue( value ); - if( impl.mDecorator && filename.size() ) + if( filename.size() ) { impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, filename ); impl.RequestTextRelayout(); @@ -420,7 +384,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P { const std::string filename = GetImageFileNameFromPropertyValue( value ); - if( impl.mDecorator && filename.size() ) + if( filename.size() ) { impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, filename ); impl.RequestTextRelayout(); @@ -431,7 +395,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P { const std::string filename = GetImageFileNameFromPropertyValue( value ); - if( impl.mDecorator && filename.size() ) + if( filename.size() ) { impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, filename ); impl.RequestTextRelayout(); @@ -442,7 +406,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P { const std::string filename = GetImageFileNameFromPropertyValue( value ); - if( impl.mDecorator && filename.size() ) + if( filename.size() ) { impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, filename ); impl.RequestTextRelayout(); @@ -453,7 +417,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P { const std::string filename = GetImageFileNameFromPropertyValue( value ); - if( impl.mDecorator && filename.size() ) + if( filename.size() ) { impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, filename ); impl.RequestTextRelayout(); @@ -465,55 +429,40 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P const Vector4 color = value.Get< Vector4 >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p SELECTION_HIGHLIGHT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a ); - if( impl.mDecorator ) - { - impl.mDecorator->SetHighlightColor( color ); - impl.RequestTextRelayout(); - } + impl.mDecorator->SetHighlightColor( color ); + impl.RequestTextRelayout(); break; } case Toolkit::TextEditor::Property::DECORATION_BOUNDING_BOX: { - if( impl.mDecorator ) - { - 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 ); + 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 ); - impl.RequestTextRelayout(); - } + impl.mDecorator->SetBoundingBox( box ); + impl.RequestTextRelayout(); break; } case Toolkit::TextEditor::Property::ENABLE_MARKUP: { - if( impl.mController ) - { - const bool enableMarkup = value.Get(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p ENABLE_MARKUP %d\n", impl.mController.Get(), enableMarkup ); + const bool enableMarkup = value.Get(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p ENABLE_MARKUP %d\n", impl.mController.Get(), enableMarkup ); - impl.mController->SetMarkupProcessorEnabled( enableMarkup ); - } + impl.mController->SetMarkupProcessorEnabled( enableMarkup ); break; } case Toolkit::TextEditor::Property::INPUT_COLOR: { - if( impl.mController ) - { - 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 ); + 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 ); - } + impl.mController->SetInputColor( inputColor ); break; } case Toolkit::TextEditor::Property::INPUT_FONT_FAMILY: { - if( impl.mController ) - { - 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 ); - } + 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 ); break; } case Toolkit::TextEditor::Property::INPUT_FONT_STYLE: @@ -523,38 +472,28 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P } case Toolkit::TextEditor::Property::INPUT_POINT_SIZE: { - if( impl.mController ) - { - const float pointSize = value.Get< float >(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p INPUT_POINT_SIZE %f\n", impl.mController.Get(), pointSize ); - impl.mController->SetInputFontPointSize( pointSize ); - } + const float pointSize = value.Get< float >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p INPUT_POINT_SIZE %f\n", impl.mController.Get(), pointSize ); + impl.mController->SetInputFontPointSize( pointSize ); break; } case Toolkit::TextEditor::Property::LINE_SPACING: { - if( impl.mController ) - { - - // The line spacing isn't supported by the TextEditor. Since it's supported - // by the TextLabel for now it must be ignored. The property is being shadowed - // locally so its value isn't affected. - const float lineSpacing = value.Get(); - impl.mLineSpacing = lineSpacing; - // set it to 0.0 due to missing implementation - impl.mController->SetDefaultLineSpacing( 0.0f ); - impl.mRenderer.Reset(); - } + // The line spacing isn't supported by the TextEditor. Since it's supported + // by the TextLabel for now it must be ignored. The property is being shadowed + // locally so its value isn't affected. + const float lineSpacing = value.Get(); + impl.mLineSpacing = lineSpacing; + // set it to 0.0 due to missing implementation + impl.mController->SetDefaultLineSpacing( 0.0f ); + impl.mRenderer.Reset(); break; } case Toolkit::TextEditor::Property::INPUT_LINE_SPACING: { - if( impl.mController ) - { - const float lineSpacing = value.Get(); - impl.mController->SetInputLineSpacing( lineSpacing ); - impl.mRenderer.Reset(); - } + const float lineSpacing = value.Get(); + impl.mController->SetInputLineSpacing( lineSpacing ); + impl.mRenderer.Reset(); break; } case Toolkit::TextEditor::Property::UNDERLINE: @@ -675,52 +614,40 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P } case Toolkit::TextEditor::Property::PIXEL_SIZE: { - if( impl.mController ) - { - const float pixelSize = value.Get< float >(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p PIXEL_SIZE %f\n", impl.mController.Get(), pixelSize ); + const float pixelSize = value.Get< float >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p PIXEL_SIZE %f\n", impl.mController.Get(), pixelSize ); - if( !Equals( impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE ), pixelSize ) ) - { - impl.mController->SetDefaultFontSize( pixelSize, Text::Controller::PIXEL_SIZE ); - } + if( !Equals( impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE ), pixelSize ) ) + { + impl.mController->SetDefaultFontSize( pixelSize, Text::Controller::PIXEL_SIZE ); } break; } case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT: { - if( impl.mController ) - { - const std::string& text = value.Get< std::string >(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor::OnPropertySet %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str() ); + const std::string& text = value.Get< std::string >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor::OnPropertySet %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str() ); - impl.mController->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text ); - } + impl.mController->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text ); break; } case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR: { - if( impl.mController ) + const Vector4& textColor = value.Get< Vector4 >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p PLACEHOLDER_TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a ); + + if( impl.mController->GetPlaceholderTextColor() != textColor ) { - const Vector4& textColor = value.Get< Vector4 >(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p PLACEHOLDER_TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a ); - - if( impl.mController->GetPlaceholderTextColor() != textColor ) - { - impl.mController->SetPlaceholderTextColor( textColor ); - impl.mRenderer.Reset(); - } + impl.mController->SetPlaceholderTextColor( textColor ); + impl.mRenderer.Reset(); } break; } case Toolkit::TextEditor::Property::ENABLE_SELECTION: { - if( impl.mController ) - { - const bool enableSelection = value.Get< bool >(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p ENABLE_SELECTION %d\n", impl.mController.Get(), enableSelection ); - impl.mController->SetSelectionEnabled( enableSelection ); - } + const bool enableSelection = value.Get< bool >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p ENABLE_SELECTION %d\n", impl.mController.Get(), enableSelection ); + impl.mController->SetSelectionEnabled( enableSelection ); break; } case Toolkit::TextEditor::Property::PLACEHOLDER: @@ -734,56 +661,41 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P } case Toolkit::TextEditor::Property::LINE_WRAP_MODE: { - if( impl.mController ) + Text::LineWrap::Mode lineWrapMode( static_cast< Text::LineWrap::Mode >( -1 ) ); // Set to invalid value to ensure a valid mode does get set + if( GetLineWrapModeEnumeration( value, lineWrapMode ) ) { - Text::LineWrap::Mode lineWrapMode( static_cast< Text::LineWrap::Mode >( -1 ) ); // Set to invalid value to ensure a valid mode does get set - if( GetLineWrapModeEnumeration( value, lineWrapMode ) ) - { - DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p LineWrap::MODE %d\n", impl.mController.Get(), lineWrapMode ); - impl.mController->SetLineWrapMode( lineWrapMode ); - } + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p LineWrap::MODE %d\n", impl.mController.Get(), lineWrapMode ); + impl.mController->SetLineWrapMode( lineWrapMode ); } break; } case Toolkit::DevelTextEditor::Property::ENABLE_SHIFT_SELECTION: { - if( impl.mController ) - { - const bool shiftSelection = value.Get(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p ENABLE_SHIFT_SELECTION %d\n", impl.mController.Get(), shiftSelection ); + const bool shiftSelection = value.Get(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p ENABLE_SHIFT_SELECTION %d\n", impl.mController.Get(), shiftSelection ); - impl.mController->SetShiftSelectionEnabled( shiftSelection ); - } + impl.mController->SetShiftSelectionEnabled( shiftSelection ); break; } case Toolkit::DevelTextEditor::Property::ENABLE_GRAB_HANDLE: { - if( impl.mController ) - { - const bool grabHandleEnabled = value.Get(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p ENABLE_GRAB_HANDLE %d\n", impl.mController.Get(), grabHandleEnabled ); + const bool grabHandleEnabled = value.Get(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p ENABLE_GRAB_HANDLE %d\n", impl.mController.Get(), grabHandleEnabled ); - impl.mController->SetGrabHandleEnabled( grabHandleEnabled ); - } + impl.mController->SetGrabHandleEnabled( grabHandleEnabled ); break; } case Toolkit::DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION: { - if( impl.mController ) - { - impl.mController->SetMatchSystemLanguageDirection(value.Get< bool >()); - } + impl.mController->SetMatchSystemLanguageDirection(value.Get< bool >()); break; } case Toolkit::DevelTextEditor::Property::MAX_LENGTH: { - if( impl.mController ) - { - const int max = value.Get< int >(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p MAX_LENGTH %d\n", impl.mController.Get(), max ); + const int max = value.Get< int >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p MAX_LENGTH %d\n", impl.mController.Get(), max ); - impl.mController->SetMaximumNumberOfCharacters( max ); - } + impl.mController->SetMaximumNumberOfCharacters( max ); break; } case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_START: @@ -819,6 +731,8 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind if( textEditor ) { TextEditor& impl( GetImpl( textEditor ) ); + DALI_ASSERT_DEBUG( impl.mController && "No text contoller" ); + DALI_ASSERT_DEBUG( impl.mDecorator && "No text decorator" ); switch( index ) { @@ -829,29 +743,20 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind } case Toolkit::TextEditor::Property::TEXT: { - if( impl.mController ) - { - std::string text; - impl.mController->GetText( text ); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p returning text: %s\n", impl.mController.Get(), text.c_str() ); - value = text; - } + std::string text; + impl.mController->GetText( text ); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p returning text: %s\n", impl.mController.Get(), text.c_str() ); + value = text; break; } case Toolkit::TextEditor::Property::TEXT_COLOR: { - if ( impl.mController ) - { - value = impl.mController->GetDefaultColor(); - } + value = impl.mController->GetDefaultColor(); break; } case Toolkit::TextEditor::Property::FONT_FAMILY: { - if( impl.mController ) - { - value = impl.mController->GetDefaultFontFamily(); - } + value = impl.mController->GetDefaultFontFamily(); break; } case Toolkit::TextEditor::Property::FONT_STYLE: @@ -861,54 +766,36 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind } case Toolkit::TextEditor::Property::POINT_SIZE: { - if( impl.mController ) - { - value = impl.mController->GetDefaultFontSize( Text::Controller::POINT_SIZE ); - } + value = impl.mController->GetDefaultFontSize( Text::Controller::POINT_SIZE ); break; } case Toolkit::TextEditor::Property::HORIZONTAL_ALIGNMENT: { - if( impl.mController ) + const char* name = GetHorizontalAlignmentString( impl.mController->GetHorizontalAlignment() ); + if( name ) { - const char* name = GetHorizontalAlignmentString( impl.mController->GetHorizontalAlignment() ); - if( name ) - { - value = std::string( name ); - } + value = std::string( name ); } break; } case Toolkit::TextEditor::Property::SCROLL_THRESHOLD: { - if( impl.mDecorator ) - { - value = impl.mDecorator->GetScrollThreshold(); - } + value = impl.mDecorator->GetScrollThreshold(); break; } case Toolkit::TextEditor::Property::SCROLL_SPEED: { - if( impl.mDecorator ) - { - value = impl.mDecorator->GetScrollSpeed(); - } + value = impl.mDecorator->GetScrollSpeed(); break; } case Toolkit::TextEditor::Property::PRIMARY_CURSOR_COLOR: { - if( impl.mDecorator ) - { - value = impl.mDecorator->GetColor( PRIMARY_CURSOR ); - } + value = impl.mDecorator->GetColor( PRIMARY_CURSOR ); break; } case Toolkit::TextEditor::Property::SECONDARY_CURSOR_COLOR: { - if( impl.mDecorator ) - { - value = impl.mDecorator->GetColor( SECONDARY_CURSOR ); - } + value = impl.mDecorator->GetColor( SECONDARY_CURSOR ); break; } case Toolkit::TextEditor::Property::ENABLE_CURSOR_BLINK: @@ -918,42 +805,27 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind } case Toolkit::TextEditor::Property::CURSOR_BLINK_INTERVAL: { - if( impl.mDecorator ) - { - value = impl.mDecorator->GetCursorBlinkInterval(); - } + value = impl.mDecorator->GetCursorBlinkInterval(); break; } case Toolkit::TextEditor::Property::CURSOR_BLINK_DURATION: { - if( impl.mDecorator ) - { - value = impl.mDecorator->GetCursorBlinkDuration(); - } + value = impl.mDecorator->GetCursorBlinkDuration(); break; } case Toolkit::TextEditor::Property::CURSOR_WIDTH: { - if( impl.mDecorator ) - { - value = impl.mDecorator->GetCursorWidth(); - } + value = impl.mDecorator->GetCursorWidth(); break; } case Toolkit::TextEditor::Property::GRAB_HANDLE_IMAGE: { - if( impl.mDecorator ) - { - value = impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED ); - } + value = impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED ); break; } case Toolkit::TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE: { - if( impl.mDecorator ) - { - value = impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED ); - } + value = impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED ); break; } case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT: @@ -988,44 +860,29 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind } case Toolkit::TextEditor::Property::SELECTION_HIGHLIGHT_COLOR: { - if( impl.mDecorator ) - { - value = impl.mDecorator->GetHighlightColor(); - } + value = impl.mDecorator->GetHighlightColor(); break; } case Toolkit::TextEditor::Property::DECORATION_BOUNDING_BOX: { - if( impl.mDecorator ) - { - Rect boundingBox; - impl.mDecorator->GetBoundingBox( boundingBox ); - value = boundingBox; - } + Rect boundingBox; + impl.mDecorator->GetBoundingBox( boundingBox ); + value = boundingBox; break; } case Toolkit::TextEditor::Property::ENABLE_MARKUP: { - if( impl.mController ) - { - value = impl.mController->IsMarkupProcessorEnabled(); - } + value = impl.mController->IsMarkupProcessorEnabled(); break; } case Toolkit::TextEditor::Property::INPUT_COLOR: { - if( impl.mController ) - { - value = impl.mController->GetInputColor(); - } + value = impl.mController->GetInputColor(); break; } case Toolkit::TextEditor::Property::INPUT_FONT_FAMILY: { - if( impl.mController ) - { - value = impl.mController->GetInputFontFamily(); - } + value = impl.mController->GetInputFontFamily(); break; } case Toolkit::TextEditor::Property::INPUT_FONT_STYLE: @@ -1035,28 +892,19 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind } case Toolkit::TextEditor::Property::INPUT_POINT_SIZE: { - if( impl.mController ) - { - value = impl.mController->GetInputFontPointSize(); - } + value = impl.mController->GetInputFontPointSize(); break; } case Toolkit::TextEditor::Property::LINE_SPACING: { - if( impl.mController ) - { - // LINE_SPACING isn't implemented for the TextEditor. Returning - // only shadowed value, not the real one. - value = impl.mLineSpacing; - } + // LINE_SPACING isn't implemented for the TextEditor. Returning + // only shadowed value, not the real one. + value = impl.mLineSpacing; break; } case Toolkit::TextEditor::Property::INPUT_LINE_SPACING: { - if( impl.mController ) - { - value = impl.mController->GetInputLineSpacing(); - } + value = impl.mController->GetInputLineSpacing(); break; } case Toolkit::TextEditor::Property::UNDERLINE: @@ -1126,45 +974,30 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind } case Toolkit::TextEditor::Property::PIXEL_SIZE: { - if( impl.mController ) - { - value = impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE ); - } + value = impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE ); break; } case Toolkit::TextEditor::Property::LINE_COUNT: { - if( impl.mController ) - { - float width = textEditor.GetProperty( Actor::Property::SIZE_WIDTH ).Get(); - value = impl.mController->GetLineCount( width ); - } + float width = textEditor.GetProperty( Actor::Property::SIZE_WIDTH ).Get(); + value = impl.mController->GetLineCount( width ); break; } case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT: { - if( impl.mController ) - { - std::string text; - impl.mController->GetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text ); - value = text; - } + std::string text; + impl.mController->GetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text ); + value = text; break; } case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR: { - if( impl.mController ) - { - value = impl.mController->GetPlaceholderTextColor(); - } + value = impl.mController->GetPlaceholderTextColor(); break; } case Toolkit::TextEditor::Property::ENABLE_SELECTION: { - if( impl.mController ) - { - value = impl.mController->IsSelectionEnabled(); - } + value = impl.mController->IsSelectionEnabled(); break; } case Toolkit::TextEditor::Property::PLACEHOLDER: @@ -1176,42 +1009,27 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind } case Toolkit::TextEditor::Property::LINE_WRAP_MODE: { - if( impl.mController ) - { - value = impl.mController->GetLineWrapMode(); - } + value = impl.mController->GetLineWrapMode(); break; } case Toolkit::DevelTextEditor::Property::ENABLE_SHIFT_SELECTION: { - if( impl.mController ) - { - value = impl.mController->IsShiftSelectionEnabled(); - } + value = impl.mController->IsShiftSelectionEnabled(); break; } case Toolkit::DevelTextEditor::Property::ENABLE_GRAB_HANDLE: { - if( impl.mController ) - { - value = impl.mController->IsGrabHandleEnabled(); - } + value = impl.mController->IsGrabHandleEnabled(); break; } case Toolkit::DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION: { - if( impl.mController ) - { - value = impl.mController->IsMatchSystemLanguageDirection(); - } + value = impl.mController->IsMatchSystemLanguageDirection(); break; } case Toolkit::DevelTextEditor::Property::MAX_LENGTH: { - if( impl.mController ) - { - value = impl.mController->GetMaximumNumberOfCharacters(); - } + value = impl.mController->GetMaximumNumberOfCharacters(); break; } case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_START: 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 f4726f7..0c1c13c 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #include #include +#include #include #include #include @@ -184,10 +185,11 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField SetProperty\n"); - if( textField ) { TextField& impl( GetImpl( textField ) ); + DALI_ASSERT_DEBUG( impl.mController && "No text contoller" ); + DALI_ASSERT_DEBUG( impl.mDecorator && "No text decorator" ); switch( index ) { @@ -207,56 +209,41 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr impl.mRenderingBackend = backend; impl.mRenderer.Reset(); - if( impl.mController ) - { - // When using the vector-based rendering, the size of the GLyphs are different - TextAbstraction::GlyphType glyphType = (DevelText::RENDERING_VECTOR_BASED == impl.mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH; - impl.mController->SetGlyphType( glyphType ); - } + // When using the vector-based rendering, the size of the GLyphs are different + TextAbstraction::GlyphType glyphType = (DevelText::RENDERING_VECTOR_BASED == impl.mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH; + impl.mController->SetGlyphType( glyphType ); } break; } case Toolkit::TextField::Property::TEXT: { - if( impl.mController ) - { - 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() ); + 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 ); - } + impl.mController->SetText( text ); break; } case Toolkit::TextField::Property::PLACEHOLDER_TEXT: { - if( impl.mController ) - { - 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() ); + 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 ); - } + impl.mController->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text ); break; } case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED: { - if( impl.mController ) - { - 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() ); + 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 ); - } + impl.mController->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_ACTIVE, text ); break; } case Toolkit::TextField::Property::FONT_FAMILY: { - if( impl.mController ) - { - 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 ); - } + 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 ); break; } case Toolkit::TextField::Property::FONT_STYLE: @@ -266,27 +253,21 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr } case Toolkit::TextField::Property::POINT_SIZE: { - if( impl.mController ) - { - const float pointSize = value.Get< float >(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p POINT_SIZE %f\n", impl.mController.Get(), pointSize ); + const float pointSize = value.Get< float >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p POINT_SIZE %f\n", impl.mController.Get(), pointSize ); - if( !Equals( impl.mController->GetDefaultFontSize( Text::Controller::POINT_SIZE ), pointSize ) ) - { - impl.mController->SetDefaultFontSize( pointSize, Text::Controller::POINT_SIZE ); - } + if( !Equals( impl.mController->GetDefaultFontSize( Text::Controller::POINT_SIZE ), pointSize ) ) + { + impl.mController->SetDefaultFontSize( pointSize, Text::Controller::POINT_SIZE ); } break; } case Toolkit::TextField::Property::MAX_LENGTH: { - if( impl.mController ) - { - const int max = value.Get< int >(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p MAX_LENGTH %d\n", impl.mController.Get(), max ); + const int max = value.Get< int >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p MAX_LENGTH %d\n", impl.mController.Get(), max ); - impl.mController->SetMaximumNumberOfCharacters( max ); - } + impl.mController->SetMaximumNumberOfCharacters( max ); break; } case Toolkit::TextField::Property::EXCEED_POLICY: @@ -306,129 +287,99 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr } case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT: { - if( impl.mController ) + Text::HorizontalAlignment::Type alignment( static_cast< Text::HorizontalAlignment::Type >( -1 ) ); // Set to invalid value to ensure a valid mode does get set + if( GetHorizontalAlignmentEnumeration( value, alignment ) ) { - Text::HorizontalAlignment::Type alignment( static_cast< Text::HorizontalAlignment::Type >( -1 ) ); // Set to invalid value to ensure a valid mode does get set - if( GetHorizontalAlignmentEnumeration( value, alignment ) ) - { - DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p HORIZONTAL_ALIGNMENT %d\n", impl.mController.Get(), alignment ); - impl.mController->SetHorizontalAlignment( alignment ); - } + DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p HORIZONTAL_ALIGNMENT %d\n", impl.mController.Get(), alignment ); + impl.mController->SetHorizontalAlignment( alignment ); } break; } case Toolkit::TextField::Property::VERTICAL_ALIGNMENT: { - if( impl.mController ) + Toolkit::Text::VerticalAlignment::Type alignment( static_cast< Text::VerticalAlignment::Type >( -1 ) ); // Set to invalid value to ensure a valid mode does get set + if( GetVerticalAlignmentEnumeration( value, alignment ) ) { - Toolkit::Text::VerticalAlignment::Type alignment( static_cast< Text::VerticalAlignment::Type >( -1 ) ); // Set to invalid value to ensure a valid mode does get set - if( GetVerticalAlignmentEnumeration( value, alignment ) ) - { - impl.mController->SetVerticalAlignment( alignment ); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p VERTICAL_ALIGNMENT %d\n", impl.mController.Get(), alignment ); - } + impl.mController->SetVerticalAlignment( alignment ); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p VERTICAL_ALIGNMENT %d\n", impl.mController.Get(), alignment ); } break; } case Toolkit::TextField::Property::TEXT_COLOR: { - if( impl.mController ) + 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->GetDefaultColor() != textColor ) { - 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->GetDefaultColor() != textColor ) - { - impl.mController->SetDefaultColor( textColor ); - impl.mController->SetInputColor( textColor ); - impl.mRenderer.Reset(); - } + impl.mController->SetDefaultColor( textColor ); + impl.mController->SetInputColor( textColor ); + impl.mRenderer.Reset(); } break; } case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR: { - if( impl.mController ) + 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 ) { - 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 ) - { - impl.mController->SetPlaceholderTextColor( textColor ); - impl.mRenderer.Reset(); - } + impl.mController->SetPlaceholderTextColor( textColor ); + impl.mRenderer.Reset(); } break; } case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR: { - if( impl.mDecorator ) - { - 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 ); + 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 ); - impl.RequestTextRelayout(); - } + impl.mDecorator->SetCursorColor( PRIMARY_CURSOR, color ); + impl.RequestTextRelayout(); break; } case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR: { - if( impl.mDecorator ) - { - 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 ); + 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 ); - impl.RequestTextRelayout(); - } + impl.mDecorator->SetCursorColor( SECONDARY_CURSOR, color ); + impl.RequestTextRelayout(); break; } case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK: { - if( impl.mController ) - { - const bool enable = value.Get< bool >(); - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p ENABLE_CURSOR_BLINK %d\n", impl.mController.Get(), enable ); + const bool enable = value.Get< bool >(); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p ENABLE_CURSOR_BLINK %d\n", impl.mController.Get(), enable ); - impl.mController->SetEnableCursorBlink( enable ); - impl.RequestTextRelayout(); - } + impl.mController->SetEnableCursorBlink( enable ); + impl.RequestTextRelayout(); break; } case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL: { - if( impl.mDecorator ) - { - const float interval = value.Get< float >(); - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_INTERVAL %f\n", impl.mController.Get(), interval ); + const float interval = value.Get< float >(); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_INTERVAL %f\n", impl.mController.Get(), interval ); - impl.mDecorator->SetCursorBlinkInterval( interval ); - } + impl.mDecorator->SetCursorBlinkInterval( interval ); break; } case Toolkit::TextField::Property::CURSOR_BLINK_DURATION: { - if( impl.mDecorator ) - { - const float duration = value.Get< float >(); - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_DURATION %f\n", impl.mController.Get(), duration ); + const float duration = value.Get< float >(); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_DURATION %f\n", impl.mController.Get(), duration ); - impl.mDecorator->SetCursorBlinkDuration( duration ); - } + impl.mDecorator->SetCursorBlinkDuration( duration ); break; } case Toolkit::TextField::Property::CURSOR_WIDTH: { - if( impl.mDecorator ) - { - const int width = value.Get< int >(); - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_WIDTH %d\n", impl.mController.Get(), width ); + const int width = value.Get< int >(); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_WIDTH %d\n", impl.mController.Get(), width ); - impl.mDecorator->SetCursorWidth( width ); - impl.mController->GetLayoutEngine().SetCursorWidth( width ); - } + impl.mDecorator->SetCursorWidth( width ); + impl.mController->GetLayoutEngine().SetCursorWidth( width ); break; } case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE: @@ -436,7 +387,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr const std::string imageFileName = value.Get< std::string >(); DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str() ); - if( impl.mDecorator && imageFileName.size() ) + if( imageFileName.size() ) { impl.mDecorator->SetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED, imageFileName ); impl.RequestTextRelayout(); @@ -448,7 +399,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr const std::string imageFileName = value.Get< std::string >(); DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_PRESSED_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str() ); - if( impl.mDecorator && imageFileName.size() ) + if( imageFileName.size() ) { impl.mDecorator->SetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED, imageFileName ); impl.RequestTextRelayout(); @@ -460,10 +411,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr const float threshold = value.Get< float >(); DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p SCROLL_THRESHOLD %f\n", impl.mController.Get(), threshold ); - if( impl.mDecorator ) - { - impl.mDecorator->SetScrollThreshold( threshold ); - } + impl.mDecorator->SetScrollThreshold( threshold ); break; } case Toolkit::TextField::Property::SCROLL_SPEED: @@ -471,17 +419,14 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr const float speed = value.Get< float >(); DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p SCROLL_SPEED %f\n", impl.mController.Get(), speed ); - if( impl.mDecorator ) - { - impl.mDecorator->SetScrollSpeed( speed ); - } + impl.mDecorator->SetScrollSpeed( speed ); break; } case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT: { const std::string filename = GetImageFileNameFromPropertyValue( value ); - if( impl.mDecorator && filename.size() ) + if( filename.size() ) { impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, filename ); impl.RequestTextRelayout(); @@ -492,7 +437,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { const std::string filename = GetImageFileNameFromPropertyValue( value ); - if( impl.mDecorator && filename.size() ) + if( filename.size() ) { impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, filename ); impl.RequestTextRelayout(); @@ -503,7 +448,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { const std::string filename = GetImageFileNameFromPropertyValue( value ); - if( impl.mDecorator && filename.size() ) + if( filename.size() ) { impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, filename ); impl.RequestTextRelayout(); @@ -514,7 +459,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { const std::string filename = GetImageFileNameFromPropertyValue( value ); - if( impl.mDecorator && filename.size() ) + if( filename.size() ) { impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, filename ); impl.RequestTextRelayout(); @@ -525,7 +470,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { const std::string filename = GetImageFileNameFromPropertyValue( value ); - if( impl.mDecorator && filename.size() ) + if( filename.size() ) { impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, filename ); impl.RequestTextRelayout(); @@ -536,7 +481,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { const std::string filename = GetImageFileNameFromPropertyValue( value ); - if( impl.mDecorator && filename.size() ) + if( filename.size() ) { impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, filename ); impl.RequestTextRelayout(); @@ -548,23 +493,17 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr const Vector4 color = value.Get< Vector4 >(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SELECTION_HIGHLIGHT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a ); - if( impl.mDecorator ) - { - impl.mDecorator->SetHighlightColor( color ); - impl.RequestTextRelayout(); - } + impl.mDecorator->SetHighlightColor( color ); + impl.RequestTextRelayout(); break; } case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX: { - if( impl.mDecorator ) - { - const Rect box = value.Get< Rect >(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p DECORATION_BOUNDING_BOX %d,%d %dx%d\n", impl.mController.Get(), box.x, box.y, box.width, box.height ); + const Rect box = value.Get< Rect >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p DECORATION_BOUNDING_BOX %d,%d %dx%d\n", impl.mController.Get(), box.x, box.y, box.width, box.height ); - impl.mDecorator->SetBoundingBox( box ); - impl.RequestTextRelayout(); - } + impl.mDecorator->SetBoundingBox( box ); + impl.RequestTextRelayout(); break; } case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS: @@ -585,34 +524,25 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr } case Toolkit::TextField::Property::INPUT_COLOR: { - if( impl.mController ) - { - const Vector4 inputColor = value.Get< Vector4 >(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p INPUT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), inputColor.r, inputColor.g, inputColor.b, inputColor.a ); + const Vector4 inputColor = value.Get< Vector4 >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p INPUT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), inputColor.r, inputColor.g, inputColor.b, inputColor.a ); - impl.mController->SetInputColor( inputColor ); - } + impl.mController->SetInputColor( inputColor ); break; } case Toolkit::TextField::Property::ENABLE_MARKUP: { - if( impl.mController ) - { - const bool enableMarkup = value.Get(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_MARKUP %d\n", impl.mController.Get(), enableMarkup ); + const bool enableMarkup = value.Get(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_MARKUP %d\n", impl.mController.Get(), enableMarkup ); - impl.mController->SetMarkupProcessorEnabled( enableMarkup ); - } + impl.mController->SetMarkupProcessorEnabled( enableMarkup ); break; } case Toolkit::TextField::Property::INPUT_FONT_FAMILY: { - if( impl.mController ) - { - 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 ); - } + 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 ); break; } case Toolkit::TextField::Property::INPUT_FONT_STYLE: @@ -622,12 +552,9 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr } case Toolkit::TextField::Property::INPUT_POINT_SIZE: { - if( impl.mController ) - { - const float pointSize = value.Get< float >(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p INPUT_POINT_SIZE %f\n", impl.mController.Get(), pointSize ); - impl.mController->SetInputFontPointSize( pointSize ); - } + const float pointSize = value.Get< float >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p INPUT_POINT_SIZE %f\n", impl.mController.Get(), pointSize ); + impl.mController->SetInputFontPointSize( pointSize ); break; } case Toolkit::TextField::Property::UNDERLINE: @@ -713,26 +640,20 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr } case Toolkit::TextField::Property::PIXEL_SIZE: { - if( impl.mController ) - { - const float pixelSize = value.Get< float >(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PIXEL_SIZE %f\n", impl.mController.Get(), pixelSize ); + const float pixelSize = value.Get< float >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PIXEL_SIZE %f\n", impl.mController.Get(), pixelSize ); - if( !Equals( impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE ), pixelSize ) ) - { - impl.mController->SetDefaultFontSize( pixelSize, Text::Controller::PIXEL_SIZE ); - } + if( !Equals( impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE ), pixelSize ) ) + { + impl.mController->SetDefaultFontSize( pixelSize, Text::Controller::PIXEL_SIZE ); } break; } case Toolkit::TextField::Property::ENABLE_SELECTION: { - if( impl.mController ) - { - const bool enableSelection = value.Get< bool >(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_SELECTION %d\n", impl.mController.Get(), enableSelection ); - impl.mController->SetSelectionEnabled( enableSelection ); - } + const bool enableSelection = value.Get< bool >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_SELECTION %d\n", impl.mController.Get(), enableSelection ); + impl.mController->SetSelectionEnabled( enableSelection ); break; } case Toolkit::TextField::Property::PLACEHOLDER: @@ -746,66 +667,48 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr } case Toolkit::TextField::Property::ELLIPSIS: { - if( impl.mController ) - { - const bool ellipsis = value.Get(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ELLIPSIS %d\n", impl.mController.Get(), ellipsis ); + const bool ellipsis = value.Get(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ELLIPSIS %d\n", impl.mController.Get(), ellipsis ); - impl.mController->SetTextElideEnabled( ellipsis ); - } + impl.mController->SetTextElideEnabled( ellipsis ); break; } case Toolkit::DevelTextField::Property::ENABLE_SHIFT_SELECTION: { - if( impl.mController ) - { - const bool shiftSelection = value.Get(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_SHIFT_SELECTION %d\n", impl.mController.Get(), shiftSelection ); + const bool shiftSelection = value.Get(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_SHIFT_SELECTION %d\n", impl.mController.Get(), shiftSelection ); - impl.mController->SetShiftSelectionEnabled( shiftSelection ); - } + impl.mController->SetShiftSelectionEnabled( shiftSelection ); break; } case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE: { - if( impl.mController ) - { - const bool grabHandleEnabled = value.Get(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_GRAB_HANDLE %d\n", impl.mController.Get(), grabHandleEnabled ); + const bool grabHandleEnabled = value.Get(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_GRAB_HANDLE %d\n", impl.mController.Get(), grabHandleEnabled ); - impl.mController->SetGrabHandleEnabled( grabHandleEnabled ); - } + impl.mController->SetGrabHandleEnabled( grabHandleEnabled ); break; } case Toolkit::DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION: { - if( impl.mController ) - { - impl.mController->SetMatchSystemLanguageDirection(value.Get< bool >()); - } + impl.mController->SetMatchSystemLanguageDirection(value.Get< bool >()); break; } case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP: { - if( impl.mController ) - { - const bool grabHandlePopupEnabled = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p ENABLE_GRAB_HANDLE_POPUP %d\n", impl.mController.Get(), grabHandlePopupEnabled); + const bool grabHandlePopupEnabled = value.Get(); + DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p ENABLE_GRAB_HANDLE_POPUP %d\n", impl.mController.Get(), grabHandlePopupEnabled); - impl.mController->SetGrabHandlePopupEnabled(grabHandlePopupEnabled); - break; - } + impl.mController->SetGrabHandlePopupEnabled(grabHandlePopupEnabled); + break; } case Toolkit::DevelTextField::Property::BACKGROUND: { - if( impl.mController ) - { - const Vector4 backgroundColor = value.Get< Vector4 >(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p BACKGROUND %f,%f,%f,%f\n", impl.mController.Get(), backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a ); + const Vector4 backgroundColor = value.Get< Vector4 >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p BACKGROUND %f,%f,%f,%f\n", impl.mController.Get(), backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a ); - impl.mController->SetBackgroundEnabled( true ); - impl.mController->SetBackgroundColor( backgroundColor ); - } + impl.mController->SetBackgroundEnabled( true ); + impl.mController->SetBackgroundColor( backgroundColor ); break; } case Toolkit::DevelTextField::Property::SELECTED_TEXT_START: @@ -841,6 +744,8 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde if( textField ) { TextField& impl( GetImpl( textField ) ); + DALI_ASSERT_DEBUG( impl.mController && "No text contoller" ); + DALI_ASSERT_DEBUG( impl.mDecorator && "No text decorator" ); switch( index ) { @@ -851,41 +756,29 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde } case Toolkit::TextField::Property::TEXT: { - if( impl.mController ) - { - std::string text; - impl.mController->GetText( text ); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p returning text: %s\n", impl.mController.Get(), text.c_str() ); - value = text; - } + std::string text; + impl.mController->GetText( text ); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p returning text: %s\n", impl.mController.Get(), text.c_str() ); + value = text; break; } case Toolkit::TextField::Property::PLACEHOLDER_TEXT: { - if( impl.mController ) - { - std::string text; - impl.mController->GetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text ); - value = text; - } + std::string text; + impl.mController->GetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text ); + value = text; break; } case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED: { - if( impl.mController ) - { - std::string text; - impl.mController->GetPlaceholderText( Controller::PLACEHOLDER_TYPE_ACTIVE, text ); - value = text; - } + std::string text; + impl.mController->GetPlaceholderText( Controller::PLACEHOLDER_TYPE_ACTIVE, text ); + value = text; break; } case Toolkit::TextField::Property::FONT_FAMILY: { - if( impl.mController ) - { - value = impl.mController->GetDefaultFontFamily(); - } + value = impl.mController->GetDefaultFontFamily(); break; } case Toolkit::TextField::Property::FONT_STYLE: @@ -895,18 +788,12 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde } case Toolkit::TextField::Property::POINT_SIZE: { - if( impl.mController ) - { - value = impl.mController->GetDefaultFontSize( Text::Controller::POINT_SIZE ); - } + value = impl.mController->GetDefaultFontSize( Text::Controller::POINT_SIZE ); break; } case Toolkit::TextField::Property::MAX_LENGTH: { - if( impl.mController ) - { - value = impl.mController->GetMaximumNumberOfCharacters(); - } + value = impl.mController->GetMaximumNumberOfCharacters(); break; } case Toolkit::TextField::Property::EXCEED_POLICY: @@ -916,60 +803,42 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde } case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT: { - if( impl.mController ) - { - const char* name = Text::GetHorizontalAlignmentString( impl.mController->GetHorizontalAlignment() ); + const char* name = Text::GetHorizontalAlignmentString( impl.mController->GetHorizontalAlignment() ); - if ( name ) - { - value = std::string( name ); - } + if ( name ) + { + value = std::string( name ); } break; } case Toolkit::TextField::Property::VERTICAL_ALIGNMENT: { - if( impl.mController ) - { - const char* name = Text::GetVerticalAlignmentString( impl.mController->GetVerticalAlignment() ); + const char* name = Text::GetVerticalAlignmentString( impl.mController->GetVerticalAlignment() ); - if( name ) - { - value = std::string( name ); - } + if( name ) + { + value = std::string( name ); } break; } case Toolkit::TextField::Property::TEXT_COLOR: { - if ( impl.mController ) - { - value = impl.mController->GetDefaultColor(); - } + value = impl.mController->GetDefaultColor(); break; } case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR: { - if ( impl.mController ) - { - value = impl.mController->GetPlaceholderTextColor(); - } + value = impl.mController->GetPlaceholderTextColor(); break; } case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR: { - if( impl.mDecorator ) - { - value = impl.mDecorator->GetColor( PRIMARY_CURSOR ); - } + value = impl.mDecorator->GetColor( PRIMARY_CURSOR ); break; } case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR: { - if( impl.mDecorator ) - { - value = impl.mDecorator->GetColor( SECONDARY_CURSOR ); - } + value = impl.mDecorator->GetColor( SECONDARY_CURSOR ); break; } case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK: @@ -979,58 +848,37 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde } case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL: { - if( impl.mDecorator ) - { - value = impl.mDecorator->GetCursorBlinkInterval(); - } + value = impl.mDecorator->GetCursorBlinkInterval(); break; } case Toolkit::TextField::Property::CURSOR_BLINK_DURATION: { - if( impl.mDecorator ) - { - value = impl.mDecorator->GetCursorBlinkDuration(); - } + value = impl.mDecorator->GetCursorBlinkDuration(); break; } case Toolkit::TextField::Property::CURSOR_WIDTH: { - if( impl.mDecorator ) - { - value = impl.mDecorator->GetCursorWidth(); - } + value = impl.mDecorator->GetCursorWidth(); break; } case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE: { - if( impl.mDecorator ) - { - value = impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED ); - } + value = impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED ); break; } case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE: { - if( impl.mDecorator ) - { - value = impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED ); - } + value = impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED ); break; } case Toolkit::TextField::Property::SCROLL_THRESHOLD: { - if( impl.mDecorator ) - { - value = impl.mDecorator->GetScrollThreshold(); - } + value = impl.mDecorator->GetScrollThreshold(); break; } case Toolkit::TextField::Property::SCROLL_SPEED: { - if( impl.mDecorator ) - { - value = impl.mDecorator->GetScrollSpeed(); - } + value = impl.mDecorator->GetScrollSpeed(); break; } case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT: @@ -1065,20 +913,14 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde } case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR: { - if( impl.mDecorator ) - { - value = impl.mDecorator->GetHighlightColor(); - } + value = impl.mDecorator->GetHighlightColor(); break; } case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX: { - if( impl.mDecorator ) - { - Rect boundingBox; - impl.mDecorator->GetBoundingBox( boundingBox ); - value = boundingBox; - } + Rect boundingBox; + impl.mDecorator->GetBoundingBox( boundingBox ); + value = boundingBox; break; } case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS: @@ -1090,26 +932,17 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde } case Toolkit::TextField::Property::INPUT_COLOR: { - if( impl.mController ) - { - value = impl.mController->GetInputColor(); - } + value = impl.mController->GetInputColor(); break; } case Toolkit::TextField::Property::ENABLE_MARKUP: { - if( impl.mController ) - { - value = impl.mController->IsMarkupProcessorEnabled(); - } + value = impl.mController->IsMarkupProcessorEnabled(); break; } case Toolkit::TextField::Property::INPUT_FONT_FAMILY: { - if( impl.mController ) - { - value = impl.mController->GetInputFontFamily(); - } + value = impl.mController->GetInputFontFamily(); break; } case Toolkit::TextField::Property::INPUT_FONT_STYLE: @@ -1119,10 +952,7 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde } case Toolkit::TextField::Property::INPUT_POINT_SIZE: { - if( impl.mController ) - { - value = impl.mController->GetInputFontPointSize(); - } + value = impl.mController->GetInputFontPointSize(); break; } case Toolkit::TextField::Property::UNDERLINE: @@ -1174,18 +1004,12 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde } case Toolkit::TextField::Property::PIXEL_SIZE: { - if( impl.mController ) - { - value = impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE ); - } + value = impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE ); break; } case Toolkit::TextField::Property::ENABLE_SELECTION: { - if( impl.mController ) - { - value = impl.mController->IsSelectionEnabled(); - } + value = impl.mController->IsSelectionEnabled(); break; } case Toolkit::TextField::Property::PLACEHOLDER: @@ -1197,58 +1021,37 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde } case Toolkit::TextField::Property::ELLIPSIS: { - if( impl.mController ) - { - value = impl.mController->IsTextElideEnabled(); - } + value = impl.mController->IsTextElideEnabled(); break; } case Toolkit::DevelTextField::Property::ENABLE_SHIFT_SELECTION: { - if( impl.mController ) - { - value = impl.mController->IsShiftSelectionEnabled(); - } + value = impl.mController->IsShiftSelectionEnabled(); break; } case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE: { - if( impl.mController ) - { - value = impl.mController->IsGrabHandleEnabled(); - } + value = impl.mController->IsGrabHandleEnabled(); break; } case Toolkit::DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION: { - if( impl.mController ) - { - value = impl.mController->IsMatchSystemLanguageDirection(); - } + value = impl.mController->IsMatchSystemLanguageDirection(); break; } case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP: { - if( impl.mController ) - { - value = impl.mController->IsGrabHandlePopupEnabled(); - } + value = impl.mController->IsGrabHandlePopupEnabled(); break; } case Toolkit::DevelTextField::Property::BACKGROUND: { - if( impl.mController ) - { - value = impl.mController->GetBackgroundColor(); - } + value = impl.mController->GetBackgroundColor(); break; } case Toolkit::DevelTextField::Property::SELECTED_TEXT: { - if( impl.mController ) - { - value = impl.mController->GetSelectedText( ); - } + value = impl.mController->GetSelectedText( ); break; } case Toolkit::DevelTextField::Property::SELECTED_TEXT_START: 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 d40cd76..1cdb0f8 100755 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -19,6 +19,7 @@ #include // EXTERNAL INCLUDES +#include #include #include #include @@ -168,6 +169,8 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr if( label ) { TextLabel& impl( GetImpl( label ) ); + DALI_ASSERT_ALWAYS( impl.mController && "No text contoller" ); + switch( index ) { case Toolkit::DevelTextLabel::Property::RENDERING_BACKEND: @@ -185,32 +188,23 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr impl.mRenderingBackend = backend; impl.mTextUpdateNeeded = true; - if( impl.mController ) - { - // When using the vector-based rendering, the size of the GLyphs are different - TextAbstraction::GlyphType glyphType = (DevelText::RENDERING_VECTOR_BASED == impl.mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH; - impl.mController->SetGlyphType( glyphType ); - } + // When using the vector-based rendering, the size of the GLyphs are different + TextAbstraction::GlyphType glyphType = (DevelText::RENDERING_VECTOR_BASED == impl.mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH; + impl.mController->SetGlyphType( glyphType ); } break; } case Toolkit::TextLabel::Property::TEXT: { - if( impl.mController ) - { - impl.mController->SetText( value.Get< std::string >() ); - } + impl.mController->SetText( value.Get< std::string >() ); break; } case Toolkit::TextLabel::Property::FONT_FAMILY: { - 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 ); - } + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextLabel::SetProperty Property::FONT_FAMILY newFont(%s)\n", fontFamily.c_str() ); + impl.mController->SetDefaultFontFamily( fontFamily ); break; } case Toolkit::TextLabel::Property::FONT_STYLE: @@ -220,80 +214,62 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr } case Toolkit::TextLabel::Property::POINT_SIZE: { - if( impl.mController ) - { - const float pointSize = value.Get< float >(); + const float pointSize = value.Get< float >(); - if( !Equals( impl.mController->GetDefaultFontSize( Text::Controller::POINT_SIZE ), pointSize ) ) - { - impl.mController->SetDefaultFontSize( pointSize, Text::Controller::POINT_SIZE ); - } + if( !Equals( impl.mController->GetDefaultFontSize( Text::Controller::POINT_SIZE ), pointSize ) ) + { + impl.mController->SetDefaultFontSize( pointSize, Text::Controller::POINT_SIZE ); } break; } case Toolkit::TextLabel::Property::MULTI_LINE: { - if( impl.mController ) - { - impl.mController->SetMultiLineEnabled( value.Get< bool >() ); - } + impl.mController->SetMultiLineEnabled( value.Get< bool >() ); break; } case Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT: { - if( impl.mController ) + Text::HorizontalAlignment::Type alignment( static_cast< Text::HorizontalAlignment::Type >( -1 ) ); // Set to invalid value to ensure a valid mode does get set + if( Text::GetHorizontalAlignmentEnumeration( value, alignment ) ) { - Text::HorizontalAlignment::Type alignment( static_cast< Text::HorizontalAlignment::Type >( -1 ) ); // Set to invalid value to ensure a valid mode does get set - if( Text::GetHorizontalAlignmentEnumeration( value, alignment ) ) - { - impl.mController->SetHorizontalAlignment( alignment ); - } + impl.mController->SetHorizontalAlignment( alignment ); } break; } case Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT: { - if( impl.mController ) + Toolkit::Text::VerticalAlignment::Type alignment( static_cast< Text::VerticalAlignment::Type >( -1 ) ); // Set to invalid value to ensure a valid mode does get set + if( Text::GetVerticalAlignmentEnumeration( value, alignment ) ) { - Toolkit::Text::VerticalAlignment::Type alignment( static_cast< Text::VerticalAlignment::Type >( -1 ) ); // Set to invalid value to ensure a valid mode does get set - if( Text::GetVerticalAlignmentEnumeration( value, alignment ) ) - { - impl.mController->SetVerticalAlignment( alignment ); - } + impl.mController->SetVerticalAlignment( alignment ); } break; } case Toolkit::TextLabel::Property::ENABLE_MARKUP: { - if( impl.mController ) - { - const bool enableMarkup = value.Get(); - impl.mController->SetMarkupProcessorEnabled( enableMarkup ); - } + const bool enableMarkup = value.Get(); + impl.mController->SetMarkupProcessorEnabled( enableMarkup ); break; } case Toolkit::TextLabel::Property::ENABLE_AUTO_SCROLL: { - if( impl.mController ) + const bool enableAutoScroll = value.Get(); + // If request to auto scroll is the same as current state then do nothing. + if ( enableAutoScroll != impl.mController->IsAutoScrollEnabled() ) { - const bool enableAutoScroll = value.Get(); - // If request to auto scroll is the same as current state then do nothing. - if ( enableAutoScroll != impl.mController->IsAutoScrollEnabled() ) - { - // If request is disable (false) and auto scrolling is enabled then need to stop it - if ( enableAutoScroll == false ) - { - if( impl.mTextScroller ) - { - impl.mTextScroller->StopScrolling(); - } - } - // If request is enable (true) then start autoscroll as not already running - else + // If request is disable (false) and auto scrolling is enabled then need to stop it + if ( enableAutoScroll == false ) + { + if( impl.mTextScroller ) { - impl.mController->SetAutoScrollEnabled( enableAutoScroll ); + impl.mTextScroller->StopScrolling(); } - } + } + // If request is enable (true) then start autoscroll as not already running + else + { + impl.mController->SetAutoScrollEnabled( enableAutoScroll ); + } } break; } @@ -351,15 +327,12 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr } case Toolkit::TextLabel::Property::LINE_SPACING: { - if( impl.mController ) - { - const float lineSpacing = value.Get(); + const float lineSpacing = value.Get(); - // Don't trigger anything if the line spacing didn't change - if( impl.mController->SetDefaultLineSpacing( lineSpacing ) ) - { - impl.mTextUpdateNeeded = true; - } + // Don't trigger anything if the line spacing didn't change + if( impl.mController->SetDefaultLineSpacing( lineSpacing ) ) + { + impl.mTextUpdateNeeded = true; } break; } @@ -401,45 +374,36 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr } case Toolkit::TextLabel::Property::PIXEL_SIZE: { - if( impl.mController ) - { - const float pixelSize = value.Get< float >(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel %p PIXEL_SIZE %f\n", impl.mController.Get(), pixelSize ); + const float pixelSize = value.Get< float >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel %p PIXEL_SIZE %f\n", impl.mController.Get(), pixelSize ); - if( !Equals( impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE ), pixelSize ) ) - { - impl.mController->SetDefaultFontSize( pixelSize, Text::Controller::PIXEL_SIZE ); - } + if( !Equals( impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE ), pixelSize ) ) + { + impl.mController->SetDefaultFontSize( pixelSize, Text::Controller::PIXEL_SIZE ); } break; } case Toolkit::TextLabel::Property::ELLIPSIS: { - if( impl.mController ) - { - const bool ellipsis = value.Get(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel %p ELLIPSIS %d\n", impl.mController.Get(), ellipsis ); + const bool ellipsis = value.Get(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel %p ELLIPSIS %d\n", impl.mController.Get(), ellipsis ); - impl.mController->SetTextElideEnabled( ellipsis ); - } + impl.mController->SetTextElideEnabled( ellipsis ); break; } case Toolkit::TextLabel::Property::LINE_WRAP_MODE: { - if( impl.mController ) + Text::LineWrap::Mode lineWrapMode( static_cast< Text::LineWrap::Mode >( -1 ) ); // Set to invalid value to ensure a valid mode does get set + if( GetLineWrapModeEnumeration( value, lineWrapMode ) ) { - Text::LineWrap::Mode lineWrapMode( static_cast< Text::LineWrap::Mode >( -1 ) ); // Set to invalid value to ensure a valid mode does get set - if( GetLineWrapModeEnumeration( value, lineWrapMode ) ) - { - DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel %p LineWrap::MODE %d\n", impl.mController.Get(), lineWrapMode ); - impl.mController->SetLineWrapMode( lineWrapMode ); - } + DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel %p LineWrap::MODE %d\n", impl.mController.Get(), lineWrapMode ); + impl.mController->SetLineWrapMode( lineWrapMode ); } break; } case Toolkit::DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT: { - if( impl.mController && impl.mController->GetTextModel() ) + if( impl.mController->GetTextModel() ) { DevelText::VerticalLineAlignment::Type alignment = static_cast( value.Get() ); @@ -542,14 +506,11 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr } case Toolkit::DevelTextLabel::Property::MIN_LINE_SIZE: { - if( impl.mController ) - { - const float lineSize = value.Get(); + const float lineSize = value.Get(); - if( impl.mController->SetDefaultLineSize( lineSize ) ) - { - impl.mTextUpdateNeeded = true; - } + if( impl.mController->SetDefaultLineSize( lineSize ) ) + { + impl.mTextUpdateNeeded = true; } break; } @@ -575,6 +536,8 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde if( label ) { TextLabel& impl( GetImpl( label ) ); + DALI_ASSERT_DEBUG( impl.mController && "No text contoller" ); + switch( index ) { case Toolkit::DevelTextLabel::Property::RENDERING_BACKEND: @@ -584,20 +547,14 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde } case Toolkit::TextLabel::Property::TEXT: { - if( impl.mController ) - { - std::string text; - impl.mController->GetText( text ); - value = text; - } + std::string text; + impl.mController->GetText( text ); + value = text; break; } case Toolkit::TextLabel::Property::FONT_FAMILY: { - if( impl.mController ) - { - value = impl.mController->GetDefaultFontFamily(); - } + value = impl.mController->GetDefaultFontFamily(); break; } case Toolkit::TextLabel::Property::FONT_STYLE: @@ -607,59 +564,41 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde } case Toolkit::TextLabel::Property::POINT_SIZE: { - if( impl.mController ) - { - value = impl.mController->GetDefaultFontSize( Text::Controller::POINT_SIZE ); - } + value = impl.mController->GetDefaultFontSize( Text::Controller::POINT_SIZE ); break; } case Toolkit::TextLabel::Property::MULTI_LINE: { - if( impl.mController ) - { - value = impl.mController->IsMultiLineEnabled(); - } + value = impl.mController->IsMultiLineEnabled(); break; } case Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT: { - if( impl.mController ) - { - const char* name = Text::GetHorizontalAlignmentString( impl.mController->GetHorizontalAlignment() ); + const char* name = Text::GetHorizontalAlignmentString( impl.mController->GetHorizontalAlignment() ); - if ( name ) - { - value = std::string( name ); - } + if ( name ) + { + value = std::string( name ); } break; } case Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT: { - if( impl.mController ) + const char* name = Text::GetVerticalAlignmentString( impl.mController->GetVerticalAlignment() ); + if( name ) { - const char* name = Text::GetVerticalAlignmentString( impl.mController->GetVerticalAlignment() ); - if( name ) - { - value = std::string( name ); - } + value = std::string( name ); } break; } case Toolkit::TextLabel::Property::ENABLE_MARKUP: { - if( impl.mController ) - { - value = impl.mController->IsMarkupProcessorEnabled(); - } + value = impl.mController->IsMarkupProcessorEnabled(); break; } case Toolkit::TextLabel::Property::ENABLE_AUTO_SCROLL: { - if( impl.mController ) - { - value = impl.mController->IsAutoScrollEnabled(); - } + value = impl.mController->IsAutoScrollEnabled(); break; } case Toolkit::TextLabel::Property::AUTO_SCROLL_STOP_MODE: @@ -678,7 +617,6 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde } case Toolkit::TextLabel::Property::AUTO_SCROLL_SPEED: { - TextLabel& impl( GetImpl( label ) ); if ( impl.mTextScroller ) { value = impl.mTextScroller->GetSpeed(); @@ -687,31 +625,22 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde } case Toolkit::TextLabel::Property::AUTO_SCROLL_LOOP_COUNT: { - if( impl.mController ) + if ( impl.mTextScroller ) { - TextLabel& impl( GetImpl( label ) ); - if ( impl.mTextScroller ) - { - value = impl.mTextScroller->GetLoopCount(); - } + value = impl.mTextScroller->GetLoopCount(); } break; } case Toolkit::TextLabel::Property::AUTO_SCROLL_LOOP_DELAY: { - if( impl.mController ) + if ( impl.mTextScroller ) { - TextLabel& impl( GetImpl( label ) ); - if ( impl.mTextScroller ) - { - value = impl.mTextScroller->GetLoopDelay(); - } + value = impl.mTextScroller->GetLoopDelay(); } break; } case Toolkit::TextLabel::Property::AUTO_SCROLL_GAP: { - TextLabel& impl( GetImpl( label ) ); if ( impl.mTextScroller ) { value = impl.mTextScroller->GetGap(); @@ -720,10 +649,7 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde } case Toolkit::TextLabel::Property::LINE_SPACING: { - if( impl.mController ) - { - value = impl.mController->GetDefaultLineSpacing(); - } + value = impl.mController->GetDefaultLineSpacing(); break; } case Toolkit::TextLabel::Property::UNDERLINE: @@ -748,51 +674,33 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde } case Toolkit::TextLabel::Property::PIXEL_SIZE: { - if( impl.mController ) - { - value = impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE ); - } + value = impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE ); break; } case Toolkit::TextLabel::Property::ELLIPSIS: { - if( impl.mController ) - { - value = impl.mController->IsTextElideEnabled(); - } + value = impl.mController->IsTextElideEnabled(); break; } case Toolkit::TextLabel::Property::LINE_WRAP_MODE: { - if( impl.mController ) - { - value = impl.mController->GetLineWrapMode(); - } + value = impl.mController->GetLineWrapMode(); break; } case Toolkit::TextLabel::Property::LINE_COUNT: { - if( impl.mController ) - { - float width = label.GetProperty( Actor::Property::SIZE_WIDTH ).Get(); - value = impl.mController->GetLineCount( width ); - } + float width = label.GetProperty( Actor::Property::SIZE_WIDTH ).Get(); + value = impl.mController->GetLineCount( width ); break; } case Toolkit::DevelTextLabel::Property::TEXT_DIRECTION: { - if( impl.mController ) - { - value = impl.mController->GetTextDirection(); - } + value = impl.mController->GetTextDirection(); break; } case Toolkit::DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT: { - if( impl.mController ) - { - value = impl.mController->GetVerticalLineAlignment(); - } + value = impl.mController->GetVerticalLineAlignment(); break; } case Toolkit::DevelTextLabel::Property::BACKGROUND: @@ -829,10 +737,7 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde } case Toolkit::DevelTextLabel::Property::MIN_LINE_SIZE: { - if( impl.mController ) - { - value = impl.mController->GetDefaultLineSize(); - } + value = impl.mController->GetDefaultLineSize(); break; } } @@ -854,10 +759,9 @@ void TextLabel::OnInitialize() TextVisual::SetAnimatableTextColorProperty( mVisual, Toolkit::TextLabel::Property::TEXT_COLOR ); mController = TextVisual::GetController(mVisual); - if( mController ) - { - mController->SetControlInterface(this); - } + DALI_ASSERT_DEBUG( mController && "Invalid Text Controller") + + mController->SetControlInterface(this); // Use height-for-width negotiation by default self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); diff --git a/dali-toolkit/internal/text/text-scroller.cpp b/dali-toolkit/internal/text/text-scroller.cpp old mode 100644 new mode 100755 index 22f1156..6d0930b --- a/dali-toolkit/internal/text/text-scroller.cpp +++ b/dali-toolkit/internal/text/text-scroller.cpp @@ -271,7 +271,10 @@ void TextScroller::SetParameters( Actor scrollingTextActor, Renderer renderer, T // Reset to the original shader and texture before scrolling mRenderer.SetShader(mShader); - mRenderer.SetTextures( mTextureSet ); + if( mTextureSet ) + { + mRenderer.SetTextures( mTextureSet ); + } } mShader = mRenderer.GetShader(); diff --git a/dali-toolkit/internal/visuals/svg/svg-rasterize-thread.cpp b/dali-toolkit/internal/visuals/svg/svg-rasterize-thread.cpp index f0dc4a4..151eda8 100644 --- a/dali-toolkit/internal/visuals/svg/svg-rasterize-thread.cpp +++ b/dali-toolkit/internal/visuals/svg/svg-rasterize-thread.cpp @@ -24,7 +24,9 @@ #include // INTERNAL INCLUDES +#ifdef NO_THORVG #include +#endif /* NO_THORVG */ #include namespace Dali @@ -41,6 +43,7 @@ namespace const char * const UNITS("px"); } +#ifdef NO_THORVG RasterizingTask::RasterizingTask( SvgVisual* svgRenderer, NSVGimage* parsedSvg, const VisualUrl& url, float dpi, unsigned int width, unsigned int height) : mSvgVisual( svgRenderer ), mParsedSvg( parsedSvg ), @@ -51,14 +54,30 @@ RasterizingTask::RasterizingTask( SvgVisual* svgRenderer, NSVGimage* parsedSvg, { mRasterizer = nsvgCreateRasterizer(); } +#else /* NO_THORVG */ +RasterizingTask::RasterizingTask( SvgVisual* svgRenderer, VectorImageRenderer vectorRenderer, const VisualUrl& url, float dpi, unsigned int width, unsigned int height, bool loaded) +: mSvgVisual( svgRenderer ), + mVectorRenderer( vectorRenderer ), + mUrl( url ), + mDpi( dpi ), + mWidth( width ), + mHeight( height ), + mLoaded( loaded ) +{ + +} +#endif /* NO_THORVG */ RasterizingTask::~RasterizingTask() { +#ifdef NO_THORVG nsvgDeleteRasterizer( mRasterizer ); +#endif /* NO_THORVG */ } void RasterizingTask::Load() { +#ifdef NO_THORVG if( mParsedSvg != NULL) { return; @@ -77,10 +96,33 @@ void RasterizingTask::Load() remoteBuffer.PushBack( '\0' ); mParsedSvg = nsvgParse( reinterpret_cast(remoteBuffer.begin()), UNITS, mDpi ); } +#else /* NO_THORVG */ + if( !mLoaded && !mUrl.IsLocalResource() ) + { + Dali::Vector remoteBuffer; + + if( !Dali::FileLoader::DownloadFileSynchronously( mUrl.GetUrl(), remoteBuffer )) + { + DALI_LOG_ERROR("Failed to download file!\n"); + return; + } + + remoteBuffer.PushBack( '\0' ); + char *data = reinterpret_cast(remoteBuffer.begin()); + if ( !mVectorRenderer.Load( data, remoteBuffer.Size())) + { + DALI_LOG_ERROR( "Failed to load data!\n" ); + return; + } + + mLoaded = true; + } +#endif /* NO_THORVG */ } void RasterizingTask::Rasterize( ) { +#ifdef NO_THORVG if( mParsedSvg != NULL && mWidth > 0u && mHeight > 0u ) { float scaleX = static_cast( mWidth ) / mParsedSvg->width; @@ -96,12 +138,54 @@ void RasterizingTask::Rasterize( ) mPixelData = Dali::PixelData::New( buffer, bufferSize, mWidth, mHeight, Pixel::RGBA8888, Dali::PixelData::DELETE_ARRAY ); } +#else /* NO_THORVG */ + if ( mWidth <= 0u || mHeight <= 0u ) + { + DALI_LOG_ERROR( "Size is zero!\n" ); + return; + } + + Devel::PixelBuffer pixelBuffer = Devel::PixelBuffer::New( mWidth, mHeight, Dali::Pixel::RGBA8888 ); + mVectorRenderer.SetBuffer( pixelBuffer ); + { + uint32_t defaultWidth, defaultHeight; + mVectorRenderer.GetDefaultSize( defaultWidth, defaultHeight ); + + float scaleX = static_cast( mWidth ) / static_cast( defaultWidth ); + float scaleY = static_cast( mHeight ) / static_cast( defaultHeight ); + float scale = scaleX < scaleY ? scaleX : scaleY; + + if ( !mVectorRenderer.Render( scale ) ) + { + DALI_LOG_ERROR( "SVG Render Fail!\n" ); + return; + } + + mPixelData = Devel::PixelBuffer::Convert( pixelBuffer ); + if ( !mPixelData ) + { + DALI_LOG_ERROR( "Pixel Data is null\n" ); + } + } +#endif /* NO_THORVG */ } +#ifdef NO_THORVG NSVGimage* RasterizingTask::GetParsedImage() const { return mParsedSvg; } +#else /* NO_THORVG */ +VectorImageRenderer RasterizingTask::GetVectorRenderer() const +{ + return mVectorRenderer; +} + +bool RasterizingTask::IsLoaded() const +{ + return mLoaded; +} +#endif /* NO_THORVG */ SvgVisual* RasterizingTask::GetSvgVisual() const { @@ -203,6 +287,7 @@ void SvgRasterizeThread::RemoveTask( SvgVisual* visual ) } } +#ifdef NO_THORVG void SvgRasterizeThread::DeleteImage( NSVGimage* parsedSvg ) { // Lock while adding image to the delete queue @@ -217,6 +302,22 @@ void SvgRasterizeThread::DeleteImage( NSVGimage* parsedSvg ) mDeleteSvg.PushBack( parsedSvg ); } } +#else /* NO_THORVG */ +void SvgRasterizeThread::DeleteImage( VectorImageRenderer vectorRenderer ) +{ + // Lock while adding image to the delete queue + ConditionalWait::ScopedLock lock( mConditionalWait ); + + if( mIsThreadWaiting ) // no rasterization is ongoing, save to delete + { + // TODO: what? + } + else // wait to delete until current rasterization completed. + { + mDeleteSvg.PushBack( &vectorRenderer ); + } +} +#endif /* NO_THORVG */ RasterizingTaskPtr SvgRasterizeThread::NextTaskToProcess() { @@ -226,12 +327,14 @@ RasterizingTaskPtr SvgRasterizeThread::NextTaskToProcess() // Delete the image here to make sure that it is not used in the nsvgRasterize() if( !mDeleteSvg.Empty() ) { +#ifdef NO_THORVG for( Vector< NSVGimage* >::Iterator it = mDeleteSvg.Begin(), endIt = mDeleteSvg.End(); it != endIt; ++it ) { nsvgDelete( *it ); } +#endif /* NO_THORVG */ mDeleteSvg.Clear(); } diff --git a/dali-toolkit/internal/visuals/svg/svg-rasterize-thread.h b/dali-toolkit/internal/visuals/svg/svg-rasterize-thread.h index 11fa03f..5c8b323 100644 --- a/dali-toolkit/internal/visuals/svg/svg-rasterize-thread.h +++ b/dali-toolkit/internal/visuals/svg/svg-rasterize-thread.h @@ -29,8 +29,13 @@ #include #include +#ifdef NO_THORVG struct NSVGimage; struct NSVGrasterizer; +#else /* NO_THORVG */ +#include +#include +#endif /* NO_THORVG */ namespace Dali { @@ -58,6 +63,7 @@ typedef IntrusivePtr< RasterizingTask > RasterizingTaskPtr; class RasterizingTask : public RefObject { public: +#ifdef NO_THORVG /** * Constructor * @@ -70,6 +76,17 @@ public: * @param[in] height The rasterization height. */ RasterizingTask( SvgVisual* svgRenderer, NSVGimage* parsedSvg, const VisualUrl& url, float dpi, unsigned int width, unsigned int height ); +#else /* NO_THORVG */ + /** + * Constructor + * @param[in] svgRenderer The renderer which the rasterized image to be applied. + * @param[in] url The URL to svg resource to use. + * @param[in] width The rasterization width. + * @param[in] height The rasterization height. + * @param[in] loaded The svg resource is loaded or not. + */ + RasterizingTask( SvgVisual* svgRenderer, VectorImageRenderer vectorRenderer, const VisualUrl& url, float dpi, unsigned int width, unsigned int height, bool loaded ); +#endif /* NO_THORVG */ /** * Destructor. @@ -92,11 +109,31 @@ public: */ PixelData GetPixelData() const; +#ifdef NO_THORVG /** * Get the parsed data. * @return parsed image data. */ NSVGimage* GetParsedImage() const; + /** + * Get default size of svg + * + * @param[out] width The default width of svg + * @param[out] height The default height of svg + */ + void GetDefaultSize( uint32_t& width, uint32_t& height ) const; +#else /* NO_THORVG */ + /** + * Get the VectorRenderer. + * @return VectorRenderer. + */ + VectorImageRenderer GetVectorRenderer() const; + /** + * Whether the resource is loaded. + * @return True if the resource is loaded. + */ + bool IsLoaded() const; +#endif /* NO_THORVG */ /** * Load svg file @@ -112,13 +149,21 @@ private: private: SvgVisualPtr mSvgVisual; +#ifdef NO_THORVG NSVGimage* mParsedSvg; +#else /* NO_THORVG */ + VectorImageRenderer mVectorRenderer; +#endif /* NO_THORVG */ VisualUrl mUrl; PixelData mPixelData; float mDpi; unsigned int mWidth; unsigned int mHeight; +#ifdef NO_THORVG NSVGrasterizer* mRasterizer; +#else /* NO_THORVG */ + bool mLoaded; +#endif /* NO_THORVG */ }; /** @@ -163,14 +208,25 @@ public: */ void RemoveTask( SvgVisual* visual ); +#ifdef NO_THORVG /** * Delete the parsed SVG image, called by main thread. * - * The parsed svg should be delelted in worker thread, as the main thread does not know whether a rasterization of this svg is ongoing. + * The parsed svg should be deleted in worker thread, as the main thread does not know whether a rasterization of this svg is ongoing. * * @param[in] parsedImage The image to be deleted */ void DeleteImage( NSVGimage* parsedSvg ); +#else /* NO_THORVG */ + /** + * Delete the parsed SVG image, called by main thread. + * + * The parsed svg should be deleted in worker thread, as the main thread does not know whether a rasterization of this svg is ongoing. + * + * @param[in] VectorImage The image to be deleted + */ + void DeleteImage( VectorImageRenderer vectorImage ); +#endif /* NO_THORVG */ private: @@ -214,7 +270,11 @@ private: std::vector mRasterizeTasks; //The queue of the tasks waiting to rasterize the SVG image std::vector mCompletedTasks; //The queue of the tasks with the SVG rasterization completed +#ifdef NO_THORVG Vector mDeleteSvg; //The images that the event thread requested to delete +#else /* NO_THORVG */ + Vector mDeleteSvg; //The images that the event thread requested to delete +#endif /* NO_THORVG */ ConditionalWait mConditionalWait; Dali::Mutex mMutex; diff --git a/dali-toolkit/internal/visuals/svg/svg-visual.cpp b/dali-toolkit/internal/visuals/svg/svg-visual.cpp index a9989c0..0e005b3 100644 --- a/dali-toolkit/internal/visuals/svg/svg-visual.cpp +++ b/dali-toolkit/internal/visuals/svg/svg-visual.cpp @@ -19,8 +19,10 @@ #include "svg-visual.h" // INTERNAL INCLUDES +#ifdef NO_THORVG #include #include +#endif /* NO_THORVG */ #include #include #include @@ -54,8 +56,13 @@ const Dali::Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f); SvgVisualPtr SvgVisual::New( VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, const Property::Map& properties ) { SvgVisualPtr svgVisual( new SvgVisual( factoryCache, shaderFactory, imageUrl ) ); +#ifdef NO_THORVG svgVisual->ParseFromUrl( imageUrl ); svgVisual->SetProperties( properties ); +#else /* NO_THORVG */ + svgVisual->Load(); + svgVisual->SetProperties( properties ); +#endif /* NO_THORVG */ return svgVisual; } @@ -63,7 +70,11 @@ SvgVisualPtr SvgVisual::New( VisualFactoryCache& factoryCache, ImageVisualShader SvgVisualPtr SvgVisual::New( VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl ) { SvgVisualPtr svgVisual( new SvgVisual( factoryCache, shaderFactory, imageUrl ) ); +#ifdef NO_THORVG svgVisual->ParseFromUrl( imageUrl ); +#else /* NO_THORVG */ + svgVisual->Load(); +#endif /* NO_THORVG */ return svgVisual; } @@ -73,7 +84,15 @@ SvgVisual::SvgVisual( VisualFactoryCache& factoryCache, ImageVisualShaderFactory mImageVisualShaderFactory( shaderFactory ), mAtlasRect( FULL_TEXTURE_RECT ), mImageUrl( imageUrl ), +#ifdef NO_THORVG mParsedImage( NULL ), +#else + mVectorRenderer( VectorImageRenderer::New() ), + mDefaultWidth( 0 ), + mDefaultHeight( 0 ), + mLoaded( false ), + mLocalResource( true ), +#endif /* NO_THORVG */ mPlacementActor(), mVisualSize(Vector2::ZERO), mAttemptAtlasing( false ) @@ -84,10 +103,12 @@ SvgVisual::SvgVisual( VisualFactoryCache& factoryCache, ImageVisualShaderFactory SvgVisual::~SvgVisual() { +#ifdef NO_THORVG if( mParsedImage ) { nsvgDelete( mParsedImage ); } +#endif /* NO_THORVG */ } void SvgVisual::DoSetProperties( const Property::Map& propertyMap ) @@ -190,11 +211,19 @@ void SvgVisual::DoSetOffScene( Actor& actor ) void SvgVisual::GetNaturalSize( Vector2& naturalSize ) { +#ifdef NO_THORVG if( mParsedImage ) { naturalSize.x = mParsedImage->width; naturalSize.y = mParsedImage->height; } +#else /* NO_THORVG */ + if ( mLoaded ) + { + naturalSize.x = mDefaultWidth; + naturalSize.y = mDefaultHeight; + } +#endif /* NO_THORVG */ else { naturalSize = Vector2::ZERO; @@ -218,6 +247,7 @@ void SvgVisual::DoCreateInstancePropertyMap( Property::Map& map ) const // Do nothing } +#ifdef NO_THORVG void SvgVisual::ParseFromUrl( const VisualUrl& imageUrl ) { mImageUrl = imageUrl; @@ -233,6 +263,33 @@ void SvgVisual::ParseFromUrl( const VisualUrl& imageUrl ) } } } +#else /* NO_THORVG */ +void SvgVisual::Load() +{ + if( mLoaded || !mLocalResource ) + { + return; + } + + mLocalResource = mImageUrl.IsLocalResource(); + + if( !mLocalResource ) + { + // load remote resource on svg rasterize thread. + return; + } + + if( !mVectorRenderer.Load( mImageUrl.GetUrl() ) ) + { + DALI_LOG_ERROR( "Failed to load file!\n" ); + return; + } + + mVectorRenderer.GetDefaultSize(mDefaultWidth, mDefaultHeight); + mLoaded = true; +} +#endif /* NO_THORVG */ + void SvgVisual::AddRasterizationTask( const Vector2& size ) { @@ -244,11 +301,21 @@ void SvgVisual::AddRasterizationTask( const Vector2& size ) Vector2 dpi = Stage::GetCurrent().GetDpi(); float meanDpi = ( dpi.height + dpi.width ) * 0.5f; +#ifdef NO_THORVG RasterizingTaskPtr newTask = new RasterizingTask( this, mParsedImage, mImageUrl, meanDpi, width, height ); +#else /* NO_THORVG */ + RasterizingTaskPtr newTask = new RasterizingTask( this, mVectorRenderer, mImageUrl, meanDpi, width, height, mLoaded ); +#endif /* NO_THORVG */ if ( IsSynchronousLoadingRequired() ) { +#ifdef NO_THORVG newTask->Rasterize(); ApplyRasterizedImage( newTask->GetParsedImage(), newTask->GetPixelData() ); +#else /* NO_THORVG */ + newTask->Load(); + newTask->Rasterize(); + ApplyRasterizedImage( newTask->GetVectorRenderer(), newTask->GetPixelData(), newTask->IsLoaded() ); +#endif /* NO_THORVG */ } else { @@ -257,6 +324,7 @@ void SvgVisual::AddRasterizationTask( const Vector2& size ) } } +#ifdef NO_THORVG void SvgVisual::ApplyRasterizedImage( NSVGimage* parsedSvg, PixelData rasterizedPixelData ) { if( mParsedImage == NULL) @@ -265,6 +333,13 @@ void SvgVisual::ApplyRasterizedImage( NSVGimage* parsedSvg, PixelData rasterized } if( mParsedImage && IsOnScene() ) +#else /* NO_THORVG */ +void SvgVisual::ApplyRasterizedImage( VectorImageRenderer vectorRenderer, PixelData rasterizedPixelData, bool isLoaded ) +{ + mLoaded = isLoaded; + + if( isLoaded && rasterizedPixelData && IsOnScene() ) +#endif /* NO_THORVG */ { TextureSet currentTextureSet = mImpl->mRenderer.GetTextures(); if( mImpl->mFlags & Impl::IS_ATLASING_APPLIED ) @@ -328,7 +403,11 @@ void SvgVisual::ApplyRasterizedImage( NSVGimage* parsedSvg, PixelData rasterized // Svg loaded and ready to display ResourceReady( Toolkit::Visual::ResourceStatus::READY ); } +#ifdef NO_THORVG else if( !mParsedImage ) +#else /* NO_THORVG */ + else if( !isLoaded || !rasterizedPixelData ) +#endif /* NO_THORVG */ { ResourceReady( Toolkit::Visual::ResourceStatus::FAILED ); } diff --git a/dali-toolkit/internal/visuals/svg/svg-visual.h b/dali-toolkit/internal/visuals/svg/svg-visual.h index e18d5cf..0f1dc95 100644 --- a/dali-toolkit/internal/visuals/svg/svg-visual.h +++ b/dali-toolkit/internal/visuals/svg/svg-visual.h @@ -26,7 +26,9 @@ #include #include +#ifdef NO_THORVG struct NSVGimage; +#endif /* NO_THORVG */ namespace Dali { @@ -142,6 +144,7 @@ protected: public: +#ifdef NO_THORVG /** * @bried Apply the rasterized image to the visual. * @@ -149,14 +152,31 @@ public: * @param[in] rasterizedPixelData The pixel buffer with the rasterized pixels */ void ApplyRasterizedImage( NSVGimage* parsedSvg, PixelData rasterizedPixelData ); +#else /* NO_THORVG */ + /** + * @bried Apply the rasterized image to the visual. + * + * @param[in] vectorImage The data of vector image. + * @param[in] rasterizedPixelData The pixel buffer with the rasterized pixels + * @param[in] bool Whether the resource is loaded + */ + void ApplyRasterizedImage( VectorImageRenderer vectorImage, PixelData rasterizedPixelData, bool isLoaded ); +#endif /* NO_THORVG */ private: +#ifdef NO_THORVG /** * @brief Parses the SVG Image from the set URL. * * @param[in] imageUrl The URL of the image to parse the SVG from. */ void ParseFromUrl( const VisualUrl& imageUrl ); +#else /* NO_THORVG */ + /** + * @brief Load the SVG Image from the set URL. + */ + void Load(); +#endif /* NO_THORVG */ /** * @bried Rasterize the svg with the given size, and add it to the visual. @@ -182,7 +202,15 @@ private: ImageVisualShaderFactory& mImageVisualShaderFactory; Vector4 mAtlasRect; VisualUrl mImageUrl; +#ifdef NO_THORVG NSVGimage* mParsedImage; +#else /* NO_THORVG */ + VectorImageRenderer mVectorRenderer; + uint32_t mDefaultWidth; + uint32_t mDefaultHeight; + bool mLoaded; + bool mLocalResource; +#endif /* NO_THORVG */ WeakHandle mPlacementActor; Vector2 mVisualSize; bool mAttemptAtlasing; ///< If true will attempt atlasing, otherwise create unique texture diff --git a/dali-toolkit/internal/visuals/visual-factory-cache.cpp b/dali-toolkit/internal/visuals/visual-factory-cache.cpp index 218ba4f..ad5bcb3 100644 --- a/dali-toolkit/internal/visuals/visual-factory-cache.cpp +++ b/dali-toolkit/internal/visuals/visual-factory-cache.cpp @@ -144,7 +144,11 @@ void VisualFactoryCache::ApplyRasterizedSVGToSampler() { while( RasterizingTaskPtr task = mSvgRasterizeThread->NextCompletedTask() ) { +#ifdef NO_THORVG task->GetSvgVisual()->ApplyRasterizedImage( task->GetParsedImage(), task->GetPixelData() ); +#else /* NO_THORVG */ + task->GetSvgVisual()->ApplyRasterizedImage( task->GetVectorRenderer(), task->GetPixelData(), task->IsLoaded() ); +#endif /* NO_THORVG */ } }