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-field-impl.cpp;h=b5900c67eba0b88b384438dfde347b7203f3ef11;hp=09a5ecc9dff743f5683ec45b961d4e93f67a681e;hb=0207e16930421216c5a22a0fd3ac409f3bd2a7b0;hpb=b0d779c1461781f29868f5414d2475ab0ba9766b diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index 09a5ecc..b5900c6 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -53,6 +54,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() { @@ -77,6 +86,7 @@ DALI_PROPERTY_REGISTRATION( TextField, "cursor-blink-interval", FLOAT, CUR DALI_PROPERTY_REGISTRATION( TextField, "cursor-blink-duration", FLOAT, CURSOR_BLINK_DURATION ) DALI_PROPERTY_REGISTRATION( TextField, "grab-handle-image", STRING, GRAB_HANDLE_IMAGE ) DALI_PROPERTY_REGISTRATION( TextField, "decoration bounding-box", RECTANGLE, DECORATION_BOUNDING_BOX ) +DALI_PROPERTY_REGISTRATION( TextField, "alignment", STRING, ALIGNMENT ) DALI_TYPE_REGISTRATION_END() @@ -249,6 +259,20 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr } break; } + case Toolkit::TextField::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; + } } } } @@ -364,6 +388,16 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde } break; } + case Toolkit::TextField::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; + } } }