2 * Copyright (c) 2017 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/controls/text-controls/text-editor-impl.h>
24 #include <dali/public-api/adaptor-framework/key.h>
25 #include <dali/public-api/common/stage.h>
26 #include <dali/public-api/images/resource-image.h>
27 #include <dali/devel-api/adaptor-framework/virtual-keyboard.h>
28 #include <dali/devel-api/object/property-helper-devel.h>
29 #include <dali/public-api/object/type-registry-helper.h>
30 #include <dali/integration-api/adaptors/adaptor.h>
31 #include <dali/integration-api/debug.h>
34 #include <dali-toolkit/public-api/text/rendering-backend.h>
35 #include <dali-toolkit/public-api/visuals/color-visual-properties.h>
36 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
37 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
38 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
39 #include <dali-toolkit/internal/text/rendering/text-backend.h>
40 #include <dali-toolkit/internal/text/text-effects-style.h>
41 #include <dali-toolkit/internal/text/text-font-style.h>
42 #include <dali-toolkit/internal/text/text-view.h>
43 #include <dali-toolkit/internal/styling/style-manager-impl.h>
45 using namespace Dali::Toolkit::Text;
56 namespace // unnamed namespace
59 #if defined(DEBUG_ENABLED)
60 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_CONTROLS");
63 const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
64 const float DEFAULT_SCROLL_SPEED = 1200.f; ///< The default scroll speed for the text editor in pixels/second.
65 } // unnamed namespace
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] );
81 return Toolkit::TextEditor::New();
84 // Setup properties, signals and actions using the type-registry.
85 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TextEditor, Toolkit::Control, Create );
87 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "renderingBackend", INTEGER, RENDERING_BACKEND )
88 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "text", STRING, TEXT )
89 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "textColor", VECTOR4, TEXT_COLOR )
90 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "fontFamily", STRING, FONT_FAMILY )
91 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "fontStyle", MAP, FONT_STYLE )
92 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "pointSize", FLOAT, POINT_SIZE )
93 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "horizontalAlignment", STRING, HORIZONTAL_ALIGNMENT )
94 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "scrollThreshold", FLOAT, SCROLL_THRESHOLD )
95 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "scrollSpeed", FLOAT, SCROLL_SPEED )
96 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "primaryCursorColor", VECTOR4, PRIMARY_CURSOR_COLOR )
97 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "secondaryCursorColor", VECTOR4, SECONDARY_CURSOR_COLOR )
98 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "enableCursorBlink", BOOLEAN, ENABLE_CURSOR_BLINK )
99 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "cursorBlinkInterval", FLOAT, CURSOR_BLINK_INTERVAL )
100 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "cursorBlinkDuration", FLOAT, CURSOR_BLINK_DURATION )
101 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "cursorWidth", INTEGER, CURSOR_WIDTH )
102 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "grabHandleImage", STRING, GRAB_HANDLE_IMAGE )
103 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "grabHandlePressedImage", STRING, GRAB_HANDLE_PRESSED_IMAGE )
104 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "selectionHandleImageLeft", MAP, SELECTION_HANDLE_IMAGE_LEFT )
105 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "selectionHandleImageRight", MAP, SELECTION_HANDLE_IMAGE_RIGHT )
106 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "selectionHandlePressedImageLeft", MAP, SELECTION_HANDLE_PRESSED_IMAGE_LEFT )
107 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "selectionHandlePressedImageRight", MAP, SELECTION_HANDLE_PRESSED_IMAGE_RIGHT )
108 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "selectionHandleMarkerImageLeft", MAP, SELECTION_HANDLE_MARKER_IMAGE_LEFT )
109 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "selectionHandleMarkerImageRight", MAP, SELECTION_HANDLE_MARKER_IMAGE_RIGHT )
110 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "selectionHighlightColor", VECTOR4, SELECTION_HIGHLIGHT_COLOR )
111 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "decorationBoundingBox", RECTANGLE, DECORATION_BOUNDING_BOX )
112 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "enableMarkup", BOOLEAN, ENABLE_MARKUP )
113 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputColor", VECTOR4, INPUT_COLOR )
114 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputFontFamily", STRING, INPUT_FONT_FAMILY )
115 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputFontStyle", MAP, INPUT_FONT_STYLE )
116 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputPointSize", FLOAT, INPUT_POINT_SIZE )
117 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "lineSpacing", FLOAT, LINE_SPACING )
118 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputLineSpacing", FLOAT, INPUT_LINE_SPACING )
119 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "underline", MAP, UNDERLINE )
120 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputUnderline", MAP, INPUT_UNDERLINE )
121 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "shadow", MAP, SHADOW )
122 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputShadow", MAP, INPUT_SHADOW )
123 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "emboss", MAP, EMBOSS )
124 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputEmboss", MAP, INPUT_EMBOSS )
125 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "outline", MAP, OUTLINE )
126 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputOutline", MAP, INPUT_OUTLINE )
127 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "smoothScroll", BOOLEAN, SMOOTH_SCROLL )
128 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "smoothScrollDuration", FLOAT, SMOOTH_SCROLL_DURATION )
130 DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "textChanged", SIGNAL_TEXT_CHANGED )
131 DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED )
133 DALI_TYPE_REGISTRATION_END()
137 Toolkit::TextEditor TextEditor::New()
139 // Create the implementation, temporarily owned by this handle on stack
140 IntrusivePtr< TextEditor > impl = new TextEditor();
142 // Pass ownership to CustomActor handle
143 Toolkit::TextEditor handle( *impl );
145 // Second-phase init of the implementation
146 // This can only be done after the CustomActor connection has been made...
152 void TextEditor::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
154 Toolkit::TextEditor textEditor = Toolkit::TextEditor::DownCast( Dali::BaseHandle( object ) );
156 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor SetProperty\n");
161 TextEditor& impl( GetImpl( textEditor ) );
165 case Toolkit::TextEditor::Property::RENDERING_BACKEND:
167 int backend = value.Get< int >();
168 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p RENDERING_BACKEND %d\n", impl.mController.Get(), backend );
170 if( impl.mRenderingBackend != backend )
172 impl.mRenderingBackend = backend;
173 impl.mRenderer.Reset();
174 impl.RequestTextRelayout();
178 case Toolkit::TextEditor::Property::TEXT:
180 if( impl.mController )
182 const std::string& text = value.Get< std::string >();
183 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p TEXT %s\n", impl.mController.Get(), text.c_str() );
185 impl.mController->SetText( text );
189 case Toolkit::TextEditor::Property::TEXT_COLOR:
191 if( impl.mController )
193 const Vector4& textColor = value.Get< Vector4 >();
194 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a );
196 if( impl.mController->GetDefaultColor() != textColor )
198 impl.mController->SetDefaultColor( textColor );
199 impl.mController->SetInputColor( textColor );
200 impl.mRenderer.Reset();
205 case Toolkit::TextEditor::Property::FONT_FAMILY:
207 if( impl.mController )
209 const std::string& fontFamily = value.Get< std::string >();
210 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
211 impl.mController->SetDefaultFontFamily( fontFamily );
215 case Toolkit::TextEditor::Property::FONT_STYLE:
217 SetFontStyleProperty( impl.mController, value, Text::FontStyle::DEFAULT );
220 case Toolkit::TextEditor::Property::POINT_SIZE:
222 if( impl.mController )
224 const float pointSize = value.Get< float >();
225 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p POINT_SIZE %f\n", impl.mController.Get(), pointSize );
227 if( !Equals( impl.mController->GetDefaultPointSize(), pointSize ) )
229 impl.mController->SetDefaultPointSize( pointSize );
234 case Toolkit::TextEditor::Property::HORIZONTAL_ALIGNMENT:
236 if( impl.mController )
238 const std::string& alignStr = value.Get< std::string >();
239 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p HORIZONTAL_ALIGNMENT %s\n", impl.mController.Get(), alignStr.c_str() );
241 Layout::HorizontalAlignment alignment( Layout::HORIZONTAL_ALIGN_BEGIN );
242 if( Scripting::GetEnumeration< Layout::HorizontalAlignment >( alignStr.c_str(),
243 HORIZONTAL_ALIGNMENT_STRING_TABLE,
244 HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
247 impl.mController->SetHorizontalAlignment( alignment );
252 case Toolkit::TextEditor::Property::SCROLL_THRESHOLD:
254 const float threshold = value.Get< float >();
255 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p SCROLL_THRESHOLD %f\n", impl.mController.Get(), threshold );
257 if( impl.mDecorator )
259 impl.mDecorator->SetScrollThreshold( threshold );
263 case Toolkit::TextEditor::Property::SCROLL_SPEED:
265 const float speed = value.Get< float >();
266 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p SCROLL_SPEED %f\n", impl.mController.Get(), speed );
268 if( impl.mDecorator )
270 impl.mDecorator->SetScrollSpeed( speed );
274 case Toolkit::TextEditor::Property::PRIMARY_CURSOR_COLOR:
276 if( impl.mDecorator )
278 const Vector4& color = value.Get< Vector4 >();
279 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p PRIMARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
281 impl.mDecorator->SetCursorColor( PRIMARY_CURSOR, color );
282 impl.RequestTextRelayout();
286 case Toolkit::TextEditor::Property::SECONDARY_CURSOR_COLOR:
288 if( impl.mDecorator )
290 const Vector4& color = value.Get< Vector4 >();
291 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p SECONDARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
293 impl.mDecorator->SetCursorColor( SECONDARY_CURSOR, color );
294 impl.RequestTextRelayout();
298 case Toolkit::TextEditor::Property::ENABLE_CURSOR_BLINK:
300 if( impl.mController )
302 const bool enable = value.Get< bool >();
303 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p ENABLE_CURSOR_BLINK %d\n", impl.mController.Get(), enable );
305 impl.mController->SetEnableCursorBlink( enable );
306 impl.RequestTextRelayout();
310 case Toolkit::TextEditor::Property::CURSOR_BLINK_INTERVAL:
312 if( impl.mDecorator )
314 const float interval = value.Get< float >();
315 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p CURSOR_BLINK_INTERVAL %f\n", impl.mController.Get(), interval );
317 impl.mDecorator->SetCursorBlinkInterval( interval );
321 case Toolkit::TextEditor::Property::CURSOR_BLINK_DURATION:
323 if( impl.mDecorator )
325 const float duration = value.Get< float >();
326 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p CURSOR_BLINK_DURATION %f\n", impl.mController.Get(), duration );
328 impl.mDecorator->SetCursorBlinkDuration( duration );
332 case Toolkit::TextEditor::Property::CURSOR_WIDTH:
334 if( impl.mDecorator )
336 const int width = value.Get< int >();
337 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p CURSOR_WIDTH %d\n", impl.mController.Get(), width );
339 impl.mDecorator->SetCursorWidth( width );
340 impl.mController->GetLayoutEngine().SetCursorWidth( width );
344 case Toolkit::TextEditor::Property::GRAB_HANDLE_IMAGE:
346 const ResourceImage image = ResourceImage::New( value.Get< std::string >() );
347 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p GRAB_HANDLE_IMAGE %s\n", impl.mController.Get(), image.GetUrl().c_str() );
349 if( impl.mDecorator )
351 impl.mDecorator->SetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED, image );
352 impl.RequestTextRelayout();
356 case Toolkit::TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE:
358 const ResourceImage image = ResourceImage::New( value.Get< std::string >() );
359 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p GRAB_HANDLE_PRESSED_IMAGE %s\n", impl.mController.Get(), image.GetUrl().c_str() );
361 if( impl.mDecorator )
363 impl.mDecorator->SetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED, image );
364 impl.RequestTextRelayout();
368 case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT:
370 const Image image = Scripting::NewImage( value );
372 if( impl.mDecorator && image )
374 impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, image );
375 impl.RequestTextRelayout();
379 case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT:
381 const Image image = Scripting::NewImage( value );
383 if( impl.mDecorator && image )
385 impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, image );
386 impl.RequestTextRelayout();
390 case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
392 const Image image = Scripting::NewImage( value );
394 if( impl.mDecorator && image )
396 impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, image );
397 impl.RequestTextRelayout();
401 case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
403 const Image image = Scripting::NewImage( value );
405 if( impl.mDecorator && image )
407 impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, image );
408 impl.RequestTextRelayout();
412 case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
414 const Image image = Scripting::NewImage( value );
416 if( impl.mDecorator && image )
418 impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, image );
419 impl.RequestTextRelayout();
423 case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
425 const Image image = Scripting::NewImage( value );
427 if( impl.mDecorator && image )
429 impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, image );
430 impl.RequestTextRelayout();
434 case Toolkit::TextEditor::Property::SELECTION_HIGHLIGHT_COLOR:
436 const Vector4 color = value.Get< Vector4 >();
437 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p SELECTION_HIGHLIGHT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
439 if( impl.mDecorator )
441 impl.mDecorator->SetHighlightColor( color );
442 impl.RequestTextRelayout();
446 case Toolkit::TextEditor::Property::DECORATION_BOUNDING_BOX:
448 if( impl.mDecorator )
450 const Rect<int>& box = value.Get< Rect<int> >();
451 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p DECORATION_BOUNDING_BOX %d,%d %dx%d\n", impl.mController.Get(), box.x, box.y, box.width, box.height );
453 impl.mDecorator->SetBoundingBox( box );
454 impl.RequestTextRelayout();
458 case Toolkit::TextEditor::Property::ENABLE_MARKUP:
460 if( impl.mController )
462 const bool enableMarkup = value.Get<bool>();
463 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p ENABLE_MARKUP %d\n", impl.mController.Get(), enableMarkup );
465 impl.mController->SetMarkupProcessorEnabled( enableMarkup );
469 case Toolkit::TextEditor::Property::INPUT_COLOR:
471 if( impl.mController )
473 const Vector4& inputColor = value.Get< Vector4 >();
474 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p INPUT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), inputColor.r, inputColor.g, inputColor.b, inputColor.a );
476 impl.mController->SetInputColor( inputColor );
480 case Toolkit::TextEditor::Property::INPUT_FONT_FAMILY:
482 if( impl.mController )
484 const std::string& fontFamily = value.Get< std::string >();
485 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p INPUT_FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
486 impl.mController->SetInputFontFamily( fontFamily );
490 case Toolkit::TextEditor::Property::INPUT_FONT_STYLE:
492 SetFontStyleProperty( impl.mController, value, Text::FontStyle::INPUT );
495 case Toolkit::TextEditor::Property::INPUT_POINT_SIZE:
497 if( impl.mController )
499 const float pointSize = value.Get< float >();
500 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p INPUT_POINT_SIZE %f\n", impl.mController.Get(), pointSize );
501 impl.mController->SetInputFontPointSize( pointSize );
505 case Toolkit::TextEditor::Property::LINE_SPACING:
507 if( impl.mController )
509 const float lineSpacing = value.Get<float>();
510 impl.mController->SetDefaultLineSpacing( lineSpacing );
511 impl.mRenderer.Reset();
515 case Toolkit::TextEditor::Property::INPUT_LINE_SPACING:
517 if( impl.mController )
519 const float lineSpacing = value.Get<float>();
520 impl.mController->SetInputLineSpacing( lineSpacing );
521 impl.mRenderer.Reset();
525 case Toolkit::TextEditor::Property::UNDERLINE:
527 const bool update = SetUnderlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
530 impl.mRenderer.Reset();
534 case Toolkit::TextEditor::Property::INPUT_UNDERLINE:
536 const bool update = SetUnderlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
539 impl.mRenderer.Reset();
543 case Toolkit::TextEditor::Property::SHADOW:
545 const bool update = SetShadowProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
548 impl.mRenderer.Reset();
552 case Toolkit::TextEditor::Property::INPUT_SHADOW:
554 const bool update = SetShadowProperties( impl.mController, value, Text::EffectStyle::INPUT );
557 impl.mRenderer.Reset();
561 case Toolkit::TextEditor::Property::EMBOSS:
563 const bool update = SetEmbossProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
566 impl.mRenderer.Reset();
570 case Toolkit::TextEditor::Property::INPUT_EMBOSS:
572 const bool update = SetEmbossProperties( impl.mController, value, Text::EffectStyle::INPUT );
575 impl.mRenderer.Reset();
579 case Toolkit::TextEditor::Property::OUTLINE:
581 const bool update = SetOutlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
584 impl.mRenderer.Reset();
588 case Toolkit::TextEditor::Property::INPUT_OUTLINE:
590 const bool update = SetOutlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
593 impl.mRenderer.Reset();
597 case Toolkit::DevelTextEditor::Property::SMOOTH_SCROLL:
599 const bool enable = value.Get< bool >();
600 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor SMOOTH_SCROLL %d\n", enable );
602 impl.mScrollAnimationEnabled = enable;
605 case Toolkit::DevelTextEditor::Property::SMOOTH_SCROLL_DURATION:
607 const float duration = value.Get< float >();
608 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor SMOOTH_SCROLL_DURATION %f\n", duration );
610 impl.mScrollAnimationDuration = duration;
611 if ( impl.mTextVerticalScroller )
613 impl.mTextVerticalScroller->SetDuration( duration );
621 Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index index )
623 Property::Value value;
625 Toolkit::TextEditor textEditor = Toolkit::TextEditor::DownCast( Dali::BaseHandle( object ) );
629 TextEditor& impl( GetImpl( textEditor ) );
633 case Toolkit::TextEditor::Property::RENDERING_BACKEND:
635 value = impl.mRenderingBackend;
638 case Toolkit::TextEditor::Property::TEXT:
640 if( impl.mController )
643 impl.mController->GetText( text );
644 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p returning text: %s\n", impl.mController.Get(), text.c_str() );
649 case Toolkit::TextEditor::Property::TEXT_COLOR:
651 if ( impl.mController )
653 value = impl.mController->GetDefaultColor();
657 case Toolkit::TextEditor::Property::FONT_FAMILY:
659 if( impl.mController )
661 value = impl.mController->GetDefaultFontFamily();
665 case Toolkit::TextEditor::Property::FONT_STYLE:
667 GetFontStyleProperty( impl.mController, value, Text::FontStyle::DEFAULT );
670 case Toolkit::TextEditor::Property::POINT_SIZE:
672 if( impl.mController )
674 value = impl.mController->GetDefaultPointSize();
678 case Toolkit::TextEditor::Property::HORIZONTAL_ALIGNMENT:
680 if( impl.mController )
682 const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::HorizontalAlignment >( impl.mController->GetHorizontalAlignment(),
683 HORIZONTAL_ALIGNMENT_STRING_TABLE,
684 HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
687 value = std::string( name );
692 case Toolkit::TextEditor::Property::SCROLL_THRESHOLD:
694 if( impl.mDecorator )
696 value = impl.mDecorator->GetScrollThreshold();
700 case Toolkit::TextEditor::Property::SCROLL_SPEED:
702 if( impl.mDecorator )
704 value = impl.mDecorator->GetScrollSpeed();
708 case Toolkit::TextEditor::Property::PRIMARY_CURSOR_COLOR:
710 if( impl.mDecorator )
712 value = impl.mDecorator->GetColor( PRIMARY_CURSOR );
716 case Toolkit::TextEditor::Property::SECONDARY_CURSOR_COLOR:
718 if( impl.mDecorator )
720 value = impl.mDecorator->GetColor( SECONDARY_CURSOR );
724 case Toolkit::TextEditor::Property::ENABLE_CURSOR_BLINK:
726 value = impl.mController->GetEnableCursorBlink();
729 case Toolkit::TextEditor::Property::CURSOR_BLINK_INTERVAL:
731 if( impl.mDecorator )
733 value = impl.mDecorator->GetCursorBlinkInterval();
737 case Toolkit::TextEditor::Property::CURSOR_BLINK_DURATION:
739 if( impl.mDecorator )
741 value = impl.mDecorator->GetCursorBlinkDuration();
745 case Toolkit::TextEditor::Property::CURSOR_WIDTH:
747 if( impl.mDecorator )
749 value = impl.mDecorator->GetCursorWidth();
753 case Toolkit::TextEditor::Property::GRAB_HANDLE_IMAGE:
755 if( impl.mDecorator )
757 ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED ) );
760 value = image.GetUrl();
765 case Toolkit::TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE:
767 if( impl.mDecorator )
769 ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED ) );
772 value = image.GetUrl();
777 case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT:
779 impl.GetHandleImagePropertyValue( value, LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED );
782 case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT:
784 impl.GetHandleImagePropertyValue( value, RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED ) ;
787 case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
789 impl.GetHandleImagePropertyValue( value, LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED );
792 case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
794 impl.GetHandleImagePropertyValue( value, RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED );
797 case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
799 impl.GetHandleImagePropertyValue( value, LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED );
802 case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
804 impl.GetHandleImagePropertyValue( value, RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED );
807 case Toolkit::TextEditor::Property::SELECTION_HIGHLIGHT_COLOR:
809 if( impl.mDecorator )
811 value = impl.mDecorator->GetHighlightColor();
815 case Toolkit::TextEditor::Property::DECORATION_BOUNDING_BOX:
817 if( impl.mDecorator )
819 Rect<int> boundingBox;
820 impl.mDecorator->GetBoundingBox( boundingBox );
825 case Toolkit::TextEditor::Property::ENABLE_MARKUP:
827 if( impl.mController )
829 value = impl.mController->IsMarkupProcessorEnabled();
833 case Toolkit::TextEditor::Property::INPUT_COLOR:
835 if( impl.mController )
837 value = impl.mController->GetInputColor();
841 case Toolkit::TextEditor::Property::INPUT_FONT_FAMILY:
843 if( impl.mController )
845 value = impl.mController->GetInputFontFamily();
849 case Toolkit::TextEditor::Property::INPUT_FONT_STYLE:
851 GetFontStyleProperty( impl.mController, value, Text::FontStyle::INPUT );
854 case Toolkit::TextEditor::Property::INPUT_POINT_SIZE:
856 if( impl.mController )
858 value = impl.mController->GetInputFontPointSize();
862 case Toolkit::TextEditor::Property::LINE_SPACING:
864 if( impl.mController )
866 value = impl.mController->GetDefaultLineSpacing();
870 case Toolkit::TextEditor::Property::INPUT_LINE_SPACING:
872 if( impl.mController )
874 value = impl.mController->GetInputLineSpacing();
878 case Toolkit::TextEditor::Property::UNDERLINE:
880 GetUnderlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
883 case Toolkit::TextEditor::Property::INPUT_UNDERLINE:
885 GetUnderlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
888 case Toolkit::TextEditor::Property::SHADOW:
890 GetShadowProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
893 case Toolkit::TextEditor::Property::INPUT_SHADOW:
895 GetShadowProperties( impl.mController, value, Text::EffectStyle::INPUT );
898 case Toolkit::TextEditor::Property::EMBOSS:
900 GetEmbossProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
903 case Toolkit::TextEditor::Property::INPUT_EMBOSS:
905 GetEmbossProperties( impl.mController, value, Text::EffectStyle::INPUT );
908 case Toolkit::TextEditor::Property::OUTLINE:
910 GetOutlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
913 case Toolkit::TextEditor::Property::INPUT_OUTLINE:
915 GetOutlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
918 case Toolkit::DevelTextEditor::Property::SMOOTH_SCROLL:
920 value = impl.mScrollAnimationEnabled;
923 case Toolkit::DevelTextEditor::Property::SMOOTH_SCROLL_DURATION:
925 value = impl.mScrollAnimationDuration;
934 bool TextEditor::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
936 Dali::BaseHandle handle( object );
938 bool connected( true );
939 Toolkit::TextEditor editor = Toolkit::TextEditor::DownCast( handle );
941 if( 0 == strcmp( signalName.c_str(), SIGNAL_TEXT_CHANGED ) )
943 editor.TextChangedSignal().Connect( tracker, functor );
945 else if( 0 == strcmp( signalName.c_str(), SIGNAL_INPUT_STYLE_CHANGED ) )
947 editor.InputStyleChangedSignal().Connect( tracker, functor );
951 // signalName does not match any signal
958 Toolkit::TextEditor::TextChangedSignalType& TextEditor::TextChangedSignal()
960 return mTextChangedSignal;
963 Toolkit::TextEditor::InputStyleChangedSignalType& TextEditor::InputStyleChangedSignal()
965 return mInputStyleChangedSignal;
968 void TextEditor::OnInitialize()
972 mController = Text::Controller::New( this, this );
974 mDecorator = Text::Decorator::New( *mController,
977 mController->GetLayoutEngine().SetLayout( Layout::Engine::MULTI_LINE_BOX );
979 // Enables the text input.
980 mController->EnableTextInput( mDecorator );
982 // Enables the vertical scrolling after the text input has been enabled.
983 mController->SetVerticalScrollEnabled( true );
985 // Disables the horizontal scrolling.
986 mController->SetHorizontalScrollEnabled( false );
988 // Sets the maximum number of characters.
989 mController->SetMaximumNumberOfCharacters( std::numeric_limits<Length>::max() );
991 // Enable the smooth handle panning.
992 mController->SetSmoothHandlePanEnabled( true );
994 // Forward input events to controller
995 EnableGestureDetection( static_cast<Gesture::Type>( Gesture::Tap | Gesture::Pan | Gesture::LongPress ) );
996 GetTapGestureDetector().SetMaximumTapsRequired( 2 );
998 self.TouchSignal().Connect( this, &TextEditor::OnTouched );
1000 // Set BoundingBox to stage size if not already set.
1001 Rect<int> boundingBox;
1002 mDecorator->GetBoundingBox( boundingBox );
1004 if( boundingBox.IsEmpty() )
1006 Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
1007 mDecorator->SetBoundingBox( Rect<int>( 0.0f, 0.0f, stageSize.width, stageSize.height ) );
1010 // Whether to flip the selection handles as soon as they cross.
1011 mDecorator->FlipSelectionHandlesOnCrossEnabled( true );
1013 // Set the default scroll speed.
1014 mDecorator->SetScrollSpeed( DEFAULT_SCROLL_SPEED );
1016 // Fill-parent area by default
1017 self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
1018 self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
1019 self.OnStageSignal().Connect( this, &TextEditor::OnStageConnect );
1021 // Creates an extra control to be used as stencil buffer.
1022 mStencil = Control::New();
1023 mStencil.SetAnchorPoint( AnchorPoint::CENTER );
1024 mStencil.SetParentOrigin( ParentOrigin::CENTER );
1026 // Creates a background visual. Even if the color is transparent it updates the stencil.
1027 mStencil.SetProperty( Toolkit::Control::Property::BACKGROUND,
1028 Property::Map().Add( Toolkit::Visual::Property::TYPE, DevelVisual::COLOR ).
1029 Add( ColorVisual::Property::MIX_COLOR, Color::TRANSPARENT ) );
1031 // Enable the clipping property.
1032 mStencil.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
1033 mStencil.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
1035 self.Add( mStencil );
1038 void TextEditor::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
1040 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnStyleChange\n");
1044 case StyleChange::DEFAULT_FONT_CHANGE:
1046 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnStyleChange DEFAULT_FONT_CHANGE\n");
1047 const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily();
1048 // Property system did not set the font so should update it.
1049 mController->UpdateAfterFontChange( newFont );
1053 case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
1055 GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
1058 case StyleChange::THEME_CHANGE:
1060 GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
1066 Vector3 TextEditor::GetNaturalSize()
1068 return mController->GetNaturalSize();
1071 float TextEditor::GetHeightForWidth( float width )
1073 return mController->GetHeightForWidth( width );
1076 void TextEditor::OnRelayout( const Vector2& size, RelayoutContainer& container )
1078 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor OnRelayout\n");
1080 const Text::Controller::UpdateTextType updateTextType = mController->Relayout( size );
1082 if( ( Text::Controller::NONE_UPDATED != updateTextType ) ||
1085 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnRelayout %p Displaying new contents\n", mController.Get() );
1088 ( Text::Controller::NONE_UPDATED != ( Text::Controller::DECORATOR_UPDATED & updateTextType ) ) )
1090 mDecorator->Relayout( size );
1095 mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
1098 RenderText( updateTextType );
1101 // The text-editor emits signals when the input style changes. These changes of style are
1102 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1103 // can't be emitted during the size negotiation as the callbacks may update the UI.
1104 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1105 if( !mController->IsInputStyleChangedSignalsQueueEmpty() )
1107 if( Adaptor::IsAvailable() )
1109 Adaptor& adaptor = Adaptor::Get();
1111 if( NULL == mIdleCallback )
1113 // @note: The callback manager takes the ownership of the callback object.
1114 mIdleCallback = MakeCallback( this, &TextEditor::OnIdleSignal );
1115 adaptor.AddIdle( mIdleCallback );
1121 void TextEditor::RenderText( Text::Controller::UpdateTextType updateTextType )
1123 Actor renderableActor;
1125 if( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) )
1129 renderableActor = mRenderer->Render( mController->GetView(),
1131 DepthIndex::CONTENT );
1134 if( renderableActor != mRenderableActor )
1136 UnparentAndReset( mRenderableActor );
1137 mRenderableActor = renderableActor;
1141 if( mRenderableActor )
1143 // Make sure the actors are parented correctly with/without clipping
1144 Actor self = mStencil ? mStencil : Self();
1146 for( std::vector<Actor>::const_iterator it = mClippingDecorationActors.begin(),
1147 endIt = mClippingDecorationActors.end();
1153 mClippingDecorationActors.clear();
1155 self.Add( mRenderableActor );
1157 ApplyScrollPosition();
1161 void TextEditor::OnKeyInputFocusGained()
1163 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnKeyInputFocusGained %p\n", mController.Get() );
1165 VirtualKeyboard::StatusChangedSignal().Connect( this, &TextEditor::KeyboardStatusChanged );
1167 ImfManager imfManager = ImfManager::Get();
1171 imfManager.EventReceivedSignal().Connect( this, &TextEditor::OnImfEvent );
1173 // Notify that the text editing start.
1174 imfManager.Activate();
1176 // When window gain lost focus, the imf manager is deactivated. Thus when window gain focus again, the imf manager must be activated.
1177 imfManager.SetRestoreAfterFocusLost( true );
1180 ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
1184 notifier.ContentSelectedSignal().Connect( this, &TextEditor::OnClipboardTextSelected );
1187 mController->KeyboardFocusGainEvent(); // Called in the case of no virtual keyboard to trigger this event
1189 EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last.
1192 void TextEditor::OnKeyInputFocusLost()
1194 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor:OnKeyInputFocusLost %p\n", mController.Get() );
1196 VirtualKeyboard::StatusChangedSignal().Disconnect( this, &TextEditor::KeyboardStatusChanged );
1198 ImfManager imfManager = ImfManager::Get();
1201 // The text editing is finished. Therefore the imf manager don't have restore activation.
1202 imfManager.SetRestoreAfterFocusLost( false );
1204 // Notify that the text editing finish.
1205 imfManager.Deactivate();
1207 imfManager.EventReceivedSignal().Disconnect( this, &TextEditor::OnImfEvent );
1210 ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
1214 notifier.ContentSelectedSignal().Disconnect( this, &TextEditor::OnClipboardTextSelected );
1217 mController->KeyboardFocusLostEvent();
1219 EmitKeyInputFocusSignal( false ); // Calls back into the Control hence done last.
1222 void TextEditor::OnTap( const TapGesture& gesture )
1224 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnTap %p\n", mController.Get() );
1226 // Show the keyboard if it was hidden.
1227 if (!VirtualKeyboard::IsVisible())
1229 VirtualKeyboard::Show();
1232 // Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures
1233 mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x, gesture.localPoint.y );
1238 void TextEditor::OnPan( const PanGesture& gesture )
1240 mController->PanEvent( gesture.state, gesture.displacement );
1243 void TextEditor::OnLongPress( const LongPressGesture& gesture )
1245 // Show the keyboard if it was hidden.
1246 if (!VirtualKeyboard::IsVisible())
1248 VirtualKeyboard::Show();
1251 mController->LongPressEvent( gesture.state, gesture.localPoint.x, gesture.localPoint.y );
1256 bool TextEditor::OnKeyEvent( const KeyEvent& event )
1258 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnKeyEvent %p keyCode %d\n", mController.Get(), event.keyCode );
1260 if( Dali::DALI_KEY_ESCAPE == event.keyCode ) // Make a Dali key code for this
1262 ClearKeyInputFocus();
1266 return mController->KeyEvent( event );
1269 void TextEditor::RequestTextRelayout()
1274 void TextEditor::TextChanged()
1276 Dali::Toolkit::TextEditor handle( GetOwner() );
1277 mTextChangedSignal.Emit( handle );
1280 void TextEditor::MaxLengthReached()
1282 // Nothing to do as TextEditor doesn't emit a max length reached signal.
1285 void TextEditor::InputStyleChanged( Text::InputStyle::Mask inputStyleMask )
1287 Dali::Toolkit::TextEditor handle( GetOwner() );
1289 Toolkit::TextEditor::InputStyle::Mask editorInputStyleMask = Toolkit::TextEditor::InputStyle::NONE;
1291 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_COLOR ) )
1293 editorInputStyleMask = static_cast<Toolkit::TextEditor::InputStyle::Mask>( editorInputStyleMask | Toolkit::TextEditor::InputStyle::COLOR );
1295 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_FONT_FAMILY ) )
1297 editorInputStyleMask = static_cast<Toolkit::TextEditor::InputStyle::Mask>( editorInputStyleMask | Toolkit::TextEditor::InputStyle::FONT_FAMILY );
1299 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_POINT_SIZE ) )
1301 editorInputStyleMask = static_cast<Toolkit::TextEditor::InputStyle::Mask>( editorInputStyleMask | Toolkit::TextEditor::InputStyle::POINT_SIZE );
1303 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_FONT_WEIGHT ) )
1305 editorInputStyleMask = static_cast<Toolkit::TextEditor::InputStyle::Mask>( editorInputStyleMask | Toolkit::TextEditor::InputStyle::FONT_STYLE );
1307 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_FONT_WIDTH ) )
1309 editorInputStyleMask = static_cast<Toolkit::TextEditor::InputStyle::Mask>( editorInputStyleMask | Toolkit::TextEditor::InputStyle::FONT_STYLE );
1311 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_FONT_SLANT ) )
1313 editorInputStyleMask = static_cast<Toolkit::TextEditor::InputStyle::Mask>( editorInputStyleMask | Toolkit::TextEditor::InputStyle::FONT_STYLE );
1315 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_LINE_SPACING ) )
1317 editorInputStyleMask = static_cast<Toolkit::TextEditor::InputStyle::Mask>( editorInputStyleMask | Toolkit::TextEditor::InputStyle::LINE_SPACING );
1319 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_UNDERLINE ) )
1321 editorInputStyleMask = static_cast<Toolkit::TextEditor::InputStyle::Mask>( editorInputStyleMask | Toolkit::TextEditor::InputStyle::UNDERLINE );
1323 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_SHADOW ) )
1325 editorInputStyleMask = static_cast<Toolkit::TextEditor::InputStyle::Mask>( editorInputStyleMask | Toolkit::TextEditor::InputStyle::SHADOW );
1327 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_EMBOSS ) )
1329 editorInputStyleMask = static_cast<Toolkit::TextEditor::InputStyle::Mask>( editorInputStyleMask | Toolkit::TextEditor::InputStyle::EMBOSS );
1331 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_OUTLINE ) )
1333 editorInputStyleMask = static_cast<Toolkit::TextEditor::InputStyle::Mask>( editorInputStyleMask | Toolkit::TextEditor::InputStyle::OUTLINE );
1336 mInputStyleChangedSignal.Emit( handle, editorInputStyleMask );
1339 void TextEditor::AddDecoration( Actor& actor, bool needsClipping )
1345 mClippingDecorationActors.push_back( actor );
1349 Self().Add( actor );
1354 void TextEditor::OnStageConnect( Dali::Actor actor )
1356 if ( mHasBeenStaged )
1358 RenderText( static_cast<Text::Controller::UpdateTextType>( Text::Controller::MODEL_UPDATED | Text::Controller::DECORATOR_UPDATED ) );
1362 mHasBeenStaged = true;
1366 ImfManager::ImfCallbackData TextEditor::OnImfEvent( Dali::ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
1368 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnImfEvent %p eventName %d\n", mController.Get(), imfEvent.eventName );
1369 return mController->OnImfEvent( imfManager, imfEvent );
1372 void TextEditor::GetHandleImagePropertyValue( Property::Value& value, Text::HandleType handleType, Text::HandleImageType handleImageType )
1376 ResourceImage image = ResourceImage::DownCast( mDecorator->GetHandleImage( handleType, handleImageType ) );
1381 Scripting::CreatePropertyMap( image, map );
1387 void TextEditor::OnClipboardTextSelected( ClipboardEventNotifier& clipboard )
1389 mController->PasteClipboardItemEvent();
1392 void TextEditor::KeyboardStatusChanged(bool keyboardShown)
1394 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::KeyboardStatusChanged %p keyboardShown %d\n", mController.Get(), keyboardShown );
1396 // Just hide the grab handle when keyboard is hidden.
1397 if (!keyboardShown )
1399 mController->KeyboardFocusLostEvent();
1403 mController->KeyboardFocusGainEvent(); // Initially called by OnKeyInputFocusGained
1407 void TextEditor::OnStageConnection( int depth )
1409 // Sets the depth to the visuals inside the text's decorator.
1410 mDecorator->SetTextDepth( depth );
1412 // The depth of the text renderer is set in the RenderText() called from OnRelayout().
1414 // Call the Control::OnStageConnection() to set the depth of the background.
1415 Control::OnStageConnection( depth );
1418 bool TextEditor::OnTouched( Actor actor, const TouchData& touch )
1423 void TextEditor::OnIdleSignal()
1425 // Emits the change of input style signals.
1426 mController->ProcessInputStyleChangedSignals();
1428 // Set the pointer to null as the callback manager deletes the callback after execute it.
1429 mIdleCallback = NULL;
1432 void TextEditor::ApplyScrollPosition()
1434 const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition();
1435 float scrollAmount = 0.0f;
1437 if ( mScrollAnimationEnabled )
1439 scrollAmount = mController->GetScrollAmountByUserInput();
1441 if ( mTextVerticalScroller )
1443 mTextVerticalScroller->CheckStartAnimation( mRenderableActor, scrollOffset.x + mAlignmentOffset, scrollOffset.y - scrollAmount, scrollAmount );
1445 else if ( Equals( scrollAmount, 0.0f, Math::MACHINE_EPSILON_1 ))
1447 mRenderableActor.SetPosition( scrollOffset.x + mAlignmentOffset, scrollOffset.y - scrollAmount );
1451 mTextVerticalScroller = Text::TextVerticalScroller::New();
1452 if ( !Equals( mScrollAnimationDuration, 0.0f, Math::MACHINE_EPSILON_1 ))
1454 mTextVerticalScroller->SetDuration( mScrollAnimationDuration );
1456 mTextVerticalScroller->CheckStartAnimation( mRenderableActor, scrollOffset.x + mAlignmentOffset, scrollOffset.y - scrollAmount, scrollAmount );
1460 TextEditor::TextEditor()
1461 : Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
1462 mIdleCallback( NULL ),
1463 mAlignmentOffset( 0.f ),
1464 mScrollAnimationDuration( 0.f ),
1465 mRenderingBackend( DEFAULT_RENDERING_BACKEND ),
1466 mHasBeenStaged( false ),
1467 mScrollAnimationEnabled( false )
1471 TextEditor::~TextEditor()
1473 UnparentAndReset( mStencil );
1475 if( ( NULL != mIdleCallback ) && Adaptor::IsAvailable() )
1477 // Removes the callback from the callback manager in case the text-editor is destroyed before the callback is executed.
1478 Adaptor::Get().RemoveIdle( mIdleCallback );
1482 } // namespace Internal
1484 } // namespace Toolkit