X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Ftext-controls%2Ftext-label-impl.cpp;h=8b1cb704de53ff9a9f81fa759e573873a28700a0;hp=7c7de295a09ff03163ec59f6e6406a9416357ace;hb=beacebbb139c15b44535e3d28c835fc31b412c7c;hpb=297b1b9a9b6ed72fe98d5afb018ff4d1c951ce7d 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 7c7de29..8b1cb70 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -23,8 +23,8 @@ #include // INTERNAL INCLUDES -#include -#include +#include +#include using Dali::Toolkit::Text::LayoutEngine; using Dali::Toolkit::Text::Backend; @@ -42,10 +42,6 @@ namespace Dali namespace Toolkit { -const Property::Index TextLabel::PROPERTY_RENDERING_BACKEND( Internal::TextLabel::TEXTLABEL_PROPERTY_START_INDEX ); -const Property::Index TextLabel::PROPERTY_TEXT( Internal::TextLabel::TEXTLABEL_PROPERTY_START_INDEX + 1 ); -const Property::Index TextLabel::PROPERTY_MULTI_LINE( Internal::TextLabel::TEXTLABEL_PROPERTY_START_INDEX + 2 ); - namespace Internal { @@ -58,11 +54,17 @@ BaseHandle Create() return Toolkit::TextLabel::New(); } -TypeRegistration mType( typeid(Toolkit::TextLabel), typeid(Toolkit::Control), Create ); +// Setup properties, signals and actions using the type-registry. +DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TextLabel, Toolkit::Control, Create ); + +DALI_PROPERTY_REGISTRATION( TextLabel, "rendering-backend", INT, RENDERING_BACKEND ) +DALI_PROPERTY_REGISTRATION( TextLabel, "text", STRING, TEXT ) +DALI_PROPERTY_REGISTRATION( TextLabel, "font-family", STRING, FONT_FAMILY ) +DALI_PROPERTY_REGISTRATION( TextLabel, "font-style", STRING, FONT_STYLE ) +DALI_PROPERTY_REGISTRATION( TextLabel, "point-size", FLOAT, POINT_SIZE ) +DALI_PROPERTY_REGISTRATION( TextLabel, "multi-line", BOOLEAN, MULTI_LINE ) -PropertyRegistration property1( mType, "rendering-backend", Toolkit::TextLabel::PROPERTY_RENDERING_BACKEND, Property::INTEGER, &TextLabel::SetProperty, &TextLabel::GetProperty ); -PropertyRegistration property2( mType, "text", Toolkit::TextLabel::PROPERTY_TEXT, Property::STRING, &TextLabel::SetProperty, &TextLabel::GetProperty ); -PropertyRegistration property3( mType, "multi-line", Toolkit::TextLabel::PROPERTY_MULTI_LINE, Property::STRING, &TextLabel::SetProperty, &TextLabel::GetProperty ); +DALI_TYPE_REGISTRATION_END() } // namespace @@ -98,6 +100,7 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr { impl.mRenderingBackend = static_cast< unsigned int >( backend ); impl.mRenderer.Reset(); + impl.RequestTextRelayout(); } break; } @@ -106,6 +109,49 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr if( impl.mController ) { impl.mController->SetText( value.Get< std::string >() ); + impl.RequestTextRelayout(); + } + break; + } + case Toolkit::TextLabel::PROPERTY_FONT_FAMILY: + { + if( impl.mController ) + { + std::string fontFamily = value.Get< std::string >(); + + if( impl.mController->GetDefaultFontFamily() != fontFamily ) + { + impl.mController->SetDefaultFontFamily( fontFamily ); + impl.RequestTextRelayout(); + } + } + break; + } + case Toolkit::TextLabel::PROPERTY_FONT_STYLE: + { + if( impl.mController ) + { + std::string fontStyle = value.Get< std::string >(); + + if( impl.mController->GetDefaultFontStyle() != fontStyle ) + { + impl.mController->SetDefaultFontStyle( fontStyle ); + impl.RequestTextRelayout(); + } + } + break; + } + case Toolkit::TextLabel::PROPERTY_POINT_SIZE: + { + if( impl.mController ) + { + float pointSize = value.Get< float >(); + + if( impl.mController->GetDefaultPointSize() != pointSize /*TODO - epsilon*/ ) + { + impl.mController->SetDefaultPointSize( pointSize ); + impl.RequestTextRelayout(); + } } break; } @@ -113,8 +159,14 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr { if( impl.mController ) { + LayoutEngine& engine = impl.mController->GetLayoutEngine(); LayoutEngine::Layout layout = value.Get< bool >() ? LayoutEngine::MULTI_LINE_BOX : LayoutEngine::SINGLE_LINE_BOX; - impl.mController->GetLayoutEngine().SetLayout( layout ); + + if( engine.GetLayout() != layout ) + { + impl.mController->GetLayoutEngine().SetLayout( layout ); + impl.RequestTextRelayout(); + } } break; } @@ -138,18 +190,23 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde value = impl.mRenderingBackend; break; } - case Toolkit::TextLabel::PROPERTY_TEXT: { + if( impl.mController ) + { + std::string text; + impl.mController->GetText( text ); + value = text; + } + DALI_LOG_WARNING( "UTF-8 text representation was discarded\n" ); break; } - case Toolkit::TextLabel::PROPERTY_MULTI_LINE: { if( impl.mController ) { - value = impl.mController->GetLayoutEngine().GetLayout(); + value = static_cast( LayoutEngine::MULTI_LINE_BOX == impl.mController->GetLayoutEngine().GetLayout() ); } break; } @@ -176,21 +233,30 @@ float TextLabel::GetHeightForWidth( float width ) void TextLabel::OnRelayout( const Vector2& size, ActorSizeContainer& container ) { - if( mController->Relayout( size ) ) + if( mController->Relayout( size ) || + !mRenderer ) { if( !mRenderer ) { mRenderer = Backend::Get().NewRenderer( mRenderingBackend ); } + RenderableActor renderableActor; if( mRenderer ) { - Actor renderableActor = mRenderer->Render( mController->GetView() ); + renderableActor = mRenderer->Render( mController->GetView() ); + } + + if( renderableActor != mRenderableActor ) + { + UnparentAndReset( mRenderableActor ); if( renderableActor ) { Self().Add( renderableActor ); } + + mRenderableActor = renderableActor; } } }