2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/internal/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/public-api/object/type-registry-helper.h>
29 #include <dali/integration-api/adaptors/adaptor.h>
30 #include <dali/integration-api/debug.h>
33 #include <dali-toolkit/public-api/text/rendering-backend.h>
34 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
35 #include <dali-toolkit/internal/text/rendering/text-backend.h>
36 #include <dali-toolkit/internal/text/text-effects-style.h>
37 #include <dali-toolkit/internal/text/text-font-style.h>
38 #include <dali-toolkit/internal/text/text-view.h>
39 #include <dali-toolkit/internal/styling/style-manager-impl.h>
41 using namespace Dali::Toolkit::Text;
52 namespace // unnamed namespace
55 #if defined(DEBUG_ENABLED)
56 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_CONTROLS");
59 const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
60 const float DEFAULT_SCROLL_SPEED = 1200.f; ///< The default scroll speed for the text editor in pixels/second.
61 } // unnamed namespace
66 const Scripting::StringEnum HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
68 { "BEGIN", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_BEGIN },
69 { "CENTER", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_CENTER },
70 { "END", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_END },
72 const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] );
77 return Toolkit::TextEditor::New();
80 // Setup properties, signals and actions using the type-registry.
81 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TextEditor, Toolkit::Control, Create );
83 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "renderingBackend", INTEGER, RENDERING_BACKEND )
84 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "text", STRING, TEXT )
85 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "textColor", VECTOR4, TEXT_COLOR )
86 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "fontFamily", STRING, FONT_FAMILY )
87 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "fontStyle", STRING, FONT_STYLE )
88 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "pointSize", FLOAT, POINT_SIZE )
89 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "horizontalAlignment", STRING, HORIZONTAL_ALIGNMENT )
90 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "scrollThreshold", FLOAT, SCROLL_THRESHOLD )
91 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "scrollSpeed", FLOAT, SCROLL_SPEED )
92 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "primaryCursorColor", VECTOR4, PRIMARY_CURSOR_COLOR )
93 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "secondaryCursorColor", VECTOR4, SECONDARY_CURSOR_COLOR )
94 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "enableCursorBlink", BOOLEAN, ENABLE_CURSOR_BLINK )
95 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "cursorBlinkInterval", FLOAT, CURSOR_BLINK_INTERVAL )
96 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "cursorBlinkDuration", FLOAT, CURSOR_BLINK_DURATION )
97 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "cursorWidth", INTEGER, CURSOR_WIDTH )
98 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "grabHandleImage", STRING, GRAB_HANDLE_IMAGE )
99 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "grabHandlePressedImage", STRING, GRAB_HANDLE_PRESSED_IMAGE )
100 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "selectionHandleImageLeft", MAP, SELECTION_HANDLE_IMAGE_LEFT )
101 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "selectionHandleImageRight", MAP, SELECTION_HANDLE_IMAGE_RIGHT )
102 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "selectionHandlePressedImageLeft", MAP, SELECTION_HANDLE_PRESSED_IMAGE_LEFT )
103 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "selectionHandlePressedImageRight", MAP, SELECTION_HANDLE_PRESSED_IMAGE_RIGHT )
104 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "selectionHandleMarkerImageLeft", MAP, SELECTION_HANDLE_MARKER_IMAGE_LEFT )
105 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "selectionHandleMarkerImageRight", MAP, SELECTION_HANDLE_MARKER_IMAGE_RIGHT )
106 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "selectionHighlightColor", VECTOR4, SELECTION_HIGHLIGHT_COLOR )
107 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "decorationBoundingBox", RECTANGLE, DECORATION_BOUNDING_BOX )
108 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "enableMarkup", BOOLEAN, ENABLE_MARKUP )
109 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputColor", VECTOR4, INPUT_COLOR )
110 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputFontFamily", STRING, INPUT_FONT_FAMILY )
111 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputFontStyle", STRING, INPUT_FONT_STYLE )
112 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputPointSize", FLOAT, INPUT_POINT_SIZE )
113 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "lineSpacing", FLOAT, LINE_SPACING )
114 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputLineSpacing", FLOAT, INPUT_LINE_SPACING )
115 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "underline", STRING, UNDERLINE )
116 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputUnderline", STRING, INPUT_UNDERLINE )
117 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "shadow", STRING, SHADOW )
118 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputShadow", STRING, INPUT_SHADOW )
119 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "emboss", STRING, EMBOSS )
120 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputEmboss", STRING, INPUT_EMBOSS )
121 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "outline", STRING, OUTLINE )
122 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputOutline", STRING, INPUT_OUTLINE )
124 DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "textChanged", SIGNAL_TEXT_CHANGED )
125 DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED )
127 DALI_TYPE_REGISTRATION_END()
131 Toolkit::TextEditor TextEditor::New()
133 // Create the implementation, temporarily owned by this handle on stack
134 IntrusivePtr< TextEditor > impl = new TextEditor();
136 // Pass ownership to CustomActor handle
137 Toolkit::TextEditor handle( *impl );
139 // Second-phase init of the implementation
140 // This can only be done after the CustomActor connection has been made...
146 void TextEditor::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
148 Toolkit::TextEditor textEditor = Toolkit::TextEditor::DownCast( Dali::BaseHandle( object ) );
150 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor SetProperty\n");
155 TextEditor& impl( GetImpl( textEditor ) );
159 case Toolkit::TextEditor::Property::RENDERING_BACKEND:
161 int backend = value.Get< int >();
162 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p RENDERING_BACKEND %d\n", impl.mController.Get(), backend );
164 if( impl.mRenderingBackend != backend )
166 impl.mRenderingBackend = backend;
167 impl.mRenderer.Reset();
168 impl.RequestTextRelayout();
172 case Toolkit::TextEditor::Property::TEXT:
174 if( impl.mController )
176 const std::string text = value.Get< std::string >();
177 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p TEXT %s\n", impl.mController.Get(), text.c_str() );
179 impl.mController->SetText( text );
183 case Toolkit::TextEditor::Property::TEXT_COLOR:
185 if( impl.mController )
187 const Vector4 textColor = value.Get< Vector4 >();
188 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 );
190 if( impl.mController->GetTextColor() != textColor )
192 impl.mController->SetTextColor( textColor );
193 impl.mController->SetInputColor( textColor );
194 impl.mRenderer.Reset();
199 case Toolkit::TextEditor::Property::FONT_FAMILY:
201 if( impl.mController )
203 const std::string fontFamily = value.Get< std::string >();
204 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
205 impl.mController->SetDefaultFontFamily( fontFamily );
209 case Toolkit::TextEditor::Property::FONT_STYLE:
211 SetFontStyleProperty( impl.mController, value, Text::FontStyle::DEFAULT );
214 case Toolkit::TextEditor::Property::POINT_SIZE:
216 if( impl.mController )
218 const float pointSize = value.Get< float >();
219 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p POINT_SIZE %f\n", impl.mController.Get(), pointSize );
221 if( !Equals( impl.mController->GetDefaultPointSize(), pointSize ) )
223 impl.mController->SetDefaultPointSize( pointSize );
228 case Toolkit::TextEditor::Property::HORIZONTAL_ALIGNMENT:
230 if( impl.mController )
232 const std::string alignStr = value.Get< std::string >();
233 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p HORIZONTAL_ALIGNMENT %s\n", impl.mController.Get(), alignStr.c_str() );
235 LayoutEngine::HorizontalAlignment alignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN );
236 if( Scripting::GetEnumeration< LayoutEngine::HorizontalAlignment >( alignStr.c_str(),
237 HORIZONTAL_ALIGNMENT_STRING_TABLE,
238 HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
241 impl.mController->SetHorizontalAlignment( alignment );
246 case Toolkit::TextEditor::Property::SCROLL_THRESHOLD:
248 const float threshold = value.Get< float >();
249 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p SCROLL_THRESHOLD %f\n", impl.mController.Get(), threshold );
251 if( impl.mDecorator )
253 impl.mDecorator->SetScrollThreshold( threshold );
257 case Toolkit::TextEditor::Property::SCROLL_SPEED:
259 const float speed = value.Get< float >();
260 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p SCROLL_SPEED %f\n", impl.mController.Get(), speed );
262 if( impl.mDecorator )
264 impl.mDecorator->SetScrollSpeed( speed );
268 case Toolkit::TextEditor::Property::PRIMARY_CURSOR_COLOR:
270 if( impl.mDecorator )
272 const Vector4 color = value.Get< Vector4 >();
273 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 );
275 impl.mDecorator->SetCursorColor( PRIMARY_CURSOR, color );
276 impl.RequestTextRelayout();
280 case Toolkit::TextEditor::Property::SECONDARY_CURSOR_COLOR:
282 if( impl.mDecorator )
284 const Vector4 color = value.Get< Vector4 >();
285 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 );
287 impl.mDecorator->SetCursorColor( SECONDARY_CURSOR, color );
288 impl.RequestTextRelayout();
292 case Toolkit::TextEditor::Property::ENABLE_CURSOR_BLINK:
294 if( impl.mController )
296 const bool enable = value.Get< bool >();
297 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p ENABLE_CURSOR_BLINK %d\n", impl.mController.Get(), enable );
299 impl.mController->SetEnableCursorBlink( enable );
300 impl.RequestTextRelayout();
304 case Toolkit::TextEditor::Property::CURSOR_BLINK_INTERVAL:
306 if( impl.mDecorator )
308 const float interval = value.Get< float >();
309 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p CURSOR_BLINK_INTERVAL %f\n", impl.mController.Get(), interval );
311 impl.mDecorator->SetCursorBlinkInterval( interval );
315 case Toolkit::TextEditor::Property::CURSOR_BLINK_DURATION:
317 if( impl.mDecorator )
319 const float duration = value.Get< float >();
320 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p CURSOR_BLINK_DURATION %f\n", impl.mController.Get(), duration );
322 impl.mDecorator->SetCursorBlinkDuration( duration );
326 case Toolkit::TextEditor::Property::CURSOR_WIDTH:
328 if( impl.mDecorator )
330 const int width = value.Get< int >();
331 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p CURSOR_WIDTH %d\n", impl.mController.Get(), width );
333 impl.mDecorator->SetCursorWidth( width );
334 impl.mController->GetLayoutEngine().SetCursorWidth( width );
338 case Toolkit::TextEditor::Property::GRAB_HANDLE_IMAGE:
340 const ResourceImage image = ResourceImage::New( value.Get< std::string >() );
341 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p GRAB_HANDLE_IMAGE %s\n", impl.mController.Get(), image.GetUrl().c_str() );
343 if( impl.mDecorator )
345 impl.mDecorator->SetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED, image );
346 impl.RequestTextRelayout();
350 case Toolkit::TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE:
352 const ResourceImage image = ResourceImage::New( value.Get< std::string >() );
353 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor %p GRAB_HANDLE_PRESSED_IMAGE %s\n", impl.mController.Get(), image.GetUrl().c_str() );
355 if( impl.mDecorator )
357 impl.mDecorator->SetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED, image );
358 impl.RequestTextRelayout();
362 case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT:
364 const Image image = Scripting::NewImage( value );
366 if( impl.mDecorator && image )
368 impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, image );
369 impl.RequestTextRelayout();
373 case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT:
375 const Image image = Scripting::NewImage( value );
377 if( impl.mDecorator && image )
379 impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, image );
380 impl.RequestTextRelayout();
384 case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
386 const Image image = Scripting::NewImage( value );
388 if( impl.mDecorator && image )
390 impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, image );
391 impl.RequestTextRelayout();
395 case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
397 const Image image = Scripting::NewImage( value );
399 if( impl.mDecorator && image )
401 impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, image );
402 impl.RequestTextRelayout();
406 case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
408 const Image image = Scripting::NewImage( value );
410 if( impl.mDecorator && image )
412 impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, image );
413 impl.RequestTextRelayout();
417 case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
419 const Image image = Scripting::NewImage( value );
421 if( impl.mDecorator && image )
423 impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, image );
424 impl.RequestTextRelayout();
428 case Toolkit::TextEditor::Property::SELECTION_HIGHLIGHT_COLOR:
430 const Vector4 color = value.Get< Vector4 >();
431 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 );
433 if( impl.mDecorator )
435 impl.mDecorator->SetHighlightColor( color );
436 impl.RequestTextRelayout();
440 case Toolkit::TextEditor::Property::DECORATION_BOUNDING_BOX:
442 if( impl.mDecorator )
444 const Rect<int> box = value.Get< Rect<int> >();
445 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 );
447 impl.mDecorator->SetBoundingBox( box );
448 impl.RequestTextRelayout();
452 case Toolkit::TextEditor::Property::ENABLE_MARKUP:
454 if( impl.mController )
456 const bool enableMarkup = value.Get<bool>();
457 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p ENABLE_MARKUP %d\n", impl.mController.Get(), enableMarkup );
459 impl.mController->SetMarkupProcessorEnabled( enableMarkup );
463 case Toolkit::TextEditor::Property::INPUT_COLOR:
465 if( impl.mController )
467 const Vector4 inputColor = value.Get< Vector4 >();
468 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 );
470 impl.mController->SetInputColor( inputColor );
474 case Toolkit::TextEditor::Property::INPUT_FONT_FAMILY:
476 if( impl.mController )
478 const std::string fontFamily = value.Get< std::string >();
479 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p INPUT_FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
480 impl.mController->SetInputFontFamily( fontFamily );
484 case Toolkit::TextEditor::Property::INPUT_FONT_STYLE:
486 SetFontStyleProperty( impl.mController, value, Text::FontStyle::INPUT );
489 case Toolkit::TextEditor::Property::INPUT_POINT_SIZE:
491 if( impl.mController )
493 const float pointSize = value.Get< float >();
494 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p INPUT_POINT_SIZE %f\n", impl.mController.Get(), pointSize );
495 impl.mController->SetInputFontPointSize( pointSize );
499 case Toolkit::TextEditor::Property::LINE_SPACING:
501 if( impl.mController )
503 const float lineSpacing = value.Get<float>();
504 impl.mController->SetDefaultLineSpacing( lineSpacing );
505 impl.mRenderer.Reset();
509 case Toolkit::TextEditor::Property::INPUT_LINE_SPACING:
511 if( impl.mController )
513 const float lineSpacing = value.Get<float>();
514 impl.mController->SetInputLineSpacing( lineSpacing );
515 impl.mRenderer.Reset();
519 case Toolkit::TextEditor::Property::UNDERLINE:
521 const bool update = SetUnderlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
524 impl.mRenderer.Reset();
528 case Toolkit::TextEditor::Property::INPUT_UNDERLINE:
530 const bool update = SetUnderlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
533 impl.mRenderer.Reset();
537 case Toolkit::TextEditor::Property::SHADOW:
539 const bool update = SetShadowProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
542 impl.mRenderer.Reset();
546 case Toolkit::TextEditor::Property::INPUT_SHADOW:
548 const bool update = SetShadowProperties( impl.mController, value, Text::EffectStyle::INPUT );
551 impl.mRenderer.Reset();
555 case Toolkit::TextEditor::Property::EMBOSS:
557 const bool update = SetEmbossProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
560 impl.mRenderer.Reset();
564 case Toolkit::TextEditor::Property::INPUT_EMBOSS:
566 const bool update = SetEmbossProperties( impl.mController, value, Text::EffectStyle::INPUT );
569 impl.mRenderer.Reset();
573 case Toolkit::TextEditor::Property::OUTLINE:
575 const bool update = SetOutlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
578 impl.mRenderer.Reset();
582 case Toolkit::TextEditor::Property::INPUT_OUTLINE:
584 const bool update = SetOutlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
587 impl.mRenderer.Reset();
595 Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index index )
597 Property::Value value;
599 Toolkit::TextEditor textEditor = Toolkit::TextEditor::DownCast( Dali::BaseHandle( object ) );
603 TextEditor& impl( GetImpl( textEditor ) );
607 case Toolkit::TextEditor::Property::RENDERING_BACKEND:
609 value = impl.mRenderingBackend;
612 case Toolkit::TextEditor::Property::TEXT:
614 if( impl.mController )
617 impl.mController->GetText( text );
618 DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p returning text: %s\n", impl.mController.Get(), text.c_str() );
623 case Toolkit::TextEditor::Property::TEXT_COLOR:
625 if ( impl.mController )
627 value = impl.mController->GetTextColor();
631 case Toolkit::TextEditor::Property::FONT_FAMILY:
633 if( impl.mController )
635 value = impl.mController->GetDefaultFontFamily();
639 case Toolkit::TextEditor::Property::FONT_STYLE:
641 GetFontStyleProperty( impl.mController, value, Text::FontStyle::DEFAULT );
644 case Toolkit::TextEditor::Property::POINT_SIZE:
646 if( impl.mController )
648 value = impl.mController->GetDefaultPointSize();
652 case Toolkit::TextEditor::Property::HORIZONTAL_ALIGNMENT:
654 if( impl.mController )
656 const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetLayoutEngine().GetHorizontalAlignment(),
657 HORIZONTAL_ALIGNMENT_STRING_TABLE,
658 HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
661 value = std::string( name );
666 case Toolkit::TextEditor::Property::SCROLL_THRESHOLD:
668 if( impl.mDecorator )
670 value = impl.mDecorator->GetScrollThreshold();
674 case Toolkit::TextEditor::Property::SCROLL_SPEED:
676 if( impl.mDecorator )
678 value = impl.mDecorator->GetScrollSpeed();
682 case Toolkit::TextEditor::Property::PRIMARY_CURSOR_COLOR:
684 if( impl.mDecorator )
686 value = impl.mDecorator->GetColor( PRIMARY_CURSOR );
690 case Toolkit::TextEditor::Property::SECONDARY_CURSOR_COLOR:
692 if( impl.mDecorator )
694 value = impl.mDecorator->GetColor( SECONDARY_CURSOR );
698 case Toolkit::TextEditor::Property::ENABLE_CURSOR_BLINK:
700 value = impl.mController->GetEnableCursorBlink();
703 case Toolkit::TextEditor::Property::CURSOR_BLINK_INTERVAL:
705 if( impl.mDecorator )
707 value = impl.mDecorator->GetCursorBlinkInterval();
711 case Toolkit::TextEditor::Property::CURSOR_BLINK_DURATION:
713 if( impl.mDecorator )
715 value = impl.mDecorator->GetCursorBlinkDuration();
719 case Toolkit::TextEditor::Property::CURSOR_WIDTH:
721 if( impl.mDecorator )
723 value = impl.mDecorator->GetCursorWidth();
727 case Toolkit::TextEditor::Property::GRAB_HANDLE_IMAGE:
729 if( impl.mDecorator )
731 ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED ) );
734 value = image.GetUrl();
739 case Toolkit::TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE:
741 if( impl.mDecorator )
743 ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED ) );
746 value = image.GetUrl();
751 case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT:
753 impl.GetHandleImagePropertyValue( value, LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED );
756 case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT:
758 impl.GetHandleImagePropertyValue( value, RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED ) ;
761 case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
763 impl.GetHandleImagePropertyValue( value, LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED );
766 case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
768 impl.GetHandleImagePropertyValue( value, RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED );
771 case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
773 impl.GetHandleImagePropertyValue( value, LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED );
776 case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
778 impl.GetHandleImagePropertyValue( value, RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED );
781 case Toolkit::TextEditor::Property::SELECTION_HIGHLIGHT_COLOR:
783 if( impl.mDecorator )
785 value = impl.mDecorator->GetHighlightColor();
789 case Toolkit::TextEditor::Property::DECORATION_BOUNDING_BOX:
791 if( impl.mDecorator )
793 Rect<int> boundingBox;
794 impl.mDecorator->GetBoundingBox( boundingBox );
799 case Toolkit::TextEditor::Property::ENABLE_MARKUP:
801 if( impl.mController )
803 value = impl.mController->IsMarkupProcessorEnabled();
807 case Toolkit::TextEditor::Property::INPUT_COLOR:
809 if( impl.mController )
811 value = impl.mController->GetInputColor();
815 case Toolkit::TextEditor::Property::INPUT_FONT_FAMILY:
817 if( impl.mController )
819 value = impl.mController->GetInputFontFamily();
823 case Toolkit::TextEditor::Property::INPUT_FONT_STYLE:
825 GetFontStyleProperty( impl.mController, value, Text::FontStyle::INPUT );
828 case Toolkit::TextEditor::Property::INPUT_POINT_SIZE:
830 if( impl.mController )
832 value = impl.mController->GetInputFontPointSize();
836 case Toolkit::TextEditor::Property::LINE_SPACING:
838 if( impl.mController )
840 value = impl.mController->GetDefaultLineSpacing();
844 case Toolkit::TextEditor::Property::INPUT_LINE_SPACING:
846 if( impl.mController )
848 value = impl.mController->GetInputLineSpacing();
852 case Toolkit::TextEditor::Property::UNDERLINE:
854 GetUnderlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
857 case Toolkit::TextEditor::Property::INPUT_UNDERLINE:
859 GetUnderlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
862 case Toolkit::TextEditor::Property::SHADOW:
864 GetShadowProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
867 case Toolkit::TextEditor::Property::INPUT_SHADOW:
869 GetShadowProperties( impl.mController, value, Text::EffectStyle::INPUT );
872 case Toolkit::TextEditor::Property::EMBOSS:
874 GetEmbossProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
877 case Toolkit::TextEditor::Property::INPUT_EMBOSS:
879 GetEmbossProperties( impl.mController, value, Text::EffectStyle::INPUT );
882 case Toolkit::TextEditor::Property::OUTLINE:
884 GetOutlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
887 case Toolkit::TextEditor::Property::INPUT_OUTLINE:
889 GetOutlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
898 bool TextEditor::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
900 Dali::BaseHandle handle( object );
902 bool connected( true );
903 Toolkit::TextEditor editor = Toolkit::TextEditor::DownCast( handle );
905 if( 0 == strcmp( signalName.c_str(), SIGNAL_TEXT_CHANGED ) )
907 editor.TextChangedSignal().Connect( tracker, functor );
909 else if( 0 == strcmp( signalName.c_str(), SIGNAL_INPUT_STYLE_CHANGED ) )
911 editor.InputStyleChangedSignal().Connect( tracker, functor );
915 // signalName does not match any signal
922 Toolkit::TextEditor::TextChangedSignalType& TextEditor::TextChangedSignal()
924 return mTextChangedSignal;
927 Toolkit::TextEditor::InputStyleChangedSignalType& TextEditor::InputStyleChangedSignal()
929 return mInputStyleChangedSignal;
932 void TextEditor::OnInitialize()
936 mController = Text::Controller::New( this, this );
938 mDecorator = Text::Decorator::New( *mController,
941 mController->GetLayoutEngine().SetLayout( LayoutEngine::MULTI_LINE_BOX );
943 // Enables the text input.
944 mController->EnableTextInput( mDecorator );
946 // Enables the vertical scrolling after the text input has been enabled.
947 mController->SetVerticalScrollEnabled( true );
949 // Disables the horizontal scrolling.
950 mController->SetHorizontalScrollEnabled( false );
952 // Sets the maximum number of characters.
953 mController->SetMaximumNumberOfCharacters( std::numeric_limits<Length>::max() );
955 // Enable the smooth handle panning.
956 mController->SetSmoothHandlePanEnabled( true );
958 // Forward input events to controller
959 EnableGestureDetection( static_cast<Gesture::Type>( Gesture::Tap | Gesture::Pan | Gesture::LongPress ) );
960 GetTapGestureDetector().SetMaximumTapsRequired( 2 );
962 self.TouchSignal().Connect( this, &TextEditor::OnTouched );
964 // Set BoundingBox to stage size if not already set.
965 Rect<int> boundingBox;
966 mDecorator->GetBoundingBox( boundingBox );
968 if( boundingBox.IsEmpty() )
970 Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
971 mDecorator->SetBoundingBox( Rect<int>( 0.0f, 0.0f, stageSize.width, stageSize.height ) );
974 // Whether to flip the selection handles as soon as they cross.
975 mDecorator->FlipSelectionHandlesOnCrossEnabled( true );
977 // Set the default scroll speed.
978 mDecorator->SetScrollSpeed( DEFAULT_SCROLL_SPEED );
980 // Fill-parent area by default
981 self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
982 self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
983 self.OnStageSignal().Connect( this, &TextEditor::OnStageConnect );
986 void TextEditor::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
988 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnStyleChange\n");
992 case StyleChange::DEFAULT_FONT_CHANGE:
994 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnStyleChange DEFAULT_FONT_CHANGE\n");
995 const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily();
996 // Property system did not set the font so should update it.
997 mController->UpdateAfterFontChange( newFont );
1001 case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
1003 GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
1006 case StyleChange::THEME_CHANGE:
1008 GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
1014 Vector3 TextEditor::GetNaturalSize()
1016 return mController->GetNaturalSize();
1019 float TextEditor::GetHeightForWidth( float width )
1021 return mController->GetHeightForWidth( width );
1024 void TextEditor::OnRelayout( const Vector2& size, RelayoutContainer& container )
1026 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor OnRelayout\n");
1028 const Text::Controller::UpdateTextType updateTextType = mController->Relayout( size );
1030 if( ( Text::Controller::NONE_UPDATED != updateTextType ) ||
1033 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnRelayout %p Displaying new contents\n", mController.Get() );
1036 ( Text::Controller::NONE_UPDATED != ( Text::Controller::DECORATOR_UPDATED & updateTextType ) ) )
1038 mDecorator->Relayout( size );
1043 mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
1046 EnableClipping( size );
1047 RenderText( updateTextType );
1050 // The text-editor emits signals when the input style changes. These changes of style are
1051 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1052 // can't be emitted during the size negotiation as the callbacks may update the UI.
1053 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1054 if( !mController->IsInputStyleChangedSignalsQueueEmpty() )
1056 if( Adaptor::IsAvailable() )
1058 Adaptor& adaptor = Adaptor::Get();
1060 if( NULL == mIdleCallback )
1062 // @note: The callback manager takes the ownership of the callback object.
1063 mIdleCallback = MakeCallback( this, &TextEditor::OnIdleSignal );
1064 adaptor.AddIdle( mIdleCallback );
1070 void TextEditor::RenderText( Text::Controller::UpdateTextType updateTextType )
1072 Actor self = Self();
1073 Actor renderableActor;
1075 if( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) )
1079 renderableActor = mRenderer->Render( mController->GetView(), DepthIndex::TEXT );
1082 if( renderableActor != mRenderableActor )
1084 UnparentAndReset( mRenderableActor );
1085 mRenderableActor = renderableActor;
1089 if( mRenderableActor )
1091 const Vector2& scrollOffset = mController->GetScrollPosition();
1093 mRenderableActor.SetPosition( scrollOffset.x, scrollOffset.y );
1095 Actor clipRootActor;
1098 clipRootActor = mClipper->GetRootActor();
1101 for( std::vector<Actor>::const_iterator it = mClippingDecorationActors.begin(),
1102 endIt = mClippingDecorationActors.end();
1110 clipRootActor.Add( actor );
1117 mClippingDecorationActors.clear();
1119 // Make sure the actor is parented correctly with/without clipping
1122 clipRootActor.Add( mRenderableActor );
1126 self.Add( mRenderableActor );
1131 void TextEditor::OnKeyInputFocusGained()
1133 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnKeyInputFocusGained %p\n", mController.Get() );
1135 VirtualKeyboard::StatusChangedSignal().Connect( this, &TextEditor::KeyboardStatusChanged );
1137 ImfManager imfManager = ImfManager::Get();
1141 imfManager.EventReceivedSignal().Connect( this, &TextEditor::OnImfEvent );
1143 // Notify that the text editing start.
1144 imfManager.Activate();
1146 // When window gain lost focus, the imf manager is deactivated. Thus when window gain focus again, the imf manager must be activated.
1147 imfManager.SetRestoreAfterFocusLost( true );
1150 ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
1154 notifier.ContentSelectedSignal().Connect( this, &TextEditor::OnClipboardTextSelected );
1157 mController->KeyboardFocusGainEvent(); // Called in the case of no virtual keyboard to trigger this event
1159 EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last.
1162 void TextEditor::OnKeyInputFocusLost()
1164 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor:OnKeyInputFocusLost %p\n", mController.Get() );
1166 VirtualKeyboard::StatusChangedSignal().Disconnect( this, &TextEditor::KeyboardStatusChanged );
1168 ImfManager imfManager = ImfManager::Get();
1171 // The text editing is finished. Therefore the imf manager don't have restore activation.
1172 imfManager.SetRestoreAfterFocusLost( false );
1174 // Notify that the text editing finish.
1175 imfManager.Deactivate();
1177 imfManager.EventReceivedSignal().Disconnect( this, &TextEditor::OnImfEvent );
1180 ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
1184 notifier.ContentSelectedSignal().Disconnect( this, &TextEditor::OnClipboardTextSelected );
1187 mController->KeyboardFocusLostEvent();
1189 EmitKeyInputFocusSignal( false ); // Calls back into the Control hence done last.
1192 void TextEditor::OnTap( const TapGesture& gesture )
1194 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnTap %p\n", mController.Get() );
1196 // Show the keyboard if it was hidden.
1197 if (!VirtualKeyboard::IsVisible())
1199 VirtualKeyboard::Show();
1202 // Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures
1203 mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x, gesture.localPoint.y );
1208 void TextEditor::OnPan( const PanGesture& gesture )
1210 mController->PanEvent( gesture.state, gesture.displacement );
1213 void TextEditor::OnLongPress( const LongPressGesture& gesture )
1215 // Show the keyboard if it was hidden.
1216 if (!VirtualKeyboard::IsVisible())
1218 VirtualKeyboard::Show();
1221 mController->LongPressEvent( gesture.state, gesture.localPoint.x, gesture.localPoint.y );
1226 bool TextEditor::OnKeyEvent( const KeyEvent& event )
1228 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnKeyEvent %p keyCode %d\n", mController.Get(), event.keyCode );
1230 if( Dali::DALI_KEY_ESCAPE == event.keyCode ) // Make a Dali key code for this
1232 ClearKeyInputFocus();
1236 return mController->KeyEvent( event );
1239 void TextEditor::RequestTextRelayout()
1244 void TextEditor::TextChanged()
1246 Dali::Toolkit::TextEditor handle( GetOwner() );
1247 mTextChangedSignal.Emit( handle );
1250 void TextEditor::MaxLengthReached()
1252 // Nothing to do as TextEditor doesn't emit a max length reached signal.
1255 void TextEditor::InputStyleChanged( Text::InputStyle::Mask inputStyleMask )
1257 Dali::Toolkit::TextEditor handle( GetOwner() );
1259 Toolkit::TextEditor::InputStyle::Mask editorInputStyleMask = Toolkit::TextEditor::InputStyle::NONE;
1261 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_COLOR ) )
1263 editorInputStyleMask = static_cast<Toolkit::TextEditor::InputStyle::Mask>( editorInputStyleMask | Toolkit::TextEditor::InputStyle::COLOR );
1265 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_FONT_FAMILY ) )
1267 editorInputStyleMask = static_cast<Toolkit::TextEditor::InputStyle::Mask>( editorInputStyleMask | Toolkit::TextEditor::InputStyle::FONT_FAMILY );
1269 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_POINT_SIZE ) )
1271 editorInputStyleMask = static_cast<Toolkit::TextEditor::InputStyle::Mask>( editorInputStyleMask | Toolkit::TextEditor::InputStyle::POINT_SIZE );
1273 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_FONT_WEIGHT ) )
1275 editorInputStyleMask = static_cast<Toolkit::TextEditor::InputStyle::Mask>( editorInputStyleMask | Toolkit::TextEditor::InputStyle::FONT_STYLE );
1277 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_FONT_WIDTH ) )
1279 editorInputStyleMask = static_cast<Toolkit::TextEditor::InputStyle::Mask>( editorInputStyleMask | Toolkit::TextEditor::InputStyle::FONT_STYLE );
1281 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_FONT_SLANT ) )
1283 editorInputStyleMask = static_cast<Toolkit::TextEditor::InputStyle::Mask>( editorInputStyleMask | Toolkit::TextEditor::InputStyle::FONT_STYLE );
1285 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_LINE_SPACING ) )
1287 editorInputStyleMask = static_cast<Toolkit::TextEditor::InputStyle::Mask>( editorInputStyleMask | Toolkit::TextEditor::InputStyle::LINE_SPACING );
1289 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_UNDERLINE ) )
1291 editorInputStyleMask = static_cast<Toolkit::TextEditor::InputStyle::Mask>( editorInputStyleMask | Toolkit::TextEditor::InputStyle::UNDERLINE );
1293 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_SHADOW ) )
1295 editorInputStyleMask = static_cast<Toolkit::TextEditor::InputStyle::Mask>( editorInputStyleMask | Toolkit::TextEditor::InputStyle::SHADOW );
1297 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_EMBOSS ) )
1299 editorInputStyleMask = static_cast<Toolkit::TextEditor::InputStyle::Mask>( editorInputStyleMask | Toolkit::TextEditor::InputStyle::EMBOSS );
1301 if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_OUTLINE ) )
1303 editorInputStyleMask = static_cast<Toolkit::TextEditor::InputStyle::Mask>( editorInputStyleMask | Toolkit::TextEditor::InputStyle::OUTLINE );
1306 mInputStyleChangedSignal.Emit( handle, editorInputStyleMask );
1309 void TextEditor::AddDecoration( Actor& actor, bool needsClipping )
1315 mClippingDecorationActors.push_back( actor );
1319 Self().Add( actor );
1324 void TextEditor::OnStageConnect( Dali::Actor actor )
1326 if ( mHasBeenStaged )
1328 RenderText( static_cast<Text::Controller::UpdateTextType>( Text::Controller::MODEL_UPDATED | Text::Controller::DECORATOR_UPDATED ) );
1332 mHasBeenStaged = true;
1336 ImfManager::ImfCallbackData TextEditor::OnImfEvent( Dali::ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
1338 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnImfEvent %p eventName %d\n", mController.Get(), imfEvent.eventName );
1339 return mController->OnImfEvent( imfManager, imfEvent );
1342 void TextEditor::GetHandleImagePropertyValue( Property::Value& value, Text::HandleType handleType, Text::HandleImageType handleImageType )
1346 ResourceImage image = ResourceImage::DownCast( mDecorator->GetHandleImage( handleType, handleImageType ) );
1351 Scripting::CreatePropertyMap( image, map );
1357 void TextEditor::EnableClipping( const Vector2& size )
1359 // Not worth to created clip actor if width or height is equal to zero.
1360 if( size.width > Math::MACHINE_EPSILON_1000 && size.height > Math::MACHINE_EPSILON_1000 )
1364 Actor self = Self();
1366 mClipper = Clipper::New( size );
1367 self.Add( mClipper->GetRootActor() );
1368 self.Add( mClipper->GetImageView() );
1370 else if ( mClipper )
1372 mClipper->Refresh( size );
1377 void TextEditor::OnClipboardTextSelected( ClipboardEventNotifier& clipboard )
1379 mController->PasteClipboardItemEvent();
1382 void TextEditor::KeyboardStatusChanged(bool keyboardShown)
1384 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::KeyboardStatusChanged %p keyboardShown %d\n", mController.Get(), keyboardShown );
1386 // Just hide the grab handle when keyboard is hidden.
1387 if (!keyboardShown )
1389 mController->KeyboardFocusLostEvent();
1393 mController->KeyboardFocusGainEvent(); // Initially called by OnKeyInputFocusGained
1397 void TextEditor::OnStageConnection( int depth )
1399 // Call the Control::OnStageConnection() to set the depth of the background.
1400 Control::OnStageConnection( depth );
1402 // Sets the depth to the visuals inside the text's decorator.
1403 mDecorator->SetTextDepth( depth );
1405 // The depth of the text renderer is set in the RenderText() called from OnRelayout().
1408 bool TextEditor::OnTouched( Actor actor, const TouchData& touch )
1413 void TextEditor::OnIdleSignal()
1415 // Emits the change of input style signals.
1416 mController->ProcessInputStyleChangedSignals();
1418 // Set the pointer to null as the callback manager deletes the callback after execute it.
1419 mIdleCallback = NULL;
1422 TextEditor::TextEditor()
1423 : Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
1424 mIdleCallback( NULL ),
1425 mRenderingBackend( DEFAULT_RENDERING_BACKEND ),
1426 mHasBeenStaged( false )
1430 TextEditor::~TextEditor()
1434 if( ( NULL != mIdleCallback ) && Adaptor::IsAvailable() )
1436 // Removes the callback from the callback manager in case the text-editor is destroyed before the callback is executed.
1437 Adaptor::Get().RemoveIdle( mIdleCallback );
1441 } // namespace Internal
1443 } // namespace Toolkit