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>
25 #include <dali-toolkit/public-api/text/rendering-backend.h>
26 #include <dali-toolkit/public-api/visuals/text-visual-properties.h>
27 #include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
28 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
29 #include <dali-toolkit/internal/text/layouts/layout-alignment.h>
30 #include <dali-toolkit/internal/text/rendering/text-backend.h>
31 #include <dali-toolkit/internal/text/text-effects-style.h>
32 #include <dali-toolkit/internal/text/text-font-style.h>
33 #include <dali-toolkit/internal/text/text-view.h>
34 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
35 #include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
50 const char * const RENDERING_BACKEND_PROPERTY( "renderingBackend" );
51 const char * const TEXT_PROPERTY( "text" );
52 const char * const FONT_FAMILY_PROPERTY( "fontFamily" );
53 const char * const FONT_STYLE_PROPERTY( "fontStyle" );
54 const char * const POINT_SIZE_PROPERTY( "pointSize" );
55 const char * const MULTI_LINE_PROPERTY( "multiLine" );
56 const char * const HORIZONTAL_ALIGNMENT_PROPERTY( "horizontalAlignment" );
57 const char * const VERTICAL_ALIGNMENT_PROPERTY( "verticalAlignment" );
58 const char * const TEXT_COLOR_PROPERTY( "textColor" );
59 const char * const ENABLE_MARKUP_PROPERTY( "enableMarkup" );
60 const char * const ENABLE_AUTO_SCROLL_PROPERTY( "enableAutoScroll" );
61 const char * const AUTO_SCROLL_SPEED_PROPERTY( "autoScrollSpeed" );
62 const char * const AUTO_SCROLL_LOOP_COUNT_PROPERTY( "autoScrollLoopCount" );
63 const char * const AUTO_SCROLL_GAP_PROPERTY( "autoScrollGap" );
64 const char * const LINE_SPACING_PROPERTY( "lineSpacing" );
65 const char * const UNDERLINE_PROPERTY( "underline" );
66 const char * const SHADOW_PROPERTY( "shadow" );
67 const char * const OUTLINE_PROPERTY( "outline" );
68 const char * const BATCHING_ENABLED_PROPERTY( "batchingEnabled" );
70 const Scripting::StringEnum HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
72 { "BEGIN", Toolkit::Text::Layout::HORIZONTAL_ALIGN_BEGIN },
73 { "CENTER", Toolkit::Text::Layout::HORIZONTAL_ALIGN_CENTER },
74 { "END", Toolkit::Text::Layout::HORIZONTAL_ALIGN_END },
76 const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] );
78 const Scripting::StringEnum VERTICAL_ALIGNMENT_STRING_TABLE[] =
80 { "TOP", Toolkit::Text::Layout::VERTICAL_ALIGN_TOP },
81 { "CENTER", Toolkit::Text::Layout::VERTICAL_ALIGN_CENTER },
82 { "BOTTOM", Toolkit::Text::Layout::VERTICAL_ALIGN_BOTTOM },
84 const unsigned int VERTICAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( VERTICAL_ALIGNMENT_STRING_TABLE ) / sizeof( VERTICAL_ALIGNMENT_STRING_TABLE[0] );
86 std::string GetHorizontalAlignment( Toolkit::Text::Layout::HorizontalAlignment alignment )
88 const char* name = Scripting::GetEnumerationName<Toolkit::Text::Layout::HorizontalAlignment>( alignment,
89 HORIZONTAL_ALIGNMENT_STRING_TABLE,
90 HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
92 return std::string( name );
95 std::string GetVerticalAlignment( Toolkit::Text::Layout::VerticalAlignment alignment )
97 const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::VerticalAlignment >( alignment,
98 VERTICAL_ALIGNMENT_STRING_TABLE,
99 VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
101 return std::string( name );
104 const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
105 attribute mediump vec2 aPosition;\n
106 uniform mediump mat4 uMvpMatrix;\n
107 uniform mediump vec3 uSize;\n
108 uniform mediump vec4 pixelArea;
109 varying mediump vec2 vTexCoord;\n
113 mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
114 vertexPosition.xyz *= uSize;\n
115 vertexPosition = uMvpMatrix * vertexPosition;\n
117 vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );\n
118 gl_Position = vertexPosition;\n
122 const char* FRAGMENT_SHADER_ATLAS_CLAMP = DALI_COMPOSE_SHADER(
123 varying mediump vec2 vTexCoord;\n
124 uniform sampler2D sTexture;\n
125 uniform mediump vec4 uAtlasRect;\n
126 uniform lowp vec4 uColor;\n
130 mediump vec2 texCoord = clamp( mix( uAtlasRect.xy, uAtlasRect.zw, vTexCoord ), uAtlasRect.xy, uAtlasRect.zw );\n
131 gl_FragColor = texture2D( sTexture, texCoord ) * uColor;\n
135 Geometry CreateGeometry( VisualFactoryCache& factoryCache, ImageDimensions gridSize )
139 if( gridSize == ImageDimensions( 1, 1 ) )
141 geometry = factoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
144 geometry = VisualFactoryCache::CreateQuadGeometry();
145 factoryCache.SaveGeometry( VisualFactoryCache::QUAD_GEOMETRY, geometry );
150 geometry = VisualFactoryCache::CreateGridGeometry( gridSize );
156 } // unnamed namespace
158 TextVisualPtr TextVisual::New( VisualFactoryCache& factoryCache )
160 return new TextVisual( factoryCache );
163 float TextVisual::GetHeightForWidth( float width ) const
165 return mController->GetHeightForWidth( width );
168 void TextVisual::GetNaturalSize( Vector2& naturalSize )
170 naturalSize = mController->GetNaturalSize().GetVectorXY();
173 void TextVisual::DoCreatePropertyMap( Property::Map& map ) const
175 Property::Value value;
178 map.Insert( Toolkit::VisualProperty::TYPE, Toolkit::Visual::TEXT );
180 map.Insert( Toolkit::TextVisual::Property::RENDERING_BACKEND, mRenderingBackend );
183 mController->GetText( text );
184 map.Insert( Toolkit::TextVisual::Property::TEXT, text );
186 map.Insert( Toolkit::TextVisual::Property::FONT_FAMILY, mController->GetDefaultFontFamily() );
188 GetFontStyleProperty( mController, value, Text::FontStyle::DEFAULT );
189 map.Insert( Toolkit::TextVisual::Property::FONT_STYLE, value );
191 map.Insert( Toolkit::TextVisual::Property::POINT_SIZE, mController->GetDefaultPointSize() );
193 map.Insert( Toolkit::TextVisual::Property::MULTI_LINE, mController->IsMultiLineEnabled() );
195 map.Insert( Toolkit::TextVisual::Property::HORIZONTAL_ALIGNMENT, GetHorizontalAlignment( mController->GetHorizontalAlignment() ) );
197 map.Insert( Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT, GetVerticalAlignment( mController->GetVerticalAlignment() ) );
199 map.Insert( Toolkit::TextVisual::Property::TEXT_COLOR, mController->GetDefaultColor() );
201 map.Insert( Toolkit::TextVisual::Property::ENABLE_MARKUP, mController->IsMarkupProcessorEnabled() );
203 map.Insert( Toolkit::TextVisual::Property::LINE_SPACING, mController->GetDefaultLineSpacing() );
205 GetUnderlineProperties( mController, value, Text::EffectStyle::DEFAULT );
206 map.Insert( Toolkit::TextVisual::Property::UNDERLINE, value );
208 GetShadowProperties( mController, value, Text::EffectStyle::DEFAULT );
209 map.Insert( Toolkit::TextVisual::Property::SHADOW, value );
211 GetOutlineProperties( mController, value, Text::EffectStyle::DEFAULT );
212 map.Insert( Toolkit::TextVisual::Property::OUTLINE, value );
214 map.Insert( Toolkit::TextVisual::Property::BATCHING_ENABLED, false ); // TODO
217 TextVisual::TextVisual( VisualFactoryCache& factoryCache )
218 : Visual::Base( factoryCache ),
219 mController( Text::Controller::New() ),
220 mRenderingBackend( Toolkit::Text::DEFAULT_RENDERING_BACKEND ),
221 mHasBeenStaged( false )
225 TextVisual::~TextVisual()
229 void TextVisual::DoSetProperties( const Property::Map& propertyMap )
231 for( Property::Map::SizeType index = 0u, count = propertyMap.Count(); index < count; ++index )
233 const KeyValuePair& keyValue = propertyMap.GetKeyValue( index );
235 switch( keyValue.first.type )
237 case Property::Key::INDEX:
239 if( Toolkit::VisualProperty::TYPE != keyValue.first.indexKey ) // Toolkit::VisualProperty::TYPE is not a TextVisual's property.
241 DoSetProperty( keyValue.first.indexKey, keyValue.second );
245 case Property::Key::STRING:
247 if( keyValue.first.stringKey == RENDERING_BACKEND_PROPERTY )
249 DoSetProperty( Toolkit::TextVisual::Property::RENDERING_BACKEND, keyValue.second );
251 else if( keyValue.first.stringKey == TEXT_PROPERTY )
253 DoSetProperty( Toolkit::TextVisual::Property::TEXT, keyValue.second );
255 else if( keyValue.first.stringKey == FONT_FAMILY_PROPERTY )
257 DoSetProperty( Toolkit::TextVisual::Property::FONT_FAMILY, keyValue.second );
259 else if( keyValue.first.stringKey == FONT_STYLE_PROPERTY )
261 DoSetProperty( Toolkit::TextVisual::Property::FONT_STYLE, keyValue.second );
263 else if( keyValue.first.stringKey == POINT_SIZE_PROPERTY )
265 DoSetProperty( Toolkit::TextVisual::Property::POINT_SIZE, keyValue.second );
267 else if( keyValue.first.stringKey == MULTI_LINE_PROPERTY )
269 DoSetProperty( Toolkit::TextVisual::Property::MULTI_LINE, keyValue.second );
271 else if( keyValue.first.stringKey == HORIZONTAL_ALIGNMENT_PROPERTY )
273 DoSetProperty( Toolkit::TextVisual::Property::HORIZONTAL_ALIGNMENT, keyValue.second );
275 else if( keyValue.first.stringKey == VERTICAL_ALIGNMENT_PROPERTY )
277 DoSetProperty( Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT, keyValue.second );
279 else if( keyValue.first.stringKey == TEXT_COLOR_PROPERTY )
281 DoSetProperty( Toolkit::TextVisual::Property::TEXT_COLOR, keyValue.second );
283 else if( keyValue.first.stringKey == ENABLE_MARKUP_PROPERTY )
285 DoSetProperty( Toolkit::TextVisual::Property::ENABLE_MARKUP, keyValue.second );
287 else if( keyValue.first.stringKey == ENABLE_AUTO_SCROLL_PROPERTY )
289 DoSetProperty( Toolkit::TextVisual::Property::ENABLE_AUTO_SCROLL, keyValue.second );
291 else if( keyValue.first.stringKey == AUTO_SCROLL_SPEED_PROPERTY )
293 DoSetProperty( Toolkit::TextVisual::Property::AUTO_SCROLL_SPEED, keyValue.second );
295 else if( keyValue.first.stringKey == AUTO_SCROLL_LOOP_COUNT_PROPERTY )
297 DoSetProperty( Toolkit::TextVisual::Property::AUTO_SCROLL_LOOP_COUNT, keyValue.second );
299 else if( keyValue.first.stringKey == AUTO_SCROLL_GAP_PROPERTY )
301 DoSetProperty( Toolkit::TextVisual::Property::AUTO_SCROLL_GAP, keyValue.second );
303 else if( keyValue.first.stringKey == LINE_SPACING_PROPERTY )
305 DoSetProperty( Toolkit::TextVisual::Property::LINE_SPACING, keyValue.second );
307 else if( keyValue.first.stringKey == UNDERLINE_PROPERTY )
309 DoSetProperty( Toolkit::TextVisual::Property::UNDERLINE, keyValue.second );
311 else if( keyValue.first.stringKey == SHADOW_PROPERTY )
313 DoSetProperty( Toolkit::TextVisual::Property::SHADOW, keyValue.second );
315 else if( keyValue.first.stringKey == OUTLINE_PROPERTY )
317 DoSetProperty( Toolkit::TextVisual::Property::OUTLINE, keyValue.second );
319 else if( keyValue.first.stringKey == BATCHING_ENABLED_PROPERTY )
321 DoSetProperty( Toolkit::TextVisual::Property::BATCHING_ENABLED, keyValue.second );
328 // Elide the text if it exceeds the boundaries.
329 mController->SetTextElideEnabled( true );
331 // Retrieve the layout engine to set the cursor's width.
332 Text::Layout::Engine& engine = mController->GetLayoutEngine();
334 // Sets 0 as cursor's width.
335 engine.SetCursorWidth( 0u ); // Do not layout space for the cursor.
338 void TextVisual::DoSetOnStage( Actor& actor )
340 // TODO Create the actual renderer(s) for the text!!!!
341 // Will crash if no mImpl->mRenderer is set.
345 geometry = CreateGeometry( mFactoryCache, ImageDimensions( 1, 1 ) );
347 shader = mFactoryCache.GetShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP );
350 shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_ATLAS_CLAMP );
351 mFactoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP, shader );
354 mImpl->mRenderer = Renderer::New( geometry, shader );
364 mHasBeenStaged = true;
368 void TextVisual::DoSetOffStage( Actor& actor )
373 void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
377 case Toolkit::TextVisual::Property::RENDERING_BACKEND:
379 int backend = propertyValue.Get<int>();
381 #ifndef ENABLE_VECTOR_BASED_TEXT_RENDERING
382 if( Text::RENDERING_VECTOR_BASED == backend )
384 backend = TextAbstraction::BITMAP_GLYPH; // Fallback to bitmap-based rendering
387 if( mRenderingBackend != backend )
389 mRenderingBackend = backend;
392 // When using the vector-based rendering, the size of the GLyphs are different
393 TextAbstraction::GlyphType glyphType = ( Text::RENDERING_VECTOR_BASED == mRenderingBackend ) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH;
394 mController->SetGlyphType( glyphType );
398 case Toolkit::TextVisual::Property::TEXT:
400 mController->SetText( propertyValue.Get<std::string>() );
403 case Toolkit::TextVisual::Property::FONT_FAMILY:
405 SetFontFamilyProperty( mController, propertyValue );
408 case Toolkit::TextVisual::Property::FONT_STYLE:
410 SetFontStyleProperty( mController, propertyValue, Text::FontStyle::DEFAULT );
413 case Toolkit::TextVisual::Property::POINT_SIZE:
415 const float pointSize = propertyValue.Get<float>();
417 if( !Equals( mController->GetDefaultPointSize(), pointSize ) )
419 mController->SetDefaultPointSize( pointSize );
423 case Toolkit::TextVisual::Property::MULTI_LINE:
425 mController->SetMultiLineEnabled( propertyValue.Get<bool>() );
428 case Toolkit::TextVisual::Property::HORIZONTAL_ALIGNMENT:
430 Toolkit::Text::Layout::HorizontalAlignment alignment( Toolkit::Text::Layout::HORIZONTAL_ALIGN_BEGIN );
431 if( Scripting::GetEnumeration< Toolkit::Text::Layout::HorizontalAlignment >( propertyValue.Get< std::string >().c_str(),
432 HORIZONTAL_ALIGNMENT_STRING_TABLE,
433 HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
436 mController->SetHorizontalAlignment( alignment );
440 case Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT:
442 Toolkit::Text::Layout::VerticalAlignment alignment( Toolkit::Text::Layout::VERTICAL_ALIGN_BOTTOM );
443 if( Scripting::GetEnumeration< Toolkit::Text::Layout::VerticalAlignment >( propertyValue.Get< std::string >().c_str(),
444 VERTICAL_ALIGNMENT_STRING_TABLE,
445 VERTICAL_ALIGNMENT_STRING_TABLE_COUNT,
448 mController->SetVerticalAlignment( alignment );
452 case Toolkit::TextVisual::Property::TEXT_COLOR:
454 const Vector4& textColor = propertyValue.Get< Vector4 >();
455 if( mController->GetDefaultColor() != textColor )
457 mController->SetDefaultColor( textColor );
462 case Toolkit::TextVisual::Property::ENABLE_MARKUP:
464 const bool enableMarkup = propertyValue.Get<bool>();
465 mController->SetMarkupProcessorEnabled( enableMarkup );
468 case Toolkit::TextVisual::Property::ENABLE_AUTO_SCROLL:
473 case Toolkit::TextVisual::Property::AUTO_SCROLL_SPEED:
478 case Toolkit::TextVisual::Property::AUTO_SCROLL_LOOP_COUNT:
483 case Toolkit::TextVisual::Property::AUTO_SCROLL_GAP:
488 case Toolkit::TextVisual::Property::LINE_SPACING:
490 const float lineSpacing = propertyValue.Get<float>();
491 mController->SetDefaultLineSpacing( lineSpacing );
495 case Toolkit::TextVisual::Property::UNDERLINE:
497 // TODO : This switch can be removed when the deprecated SHADOW_OFFSET and SHADOW_COLOR properties are finally removed.
498 // Only the code for the MAP case should be kept.
499 switch( propertyValue.GetType() )
501 case Property::VECTOR4:
503 const Vector4& color = propertyValue.Get<Vector4>();
504 if( mController->GetUnderlineColor() != color )
506 mController->SetUnderlineColor( color );
511 case Property::FLOAT:
513 float height = propertyValue.Get<float>();
514 if( fabsf( mController->GetUnderlineHeight() - height ) > Math::MACHINE_EPSILON_1000 )
516 mController->SetUnderlineHeight( height );
521 case Property::BOOLEAN:
523 const bool enabled = propertyValue.Get<bool>();
524 if( mController->IsUnderlineEnabled() != enabled )
526 mController->SetUnderlineEnabled( enabled );
533 const bool update = SetUnderlineProperties( mController, propertyValue, Text::EffectStyle::DEFAULT );
549 case Toolkit::TextVisual::Property::SHADOW:
551 // TODO : This switch can be removed when the deprecated SHADOW_OFFSET and SHADOW_COLOR properties are finally removed.
552 // Only the code for the MAP case should be kept.
553 switch( propertyValue.GetType() )
555 case Property::VECTOR2:
557 const Vector2& shadowOffset = propertyValue.Get<Vector2>();
558 if( mController->GetShadowOffset() != shadowOffset )
560 mController->SetShadowOffset( shadowOffset );
565 case Property::VECTOR4:
567 const Vector4& shadowColor = propertyValue.Get<Vector4>();
568 if( mController->GetShadowColor() != shadowColor )
570 mController->SetShadowColor( shadowColor );
577 const bool update = SetShadowProperties( mController, propertyValue, Text::EffectStyle::DEFAULT );
592 case Toolkit::TextVisual::Property::EMBOSS:
594 const bool update = SetEmbossProperties( mController, propertyValue, Text::EffectStyle::DEFAULT );
601 case Toolkit::TextVisual::Property::OUTLINE:
603 const bool update = SetOutlineProperties( mController, propertyValue, Text::EffectStyle::DEFAULT );
610 case Toolkit::TextVisual::Property::BATCHING_ENABLED:
617 // Should not arrive here.
618 DALI_ASSERT_DEBUG( false );
623 Dali::Property::Value TextVisual::DoGetProperty( Dali::Property::Index index )
625 Dali::Property::Value value;
629 case Toolkit::TextVisual::Property::RENDERING_BACKEND:
631 value = mRenderingBackend;
634 case Toolkit::TextVisual::Property::TEXT:
637 mController->GetText( text );
641 case Toolkit::TextVisual::Property::FONT_FAMILY:
643 value = mController->GetDefaultFontFamily();
646 case Toolkit::TextVisual::Property::FONT_STYLE:
648 GetFontStyleProperty( mController, value, Text::FontStyle::DEFAULT );
651 case Toolkit::TextVisual::Property::POINT_SIZE:
653 value = mController->GetDefaultPointSize();
656 case Toolkit::TextVisual::Property::MULTI_LINE:
658 value = mController->IsMultiLineEnabled();
661 case Toolkit::TextVisual::Property::HORIZONTAL_ALIGNMENT:
663 const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::HorizontalAlignment >( mController->GetHorizontalAlignment(),
664 HORIZONTAL_ALIGNMENT_STRING_TABLE,
665 HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
668 value = std::string( name );
672 case Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT:
674 const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::VerticalAlignment >( mController->GetVerticalAlignment(),
675 VERTICAL_ALIGNMENT_STRING_TABLE,
676 VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
679 value = std::string( name );
683 case Toolkit::TextVisual::Property::TEXT_COLOR:
685 value = mController->GetDefaultColor();
688 case Toolkit::TextVisual::Property::ENABLE_MARKUP:
690 value = mController->IsMarkupProcessorEnabled();
693 case Toolkit::TextVisual::Property::ENABLE_AUTO_SCROLL:
698 case Toolkit::TextVisual::Property::AUTO_SCROLL_SPEED:
703 case Toolkit::TextVisual::Property::AUTO_SCROLL_LOOP_COUNT:
708 case Toolkit::TextVisual::Property::AUTO_SCROLL_GAP:
713 case Toolkit::TextVisual::Property::LINE_SPACING:
715 value = mController->GetDefaultLineSpacing();
718 case Toolkit::TextVisual::Property::UNDERLINE:
720 GetUnderlineProperties( mController, value, Text::EffectStyle::DEFAULT );
723 case Toolkit::TextVisual::Property::SHADOW:
725 GetShadowProperties( mController, value, Text::EffectStyle::DEFAULT );
728 case Toolkit::TextVisual::Property::EMBOSS:
730 GetEmbossProperties( mController, value, Text::EffectStyle::DEFAULT );
733 case Toolkit::TextVisual::Property::OUTLINE:
735 GetOutlineProperties( mController, value, Text::EffectStyle::DEFAULT );
738 case Toolkit::TextVisual::Property::BATCHING_ENABLED:
745 // Should not arrive here.
746 DALI_ASSERT_DEBUG( false );
753 void TextVisual::OnSetTransform()
755 Vector2 visualSize = mImpl->mTransform.GetVisualSize( mImpl->mControlSize );
757 // Note, the direction should come from the layout of the parent control
758 mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT );
760 const Text::Controller::UpdateTextType updateTextType = mController->Relayout( visualSize );
762 if( ( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) ) ||
767 mRenderer = Text::Backend::Get().NewRenderer( mRenderingBackend );
773 void TextVisual::RenderText()
775 Actor self = mSelf.GetHandle();
778 // Nothing to do if the handle is not initialized.
782 Actor renderableActor;
786 renderableActor = mRenderer->Render( mController->GetView(), Toolkit::DepthIndex::TEXT );
789 if( renderableActor != mRenderableActor )
791 UnparentAndReset( mRenderableActor );
793 if( renderableActor )
795 const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition();
796 renderableActor.SetPosition( scrollOffset.x, scrollOffset.y );
798 self.Add( renderableActor );
800 mRenderableActor = renderableActor;
804 } // namespace Internal
806 } // namespace Toolkit