#include <dali/public-api/common/stage.h>
#include <dali/public-api/images/resource-image.h>
#include <dali/devel-api/adaptor-framework/virtual-keyboard.h>
-#include <dali/devel-api/object/type-registry-helper.h>
+#include <dali/public-api/object/type-registry-helper.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/text/rendering-backend.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
-#include <dali-toolkit/internal/controls/text-controls/text-font-style.h>
#include <dali-toolkit/internal/text/rendering/text-backend.h>
+#include <dali-toolkit/internal/text/text-effects-style.h>
+#include <dali-toolkit/internal/text/text-font-style.h>
#include <dali-toolkit/internal/text/text-view.h>
#include <dali-toolkit/internal/styling/style-manager-impl.h>
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputMethodSettings", MAP, INPUT_METHOD_SETTINGS )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputColor", VECTOR4, INPUT_COLOR )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "enableMarkup", BOOLEAN, ENABLE_MARKUP )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputFontFamily", STRING, INPUT_FONT_FAMILY )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputFontStyle", STRING, INPUT_FONT_STYLE )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputPointSize", FLOAT, INPUT_POINT_SIZE )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "underline", STRING, UNDERLINE )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputUnderline", STRING, INPUT_UNDERLINE )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "shadow", STRING, SHADOW )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputShadow", STRING, INPUT_SHADOW )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "emboss", STRING, EMBOSS )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputEmboss", STRING, INPUT_EMBOSS )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "outline", STRING, OUTLINE )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputOutline", STRING, INPUT_OUTLINE )
DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "textChanged", SIGNAL_TEXT_CHANGED )
DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "maxLengthReached", SIGNAL_MAX_LENGTH_REACHED )
int backend = value.Get< int >();
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p RENDERING_BACKEND %d\n", impl.mController.Get(), backend );
+#ifndef ENABLE_VECTOR_BASED_TEXT_RENDERING
+ if( Text::RENDERING_VECTOR_BASED == backend )
+ {
+ backend = TextAbstraction::BITMAP_GLYPH; // Fallback to bitmap-based rendering
+ }
+#endif
if( impl.mRenderingBackend != backend )
{
impl.mRenderingBackend = backend;
impl.mRenderer.Reset();
- impl.RequestTextRelayout();
+
+ if( impl.mController )
+ {
+ // When using the vector-based rendering, the size of the GLyphs are different
+ TextAbstraction::GlyphType glyphType = (Text::RENDERING_VECTOR_BASED == impl.mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH;
+ impl.mController->SetGlyphType( glyphType );
+ }
}
break;
}
}
case Toolkit::TextField::Property::FONT_STYLE:
{
- SetFontStyleProperty( impl.mController, value );
+ SetFontStyleProperty( impl.mController, value, Text::FontStyle::DEFAULT );
break;
}
case Toolkit::TextField::Property::POINT_SIZE:
}
break;
}
+ case Toolkit::TextField::Property::INPUT_FONT_FAMILY:
+ {
+ if( impl.mController )
+ {
+ const std::string fontFamily = value.Get< std::string >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p INPUT_FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
+ impl.mController->SetInputFontFamily( fontFamily );
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::INPUT_FONT_STYLE:
+ {
+ SetFontStyleProperty( impl.mController, value, Text::FontStyle::INPUT );
+ break;
+ }
+ case Toolkit::TextField::Property::INPUT_POINT_SIZE:
+ {
+ if( impl.mController )
+ {
+ const float pointSize = value.Get< float >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p INPUT_POINT_SIZE %f\n", impl.mController.Get(), pointSize );
+ impl.mController->SetInputFontPointSize( pointSize );
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::UNDERLINE:
+ {
+ const bool update = SetUnderlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
+ if( update )
+ {
+ impl.mRenderer.Reset();
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::INPUT_UNDERLINE:
+ {
+ const bool update = SetUnderlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
+ if( update )
+ {
+ impl.mRenderer.Reset();
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::SHADOW:
+ {
+ const bool update = SetShadowProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
+ if( update )
+ {
+ impl.mRenderer.Reset();
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::INPUT_SHADOW:
+ {
+ const bool update = SetShadowProperties( impl.mController, value, Text::EffectStyle::INPUT );
+ if( update )
+ {
+ impl.mRenderer.Reset();
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::EMBOSS:
+ {
+ const bool update = SetEmbossProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
+ if( update )
+ {
+ impl.mRenderer.Reset();
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::INPUT_EMBOSS:
+ {
+ const bool update = SetEmbossProperties( impl.mController, value, Text::EffectStyle::INPUT );
+ if( update )
+ {
+ impl.mRenderer.Reset();
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::OUTLINE:
+ {
+ const bool update = SetOutlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
+ if( update )
+ {
+ impl.mRenderer.Reset();
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::INPUT_OUTLINE:
+ {
+ const bool update = SetOutlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
+ if( update )
+ {
+ impl.mRenderer.Reset();
+ }
+ break;
+ }
} // switch
} // textfield
}
}
case Toolkit::TextField::Property::FONT_STYLE:
{
- GetFontStyleProperty( impl.mController, value );
+ GetFontStyleProperty( impl.mController, value, Text::FontStyle::DEFAULT );
break;
}
case Toolkit::TextField::Property::POINT_SIZE:
}
break;
}
- case Toolkit::TextField::Property::INPUT_COLOR:
- {
- if( impl.mController )
- {
- value = impl.mController->GetInputColor();
- }
- break;
- }
case Toolkit::TextField::Property::SHADOW_OFFSET:
{
if ( impl.mController )
{
break;
}
+ case Toolkit::TextField::Property::INPUT_COLOR:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->GetInputColor();
+ }
+ break;
+ }
case Toolkit::TextField::Property::ENABLE_MARKUP:
{
if( impl.mController )
}
break;
}
+ case Toolkit::TextField::Property::INPUT_FONT_FAMILY:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->GetInputFontFamily();
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::INPUT_FONT_STYLE:
+ {
+ GetFontStyleProperty( impl.mController, value, Text::FontStyle::INPUT );
+ break;
+ }
+ case Toolkit::TextField::Property::INPUT_POINT_SIZE:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->GetInputFontPointSize();
+ }
+ break;
+ }
+ case Toolkit::TextField::Property::UNDERLINE:
+ {
+ GetUnderlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
+ break;
+ }
+ case Toolkit::TextField::Property::INPUT_UNDERLINE:
+ {
+ GetUnderlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
+ break;
+ }
+ case Toolkit::TextField::Property::SHADOW:
+ {
+ GetShadowProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
+ break;
+ }
+ case Toolkit::TextField::Property::INPUT_SHADOW:
+ {
+ GetShadowProperties( impl.mController, value, Text::EffectStyle::INPUT );
+ break;
+ }
+ case Toolkit::TextField::Property::EMBOSS:
+ {
+ GetEmbossProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
+ break;
+ }
+ case Toolkit::TextField::Property::INPUT_EMBOSS:
+ {
+ GetEmbossProperties( impl.mController, value, Text::EffectStyle::INPUT );
+ break;
+ }
+ case Toolkit::TextField::Property::OUTLINE:
+ {
+ GetOutlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
+ break;
+ }
+ case Toolkit::TextField::Property::INPUT_OUTLINE:
+ {
+ GetOutlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
+ break;
+ }
} //switch
}
mController = Text::Controller::New( *this );
+ // When using the vector-based rendering, the size of the GLyphs are different
+ TextAbstraction::GlyphType glyphType = (Text::RENDERING_VECTOR_BASED == mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH;
+ mController->SetGlyphType( glyphType );
+
mDecorator = Text::Decorator::New( *mController,
*mController );
mController->GetLayoutEngine().SetLayout( LayoutEngine::SINGLE_LINE_BOX );
+ // Enables the text input.
mController->EnableTextInput( mDecorator );
+ // Enables the horizontal scrolling after the text input has been enabled.
+ mController->SetHorizontalScrollEnabled( true );
+
+ // Disables the vertical scrolling.
+ mController->SetVerticalScrollEnabled( false );
+
+ // Disable the smooth handle panning.
+ mController->SetSmoothHandlePanEnabled( false );
+
// Forward input events to controller
EnableGestureDetection( static_cast<Gesture::Type>( Gesture::Tap | Gesture::Pan | Gesture::LongPress ) );
GetTapGestureDetector().SetMaximumTapsRequired( 2 );
- self.TouchedSignal().Connect( this, &TextField::OnTouched );
+ self.TouchSignal().Connect( this, &TextField::OnTouched );
// Set BoundingBox to stage size if not already set.
Rect<int> boundingBox;
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange\n");
- switch ( change )
- {
- case StyleChange::DEFAULT_FONT_CHANGE:
- {
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange DEFAULT_FONT_CHANGE\n");
- std::string newFont = styleManager.GetDefaultFontFamily();
- // Property system did not set the font so should update it.
- mController->UpdateAfterFontChange( newFont );
- break;
- }
-
- case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
- {
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField::OnStyleChange StyleChange::DEFAULT_FONT_SIZE_CHANGE (%f)\n", mController->GetDefaultPointSize() );
-
- if ( (mController->GetDefaultPointSize() <= 0.0f) ) // If DefaultPointSize not set by Property system it will be 0.0f
- {
- // Property system did not set the PointSize so should update it.
- // todo instruct text-controller to update model
- }
- break;
- }
- case StyleChange::THEME_CHANGE:
- {
- GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
- break;
- }
- }
+ switch ( change )
+ {
+ case StyleChange::DEFAULT_FONT_CHANGE:
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange DEFAULT_FONT_CHANGE\n");
+ const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily();
+ // Property system did not set the font so should update it.
+ mController->UpdateAfterFontChange( newFont );
+ break;
+ }
+
+ case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
+ {
+ GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+ break;
+ }
+ case StyleChange::THEME_CHANGE:
+ {
+ GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+ break;
+ }
+ }
}
Vector3 TextField::GetNaturalSize()
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField OnRelayout\n");
- if( mController->Relayout( size ) ||
+ const Text::Controller::UpdateTextType updateTextType = mController->Relayout( size );
+
+ if( ( Text::Controller::NONE_UPDATED != updateTextType ) ||
!mRenderer )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnRelayout %p Displaying new contents\n", mController.Get() );
- if( mDecorator )
+ if( mDecorator &&
+ ( Text::Controller::NONE_UPDATED != ( Text::Controller::DECORATOR_UPDATED & updateTextType ) ) )
{
mDecorator->Relayout( size );
}
mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
}
- EnableClipping( (Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy), size );
- RenderText();
+ EnableClipping( ( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy ), size );
+ RenderText( updateTextType );
}
}
-void TextField::RenderText()
+void TextField::RenderText( Text::Controller::UpdateTextType updateTextType )
{
Actor self = Self();
Actor renderableActor;
- if( mRenderer )
- {
- renderableActor = mRenderer->Render( mController->GetView(), DepthIndex::TEXT );
- }
- if( renderableActor != mRenderableActor )
+ if( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) )
{
- UnparentAndReset( mRenderableActor );
- mRenderableActor = renderableActor;
+ if( mRenderer )
+ {
+ renderableActor = mRenderer->Render( mController->GetView(), DepthIndex::TEXT );
+ }
+
+ if( renderableActor != mRenderableActor )
+ {
+ UnparentAndReset( mRenderableActor );
+ mRenderableActor = renderableActor;
+ }
}
if( mRenderableActor )
{
- const Vector2 offset = mController->GetScrollPosition() + mController->GetAlignmentOffset();
+ const Vector2& scrollOffset = mController->GetScrollPosition();
- mRenderableActor.SetPosition( offset.x, offset.y );
+ mRenderableActor.SetPosition( scrollOffset.x, scrollOffset.y );
Actor clipRootActor;
if( mClipper )
{
if ( mHasBeenStaged )
{
- RenderText();
+ RenderText( static_cast<Text::Controller::UpdateTextType>( Text::Controller::MODEL_UPDATED | Text::Controller::DECORATOR_UPDATED ) );
}
else
{
mClipper = Clipper::New( size );
self.Add( mClipper->GetRootActor() );
- self.Add( mClipper->GetImageActor() );
+ self.Add( mClipper->GetImageView() );
}
else if ( mClipper )
{
}
else
{
- // Note - this will automatically remove the root & image actors
+ // Note - this will automatically remove the root actor & the image view
mClipper.Reset();
}
}
// Call the Control::OnStageConnection() to set the depth of the background.
Control::OnStageConnection( depth );
- // Sets the depth to the renderers inside the text's decorator.
+ // Sets the depth to the visuals inside the text's decorator.
mDecorator->SetTextDepth( depth );
// The depth of the text renderer is set in the RenderText() called from OnRelayout().
}
-bool TextField::OnTouched( Actor actor, const TouchEvent& event )
+bool TextField::OnTouched( Actor actor, const TouchData& touch )
{
return true;
}