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=43a600d1af19d6c7d318308e7c5e4bcbfb1b2b11;hpb=e979409480340033e0154a43bb1cbeeeb8d1c6a3;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 43a600d..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,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() @@ -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; + } } } } @@ -209,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; + } } } @@ -220,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(); @@ -252,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 ); } @@ -266,7 +308,7 @@ void TextLabel::RequestTextRelayout() } TextLabel::TextLabel() -: Control( ControlBehaviour( CONTROL_BEHAVIOUR_NONE ) ), +: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ), mRenderingBackend( DEFAULT_RENDERING_BACKEND ) { }