X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=base%2Fdali-toolkit%2Finternal%2Fcontrols%2Ftext-controls%2Ftext-label-impl.cpp;h=c498f0e4ddba625f38f161e5253eee48e13483fa;hp=ed63ba3413baa4a29a68d6ef17a1bd1e4f69fa7b;hb=20d79594120aa5db8769cff09a021e9641655bec;hpb=fc043d6d5ed6561deb09ac1c0b92134f9807518d diff --git a/base/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/base/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp index ed63ba3..c498f0e 100644 --- a/base/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/base/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -18,8 +18,15 @@ // CLASS HEADER #include -// INTERNAL INCLUDES +// EXTERNAL INCLUDES #include +#include + +// INTERNAL INCLUDES +#include +#include // TODO - Get from RendererFactory + +using Dali::Toolkit::Text::LayoutEngine; namespace { @@ -32,7 +39,8 @@ namespace Dali namespace Toolkit { -const Property::Index TextLabel::PROPERTY_TEXT( Internal::TextLabel::TEXTLABEL_PROPERTY_START_INDEX ); +const Property::Index TextLabel::PROPERTY_TEXT( Internal::TextLabel::TEXTLABEL_PROPERTY_START_INDEX ); +const Property::Index TextLabel::PROPERTY_MULTI_LINE( Internal::TextLabel::TEXTLABEL_PROPERTY_START_INDEX + 1 ); namespace Internal { @@ -48,7 +56,8 @@ BaseHandle Create() TypeRegistration mType( typeid(Toolkit::TextLabel), typeid(Toolkit::Control), Create ); -PropertyRegistration property1( mType, "text", Toolkit::TextLabel::PROPERTY_TEXT, Property::STRING, &TextLabel::SetProperty, &TextLabel::GetProperty ); +PropertyRegistration property1( mType, "text", Toolkit::TextLabel::PROPERTY_TEXT, Property::STRING, &TextLabel::SetProperty, &TextLabel::GetProperty ); +PropertyRegistration property2( mType, "multi-line", Toolkit::TextLabel::PROPERTY_MULTI_LINE, Property::STRING, &TextLabel::SetProperty, &TextLabel::GetProperty ); } // namespace @@ -83,9 +92,12 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr { case Toolkit::TextLabel::PROPERTY_TEXT: { - labelImpl.mText = value.Get< std::string >(); - - // TODO - Update Model etc. + labelImpl.SetText( value.Get< std::string >() ); + break; + } + case Toolkit::TextLabel::PROPERTY_MULTI_LINE: + { + labelImpl.SetMultiLine( value.Get< bool >() ); break; } } @@ -100,12 +112,11 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde if( label ) { - TextLabel& labelImpl( GetImpl( label ) ); switch( index ) { case Toolkit::TextLabel::PROPERTY_TEXT: { - value = labelImpl.mText; + DALI_LOG_WARNING( "UTF-8 text representation was discarded\n" ); break; } } @@ -116,6 +127,53 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde void TextLabel::OnInitialize() { + mController = Text::Controller::New(); +} + +void TextLabel::OnRelayout( const Vector2& size, ActorSizeContainer& container ) +{ + if( mController->Relayout( size ) ) + { + if( !mRenderer ) + { + // TODO - Get from RendererFactory + mRenderer = Dali::Toolkit::Text::BasicRenderer::New(); + } + + if( mRenderer ) + { + Actor renderableActor = mRenderer->Render( mController->GetView() ); + + if( renderableActor ) + { + Self().Add( renderableActor ); + } + } + } +} + +void TextLabel::SetText( const std::string& text ) +{ + if( mController ) + { + // The Controller updates the View for the renderer + mController->SetText( text ); + } +} + +void TextLabel::SetMultiLine( bool multiLine ) +{ + if( mController ) + { + if( multiLine ) + { + mController->GetLayoutEngine().SetLayout( LayoutEngine::MULTI_LINE_BOX ); + } + else + { + mController->GetLayoutEngine().SetLayout( LayoutEngine::SINGLE_LINE_BOX ); + } + } } TextLabel::TextLabel()