X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Ftext-controls%2Ftext-label-impl.cpp;h=db99cc47b4e114f5c9fa3cee8908e170870cb51d;hb=refs%2Fchanges%2F44%2F148744%2F3;hp=5f17f0016148221b6c9f0014c1be623d26cb0482;hpb=003fe1b0cb2900bd60063649e46fbbbb6e7d997d;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 5f17f00..db99cc4 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -81,6 +81,13 @@ const Scripting::StringEnum VERTICAL_ALIGNMENT_STRING_TABLE[] = }; const unsigned int VERTICAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( VERTICAL_ALIGNMENT_STRING_TABLE ) / sizeof( VERTICAL_ALIGNMENT_STRING_TABLE[0] ); +const Scripting::StringEnum LINE_WRAP_MODE_STRING_TABLE[] = +{ + { "WRAP_MODE_WORD", Toolkit::Text::Layout::LineWrap::WORD }, + { "WRAP_MODE_CHARACTER", Toolkit::Text::Layout::LineWrap::CHARACTER } +}; +const unsigned int LINE_WRAP_MODE_STRING_TABLE_COUNT = sizeof( LINE_WRAP_MODE_STRING_TABLE ) / sizeof( LINE_WRAP_MODE_STRING_TABLE[0] ); + // Type registration BaseHandle Create() { @@ -119,7 +126,12 @@ DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "ellipsis", BOO DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollLoopDelay", FLOAT, AUTO_SCROLL_LOOP_DELAY ) DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollStopMode", STRING, AUTO_SCROLL_STOP_MODE ) DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextLabel, "lineCount", INTEGER, LINE_COUNT ) - +DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "lineWrapMode", STRING, LINE_WRAP_MODE ) +DALI_DEVEL_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT( Toolkit, TextLabel, "textColorAnimatable", Color::WHITE, TEXT_COLOR_ANIMATABLE ) +DALI_DEVEL_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, TextLabel, "textColorRed", TEXT_COLOR_RED, TEXT_COLOR_ANIMATABLE, 0) +DALI_DEVEL_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, TextLabel, "textColorGreen", TEXT_COLOR_GREEN, TEXT_COLOR_ANIMATABLE, 1) +DALI_DEVEL_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, TextLabel, "textColorBlue", TEXT_COLOR_BLUE, TEXT_COLOR_ANIMATABLE, 2) +DALI_DEVEL_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, TextLabel, "textColorAlpha", TEXT_COLOR_ALPHA, TEXT_COLOR_ANIMATABLE, 3) DALI_TYPE_REGISTRATION_END() } // namespace @@ -250,15 +262,7 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr case Toolkit::TextLabel::Property::TEXT_COLOR: { - if( impl.mController ) - { - const Vector4& textColor = value.Get< Vector4 >(); - if( impl.mController->GetDefaultColor() != textColor ) - { - impl.mController->SetDefaultColor( textColor ); - impl.mRenderer.Reset(); - } - } + SetProperty( object, DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, value ); break; } @@ -486,6 +490,21 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr } break; } + case Toolkit::DevelTextLabel::Property::LINE_WRAP_MODE: + { + const std::string& wrapModeStr = value.Get< std::string >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel %p LINE_WRAP_MODE %s\n", impl.mController.Get(), wrapModeStr.c_str() ); + + Layout::LineWrap::Mode lineWrapMode( Layout::LineWrap::WORD ); + if( Scripting::GetEnumeration< Layout::LineWrap::Mode >( wrapModeStr.c_str(), + LINE_WRAP_MODE_STRING_TABLE, + LINE_WRAP_MODE_STRING_TABLE_COUNT, + lineWrapMode ) ) + { + impl.mController->SetLineWrapMode( lineWrapMode ); + } + break; + } } } } @@ -575,7 +594,7 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde } case Toolkit::TextLabel::Property::TEXT_COLOR: { - if ( impl.mController ) + if( impl.mController ) { value = impl.mController->GetDefaultColor(); } @@ -737,6 +756,14 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde } break; } + case Toolkit::DevelTextLabel::Property::LINE_WRAP_MODE: + { + if( impl.mController ) + { + value = impl.mController->GetLineWrapMode(); + } + break; + } case Toolkit::DevelTextLabel::Property::LINE_COUNT: { if( impl.mController ) @@ -814,14 +841,46 @@ Vector3 TextLabel::GetNaturalSize() float TextLabel::GetHeightForWidth( float width ) { - return mController->GetHeightForWidth( width ); + Padding padding; + Self().GetPadding( padding ); + return mController->GetHeightForWidth( width ) + padding.top + padding.bottom; +} + +void TextLabel::OnPropertySet( Property::Index index, Property::Value propertyValue ) +{ + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextLabel::OnPropertySet index[%d]\n", index ); + + switch ( index ) + { + case Toolkit::TextLabel::Property::TEXT_COLOR: + case Toolkit::DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE: + { + const Vector4& textColor = propertyValue.Get< Vector4 >(); + if( mController->GetDefaultColor() != textColor ) + { + mController->SetDefaultColor( textColor ); + mRenderer.Reset(); + } + break; + } + default: + { + Control::OnPropertySet( index, propertyValue ); // up call to control for non-handled properties + break; + } + } } void TextLabel::OnRelayout( const Vector2& size, RelayoutContainer& container ) { DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel::OnRelayout\n" ); - const Text::Controller::UpdateTextType updateTextType = mController->Relayout( size ); + Padding padding; + Self().GetPadding( padding ); + Vector2 contentSize( size.x - ( padding.left + padding.right ), size.y - ( padding.top + padding.bottom ) ); + + + const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize ); if( ( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) ) || !mRenderer ) @@ -849,7 +908,12 @@ void TextLabel::RenderText() float alignmentOffset = 0.f; if( mRenderer ) { + + Dali::Toolkit::TextLabel handle = Dali::Toolkit::TextLabel( GetOwner() ); + renderableActor = mRenderer->Render( mController->GetView(), + handle, + Toolkit::DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, alignmentOffset, DepthIndex::CONTENT ); } @@ -861,7 +925,9 @@ void TextLabel::RenderText() if( renderableActor ) { const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition(); - renderableActor.SetPosition( scrollOffset.x + alignmentOffset, scrollOffset.y ); + Padding padding; + self.GetPadding( padding ); + renderableActor.SetPosition( scrollOffset.x + alignmentOffset + padding.left, scrollOffset.y + padding.top ); self.Add( renderableActor ); }