X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Ftext-controls%2Ftext-label-impl.cpp;h=efcecbf23a0744da4301e9d02f1da4def980e16b;hb=refs%2Fchanges%2F52%2F37252%2F3;hp=fdce0edd128a975980a20c090843e48cc7711aa2;hpb=7132bfee764dc2c7c68feb8c9e9c4e81c9a7d883;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git 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 fdce0ed..efcecbf 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -21,12 +21,14 @@ // EXTERNAL INCLUDES #include #include +#include #include // INTERNAL INCLUDES +#include #include #include -#include +#include using Dali::Toolkit::Text::LayoutEngine; using Dali::Toolkit::Text::Backend; @@ -48,6 +50,14 @@ namespace 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() { @@ -63,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() @@ -164,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; + } } } } @@ -208,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; + } } } @@ -219,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(); @@ -251,6 +291,9 @@ void TextLabel::OnRelayout( const Vector2& size, ActorSizeContainer& container ) if( renderableActor ) { + const Vector2& alignmentOffset = mController->GetAlignmentOffset(); + renderableActor.SetPosition( alignmentOffset.x, alignmentOffset.y ); + Self().Add( renderableActor ); } @@ -265,7 +308,7 @@ void TextLabel::RequestTextRelayout() } TextLabel::TextLabel() -: Control( ControlBehaviour( CONTROL_BEHAVIOUR_NONE ) ), +: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ), mRenderingBackend( DEFAULT_RENDERING_BACKEND ) { }