X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Ftext%2Ftext-visual.cpp;h=4228ecfa4a2e94b0a013c23afafa05ebb6eb2b54;hb=a2519d330569f4898996dfcc74b8d30433bace42;hp=48f9a04dbe124bd10efbd3e27e03d915991dc41d;hpb=f7ca0a1c753ea498df357add70b5c7a9bad4ea91;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/text/text-visual.cpp b/dali-toolkit/internal/visuals/text/text-visual.cpp index 48f9a04..4228ecf 100644 --- a/dali-toolkit/internal/visuals/text/text-visual.cpp +++ b/dali-toolkit/internal/visuals/text/text-visual.cpp @@ -25,6 +25,7 @@ // INTERNAL HEADER #include #include +#include #include #include #include @@ -161,36 +162,12 @@ TextVisualPtr TextVisual::New( VisualFactoryCache& factoryCache ) return new TextVisual( factoryCache ); } -void TextVisual::SetTextControlInterface( Text::ControlInterface* controlInterface ) -{ - if( mController ) - { - mController->SetTextControlInterface( controlInterface ); - } -} - -void TextVisual::SetSize( const Vector2& size ) -{ - const Text::Controller::UpdateTextType updateTextType = mController->Relayout( size ); - - if( ( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) ) || - !mRenderer ) - { - if( !mRenderer ) - { - mRenderer = Text::Backend::Get().NewRenderer( mRenderingBackend ); - } - - RenderText(); - } -} - float TextVisual::GetHeightForWidth( float width ) const { return mController->GetHeightForWidth( width ); } -void TextVisual::GetNaturalSize( Vector2& naturalSize ) const +void TextVisual::GetNaturalSize( Vector2& naturalSize ) { naturalSize = mController->GetNaturalSize().GetVectorXY(); } @@ -200,7 +177,7 @@ void TextVisual::DoCreatePropertyMap( Property::Map& map ) const Property::Value value; map.Clear(); - map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::TEXT ); + map.Insert( Toolkit::VisualProperty::TYPE, Toolkit::Visual::TEXT ); map.Insert( Toolkit::TextVisual::Property::RENDERING_BACKEND, mRenderingBackend ); @@ -225,14 +202,6 @@ void TextVisual::DoCreatePropertyMap( Property::Map& map ) const map.Insert( Toolkit::TextVisual::Property::ENABLE_MARKUP, mController->IsMarkupProcessorEnabled() ); - map.Insert( Toolkit::TextVisual::Property::ENABLE_AUTO_SCROLL, mController->IsAutoScrollEnabled() ); - - map.Insert( Toolkit::TextVisual::Property::AUTO_SCROLL_SPEED, mController->GetAutoScrollSpeed() ); - - map.Insert( Toolkit::TextVisual::Property::AUTO_SCROLL_LOOP_COUNT, mController->GetAutoScrollLoopCount() ); - - map.Insert( Toolkit::TextVisual::Property::AUTO_SCROLL_GAP, mController->GetAutoScrollWrapGap() ); - map.Insert( Toolkit::TextVisual::Property::LINE_SPACING, mController->GetDefaultLineSpacing() ); GetUnderlineProperties( mController, value, Text::EffectStyle::DEFAULT ); @@ -269,7 +238,7 @@ void TextVisual::DoSetProperties( const Property::Map& propertyMap ) { case Property::Key::INDEX: { - if( Toolkit::Visual::Property::TYPE != keyValue.first.indexKey ) // Toolkit::Visual::Property::TYPE is not a TextVisual's property. + if( Toolkit::VisualProperty::TYPE != keyValue.first.indexKey ) // Toolkit::VisualProperty::TYPE is not a TextVisual's property. { DoSetProperty( keyValue.first.indexKey, keyValue.second ); } @@ -500,47 +469,22 @@ void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Propert } case Toolkit::TextVisual::Property::ENABLE_AUTO_SCROLL: { - const bool enableAutoScroll = propertyValue.Get(); - - // If request to auto scroll is the same as current state then do nothing. - if( enableAutoScroll != mController->IsAutoScrollEnabled() ) - { - // If request is disable (false) and auto scrolling is enabled then need to stop it - if( !enableAutoScroll ) - { - StopTextAutoScrolling(); // Causes the current animation to finish playing. - } - // If request is enable (true) then start autoscroll as not already running - else - { - mController->GetLayoutEngine().SetTextEllipsisEnabled( false ); - mController->SetAutoScrollEnabled( enableAutoScroll ); - mController->RequestRelayout(); - } - } + // nothing to do. break; } case Toolkit::TextVisual::Property::AUTO_SCROLL_SPEED: { - mController->SetAutoscrollSpeed( propertyValue.Get() ); + // nothing to do. break; } case Toolkit::TextVisual::Property::AUTO_SCROLL_LOOP_COUNT: { - const int loopCount = propertyValue.Get(); - if( loopCount > 0 ) - { - mController->SetAutoScrollLoopCount( loopCount ); - } - else - { - StopTextAutoScrolling(); // Causes the current animation to finish playing. - } + // nothing to do. break; } case Toolkit::TextVisual::Property::AUTO_SCROLL_GAP: { - mController->SetAutoScrollWrapGap( propertyValue.Get() ); + // nothing to do. break; } case Toolkit::TextVisual::Property::LINE_SPACING: @@ -553,7 +497,7 @@ void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Propert case Toolkit::TextVisual::Property::UNDERLINE: { // TODO : This switch can be removed when the deprecated SHADOW_OFFSET and SHADOW_COLOR properties are finally removed. - // Only the code for the STRING case should be kept. + // Only the code for the MAP case should be kept. switch( propertyValue.GetType() ) { case Property::VECTOR4: @@ -586,7 +530,7 @@ void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Propert } break; } - case Property::STRING: + case Property::MAP: { const bool update = SetUnderlineProperties( mController, propertyValue, Text::EffectStyle::DEFAULT ); if( update ) @@ -607,7 +551,7 @@ void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Propert case Toolkit::TextVisual::Property::SHADOW: { // TODO : This switch can be removed when the deprecated SHADOW_OFFSET and SHADOW_COLOR properties are finally removed. - // Only the code for the STRING case should be kept. + // Only the code for the MAP case should be kept. switch( propertyValue.GetType() ) { case Property::VECTOR2: @@ -630,7 +574,7 @@ void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Propert } break; } - case Property::STRING: + case Property::MAP: { const bool update = SetShadowProperties( mController, propertyValue, Text::EffectStyle::DEFAULT ); if( update ) @@ -750,22 +694,22 @@ Dali::Property::Value TextVisual::DoGetProperty( Dali::Property::Index index ) } case Toolkit::TextVisual::Property::ENABLE_AUTO_SCROLL: { - value = mController->IsAutoScrollEnabled(); + // nothing to do. break; } case Toolkit::TextVisual::Property::AUTO_SCROLL_SPEED: { - value = mController->GetAutoScrollSpeed(); + // nothing to do. break; } case Toolkit::TextVisual::Property::AUTO_SCROLL_LOOP_COUNT: { - value = mController->GetAutoScrollLoopCount(); + // nothing to do. break; } case Toolkit::TextVisual::Property::AUTO_SCROLL_GAP: { - value = mController->GetAutoScrollWrapGap(); + // nothing to do. break; } case Toolkit::TextVisual::Property::LINE_SPACING: @@ -808,8 +752,35 @@ Dali::Property::Value TextVisual::DoGetProperty( Dali::Property::Index index ) return value; } +void TextVisual::OnSetTransform() +{ + Vector2 visualSize = mImpl->mTransform.GetVisualSize( mImpl->mControlSize ); + + // Note, the direction should come from the layout of the parent control + mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT ); + + const Text::Controller::UpdateTextType updateTextType = mController->Relayout( visualSize ); + + if( ( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) ) || + !mRenderer ) + { + if( !mRenderer ) + { + mRenderer = Text::Backend::Get().NewRenderer( mRenderingBackend ); + } + RenderText(); + } +} + void TextVisual::RenderText() { + Actor self = mSelf.GetHandle(); + if( !self ) + { + // Nothing to do if the handle is not initialized. + return; + } + Actor renderableActor; if( mRenderer ) @@ -826,42 +797,9 @@ void TextVisual::RenderText() const Vector2& scrollOffset = mController->GetScrollPosition(); renderableActor.SetPosition( scrollOffset.x, scrollOffset.y ); - mSelf.Add( renderableActor ); + self.Add( renderableActor ); } mRenderableActor = renderableActor; - - if( mController->IsAutoScrollEnabled() ) - { - SetUpAutoScrolling(); - } - } -} - -void TextVisual::StopTextAutoScrolling() -{ - if( mTextScroller ) - { - mTextScroller->StopScrolling(); - } -} - -void TextVisual::SetUpAutoScrolling() -{ - const Text::ScrollerData* const data = mController->GetAutoScrollData(); - - if( NULL != data ) - { - if( !mTextScroller ) - { - // If speed, loopCount or gap not set via property system then will need to create a TextScroller with defaults - mTextScroller = Text::TextScroller::New( *mController ); - } - - mTextScroller->StartScrolling( mRenderableActor, - *data ); - - mSelf.Add( mTextScroller->GetScrollingText() ); - mSelf.Add( mTextScroller->GetSourceCamera() ); } }