2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/internal/visuals/text/text-visual.h>
22 #include <dali/devel-api/scripting/enum-helper.h>
23 // #include <dali/devel-api/scripting/scripting.h>
26 #include <dali-toolkit/public-api/text/rendering-backend.h>
27 #include <dali-toolkit/public-api/visuals/text-visual-properties.h>
28 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
29 #include <dali-toolkit/internal/text/rendering/text-backend.h>
30 #include <dali-toolkit/internal/text/text-view.h>
31 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
32 #include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
33 #include <dali-toolkit/internal/text/text-font-style.h>
34 #include <dali-toolkit/internal/text/text-effects-style.h>
36 using Dali::Toolkit::Text::LayoutEngine;
51 const char * const RENDERING_BACKEND_PROPERTY( "renderingBackend" );
52 const char * const TEXT_PROPERTY( "text" );
53 const char * const FONT_FAMILY_PROPERTY( "fontFamily" );
54 const char * const FONT_STYLE_PROPERTY( "fontStyle" );
55 const char * const POINT_SIZE_PROPERTY( "pointSize" );
56 const char * const MULTI_LINE_PROPERTY( "multiLine" );
57 const char * const HORIZONTAL_ALIGNMENT_PROPERTY( "horizontalAlignment" );
58 const char * const VERTICAL_ALIGNMENT_PROPERTY( "verticalAlignment" );
59 const char * const TEXT_COLOR_PROPERTY( "textColor" );
60 const char * const ENABLE_MARKUP_PROPERTY( "enableMarkup" );
61 const char * const ENABLE_AUTO_SCROLL_PROPERTY( "enableAutoScroll" );
62 const char * const AUTO_SCROLL_SPEED_PROPERTY( "autoScrollSpeed" );
63 const char * const AUTO_SCROLL_LOOP_COUNT_PROPERTY( "autoScrollLoopCount" );
64 const char * const AUTO_SCROLL_GAP_PROPERTY( "autoScrollGap" );
65 const char * const LINE_SPACING_PROPERTY( "lineSpacing" );
66 const char * const UNDERLINE_PROPERTY( "underline" );
67 const char * const SHADOW_PROPERTY( "shadow" );
68 const char * const OUTLINE_PROPERTY( "outline" );
69 const char * const BATCHING_ENABLED_PROPERTY( "batchingEnabled" );
71 const Scripting::StringEnum HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
73 { "BEGIN", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_BEGIN },
74 { "CENTER", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_CENTER },
75 { "END", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_END },
77 const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] );
79 const Scripting::StringEnum VERTICAL_ALIGNMENT_STRING_TABLE[] =
81 { "TOP", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_TOP },
82 { "CENTER", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_CENTER },
83 { "BOTTOM", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_BOTTOM },
85 const unsigned int VERTICAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( VERTICAL_ALIGNMENT_STRING_TABLE ) / sizeof( VERTICAL_ALIGNMENT_STRING_TABLE[0] );
87 std::string GetHorizontalAlignment( LayoutEngine::HorizontalAlignment alignment )
89 const char* name = Scripting::GetEnumerationName<Toolkit::Text::LayoutEngine::HorizontalAlignment>( alignment,
90 HORIZONTAL_ALIGNMENT_STRING_TABLE,
91 HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
93 return std::string( name );
96 std::string GetVerticalAlignment( LayoutEngine::VerticalAlignment alignment )
98 const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( alignment,
99 VERTICAL_ALIGNMENT_STRING_TABLE,
100 VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
102 return std::string( name );
105 const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
106 attribute mediump vec2 aPosition;\n
107 uniform mediump mat4 uMvpMatrix;\n
108 uniform mediump vec3 uSize;\n
109 uniform mediump vec4 pixelArea;
110 varying mediump vec2 vTexCoord;\n
114 mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
115 vertexPosition.xyz *= uSize;\n
116 vertexPosition = uMvpMatrix * vertexPosition;\n
118 vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );\n
119 gl_Position = vertexPosition;\n
123 const char* FRAGMENT_SHADER_ATLAS_CLAMP = DALI_COMPOSE_SHADER(
124 varying mediump vec2 vTexCoord;\n
125 uniform sampler2D sTexture;\n
126 uniform mediump vec4 uAtlasRect;\n
127 uniform lowp vec4 uColor;\n
131 mediump vec2 texCoord = clamp( mix( uAtlasRect.xy, uAtlasRect.zw, vTexCoord ), uAtlasRect.xy, uAtlasRect.zw );\n
132 gl_FragColor = texture2D( sTexture, texCoord ) * uColor;\n
136 Geometry CreateGeometry( VisualFactoryCache& factoryCache, ImageDimensions gridSize )
140 if( gridSize == ImageDimensions( 1, 1 ) )
142 geometry = factoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
145 geometry = VisualFactoryCache::CreateQuadGeometry();
146 factoryCache.SaveGeometry( VisualFactoryCache::QUAD_GEOMETRY, geometry );
151 geometry = VisualFactoryCache::CreateGridGeometry( gridSize );
157 } // unnamed namespace
159 TextVisualPtr TextVisual::New( VisualFactoryCache& factoryCache )
161 return new TextVisual( factoryCache );
164 void TextVisual::SetTextControlInterface( Text::ControlInterface* controlInterface )
168 mController->SetTextControlInterface( controlInterface );
172 void TextVisual::SetSize( const Vector2& size )
174 const Text::Controller::UpdateTextType updateTextType = mController->Relayout( size );
176 if( ( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) ) ||
181 mRenderer = Text::Backend::Get().NewRenderer( mRenderingBackend );
188 float TextVisual::GetHeightForWidth( float width ) const
190 return mController->GetHeightForWidth( width );
193 void TextVisual::GetNaturalSize( Vector2& naturalSize ) const
195 naturalSize = mController->GetNaturalSize().GetVectorXY();
198 void TextVisual::DoCreatePropertyMap( Property::Map& map ) const
200 Property::Value value;
203 map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::TEXT );
205 map.Insert( Toolkit::TextVisual::Property::RENDERING_BACKEND, mRenderingBackend );
208 mController->GetText( text );
209 map.Insert( Toolkit::TextVisual::Property::TEXT, text );
211 map.Insert( Toolkit::TextVisual::Property::FONT_FAMILY, mController->GetDefaultFontFamily() );
213 GetFontStyleProperty( mController, value, Text::FontStyle::DEFAULT );
214 map.Insert( Toolkit::TextVisual::Property::FONT_STYLE, value );
216 map.Insert( Toolkit::TextVisual::Property::POINT_SIZE, mController->GetDefaultPointSize() );
218 map.Insert( Toolkit::TextVisual::Property::MULTI_LINE, mController->IsMultiLineEnabled() );
220 map.Insert( Toolkit::TextVisual::Property::HORIZONTAL_ALIGNMENT, GetHorizontalAlignment( mController->GetHorizontalAlignment() ) );
222 map.Insert( Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT, GetVerticalAlignment( mController->GetVerticalAlignment() ) );
224 map.Insert( Toolkit::TextVisual::Property::TEXT_COLOR, mController->GetTextColor() );
226 map.Insert( Toolkit::TextVisual::Property::ENABLE_MARKUP, mController->IsMarkupProcessorEnabled() );
228 map.Insert( Toolkit::TextVisual::Property::ENABLE_AUTO_SCROLL, mController->IsAutoScrollEnabled() );
230 map.Insert( Toolkit::TextVisual::Property::AUTO_SCROLL_SPEED, mController->GetAutoScrollSpeed() );
232 map.Insert( Toolkit::TextVisual::Property::AUTO_SCROLL_LOOP_COUNT, mController->GetAutoScrollLoopCount() );
234 map.Insert( Toolkit::TextVisual::Property::AUTO_SCROLL_GAP, mController->GetAutoScrollWrapGap() );
236 map.Insert( Toolkit::TextVisual::Property::LINE_SPACING, mController->GetDefaultLineSpacing() );
238 GetUnderlineProperties( mController, value, Text::EffectStyle::DEFAULT );
239 map.Insert( Toolkit::TextVisual::Property::UNDERLINE, value );
241 GetShadowProperties( mController, value, Text::EffectStyle::DEFAULT );
242 map.Insert( Toolkit::TextVisual::Property::SHADOW, value );
244 GetOutlineProperties( mController, value, Text::EffectStyle::DEFAULT );
245 map.Insert( Toolkit::TextVisual::Property::OUTLINE, value );
247 map.Insert( Toolkit::TextVisual::Property::BATCHING_ENABLED, false ); // TODO
250 TextVisual::TextVisual( VisualFactoryCache& factoryCache )
251 : Visual::Base( factoryCache ),
252 mController( Text::Controller::New() ),
253 mRenderingBackend( Toolkit::Text::DEFAULT_RENDERING_BACKEND ),
254 mHasBeenStaged( false )
258 TextVisual::~TextVisual()
262 void TextVisual::DoSetProperties( const Property::Map& propertyMap )
264 for( Property::Map::SizeType index = 0u, count = propertyMap.Count(); index < count; ++index )
266 const KeyValuePair& keyValue = propertyMap.GetKeyValue( index );
268 switch( keyValue.first.type )
270 case Property::Key::INDEX:
272 if( Toolkit::Visual::Property::TYPE != keyValue.first.indexKey ) // Toolkit::Visual::Property::TYPE is not a TextVisual's property.
274 DoSetProperty( keyValue.first.indexKey, keyValue.second );
278 case Property::Key::STRING:
280 if( keyValue.first.stringKey == RENDERING_BACKEND_PROPERTY )
282 DoSetProperty( Toolkit::TextVisual::Property::RENDERING_BACKEND, keyValue.second );
284 else if( keyValue.first.stringKey == TEXT_PROPERTY )
286 DoSetProperty( Toolkit::TextVisual::Property::TEXT, keyValue.second );
288 else if( keyValue.first.stringKey == FONT_FAMILY_PROPERTY )
290 DoSetProperty( Toolkit::TextVisual::Property::FONT_FAMILY, keyValue.second );
292 else if( keyValue.first.stringKey == FONT_STYLE_PROPERTY )
294 DoSetProperty( Toolkit::TextVisual::Property::FONT_STYLE, keyValue.second );
296 else if( keyValue.first.stringKey == POINT_SIZE_PROPERTY )
298 DoSetProperty( Toolkit::TextVisual::Property::POINT_SIZE, keyValue.second );
300 else if( keyValue.first.stringKey == MULTI_LINE_PROPERTY )
302 DoSetProperty( Toolkit::TextVisual::Property::MULTI_LINE, keyValue.second );
304 else if( keyValue.first.stringKey == HORIZONTAL_ALIGNMENT_PROPERTY )
306 DoSetProperty( Toolkit::TextVisual::Property::HORIZONTAL_ALIGNMENT, keyValue.second );
308 else if( keyValue.first.stringKey == VERTICAL_ALIGNMENT_PROPERTY )
310 DoSetProperty( Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT, keyValue.second );
312 else if( keyValue.first.stringKey == TEXT_COLOR_PROPERTY )
314 DoSetProperty( Toolkit::TextVisual::Property::TEXT_COLOR, keyValue.second );
316 else if( keyValue.first.stringKey == ENABLE_MARKUP_PROPERTY )
318 DoSetProperty( Toolkit::TextVisual::Property::ENABLE_MARKUP, keyValue.second );
320 else if( keyValue.first.stringKey == ENABLE_AUTO_SCROLL_PROPERTY )
322 DoSetProperty( Toolkit::TextVisual::Property::ENABLE_AUTO_SCROLL, keyValue.second );
324 else if( keyValue.first.stringKey == AUTO_SCROLL_SPEED_PROPERTY )
326 DoSetProperty( Toolkit::TextVisual::Property::AUTO_SCROLL_SPEED, keyValue.second );
328 else if( keyValue.first.stringKey == AUTO_SCROLL_LOOP_COUNT_PROPERTY )
330 DoSetProperty( Toolkit::TextVisual::Property::AUTO_SCROLL_LOOP_COUNT, keyValue.second );
332 else if( keyValue.first.stringKey == AUTO_SCROLL_GAP_PROPERTY )
334 DoSetProperty( Toolkit::TextVisual::Property::AUTO_SCROLL_GAP, keyValue.second );
336 else if( keyValue.first.stringKey == LINE_SPACING_PROPERTY )
338 DoSetProperty( Toolkit::TextVisual::Property::LINE_SPACING, keyValue.second );
340 else if( keyValue.first.stringKey == UNDERLINE_PROPERTY )
342 DoSetProperty( Toolkit::TextVisual::Property::UNDERLINE, keyValue.second );
344 else if( keyValue.first.stringKey == SHADOW_PROPERTY )
346 DoSetProperty( Toolkit::TextVisual::Property::SHADOW, keyValue.second );
348 else if( keyValue.first.stringKey == OUTLINE_PROPERTY )
350 DoSetProperty( Toolkit::TextVisual::Property::OUTLINE, keyValue.second );
352 else if( keyValue.first.stringKey == BATCHING_ENABLED_PROPERTY )
354 DoSetProperty( Toolkit::TextVisual::Property::BATCHING_ENABLED, keyValue.second );
361 // Retrieve the layout engine to set whether to elide the text and set the cursor's width.
362 Text::LayoutEngine& engine = mController->GetLayoutEngine();
364 // Elide the text if it exceeds the boundaries.
365 engine.SetTextEllipsisEnabled( true );
367 // Sets 0 as cursor's width.
368 engine.SetCursorWidth( 0u ); // Do not layout space for the cursor.
371 void TextVisual::DoSetOnStage( Actor& actor )
373 // TODO Create the actual renderer(s) for the text!!!!
374 // Will crash if no mImpl->mRenderer is set.
378 geometry = CreateGeometry( mFactoryCache, ImageDimensions( 1, 1 ) );
380 shader = mFactoryCache.GetShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP );
383 shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_ATLAS_CLAMP );
384 mFactoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP, shader );
387 mImpl->mRenderer = Renderer::New( geometry, shader );
397 mHasBeenStaged = true;
401 void TextVisual::DoSetOffStage( Actor& actor )
406 void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
410 case Toolkit::TextVisual::Property::RENDERING_BACKEND:
412 int backend = propertyValue.Get<int>();
414 #ifndef ENABLE_VECTOR_BASED_TEXT_RENDERING
415 if( Text::RENDERING_VECTOR_BASED == backend )
417 backend = TextAbstraction::BITMAP_GLYPH; // Fallback to bitmap-based rendering
420 if( mRenderingBackend != backend )
422 mRenderingBackend = backend;
425 // When using the vector-based rendering, the size of the GLyphs are different
426 TextAbstraction::GlyphType glyphType = ( Text::RENDERING_VECTOR_BASED == mRenderingBackend ) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH;
427 mController->SetGlyphType( glyphType );
431 case Toolkit::TextVisual::Property::TEXT:
433 mController->SetText( propertyValue.Get<std::string>() );
436 case Toolkit::TextVisual::Property::FONT_FAMILY:
438 SetFontFamilyProperty( mController, propertyValue );
441 case Toolkit::TextVisual::Property::FONT_STYLE:
443 SetFontStyleProperty( mController, propertyValue, Text::FontStyle::DEFAULT );
446 case Toolkit::TextVisual::Property::POINT_SIZE:
448 const float pointSize = propertyValue.Get<float>();
450 if( !Equals( mController->GetDefaultPointSize(), pointSize ) )
452 mController->SetDefaultPointSize( pointSize );
456 case Toolkit::TextVisual::Property::MULTI_LINE:
458 mController->SetMultiLineEnabled( propertyValue.Get<bool>() );
461 case Toolkit::TextVisual::Property::HORIZONTAL_ALIGNMENT:
463 LayoutEngine::HorizontalAlignment alignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN );
464 if( Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::HorizontalAlignment >( propertyValue.Get< std::string >().c_str(),
465 HORIZONTAL_ALIGNMENT_STRING_TABLE,
466 HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
469 mController->SetHorizontalAlignment( alignment );
473 case Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT:
475 LayoutEngine::VerticalAlignment alignment( LayoutEngine::VERTICAL_ALIGN_BOTTOM );
476 if( Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::VerticalAlignment >( propertyValue.Get< std::string >().c_str(),
477 VERTICAL_ALIGNMENT_STRING_TABLE,
478 VERTICAL_ALIGNMENT_STRING_TABLE_COUNT,
481 mController->SetVerticalAlignment( alignment );
485 case Toolkit::TextVisual::Property::TEXT_COLOR:
487 const Vector4 textColor = propertyValue.Get< Vector4 >();
488 if( mController->GetTextColor() != textColor )
490 mController->SetTextColor( textColor );
495 case Toolkit::TextVisual::Property::ENABLE_MARKUP:
497 const bool enableMarkup = propertyValue.Get<bool>();
498 mController->SetMarkupProcessorEnabled( enableMarkup );
501 case Toolkit::TextVisual::Property::ENABLE_AUTO_SCROLL:
503 const bool enableAutoScroll = propertyValue.Get<bool>();
505 // If request to auto scroll is the same as current state then do nothing.
506 if( enableAutoScroll != mController->IsAutoScrollEnabled() )
508 // If request is disable (false) and auto scrolling is enabled then need to stop it
509 if( !enableAutoScroll )
511 StopTextAutoScrolling(); // Causes the current animation to finish playing.
513 // If request is enable (true) then start autoscroll as not already running
516 mController->GetLayoutEngine().SetTextEllipsisEnabled( false );
517 mController->SetAutoScrollEnabled( enableAutoScroll );
518 mController->RequestRelayout();
523 case Toolkit::TextVisual::Property::AUTO_SCROLL_SPEED:
525 mController->SetAutoscrollSpeed( propertyValue.Get<int>() );
528 case Toolkit::TextVisual::Property::AUTO_SCROLL_LOOP_COUNT:
530 const int loopCount = propertyValue.Get<int>();
533 mController->SetAutoScrollLoopCount( loopCount );
537 StopTextAutoScrolling(); // Causes the current animation to finish playing.
541 case Toolkit::TextVisual::Property::AUTO_SCROLL_GAP:
543 mController->SetAutoScrollWrapGap( propertyValue.Get<float>() );
546 case Toolkit::TextVisual::Property::LINE_SPACING:
548 const float lineSpacing = propertyValue.Get<float>();
549 mController->SetDefaultLineSpacing( lineSpacing );
553 case Toolkit::TextVisual::Property::UNDERLINE:
555 // TODO : This switch can be removed when the deprecated SHADOW_OFFSET and SHADOW_COLOR properties are finally removed.
556 // Only the code for the STRING case should be kept.
557 switch( propertyValue.GetType() )
559 case Property::VECTOR4:
561 const Vector4 color = propertyValue.Get<Vector4>();
562 if( mController->GetUnderlineColor() != color )
564 mController->SetUnderlineColor( color );
569 case Property::FLOAT:
571 float height = propertyValue.Get<float>();
572 if( fabsf( mController->GetUnderlineHeight() - height ) > Math::MACHINE_EPSILON_1000 )
574 mController->SetUnderlineHeight( height );
579 case Property::BOOLEAN:
581 const bool enabled = propertyValue.Get<bool>();
582 if( mController->IsUnderlineEnabled() != enabled )
584 mController->SetUnderlineEnabled( enabled );
589 case Property::STRING:
591 const bool update = SetUnderlineProperties( mController, propertyValue, Text::EffectStyle::DEFAULT );
607 case Toolkit::TextVisual::Property::SHADOW:
609 // TODO : This switch can be removed when the deprecated SHADOW_OFFSET and SHADOW_COLOR properties are finally removed.
610 // Only the code for the STRING case should be kept.
611 switch( propertyValue.GetType() )
613 case Property::VECTOR2:
615 const Vector2 shadowOffset = propertyValue.Get<Vector2>();
616 if( mController->GetShadowOffset() != shadowOffset )
618 mController->SetShadowOffset( shadowOffset );
623 case Property::VECTOR4:
625 const Vector4 shadowColor = propertyValue.Get<Vector4>();
626 if( mController->GetShadowColor() != shadowColor )
628 mController->SetShadowColor( shadowColor );
633 case Property::STRING:
635 const bool update = SetShadowProperties( mController, propertyValue, Text::EffectStyle::DEFAULT );
650 case Toolkit::TextVisual::Property::EMBOSS:
652 const bool update = SetEmbossProperties( mController, propertyValue, Text::EffectStyle::DEFAULT );
659 case Toolkit::TextVisual::Property::OUTLINE:
661 const bool update = SetOutlineProperties( mController, propertyValue, Text::EffectStyle::DEFAULT );
668 case Toolkit::TextVisual::Property::BATCHING_ENABLED:
675 // Should not arrive here.
676 DALI_ASSERT_DEBUG( false );
681 Dali::Property::Value TextVisual::DoGetProperty( Dali::Property::Index index )
683 Dali::Property::Value value;
687 case Toolkit::TextVisual::Property::RENDERING_BACKEND:
689 value = mRenderingBackend;
692 case Toolkit::TextVisual::Property::TEXT:
695 mController->GetText( text );
699 case Toolkit::TextVisual::Property::FONT_FAMILY:
701 value = mController->GetDefaultFontFamily();
704 case Toolkit::TextVisual::Property::FONT_STYLE:
706 GetFontStyleProperty( mController, value, Text::FontStyle::DEFAULT );
709 case Toolkit::TextVisual::Property::POINT_SIZE:
711 value = mController->GetDefaultPointSize();
714 case Toolkit::TextVisual::Property::MULTI_LINE:
716 value = mController->IsMultiLineEnabled();
719 case Toolkit::TextVisual::Property::HORIZONTAL_ALIGNMENT:
721 const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( mController->GetHorizontalAlignment(),
722 HORIZONTAL_ALIGNMENT_STRING_TABLE,
723 HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
726 value = std::string( name );
730 case Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT:
732 const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( mController->GetVerticalAlignment(),
733 VERTICAL_ALIGNMENT_STRING_TABLE,
734 VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
737 value = std::string( name );
741 case Toolkit::TextVisual::Property::TEXT_COLOR:
743 value = mController->GetTextColor();
746 case Toolkit::TextVisual::Property::ENABLE_MARKUP:
748 value = mController->IsMarkupProcessorEnabled();
751 case Toolkit::TextVisual::Property::ENABLE_AUTO_SCROLL:
753 value = mController->IsAutoScrollEnabled();
756 case Toolkit::TextVisual::Property::AUTO_SCROLL_SPEED:
758 value = mController->GetAutoScrollSpeed();
761 case Toolkit::TextVisual::Property::AUTO_SCROLL_LOOP_COUNT:
763 value = mController->GetAutoScrollLoopCount();
766 case Toolkit::TextVisual::Property::AUTO_SCROLL_GAP:
768 value = mController->GetAutoScrollWrapGap();
771 case Toolkit::TextVisual::Property::LINE_SPACING:
773 value = mController->GetDefaultLineSpacing();
776 case Toolkit::TextVisual::Property::UNDERLINE:
778 GetUnderlineProperties( mController, value, Text::EffectStyle::DEFAULT );
781 case Toolkit::TextVisual::Property::SHADOW:
783 GetShadowProperties( mController, value, Text::EffectStyle::DEFAULT );
786 case Toolkit::TextVisual::Property::EMBOSS:
788 GetEmbossProperties( mController, value, Text::EffectStyle::DEFAULT );
791 case Toolkit::TextVisual::Property::OUTLINE:
793 GetOutlineProperties( mController, value, Text::EffectStyle::DEFAULT );
796 case Toolkit::TextVisual::Property::BATCHING_ENABLED:
803 // Should not arrive here.
804 DALI_ASSERT_DEBUG( false );
811 void TextVisual::RenderText()
813 Actor self = mSelf.GetHandle();
816 // Nothing to do if the handle is not initialized.
820 Actor renderableActor;
824 renderableActor = mRenderer->Render( mController->GetView(), Toolkit::DepthIndex::TEXT );
827 if( renderableActor != mRenderableActor )
829 UnparentAndReset( mRenderableActor );
831 if( renderableActor )
833 const Vector2& scrollOffset = mController->GetScrollPosition();
834 renderableActor.SetPosition( scrollOffset.x, scrollOffset.y );
836 self.Add( renderableActor );
838 mRenderableActor = renderableActor;
840 if( mController->IsAutoScrollEnabled() )
842 SetUpAutoScrolling();
847 void TextVisual::StopTextAutoScrolling()
851 mTextScroller->StopScrolling();
855 void TextVisual::SetUpAutoScrolling()
857 Actor self = mSelf.GetHandle();
860 // Nothing to do if the handle is not initialized.
864 const Text::ScrollerData* const data = mController->GetAutoScrollData();
870 // If speed, loopCount or gap not set via property system then will need to create a TextScroller with defaults
871 mTextScroller = Text::TextScroller::New( *mController );
874 mTextScroller->StartScrolling( mRenderableActor,
877 self.Add( mTextScroller->GetScrollingText() );
878 self.Add( mTextScroller->GetSourceCamera() );
882 } // namespace Internal
884 } // namespace Toolkit