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=118c2b349f5533b3dbbbd886bac7dc25743c19dd;hp=bb0607d221c4de30ace44eb79b8ef9e877de4f8b;hb=0207e16930421216c5a22a0fd3ac409f3bd2a7b0;hpb=eea53605c5acb244aebb72d75bdd9b3a68a9678a 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 bb0607d..118c2b3 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -21,22 +21,18 @@ // EXTERNAL INCLUDES #include #include +#include #include // INTERNAL INCLUDES +#include #include #include +#include using Dali::Toolkit::Text::LayoutEngine; using Dali::Toolkit::Text::Backend; -namespace -{ - -const unsigned int DEFAULT_RENDERING_BACKEND = 0; - -} // namespace - namespace Dali { @@ -48,6 +44,19 @@ namespace Internal namespace { + const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND; +} + +namespace +{ + +const Scripting::StringEnum< Toolkit::Text::LayoutEngine::Alignment > ALIGNMENT_STRING_TABLE[] = +{ + { "BEGIN", Toolkit::Text::LayoutEngine::ALIGN_BEGIN }, + { "CENTER", Toolkit::Text::LayoutEngine::ALIGN_CENTER }, + { "END", Toolkit::Text::LayoutEngine::ALIGN_END }, +}; +const unsigned int ALIGNMENT_STRING_TABLE_COUNT = sizeof( ALIGNMENT_STRING_TABLE ) / sizeof( ALIGNMENT_STRING_TABLE[0] ); // Type registration BaseHandle Create() @@ -64,6 +73,7 @@ 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 ) +DALI_PROPERTY_REGISTRATION( TextLabel, "alignment", STRING, ALIGNMENT ) DALI_TYPE_REGISTRATION_END() @@ -95,11 +105,11 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr { case Toolkit::TextLabel::Property::RENDERING_BACKEND: { - unsigned int backend = value.Get< int >(); + int backend = value.Get< int >(); if( impl.mRenderingBackend != backend ) { - impl.mRenderingBackend = static_cast< unsigned int >( backend ); + impl.mRenderingBackend = backend; impl.mRenderer.Reset(); impl.RequestTextRelayout(); } @@ -165,12 +175,26 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr if( engine.GetLayout() != layout ) { - impl.mController->GetLayoutEngine().SetLayout( layout ); + engine.SetLayout( layout ); impl.RequestTextRelayout(); } } break; } + case Toolkit::TextLabel::Property::ALIGNMENT: + { + LayoutEngine& engine = impl.mController->GetLayoutEngine(); + const LayoutEngine::Alignment alignment = Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::Alignment >( value.Get< std::string >().c_str(), + ALIGNMENT_STRING_TABLE, + ALIGNMENT_STRING_TABLE_COUNT ); + + if( engine.GetAlignment() != alignment ) + { + engine.SetAlignment( alignment ); + impl.RequestTextRelayout(); + } + break; + } } } } @@ -199,8 +223,6 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde impl.mController->GetText( text ); value = text; } - - DALI_LOG_WARNING( "UTF-8 text representation was discarded\n" ); break; } case Toolkit::TextLabel::Property::MULTI_LINE: @@ -211,6 +233,16 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde } break; } + case Toolkit::TextLabel::Property::ALIGNMENT: + { + if( impl.mController ) + { + value = std::string( Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::Alignment >( impl.mController->GetLayoutEngine().GetAlignment(), + ALIGNMENT_STRING_TABLE, + ALIGNMENT_STRING_TABLE_COUNT ) ); + } + break; + } } } @@ -222,6 +254,11 @@ void TextLabel::OnInitialize() mController = Text::Controller::New( *this ); } +void TextLabel::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change ) +{ + GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) ); +} + Vector3 TextLabel::GetNaturalSize() { return mController->GetNaturalSize(); @@ -268,7 +305,7 @@ void TextLabel::RequestTextRelayout() } TextLabel::TextLabel() -: Control( ControlBehaviour( CONTROL_BEHAVIOUR_NONE ) ), +: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ), mRenderingBackend( DEFAULT_RENDERING_BACKEND ) { }