/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// EXTERNAL INCLUDES
#include <cstring>
#include <dali/public-api/adaptor-framework/key.h>
+#include <dali/public-api/common/dali-common.h>
#include <dali/devel-api/adaptor-framework/key-devel.h>
-#include <dali/public-api/common/stage.h>
-#include <dali/public-api/images/resource-image.h>
+#include <dali/devel-api/adaptor-framework/window-devel.h>
+#include <dali/devel-api/common/stage.h>
#include <dali/devel-api/object/property-helper-devel.h>
#include <dali/devel-api/actors/actor-devel.h>
#include <dali/public-api/object/type-registry-helper.h>
-#include <dali/integration-api/adaptors/adaptor.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/text/rendering-backend.h>
#include <dali-toolkit/public-api/text/text-enumerations.h>
#include <dali-toolkit/public-api/visuals/color-visual-properties.h>
+#include <dali-toolkit/devel-api/text/rendering-backend.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
#include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
#include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
#include <dali-toolkit/internal/text/text-view.h>
#include <dali-toolkit/internal/styling/style-manager-impl.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali/integration-api/adaptor-framework/adaptor.h>
using namespace Dali::Toolkit::Text;
Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_CONTROLS");
#endif
- const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
+ const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::DevelText::DEFAULT_RENDERING_BACKEND;
} // unnamed namespace
namespace
// Setup properties, signals and actions using the type-registry.
DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TextField, Toolkit::Control, Create );
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "renderingBackend", INTEGER, RENDERING_BACKEND )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "text", STRING, TEXT )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholderText", STRING, PLACEHOLDER_TEXT )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholderTextFocused", STRING, PLACEHOLDER_TEXT_FOCUSED )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableShiftSelection", BOOLEAN, ENABLE_SHIFT_SELECTION )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableGrabHandle", BOOLEAN, ENABLE_GRAB_HANDLE )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "matchSystemLanguageDirection", BOOLEAN, MATCH_SYSTEM_LANGUAGE_DIRECTION )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableGrabHandlePopup", BOOLEAN, ENABLE_GRAB_HANDLE_POPUP )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "textBackground", VECTOR4, BACKGROUND )
+DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextField, "selectedText", STRING, SELECTED_TEXT )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "renderingBackend", INTEGER, RENDERING_BACKEND )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "selectedTextStart", INTEGER, SELECTED_TEXT_START )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "selectedTextEnd", INTEGER, SELECTED_TEXT_END )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableEditing", BOOLEAN, ENABLE_EDITING )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "fontSizeScale", FLOAT, FONT_SIZE_SCALE )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "primaryCursorPosition", INTEGER, PRIMARY_CURSOR_POSITION )
DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "textChanged", SIGNAL_TEXT_CHANGED )
DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "maxLengthReached", SIGNAL_MAX_LENGTH_REACHED )
DALI_TYPE_REGISTRATION_END()
+const char * const IMAGE_MAP_FILENAME_STRING = "filename";
+
+/// Retrieves a filename from a value that is a Property::Map
+std::string GetImageFileNameFromPropertyValue( const Property::Value& value )
+{
+ std::string filename;
+ const Property::Map* map = value.GetMap();
+ if( map )
+ {
+ const Property::Value* filenameValue = map->Find( IMAGE_MAP_FILENAME_STRING );
+ if( filenameValue )
+ {
+ filenameValue->Get( filename );
+ }
+ }
+ return filename;
+}
+
} // namespace
Toolkit::TextField TextField::New()
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField SetProperty\n");
-
if( textField )
{
TextField& impl( GetImpl( textField ) );
+ DALI_ASSERT_DEBUG( impl.mController && "No text contoller" );
+ DALI_ASSERT_DEBUG( impl.mDecorator && "No text decorator" );
switch( index )
{
- case Toolkit::TextField::Property::RENDERING_BACKEND:
+ case Toolkit::DevelTextField::Property::RENDERING_BACKEND:
{
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 )
+ if( DevelText::RENDERING_VECTOR_BASED == backend )
{
backend = TextAbstraction::BITMAP_GLYPH; // Fallback to bitmap-based rendering
}
impl.mRenderingBackend = backend;
impl.mRenderer.Reset();
- 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 );
- }
+ // When using the vector-based rendering, the size of the GLyphs are different
+ TextAbstraction::GlyphType glyphType = (DevelText::RENDERING_VECTOR_BASED == impl.mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH;
+ impl.mController->SetGlyphType( glyphType );
}
break;
}
case Toolkit::TextField::Property::TEXT:
{
- if( impl.mController )
- {
- const std::string& text = value.Get< std::string >();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p TEXT %s\n", impl.mController.Get(), text.c_str() );
+ const std::string& text = value.Get< std::string >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p TEXT %s\n", impl.mController.Get(), text.c_str() );
- impl.mController->SetText( text );
- }
+ impl.mController->SetText( text );
break;
}
case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
{
- if( impl.mController )
- {
- const std::string& text = value.Get< std::string >();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str() );
+ const std::string& text = value.Get< std::string >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str() );
- impl.mController->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text );
- }
+ impl.mController->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text );
break;
}
case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED:
{
- if( impl.mController )
- {
- const std::string& text = value.Get< std::string >();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_FOCUSED %s\n", impl.mController.Get(), text.c_str() );
+ const std::string& text = value.Get< std::string >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_FOCUSED %s\n", impl.mController.Get(), text.c_str() );
- impl.mController->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_ACTIVE, text );
- }
+ impl.mController->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_ACTIVE, text );
break;
}
case Toolkit::TextField::Property::FONT_FAMILY:
{
- if( impl.mController )
- {
- const std::string& fontFamily = value.Get< std::string >();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
- impl.mController->SetDefaultFontFamily( fontFamily );
- }
+ const std::string& fontFamily = value.Get< std::string >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
+ impl.mController->SetDefaultFontFamily( fontFamily );
break;
}
case Toolkit::TextField::Property::FONT_STYLE:
}
case Toolkit::TextField::Property::POINT_SIZE:
{
- if( impl.mController )
- {
- const float pointSize = value.Get< float >();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p POINT_SIZE %f\n", impl.mController.Get(), pointSize );
+ const float pointSize = value.Get< float >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p POINT_SIZE %f\n", impl.mController.Get(), pointSize );
- if( !Equals( impl.mController->GetDefaultFontSize( Text::Controller::POINT_SIZE ), pointSize ) )
- {
- impl.mController->SetDefaultFontSize( pointSize, Text::Controller::POINT_SIZE );
- }
+ if( !Equals( impl.mController->GetDefaultFontSize( Text::Controller::POINT_SIZE ), pointSize ) )
+ {
+ impl.mController->SetDefaultFontSize( pointSize, Text::Controller::POINT_SIZE );
}
break;
}
case Toolkit::TextField::Property::MAX_LENGTH:
{
- if( impl.mController )
- {
- const int max = value.Get< int >();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p MAX_LENGTH %d\n", impl.mController.Get(), max );
+ const int max = value.Get< int >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p MAX_LENGTH %d\n", impl.mController.Get(), max );
- impl.mController->SetMaximumNumberOfCharacters( max );
- }
+ impl.mController->SetMaximumNumberOfCharacters( max );
break;
}
case Toolkit::TextField::Property::EXCEED_POLICY:
}
case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
{
- if( impl.mController )
+ Text::HorizontalAlignment::Type alignment( static_cast< Text::HorizontalAlignment::Type >( -1 ) ); // Set to invalid value to ensure a valid mode does get set
+ if( GetHorizontalAlignmentEnumeration( value, alignment ) )
{
- Text::HorizontalAlignment::Type alignment( static_cast< Text::HorizontalAlignment::Type >( -1 ) ); // Set to invalid value to ensure a valid mode does get set
- if( GetHorizontalAlignmentEnumeration( value, alignment ) )
- {
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p HORIZONTAL_ALIGNMENT %d\n", impl.mController.Get(), alignment );
- impl.mController->SetHorizontalAlignment( alignment );
- }
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p HORIZONTAL_ALIGNMENT %d\n", impl.mController.Get(), alignment );
+ impl.mController->SetHorizontalAlignment( alignment );
}
break;
}
case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
{
- if( impl.mController )
+ Toolkit::Text::VerticalAlignment::Type alignment( static_cast< Text::VerticalAlignment::Type >( -1 ) ); // Set to invalid value to ensure a valid mode does get set
+ if( GetVerticalAlignmentEnumeration( value, alignment ) )
{
- Toolkit::Text::VerticalAlignment::Type alignment( static_cast< Text::VerticalAlignment::Type >( -1 ) ); // Set to invalid value to ensure a valid mode does get set
- if( GetVerticalAlignmentEnumeration( value, alignment ) )
- {
- impl.mController->SetVerticalAlignment( alignment );
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p VERTICAL_ALIGNMENT %d\n", impl.mController.Get(), alignment );
- }
+ impl.mController->SetVerticalAlignment( alignment );
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p VERTICAL_ALIGNMENT %d\n", impl.mController.Get(), alignment );
}
break;
}
case Toolkit::TextField::Property::TEXT_COLOR:
{
- if( impl.mController )
- {
- const Vector4& textColor = value.Get< Vector4 >();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a );
+ const Vector4& textColor = value.Get< Vector4 >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a );
- if( impl.mController->GetDefaultColor() != textColor )
- {
- impl.mController->SetDefaultColor( textColor );
- impl.mController->SetInputColor( textColor );
- impl.mRenderer.Reset();
- }
+ if( impl.mController->GetDefaultColor() != textColor )
+ {
+ impl.mController->SetDefaultColor( textColor );
+ impl.mController->SetInputColor( textColor );
+ impl.mRenderer.Reset();
}
break;
}
case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR:
{
- if( impl.mController )
- {
- const Vector4& textColor = value.Get< Vector4 >();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a );
+ const Vector4& textColor = value.Get< Vector4 >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a );
- if( impl.mController->GetPlaceholderTextColor() != textColor )
- {
- impl.mController->SetPlaceholderTextColor( textColor );
- impl.mRenderer.Reset();
- }
+ if( impl.mController->GetPlaceholderTextColor() != textColor )
+ {
+ impl.mController->SetPlaceholderTextColor( textColor );
+ impl.mRenderer.Reset();
}
break;
}
case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
{
- if( impl.mDecorator )
- {
- const Vector4& color = value.Get< Vector4 >();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PRIMARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
+ const Vector4& color = value.Get< Vector4 >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PRIMARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
- impl.mDecorator->SetCursorColor( PRIMARY_CURSOR, color );
- impl.RequestTextRelayout();
- }
+ impl.mDecorator->SetCursorColor( PRIMARY_CURSOR, color );
+ impl.RequestTextRelayout();
break;
}
case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
{
- if( impl.mDecorator )
- {
- const Vector4& color = value.Get< Vector4 >();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SECONDARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
+ const Vector4& color = value.Get< Vector4 >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SECONDARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
- impl.mDecorator->SetCursorColor( SECONDARY_CURSOR, color );
- impl.RequestTextRelayout();
- }
+ impl.mDecorator->SetCursorColor( SECONDARY_CURSOR, color );
+ impl.RequestTextRelayout();
break;
}
case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
{
- if( impl.mController )
- {
- const bool enable = value.Get< bool >();
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p ENABLE_CURSOR_BLINK %d\n", impl.mController.Get(), enable );
+ const bool enable = value.Get< bool >();
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p ENABLE_CURSOR_BLINK %d\n", impl.mController.Get(), enable );
- impl.mController->SetEnableCursorBlink( enable );
- impl.RequestTextRelayout();
- }
+ impl.mController->SetEnableCursorBlink( enable );
+ impl.RequestTextRelayout();
break;
}
case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
{
- if( impl.mDecorator )
- {
- const float interval = value.Get< float >();
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_INTERVAL %f\n", impl.mController.Get(), interval );
+ const float interval = value.Get< float >();
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_INTERVAL %f\n", impl.mController.Get(), interval );
- impl.mDecorator->SetCursorBlinkInterval( interval );
- }
+ impl.mDecorator->SetCursorBlinkInterval( interval );
break;
}
case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
{
- if( impl.mDecorator )
- {
- const float duration = value.Get< float >();
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_DURATION %f\n", impl.mController.Get(), duration );
+ const float duration = value.Get< float >();
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_DURATION %f\n", impl.mController.Get(), duration );
- impl.mDecorator->SetCursorBlinkDuration( duration );
- }
+ impl.mDecorator->SetCursorBlinkDuration( duration );
break;
}
case Toolkit::TextField::Property::CURSOR_WIDTH:
{
- if( impl.mDecorator )
- {
- const int width = value.Get< int >();
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_WIDTH %d\n", impl.mController.Get(), width );
+ const int width = value.Get< int >();
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_WIDTH %d\n", impl.mController.Get(), width );
- impl.mDecorator->SetCursorWidth( width );
- impl.mController->GetLayoutEngine().SetCursorWidth( width );
- }
+ impl.mDecorator->SetCursorWidth( width );
+ impl.mController->GetLayoutEngine().SetCursorWidth( width );
break;
}
case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
{
- const ResourceImage image = ResourceImage::New( value.Get< std::string >() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_IMAGE %s\n", impl.mController.Get(), image.GetUrl().c_str() );
+ const std::string imageFileName = value.Get< std::string >();
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str() );
- if( impl.mDecorator )
+ if( imageFileName.size() )
{
- impl.mDecorator->SetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED, image );
+ impl.mDecorator->SetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED, imageFileName );
impl.RequestTextRelayout();
}
break;
}
case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE:
{
- const ResourceImage image = ResourceImage::New( value.Get< std::string >() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_PRESSED_IMAGE %s\n", impl.mController.Get(), image.GetUrl().c_str() );
+ const std::string imageFileName = value.Get< std::string >();
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_PRESSED_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str() );
- if( impl.mDecorator )
+ if( imageFileName.size() )
{
- impl.mDecorator->SetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED, image );
+ impl.mDecorator->SetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED, imageFileName );
impl.RequestTextRelayout();
}
break;
const float threshold = value.Get< float >();
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p SCROLL_THRESHOLD %f\n", impl.mController.Get(), threshold );
- if( impl.mDecorator )
- {
- impl.mDecorator->SetScrollThreshold( threshold );
- }
+ impl.mDecorator->SetScrollThreshold( threshold );
break;
}
case Toolkit::TextField::Property::SCROLL_SPEED:
const float speed = value.Get< float >();
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p SCROLL_SPEED %f\n", impl.mController.Get(), speed );
- if( impl.mDecorator )
- {
- impl.mDecorator->SetScrollSpeed( speed );
- }
+ impl.mDecorator->SetScrollSpeed( speed );
break;
}
case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT:
{
- const Image image = Scripting::NewImage( value );
+ const std::string filename = GetImageFileNameFromPropertyValue( value );
- if( impl.mDecorator && image )
+ if( filename.size() )
{
- impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, image );
+ impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, filename );
impl.RequestTextRelayout();
}
break;
}
case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT:
{
- const Image image = Scripting::NewImage( value );
+ const std::string filename = GetImageFileNameFromPropertyValue( value );
- if( impl.mDecorator && image )
+ if( filename.size() )
{
- impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, image );
+ impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, filename );
impl.RequestTextRelayout();
}
break;
}
case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
{
- const Image image = Scripting::NewImage( value );
+ const std::string filename = GetImageFileNameFromPropertyValue( value );
- if( impl.mDecorator && image )
+ if( filename.size() )
{
- impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, image );
+ impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, filename );
impl.RequestTextRelayout();
}
break;
}
case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
{
- const Image image = Scripting::NewImage( value );
+ const std::string filename = GetImageFileNameFromPropertyValue( value );
- if( impl.mDecorator && image )
+ if( filename.size() )
{
- impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, image );
+ impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, filename );
impl.RequestTextRelayout();
}
break;
}
case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
{
- const Image image = Scripting::NewImage( value );
+ const std::string filename = GetImageFileNameFromPropertyValue( value );
- if( impl.mDecorator && image )
+ if( filename.size() )
{
- impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, image );
+ impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, filename );
impl.RequestTextRelayout();
}
break;
}
case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
{
- const Image image = Scripting::NewImage( value );
+ const std::string filename = GetImageFileNameFromPropertyValue( value );
- if( impl.mDecorator && image )
+ if( filename.size() )
{
- impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, image );
+ impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, filename );
impl.RequestTextRelayout();
}
break;
const Vector4 color = value.Get< Vector4 >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SELECTION_HIGHLIGHT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
- if( impl.mDecorator )
- {
- impl.mDecorator->SetHighlightColor( color );
- impl.RequestTextRelayout();
- }
+ impl.mDecorator->SetHighlightColor( color );
+ impl.RequestTextRelayout();
break;
}
case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
{
- if( impl.mDecorator )
- {
- const Rect<int> box = value.Get< Rect<int> >();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p DECORATION_BOUNDING_BOX %d,%d %dx%d\n", impl.mController.Get(), box.x, box.y, box.width, box.height );
+ const Rect<int> box = value.Get< Rect<int> >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p DECORATION_BOUNDING_BOX %d,%d %dx%d\n", impl.mController.Get(), box.x, box.y, box.width, box.height );
- impl.mDecorator->SetBoundingBox( box );
- impl.RequestTextRelayout();
- }
+ impl.mDecorator->SetBoundingBox( box );
+ impl.RequestTextRelayout();
break;
}
case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS:
}
case Toolkit::TextField::Property::INPUT_COLOR:
{
- if( impl.mController )
- {
- const Vector4 inputColor = value.Get< Vector4 >();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p INPUT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), inputColor.r, inputColor.g, inputColor.b, inputColor.a );
+ const Vector4 inputColor = value.Get< Vector4 >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p INPUT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), inputColor.r, inputColor.g, inputColor.b, inputColor.a );
- impl.mController->SetInputColor( inputColor );
- }
+ impl.mController->SetInputColor( inputColor );
break;
}
case Toolkit::TextField::Property::ENABLE_MARKUP:
{
- if( impl.mController )
- {
- const bool enableMarkup = value.Get<bool>();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_MARKUP %d\n", impl.mController.Get(), enableMarkup );
+ const bool enableMarkup = value.Get<bool>();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_MARKUP %d\n", impl.mController.Get(), enableMarkup );
- impl.mController->SetMarkupProcessorEnabled( enableMarkup );
- }
+ impl.mController->SetMarkupProcessorEnabled( enableMarkup );
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 );
- }
+ 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:
}
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 );
- }
+ 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:
}
case Toolkit::TextField::Property::PIXEL_SIZE:
{
- if( impl.mController )
- {
- const float pixelSize = value.Get< float >();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PIXEL_SIZE %f\n", impl.mController.Get(), pixelSize );
+ const float pixelSize = value.Get< float >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PIXEL_SIZE %f\n", impl.mController.Get(), pixelSize );
- if( !Equals( impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE ), pixelSize ) )
- {
- impl.mController->SetDefaultFontSize( pixelSize, Text::Controller::PIXEL_SIZE );
- }
+ if( !Equals( impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE ), pixelSize ) )
+ {
+ impl.mController->SetDefaultFontSize( pixelSize, Text::Controller::PIXEL_SIZE );
}
break;
}
case Toolkit::TextField::Property::ENABLE_SELECTION:
{
- if( impl.mController )
- {
- const bool enableSelection = value.Get< bool >();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_SELECTION %d\n", impl.mController.Get(), enableSelection );
- impl.mController->SetSelectionEnabled( enableSelection );
- }
+ const bool enableSelection = value.Get< bool >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_SELECTION %d\n", impl.mController.Get(), enableSelection );
+ impl.mController->SetSelectionEnabled( enableSelection );
break;
}
case Toolkit::TextField::Property::PLACEHOLDER:
}
case Toolkit::TextField::Property::ELLIPSIS:
{
- if( impl.mController )
- {
- const bool ellipsis = value.Get<bool>();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ELLIPSIS %d\n", impl.mController.Get(), ellipsis );
+ const bool ellipsis = value.Get<bool>();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ELLIPSIS %d\n", impl.mController.Get(), ellipsis );
- impl.mController->SetTextElideEnabled( ellipsis );
- }
+ impl.mController->SetTextElideEnabled( ellipsis );
break;
}
case Toolkit::DevelTextField::Property::ENABLE_SHIFT_SELECTION:
{
- if( impl.mController )
- {
- const bool shiftSelection = value.Get<bool>();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_SHIFT_SELECTION %d\n", impl.mController.Get(), shiftSelection );
+ const bool shiftSelection = value.Get<bool>();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_SHIFT_SELECTION %d\n", impl.mController.Get(), shiftSelection );
- impl.mController->SetShiftSelectionEnabled( shiftSelection );
- }
+ impl.mController->SetShiftSelectionEnabled( shiftSelection );
break;
}
case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE:
{
- if( impl.mController )
- {
- const bool grabHandleEnabled = value.Get<bool>();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_GRAB_HANDLE %d\n", impl.mController.Get(), grabHandleEnabled );
+ const bool grabHandleEnabled = value.Get<bool>();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_GRAB_HANDLE %d\n", impl.mController.Get(), grabHandleEnabled );
- impl.mController->SetGrabHandleEnabled( grabHandleEnabled );
- }
+ impl.mController->SetGrabHandleEnabled( grabHandleEnabled );
break;
}
case Toolkit::DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
{
- if( impl.mController )
+ impl.mController->SetMatchSystemLanguageDirection(value.Get< bool >());
+ break;
+ }
+ case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP:
+ {
+ const bool grabHandlePopupEnabled = value.Get<bool>();
+ DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p ENABLE_GRAB_HANDLE_POPUP %d\n", impl.mController.Get(), grabHandlePopupEnabled);
+
+ impl.mController->SetGrabHandlePopupEnabled(grabHandlePopupEnabled);
+ break;
+ }
+ case Toolkit::DevelTextField::Property::BACKGROUND:
+ {
+ const Vector4 backgroundColor = value.Get< Vector4 >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p BACKGROUND %f,%f,%f,%f\n", impl.mController.Get(), backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a );
+
+ impl.mController->SetBackgroundEnabled( true );
+ impl.mController->SetBackgroundColor( backgroundColor );
+ break;
+ }
+ case Toolkit::DevelTextField::Property::SELECTED_TEXT_START:
+ {
+ uint32_t start = static_cast<uint32_t>(value.Get< int >());
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SELECTED_TEXT_START %d\n", impl.mController.Get(), start );
+ impl.SetTextSelectionRange( &start, nullptr );
+ break;
+ }
+ case Toolkit::DevelTextField::Property::SELECTED_TEXT_END:
+ {
+ uint32_t end = static_cast<uint32_t>(value.Get< int >());
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SELECTED_TEXT_END %d\n", impl.mController.Get(), end );
+ impl.SetTextSelectionRange( nullptr, &end );
+ break;
+ }
+ case Toolkit::DevelTextField::Property::ENABLE_EDITING:
+ {
+ const bool editable = value.Get< bool >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_EDITING %d\n", impl.mController.Get(), editable );
+ impl.SetEditable( editable );
+ break;
+ }
+ case Toolkit::DevelTextField::Property::FONT_SIZE_SCALE:
+ {
+ const float scale = value.Get< float >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p FONT_SIZE_SCALE %f\n", impl.mController.Get(), scale );
+
+ if( !Equals( impl.mController->GetFontSizeScale(), scale ) )
{
- impl.mController->SetMatchSystemLanguageDirection(value.Get< bool >());
+ impl.mController->SetFontSizeScale( scale );
+ }
+ break;
+ }
+ case Toolkit::DevelTextField::Property::PRIMARY_CURSOR_POSITION:
+ {
+ uint32_t position = static_cast<uint32_t>(value.Get< int >());
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PRIMARY_CURSOR_POSITION %d\n", impl.mController.Get(), position );
+ if (impl.mController->SetPrimaryCursorPosition( position ))
+ {
+ impl.SetKeyInputFocus();
}
break;
}
if( textField )
{
TextField& impl( GetImpl( textField ) );
+ DALI_ASSERT_DEBUG( impl.mController && "No text contoller" );
+ DALI_ASSERT_DEBUG( impl.mDecorator && "No text decorator" );
switch( index )
{
- case Toolkit::TextField::Property::RENDERING_BACKEND:
+ case Toolkit::DevelTextField::Property::RENDERING_BACKEND:
{
value = impl.mRenderingBackend;
break;
}
case Toolkit::TextField::Property::TEXT:
{
- if( impl.mController )
- {
- std::string text;
- impl.mController->GetText( text );
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p returning text: %s\n", impl.mController.Get(), text.c_str() );
- value = text;
- }
+ std::string text;
+ impl.mController->GetText( text );
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p returning text: %s\n", impl.mController.Get(), text.c_str() );
+ value = text;
break;
}
case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
{
- if( impl.mController )
- {
- std::string text;
- impl.mController->GetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text );
- value = text;
- }
+ std::string text;
+ impl.mController->GetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text );
+ value = text;
break;
}
case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED:
{
- if( impl.mController )
- {
- std::string text;
- impl.mController->GetPlaceholderText( Controller::PLACEHOLDER_TYPE_ACTIVE, text );
- value = text;
- }
+ std::string text;
+ impl.mController->GetPlaceholderText( Controller::PLACEHOLDER_TYPE_ACTIVE, text );
+ value = text;
break;
}
case Toolkit::TextField::Property::FONT_FAMILY:
{
- if( impl.mController )
- {
- value = impl.mController->GetDefaultFontFamily();
- }
+ value = impl.mController->GetDefaultFontFamily();
break;
}
case Toolkit::TextField::Property::FONT_STYLE:
}
case Toolkit::TextField::Property::POINT_SIZE:
{
- if( impl.mController )
- {
- value = impl.mController->GetDefaultFontSize( Text::Controller::POINT_SIZE );
- }
+ value = impl.mController->GetDefaultFontSize( Text::Controller::POINT_SIZE );
break;
}
case Toolkit::TextField::Property::MAX_LENGTH:
{
- if( impl.mController )
- {
- value = impl.mController->GetMaximumNumberOfCharacters();
- }
+ value = impl.mController->GetMaximumNumberOfCharacters();
break;
}
case Toolkit::TextField::Property::EXCEED_POLICY:
}
case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
{
- if( impl.mController )
- {
- const char* name = Text::GetHorizontalAlignmentString( impl.mController->GetHorizontalAlignment() );
+ const char* name = Text::GetHorizontalAlignmentString( impl.mController->GetHorizontalAlignment() );
- if ( name )
- {
- value = std::string( name );
- }
+ if ( name )
+ {
+ value = std::string( name );
}
break;
}
case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
{
- if( impl.mController )
- {
- const char* name = Text::GetVerticalAlignmentString( impl.mController->GetVerticalAlignment() );
+ const char* name = Text::GetVerticalAlignmentString( impl.mController->GetVerticalAlignment() );
- if( name )
- {
- value = std::string( name );
- }
+ if( name )
+ {
+ value = std::string( name );
}
break;
}
case Toolkit::TextField::Property::TEXT_COLOR:
{
- if ( impl.mController )
- {
- value = impl.mController->GetDefaultColor();
- }
+ value = impl.mController->GetDefaultColor();
break;
}
case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR:
{
- if ( impl.mController )
- {
- value = impl.mController->GetPlaceholderTextColor();
- }
+ value = impl.mController->GetPlaceholderTextColor();
break;
}
case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
{
- if( impl.mDecorator )
- {
- value = impl.mDecorator->GetColor( PRIMARY_CURSOR );
- }
+ value = impl.mDecorator->GetColor( PRIMARY_CURSOR );
break;
}
case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
{
- if( impl.mDecorator )
- {
- value = impl.mDecorator->GetColor( SECONDARY_CURSOR );
- }
+ value = impl.mDecorator->GetColor( SECONDARY_CURSOR );
break;
}
case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
}
case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
{
- if( impl.mDecorator )
- {
- value = impl.mDecorator->GetCursorBlinkInterval();
- }
+ value = impl.mDecorator->GetCursorBlinkInterval();
break;
}
case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
{
- if( impl.mDecorator )
- {
- value = impl.mDecorator->GetCursorBlinkDuration();
- }
+ value = impl.mDecorator->GetCursorBlinkDuration();
break;
}
case Toolkit::TextField::Property::CURSOR_WIDTH:
{
- if( impl.mDecorator )
- {
- value = impl.mDecorator->GetCursorWidth();
- }
+ value = impl.mDecorator->GetCursorWidth();
break;
}
case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
{
- if( impl.mDecorator )
- {
- ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED ) );
- if( image )
- {
- value = image.GetUrl();
- }
- }
+ value = impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED );
break;
}
case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE:
{
- if( impl.mDecorator )
- {
- ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED ) );
- if( image )
- {
- value = image.GetUrl();
- }
- }
+ value = impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED );
break;
}
case Toolkit::TextField::Property::SCROLL_THRESHOLD:
{
- if( impl.mDecorator )
- {
- value = impl.mDecorator->GetScrollThreshold();
- }
+ value = impl.mDecorator->GetScrollThreshold();
break;
}
case Toolkit::TextField::Property::SCROLL_SPEED:
{
- if( impl.mDecorator )
- {
- value = impl.mDecorator->GetScrollSpeed();
- }
+ value = impl.mDecorator->GetScrollSpeed();
break;
}
case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT:
}
case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR:
{
- if( impl.mDecorator )
- {
- value = impl.mDecorator->GetHighlightColor();
- }
+ value = impl.mDecorator->GetHighlightColor();
break;
}
case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
{
- if( impl.mDecorator )
- {
- Rect<int> boundingBox;
- impl.mDecorator->GetBoundingBox( boundingBox );
- value = boundingBox;
- }
+ Rect<int> boundingBox;
+ impl.mDecorator->GetBoundingBox( boundingBox );
+ value = boundingBox;
break;
}
case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS:
}
case Toolkit::TextField::Property::INPUT_COLOR:
{
- if( impl.mController )
- {
- value = impl.mController->GetInputColor();
- }
+ value = impl.mController->GetInputColor();
break;
}
case Toolkit::TextField::Property::ENABLE_MARKUP:
{
- if( impl.mController )
- {
- value = impl.mController->IsMarkupProcessorEnabled();
- }
+ value = impl.mController->IsMarkupProcessorEnabled();
break;
}
case Toolkit::TextField::Property::INPUT_FONT_FAMILY:
{
- if( impl.mController )
- {
- value = impl.mController->GetInputFontFamily();
- }
+ value = impl.mController->GetInputFontFamily();
break;
}
case Toolkit::TextField::Property::INPUT_FONT_STYLE:
}
case Toolkit::TextField::Property::INPUT_POINT_SIZE:
{
- if( impl.mController )
- {
- value = impl.mController->GetInputFontPointSize();
- }
+ value = impl.mController->GetInputFontPointSize();
break;
}
case Toolkit::TextField::Property::UNDERLINE:
}
case Toolkit::TextField::Property::PIXEL_SIZE:
{
- if( impl.mController )
- {
- value = impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE );
- }
+ value = impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE );
break;
}
case Toolkit::TextField::Property::ENABLE_SELECTION:
{
- if( impl.mController )
- {
- value = impl.mController->IsSelectionEnabled();
- }
+ value = impl.mController->IsSelectionEnabled();
break;
}
case Toolkit::TextField::Property::PLACEHOLDER:
}
case Toolkit::TextField::Property::ELLIPSIS:
{
- if( impl.mController )
- {
- value = impl.mController->IsTextElideEnabled();
- }
+ value = impl.mController->IsTextElideEnabled();
break;
}
case Toolkit::DevelTextField::Property::ENABLE_SHIFT_SELECTION:
{
- if( impl.mController )
- {
- value = impl.mController->IsShiftSelectionEnabled();
- }
+ value = impl.mController->IsShiftSelectionEnabled();
break;
}
case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE:
{
- if( impl.mController )
- {
- value = impl.mController->IsGrabHandleEnabled();
- }
+ value = impl.mController->IsGrabHandleEnabled();
break;
}
case Toolkit::DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
{
- if( impl.mController )
- {
- value = impl.mController->IsMatchSystemLanguageDirection();
- }
+ value = impl.mController->IsMatchSystemLanguageDirection();
+ break;
+ }
+ case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP:
+ {
+ value = impl.mController->IsGrabHandlePopupEnabled();
+ break;
+ }
+ case Toolkit::DevelTextField::Property::BACKGROUND:
+ {
+ value = impl.mController->GetBackgroundColor();
+ break;
+ }
+ case Toolkit::DevelTextField::Property::SELECTED_TEXT:
+ {
+ value = impl.mController->GetSelectedText( );
+ break;
+ }
+ case Toolkit::DevelTextField::Property::SELECTED_TEXT_START:
+ {
+ Uint32Pair range = impl.GetTextSelectionRange( );
+ value = static_cast<int>(range.first);
+ break;
+ }
+ case Toolkit::DevelTextField::Property::SELECTED_TEXT_END:
+ {
+ Uint32Pair range = impl.GetTextSelectionRange( );
+ value = static_cast<int>(range.second);
+ break;
+ }
+ case Toolkit::DevelTextField::Property::ENABLE_EDITING:
+ {
+ value = impl.IsEditable();
+ break;
+ }
+ case Toolkit::DevelTextField::Property::FONT_SIZE_SCALE:
+ {
+ value = impl.mController->GetFontSizeScale();
+ break;
+ }
+ case Toolkit::DevelTextField::Property::PRIMARY_CURSOR_POSITION:
+ {
+ value = static_cast<int>(impl.mController->GetPrimaryCursorPosition());
break;
}
} //switch
return value;
}
+void TextField::SelectWholeText()
+{
+ if( mController && mController->IsShowingRealText() )
+ {
+ mController->SelectWholeText();
+ SetKeyInputFocus();
+ }
+}
+
+void TextField::SelectNone()
+{
+ if( mController && mController->IsShowingRealText() )
+ {
+ mController->SelectNone();
+ }
+}
+
+string TextField::GetSelectedText() const
+{
+ string selectedText = "";
+ if( mController && mController->IsShowingRealText() )
+ {
+ selectedText = mController->GetSelectedText( );
+ }
+ return selectedText;
+}
+
+void TextField::SetTextSelectionRange(const uint32_t *start, const uint32_t *end)
+{
+ if( mController && mController->IsShowingRealText() )
+ {
+ mController->SetTextSelectionRange( start, end );
+ SetKeyInputFocus();
+ }
+}
+
+Uint32Pair TextField::GetTextSelectionRange() const
+{
+ Uint32Pair range;
+ if( mController && mController->IsShowingRealText() )
+ {
+ range = mController->GetTextSelectionRange();
+ }
+ return range;
+}
+
+
InputMethodContext TextField::GetInputMethodContext()
{
return mInputMethodContext;
{
Actor self = Self();
- mController = Text::Controller::New( this, this );
+ mController = Text::Controller::New( this, this ,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;
+ TextAbstraction::GlyphType glyphType = (DevelText::RENDERING_VECTOR_BASED == mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH;
mController->SetGlyphType( glyphType );
mDecorator = Text::Decorator::New( *mController,
*mController );
- mInputMethodContext = InputMethodContext::New();
+ mInputMethodContext = InputMethodContext::New( self );
mController->GetLayoutEngine().SetLayout( Layout::Engine::SINGLE_LINE_BOX );
mController->SetLayoutDirection( layoutDirection );
// Forward input events to controller
- EnableGestureDetection( static_cast<Gesture::Type>( Gesture::Tap | Gesture::Pan | Gesture::LongPress ) );
+ EnableGestureDetection( static_cast<GestureType::Value>( GestureType::TAP | GestureType::PAN | GestureType::LONG_PRESS ) );
GetTapGestureDetector().SetMaximumTapsRequired( 2 );
- self.TouchSignal().Connect( this, &TextField::OnTouched );
+ self.TouchedSignal().Connect( this, &TextField::OnTouched );
// Set BoundingBox to stage size if not already set.
Rect<int> boundingBox;
// Fill-parent area by default
self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
- self.OnStageSignal().Connect( this, &TextField::OnStageConnect );
+ self.OnSceneSignal().Connect( this, &TextField::OnSceneConnect );
+
+ //Enable highightability
+ self.SetProperty( Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, true );
DevelControl::SetInputMethodContext( *this, mInputMethodContext );
{
EnableClipping();
}
+
+ DevelControl::SetAccessibilityConstructor( self, []( Dali::Actor actor ) {
+ return std::unique_ptr< Dali::Accessibility::Accessible >(
+ new AccessibleImpl( actor, Dali::Accessibility::Role::ENTRY ) );
+ } );
}
void TextField::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
Vector2 contentSize( size.x - ( padding.start + padding.end ), size.y - ( padding.top + padding.bottom ) );
// Support Right-To-Left of padding
- Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( self.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
+ Dali::LayoutDirection::Type layoutDirection;
+ if( mController->IsMatchSystemLanguageDirection() )
+ {
+ layoutDirection = static_cast<Dali::LayoutDirection::Type>( DevelWindow::Get( self ).GetRootLayer().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
+ }
+ else
+ {
+ layoutDirection = static_cast<Dali::LayoutDirection::Type>( self.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
+ }
if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection )
{
std::swap( padding.start, padding.end );
if( mStencil )
{
- mStencil.SetPosition( padding.start, padding.top );
+ mStencil.SetProperty( Actor::Property::POSITION, Vector2( padding.start, padding.top ));
}
if( mActiveLayer )
{
- mActiveLayer.SetPosition( padding.start, padding.top );
+ mActiveLayer.SetProperty( Actor::Property::POSITION, Vector2( padding.start, padding.top ));
}
const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize, layoutDirection );
}
}
+Text::ControllerPtr TextField::getController() { return mController; }
+
void TextField::RenderText( Text::Controller::UpdateTextType updateTextType )
{
Actor renderableActor;
if( renderableActor != mRenderableActor )
{
+ UnparentAndReset( mBackgroundActor );
UnparentAndReset( mRenderableActor );
mRenderableActor = renderableActor;
+
+ if ( mRenderableActor )
+ {
+ mBackgroundActor = mController->CreateBackgroundActor();
+ }
}
}
{
const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition();
+ float renderableActorPositionX, renderableActorPositionY;
+
if( mStencil )
{
- mRenderableActor.SetPosition( scrollOffset.x + mAlignmentOffset, scrollOffset.y );
+ renderableActorPositionX = scrollOffset.x + mAlignmentOffset;
+ renderableActorPositionY = scrollOffset.y;
}
else
{
std::swap( padding.start, padding.end );
}
- mRenderableActor.SetPosition( scrollOffset.x + mAlignmentOffset + padding.start, scrollOffset.y + padding.top );
+ renderableActorPositionX = scrollOffset.x + mAlignmentOffset + padding.start;
+ renderableActorPositionY = scrollOffset.y + padding.top;
}
+ mRenderableActor.SetProperty( Actor::Property::POSITION, Vector2( renderableActorPositionX, renderableActorPositionY ));
// Make sure the actors are parented correctly with/without clipping
Actor self = mStencil ? mStencil : Self();
+ Actor highlightActor;
+
for( std::vector<Actor>::iterator it = mClippingDecorationActors.begin(),
endIt = mClippingDecorationActors.end();
it != endIt;
{
self.Add( *it );
it->LowerToBottom();
+
+ if ( it->GetProperty< std::string >( Dali::Actor::Property::NAME ) == "HighlightActor" )
+ {
+ highlightActor = *it;
+ }
}
mClippingDecorationActors.clear();
self.Add( mRenderableActor );
+
+ if ( mBackgroundActor )
+ {
+ if ( mDecorator && mDecorator->IsHighlightVisible() )
+ {
+ self.Add( mBackgroundActor );
+ mBackgroundActor.SetProperty( Actor::Property::POSITION, Vector2( renderableActorPositionX, renderableActorPositionY) ); // In text field's coords.
+ mBackgroundActor.LowerBelow( highlightActor );
+ }
+ else
+ {
+ mRenderableActor.Add( mBackgroundActor );
+ mBackgroundActor.SetProperty( Actor::Property::POSITION, Vector2( 0.0f, 0.0f ) ); // In renderable actor's coords.
+ mBackgroundActor.LowerToBottom();
+ }
+ }
}
}
void TextField::OnKeyInputFocusGained()
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyInputFocusGained %p\n", mController.Get() );
- if ( mInputMethodContext )
+ if ( mInputMethodContext && IsEditable() )
{
mInputMethodContext.ApplyOptions( mInputMethodOptions );
EmitKeyInputFocusSignal( false ); // Calls back into the Control hence done last.
}
+bool TextField::OnAccessibilityActivated()
+{
+ SetKeyInputFocus();
+ return true;
+}
+
void TextField::OnTap( const TapGesture& gesture )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnTap %p\n", mController.Get() );
- if ( mInputMethodContext )
+ if ( mInputMethodContext && IsEditable() )
{
mInputMethodContext.Activate();
}
// Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures
Extents padding;
padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
- mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x - padding.start, gesture.localPoint.y - padding.top );
+ const Vector2& localPoint = gesture.GetLocalPoint();
+ mController->TapEvent( gesture.GetNumberOfTaps(), localPoint.x - padding.start, localPoint.y - padding.top );
SetKeyInputFocus();
}
void TextField::OnPan( const PanGesture& gesture )
{
- mController->PanEvent( gesture.state, gesture.displacement );
+ mController->PanEvent( gesture.GetState(), gesture.GetDisplacement() );
}
void TextField::OnLongPress( const LongPressGesture& gesture )
{
- if ( mInputMethodContext )
+ if ( mInputMethodContext && IsEditable() )
{
mInputMethodContext.Activate();
}
Extents padding;
padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
- mController->LongPressEvent( gesture.state, gesture.localPoint.x - padding.start, gesture.localPoint.y - padding.top );
+ const Vector2& localPoint = gesture.GetLocalPoint();
+ mController->LongPressEvent( gesture.GetState(), localPoint.x - padding.start, localPoint.y - padding.top );
SetKeyInputFocus();
}
bool TextField::OnKeyEvent( const KeyEvent& event )
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyEvent %p keyCode %d\n", mController.Get(), event.keyCode );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyEvent %p keyCode %d\n", mController.Get(), event.GetKeyCode() );
- if( Dali::DALI_KEY_ESCAPE == event.keyCode && mController->ShouldClearFocusOnEscape() )
+ if( Dali::DALI_KEY_ESCAPE == event.GetKeyCode() && mController->ShouldClearFocusOnEscape() )
{
// Make sure ClearKeyInputFocus when only key is up
- if( event.state == KeyEvent::Up )
+ if( event.GetState() == KeyEvent::UP )
{
ClearKeyInputFocus();
}
return true;
}
- else if( Dali::DevelKey::DALI_KEY_RETURN == event.keyCode )
+ else if( Dali::DevelKey::DALI_KEY_RETURN == event.GetKeyCode() )
{
// Do nothing when enter is comming.
return false;
RelayoutRequest();
}
+bool TextField::IsEditable() const
+{
+ return mController->IsEditable();
+}
+
+void TextField::SetEditable( bool editable )
+{
+ mController->SetEditable(editable);
+ if ( mInputMethodContext && !editable )
+ {
+ mInputMethodContext.Deactivate();
+ }
+}
+
+void TextField::TextInserted( unsigned int position, unsigned int length, const std::string &content )
+{
+ if( Accessibility::IsUp() )
+ {
+ Control::Impl::GetAccessibilityObject( Self() )->EmitTextInserted( position, length, content );
+ }
+}
+
+void TextField::TextDeleted( unsigned int position, unsigned int length, const std::string &content )
+{
+ if( Accessibility::IsUp() )
+ {
+ Control::Impl::GetAccessibilityObject( Self() )->EmitTextDeleted( position, length, content );
+ }
+}
+
+void TextField::CaretMoved( unsigned int position )
+{
+ if( Accessibility::IsUp() )
+ {
+ Control::Impl::GetAccessibilityObject( Self() )->EmitTextCaretMoved( position );
+ }
+}
+
void TextField::TextChanged()
{
Dali::Toolkit::TextField handle( GetOwner() );
}
else
{
- actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
- actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+ actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
Self().Add( actor );
mActiveLayer = actor;
}
}
}
-void TextField::OnStageConnect( Dali::Actor actor )
+void TextField::OnSceneConnect( Dali::Actor actor )
{
if ( mHasBeenStaged )
{
{
if( mDecorator )
{
- ResourceImage image = ResourceImage::DownCast( mDecorator->GetHandleImage( handleType, handleImageType ) );
-
- if ( image )
- {
- Property::Map map;
- Scripting::CreatePropertyMap( image, map );
- value = map;
- }
+ Property::Map map;
+ map[ IMAGE_MAP_FILENAME_STRING ] = mDecorator->GetHandleImage( handleType, handleImageType );
+ value = map;
}
}
{
// Creates an extra control to be used as stencil buffer.
mStencil = Control::New();
- mStencil.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- mStencil.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ mStencil.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+ mStencil.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
// Creates a background visual. Even if the color is transparent it updates the stencil.
mStencil.SetProperty( Toolkit::Control::Property::BACKGROUND,
}
}
-void TextField::OnStageConnection( int depth )
+void TextField::OnSceneConnection( int depth )
{
// 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().
- // Call the Control::OnStageConnection() to set the depth of the background.
- Control::OnStageConnection( depth );
+ // Call the Control::OnSceneConnection() to set the depth of the background.
+ Control::OnSceneConnection( depth );
}
-bool TextField::OnTouched( Actor actor, const TouchData& touch )
+bool TextField::OnTouched( Actor actor, const TouchEvent& touch )
{
- return true;
+ return false;
}
void TextField::OnIdleSignal()
}
}
+std::string TextField::AccessibleImpl::GetName()
+{
+ auto slf = Toolkit::TextField::DownCast( self );
+ return slf.GetProperty( Toolkit::TextField::Property::TEXT ).Get< std::string >();
+}
+
+std::string TextField::AccessibleImpl::GetText( size_t startOffset,
+ size_t endOffset )
+{
+ if( endOffset <= startOffset )
+ return {};
+
+ auto slf = Toolkit::TextField::DownCast( self );
+ auto txt =
+ slf.GetProperty( Toolkit::TextField::Property::TEXT ).Get< std::string >();
+
+ if( startOffset > txt.size() || endOffset > txt.size() )
+ return {};
+
+ return txt.substr( startOffset, endOffset - startOffset );
+}
+
+size_t TextField::AccessibleImpl::GetCharacterCount()
+{
+ auto slf = Toolkit::TextField::DownCast( self );
+ auto txt =
+ slf.GetProperty( Toolkit::TextField::Property::TEXT ).Get< std::string >();
+
+ return txt.size();
+}
+
+size_t TextField::AccessibleImpl::GetCaretOffset()
+{
+ auto slf = Toolkit::TextField::DownCast( self );
+ return Dali::Toolkit::GetImpl( slf ).getController()->GetCursorPosition();
+}
+
+bool TextField::AccessibleImpl::SetCaretOffset(size_t offset)
+{
+ auto slf = Toolkit::TextField::DownCast( self );
+ auto txt = slf.GetProperty( Toolkit::TextField::Property::TEXT ).Get< std::string >();
+ if (offset > txt.size())
+ return false;
+
+ auto& slfImpl = Dali::Toolkit::GetImpl( slf );
+ slfImpl.getController()->ResetCursorPosition( offset );
+ slfImpl.RequestTextRelayout();
+ return true;
+}
+
+Dali::Accessibility::Range TextField::AccessibleImpl::GetTextAtOffset(
+ size_t offset, Dali::Accessibility::TextBoundary boundary )
+{
+ auto slf = Toolkit::TextField::DownCast( self );
+ auto txt = slf.GetProperty( Toolkit::TextField::Property::TEXT ).Get< std::string >();
+ auto txt_size = txt.size();
+
+ auto range = Dali::Accessibility::Range{};
+
+ switch(boundary)
+ {
+ case Dali::Accessibility::TextBoundary::CHARACTER:
+ {
+ if (offset < txt_size)
+ {
+ range.content = txt[offset];
+ range.startOffset = offset;
+ range.endOffset = offset + 1;
+ }
+ }
+ break;
+ case Dali::Accessibility::TextBoundary::WORD:
+ case Dali::Accessibility::TextBoundary::LINE:
+ {
+ auto txt_c_string = txt.c_str();
+ auto breaks = std::vector< char >( txt_size, 0 );
+ if(boundary == Dali::Accessibility::TextBoundary::WORD)
+ Accessibility::Accessible::FindWordSeparationsUtf8((const utf8_t *) txt_c_string, txt_size, "", breaks.data());
+ else
+ Accessibility::Accessible::FindLineSeparationsUtf8((const utf8_t *) txt_c_string, txt_size, "", breaks.data());
+ auto index = 0u;
+ auto counter = 0u;
+ while( index < txt_size && counter <= offset )
+ {
+ auto start = index;
+ if(breaks[index])
+ {
+ while(breaks[index])
+ index++;
+ counter++;
+ }
+ else
+ {
+ if (boundary == Dali::Accessibility::TextBoundary::WORD)
+ index++;
+ if (boundary == Dali::Accessibility::TextBoundary::LINE)
+ counter++;
+ }
+ if ((counter > 0) && ((counter - 1) == offset))
+ {
+ range.content = txt.substr(start, index - start + 1);
+ range.startOffset = start;
+ range.endOffset = index + 1;
+ }
+ if (boundary == Dali::Accessibility::TextBoundary::LINE)
+ index++;
+ }
+ }
+ break;
+ case Dali::Accessibility::TextBoundary::SENTENCE:
+ {
+ /* not supported by efl */
+ }
+ break;
+ case Dali::Accessibility::TextBoundary::PARAGRAPH:
+ {
+ /* Paragraph is not supported by libunibreak library */
+ }
+ break;
+ default:
+ break;
+ }
+
+ return range;
+}
+
+Dali::Accessibility::Range
+TextField::AccessibleImpl::GetSelection( size_t selectionNum )
+{
+ // Since DALi supports only one selection indexes higher than 0 are ignored
+ if( selectionNum > 0 )
+ return {};
+
+ auto slf = Toolkit::TextField::DownCast( self );
+ auto ctrl = Dali::Toolkit::GetImpl( slf ).getController();
+ std::string ret;
+ ctrl->RetrieveSelection( ret );
+ auto r = ctrl->GetSelectionIndexes();
+
+ return { static_cast<size_t>(r.first), static_cast<size_t>(r.second), ret };
+}
+
+bool TextField::AccessibleImpl::RemoveSelection( size_t selectionNum )
+{
+ // Since DALi supports only one selection indexes higher than 0 are ignored
+ if( selectionNum > 0 )
+ return false;
+
+ auto slf = Toolkit::TextField::DownCast( self );
+ Dali::Toolkit::GetImpl( slf ).getController()->SetSelection( 0, 0 );
+ return true;
+}
+
+bool TextField::AccessibleImpl::SetSelection( size_t selectionNum,
+ size_t startOffset,
+ size_t endOffset )
+{
+ // Since DALi supports only one selection indexes higher than 0 are ignored
+ if( selectionNum > 0 )
+ return false;
+
+ auto slf = Toolkit::TextField::DownCast( self );
+ Dali::Toolkit::GetImpl( slf ).getController()->SetSelection( startOffset,
+ endOffset );
+ return true;
+}
+
+bool TextField::AccessibleImpl::CopyText( size_t startPosition,
+ size_t endPosition )
+{
+ if( endPosition <= startPosition )
+ return false;
+
+ auto slf = Toolkit::TextField::DownCast( self );
+ auto txt = slf.GetProperty( Toolkit::TextField::Property::TEXT ).Get<std::string>();
+ Dali::Toolkit::GetImpl( slf ).getController()->CopyStringToClipboard( txt.substr(startPosition, endPosition - startPosition) );
+
+ return true;
+}
+
+bool TextField::AccessibleImpl::CutText( size_t startPosition,
+ size_t endPosition )
+{
+ if( endPosition <= startPosition )
+ return false;
+
+ auto slf = Toolkit::TextField::DownCast( self );
+ auto txt = slf.GetProperty( Toolkit::TextField::Property::TEXT ).Get<std::string>();
+ Dali::Toolkit::GetImpl( slf ).getController()->CopyStringToClipboard( txt.substr(startPosition, endPosition - startPosition) );
+
+ slf.SetProperty( Toolkit::TextField::Property::TEXT,
+ txt.substr( 0, startPosition ) + txt.substr( endPosition - startPosition, txt.size()));
+
+ return true;
+}
+
+Dali::Accessibility::States TextField::AccessibleImpl::CalculateStates()
+{
+ using namespace Dali::Accessibility;
+
+ auto states = Control::Impl::AccessibleImpl::CalculateStates();
+
+ states[State::EDITABLE] = true;
+ states[State::FOCUSABLE] = true;
+
+ Toolkit::Control focusControl = Toolkit::KeyInputFocusManager::Get().GetCurrentFocusControl();
+ if (self == focusControl)
+ {
+ states[State::FOCUSED] = true;
+ }
+
+ return states;
+}
+
} // namespace Internal
} // namespace Toolkit