2 * Copyright (c) 2021 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-field-impl.h>
22 #include <dali/devel-api/actors/actor-devel.h>
23 #include <dali/devel-api/adaptor-framework/key-devel.h>
24 #include <dali/devel-api/common/stage.h>
25 #include <dali/devel-api/object/property-helper-devel.h>
26 #include <dali/integration-api/debug.h>
27 #include <dali/public-api/adaptor-framework/key.h>
28 #include <dali/public-api/common/dali-common.h>
29 #include <dali/public-api/object/type-registry-helper.h>
33 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
34 #include <dali-toolkit/devel-api/controls/control-devel.h>
35 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
36 #include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
37 #include <dali-toolkit/devel-api/text/rendering-backend.h>
38 #include <dali-toolkit/internal/styling/style-manager-impl.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-enumerations-impl.h>
42 #include <dali-toolkit/internal/text/text-font-style.h>
43 #include <dali-toolkit/internal/text/text-view.h>
44 #include <dali-toolkit/public-api/text/text-enumerations.h>
45 #include <dali-toolkit/public-api/visuals/color-visual-properties.h>
46 #include <dali-toolkit/public-api/visuals/visual-properties.h>
47 #include <dali/integration-api/adaptor-framework/adaptor.h>
49 using namespace Dali::Toolkit::Text;
57 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::DevelText::DEFAULT_RENDERING_BACKEND;
64 } // unnamed namespace
71 return Toolkit::TextField::New();
75 // Setup properties, signals and actions using the type-registry.
76 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TextField, Toolkit::Control, Create );
78 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "text", STRING, TEXT )
79 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "placeholderText", STRING, PLACEHOLDER_TEXT )
80 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "placeholderTextFocused", STRING, PLACEHOLDER_TEXT_FOCUSED )
81 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "fontFamily", STRING, FONT_FAMILY )
82 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "fontStyle", MAP, FONT_STYLE )
83 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "pointSize", FLOAT, POINT_SIZE )
84 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "maxLength", INTEGER, MAX_LENGTH )
85 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "exceedPolicy", INTEGER, EXCEED_POLICY )
86 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "horizontalAlignment", STRING, HORIZONTAL_ALIGNMENT )
87 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "verticalAlignment", STRING, VERTICAL_ALIGNMENT )
88 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "textColor", VECTOR4, TEXT_COLOR )
89 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "placeholderTextColor", VECTOR4, PLACEHOLDER_TEXT_COLOR )
90 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "primaryCursorColor", VECTOR4, PRIMARY_CURSOR_COLOR )
91 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "secondaryCursorColor", VECTOR4, SECONDARY_CURSOR_COLOR )
92 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "enableCursorBlink", BOOLEAN, ENABLE_CURSOR_BLINK )
93 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "cursorBlinkInterval", FLOAT, CURSOR_BLINK_INTERVAL )
94 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "cursorBlinkDuration", FLOAT, CURSOR_BLINK_DURATION )
95 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "cursorWidth", INTEGER, CURSOR_WIDTH )
96 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "grabHandleImage", STRING, GRAB_HANDLE_IMAGE )
97 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "grabHandlePressedImage", STRING, GRAB_HANDLE_PRESSED_IMAGE )
98 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "scrollThreshold", FLOAT, SCROLL_THRESHOLD )
99 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "scrollSpeed", FLOAT, SCROLL_SPEED )
100 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "selectionHandleImageLeft", MAP, SELECTION_HANDLE_IMAGE_LEFT )
101 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "selectionHandleImageRight", MAP, SELECTION_HANDLE_IMAGE_RIGHT )
102 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "selectionHandlePressedImageLeft", MAP, SELECTION_HANDLE_PRESSED_IMAGE_LEFT )
103 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "selectionHandlePressedImageRight", MAP, SELECTION_HANDLE_PRESSED_IMAGE_RIGHT)
104 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "selectionHandleMarkerImageLeft", MAP, SELECTION_HANDLE_MARKER_IMAGE_LEFT )
105 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "selectionHandleMarkerImageRight", MAP, SELECTION_HANDLE_MARKER_IMAGE_RIGHT )
106 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "selectionHighlightColor", VECTOR4, SELECTION_HIGHLIGHT_COLOR )
107 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "decorationBoundingBox", RECTANGLE, DECORATION_BOUNDING_BOX )
108 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "inputMethodSettings", MAP, INPUT_METHOD_SETTINGS )
109 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "inputColor", VECTOR4, INPUT_COLOR )
110 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "enableMarkup", BOOLEAN, ENABLE_MARKUP )
111 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "inputFontFamily", STRING, INPUT_FONT_FAMILY )
112 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "inputFontStyle", MAP, INPUT_FONT_STYLE )
113 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "inputPointSize", FLOAT, INPUT_POINT_SIZE )
114 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "underline", MAP, UNDERLINE )
115 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "inputUnderline", MAP, INPUT_UNDERLINE )
116 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "shadow", MAP, SHADOW )
117 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "inputShadow", MAP, INPUT_SHADOW )
118 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "emboss", MAP, EMBOSS )
119 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "inputEmboss", MAP, INPUT_EMBOSS )
120 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "outline", MAP, OUTLINE )
121 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "inputOutline", MAP, INPUT_OUTLINE )
122 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "hiddenInputSettings", MAP, HIDDEN_INPUT_SETTINGS )
123 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "pixelSize", FLOAT, PIXEL_SIZE )
124 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "enableSelection", BOOLEAN, ENABLE_SELECTION )
125 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "placeholder", MAP, PLACEHOLDER )
126 DALI_PROPERTY_REGISTRATION(Toolkit, TextField, "ellipsis", BOOLEAN, ELLIPSIS )
127 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "enableShiftSelection", BOOLEAN, ENABLE_SHIFT_SELECTION )
128 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "enableGrabHandle", BOOLEAN, ENABLE_GRAB_HANDLE )
129 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "matchSystemLanguageDirection", BOOLEAN, MATCH_SYSTEM_LANGUAGE_DIRECTION )
130 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "enableGrabHandlePopup", BOOLEAN, ENABLE_GRAB_HANDLE_POPUP )
131 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "textBackground", VECTOR4, BACKGROUND )
132 DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY(Toolkit, TextField, "selectedText", STRING, SELECTED_TEXT )
133 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "renderingBackend", INTEGER, RENDERING_BACKEND )
134 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "selectedTextStart", INTEGER, SELECTED_TEXT_START )
135 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "selectedTextEnd", INTEGER, SELECTED_TEXT_END )
136 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "enableEditing", BOOLEAN, ENABLE_EDITING )
137 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "fontSizeScale", FLOAT, FONT_SIZE_SCALE )
138 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "primaryCursorPosition", INTEGER, PRIMARY_CURSOR_POSITION )
139 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "grabHandleColor", VECTOR4, GRAB_HANDLE_COLOR )
140 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "inputFilter", MAP, INPUT_FILTER )
141 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextField, "ellipsisPosition", INTEGER, ELLIPSIS_POSITION )
143 DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "textChanged", SIGNAL_TEXT_CHANGED )
144 DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "maxLengthReached", SIGNAL_MAX_LENGTH_REACHED )
145 DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED )
146 DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "anchorClicked", SIGNAL_ANCHOR_CLICKED )
147 DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "inputFiltered", SIGNAL_INPUT_FILTERED )
148 DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "cursorPositionChanged", SIGNAL_CURSOR_POSITION_CHANGED)
149 DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "selectionChanged", SIGNAL_SELECTION_CHANGED )
151 DALI_TYPE_REGISTRATION_END()
154 const char* const IMAGE_MAP_FILENAME_STRING = "filename";
156 /// Retrieves a filename from a value that is a Property::Map
157 std::string GetImageFileNameFromPropertyValue(const Property::Value& value)
159 std::string filename;
160 const Property::Map* map = value.GetMap();
163 const Property::Value* filenameValue = map->Find(IMAGE_MAP_FILENAME_STRING);
166 filenameValue->Get(filename);
174 Toolkit::TextField TextField::New()
176 // Create the implementation, temporarily owned by this handle on stack
177 IntrusivePtr<TextField> impl = new TextField();
179 // Pass ownership to CustomActor handle
180 Toolkit::TextField handle(*impl);
182 // Second-phase init of the implementation
183 // This can only be done after the CustomActor connection has been made...
189 void TextField::SetProperty(BaseObject* object, Property::Index index, const Property::Value& value)
191 Toolkit::TextField textField = Toolkit::TextField::DownCast(Dali::BaseHandle(object));
193 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField SetProperty\n");
197 TextField& impl(GetImpl(textField));
198 DALI_ASSERT_DEBUG(impl.mController && "No text contoller");
199 DALI_ASSERT_DEBUG(impl.mDecorator && "No text decorator");
203 case Toolkit::DevelTextField::Property::RENDERING_BACKEND:
205 int backend = value.Get<int>();
206 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField %p RENDERING_BACKEND %d\n", impl.mController.Get(), backend);
208 #ifndef ENABLE_VECTOR_BASED_TEXT_RENDERING
209 if(DevelText::RENDERING_VECTOR_BASED == backend)
211 backend = TextAbstraction::BITMAP_GLYPH; // Fallback to bitmap-based rendering
214 if(impl.mRenderingBackend != backend)
216 impl.mRenderingBackend = backend;
217 impl.mRenderer.Reset();
219 // When using the vector-based rendering, the size of the GLyphs are different
220 TextAbstraction::GlyphType glyphType = (DevelText::RENDERING_VECTOR_BASED == impl.mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH;
221 impl.mController->SetGlyphType(glyphType);
225 case Toolkit::TextField::Property::TEXT:
227 const std::string& text = value.Get<std::string>();
228 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p TEXT %s\n", impl.mController.Get(), text.c_str());
230 impl.mController->SetText(text);
233 case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
235 const std::string& text = value.Get<std::string>();
236 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str());
238 impl.mController->SetPlaceholderText(Controller::PLACEHOLDER_TYPE_INACTIVE, text);
241 case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED:
243 const std::string& text = value.Get<std::string>();
244 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_FOCUSED %s\n", impl.mController.Get(), text.c_str());
246 impl.mController->SetPlaceholderText(Controller::PLACEHOLDER_TYPE_ACTIVE, text);
249 case Toolkit::TextField::Property::FONT_FAMILY:
251 const std::string& fontFamily = value.Get<std::string>();
252 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str());
253 impl.mController->SetDefaultFontFamily(fontFamily);
256 case Toolkit::TextField::Property::FONT_STYLE:
258 SetFontStyleProperty(impl.mController, value, Text::FontStyle::DEFAULT);
261 case Toolkit::TextField::Property::POINT_SIZE:
263 const float pointSize = value.Get<float>();
264 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p POINT_SIZE %f\n", impl.mController.Get(), pointSize);
266 if(!Equals(impl.mController->GetDefaultFontSize(Text::Controller::POINT_SIZE), pointSize))
268 impl.mController->SetDefaultFontSize(pointSize, Text::Controller::POINT_SIZE);
272 case Toolkit::TextField::Property::MAX_LENGTH:
274 const int max = value.Get<int>();
275 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p MAX_LENGTH %d\n", impl.mController.Get(), max);
277 impl.mController->SetMaximumNumberOfCharacters(max);
280 case Toolkit::TextField::Property::EXCEED_POLICY:
282 impl.mExceedPolicy = value.Get<int>();
284 if(Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == impl.mExceedPolicy)
286 impl.EnableClipping();
290 UnparentAndReset(impl.mStencil);
292 impl.RequestTextRelayout();
295 case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
297 Text::HorizontalAlignment::Type alignment(static_cast<Text::HorizontalAlignment::Type>(-1)); // Set to invalid value to ensure a valid mode does get set
298 if(GetHorizontalAlignmentEnumeration(value, alignment))
300 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p HORIZONTAL_ALIGNMENT %d\n", impl.mController.Get(), alignment);
301 impl.mController->SetHorizontalAlignment(alignment);
305 case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
307 Toolkit::Text::VerticalAlignment::Type alignment(static_cast<Text::VerticalAlignment::Type>(-1)); // Set to invalid value to ensure a valid mode does get set
308 if(GetVerticalAlignmentEnumeration(value, alignment))
310 impl.mController->SetVerticalAlignment(alignment);
311 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p VERTICAL_ALIGNMENT %d\n", impl.mController.Get(), alignment);
315 case Toolkit::TextField::Property::TEXT_COLOR:
317 const Vector4& textColor = value.Get<Vector4>();
318 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);
320 if(impl.mController->GetDefaultColor() != textColor)
322 impl.mController->SetDefaultColor(textColor);
323 impl.mController->SetInputColor(textColor);
324 impl.mRenderer.Reset();
328 case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR:
330 const Vector4& textColor = value.Get<Vector4>();
331 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);
333 if(impl.mController->GetPlaceholderTextColor() != textColor)
335 impl.mController->SetPlaceholderTextColor(textColor);
336 impl.mRenderer.Reset();
340 case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
342 const Vector4& color = value.Get<Vector4>();
343 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);
345 impl.mDecorator->SetCursorColor(PRIMARY_CURSOR, color);
346 impl.RequestTextRelayout();
349 case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
351 const Vector4& color = value.Get<Vector4>();
352 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);
354 impl.mDecorator->SetCursorColor(SECONDARY_CURSOR, color);
355 impl.RequestTextRelayout();
358 case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
360 const bool enable = value.Get<bool>();
361 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField %p ENABLE_CURSOR_BLINK %d\n", impl.mController.Get(), enable);
363 impl.mController->SetEnableCursorBlink(enable);
364 impl.RequestTextRelayout();
367 case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
369 const float interval = value.Get<float>();
370 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_INTERVAL %f\n", impl.mController.Get(), interval);
372 impl.mDecorator->SetCursorBlinkInterval(interval);
375 case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
377 const float duration = value.Get<float>();
378 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_DURATION %f\n", impl.mController.Get(), duration);
380 impl.mDecorator->SetCursorBlinkDuration(duration);
383 case Toolkit::TextField::Property::CURSOR_WIDTH:
385 const int width = value.Get<int>();
386 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField %p CURSOR_WIDTH %d\n", impl.mController.Get(), width);
388 impl.mDecorator->SetCursorWidth(width);
389 impl.mController->GetLayoutEngine().SetCursorWidth(width);
392 case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
394 const std::string imageFileName = value.Get<std::string>();
395 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str());
397 if(imageFileName.size())
399 impl.mDecorator->SetHandleImage(GRAB_HANDLE, HANDLE_IMAGE_RELEASED, imageFileName);
400 impl.RequestTextRelayout();
404 case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE:
406 const std::string imageFileName = value.Get<std::string>();
407 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_PRESSED_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str());
409 if(imageFileName.size())
411 impl.mDecorator->SetHandleImage(GRAB_HANDLE, HANDLE_IMAGE_PRESSED, imageFileName);
412 impl.RequestTextRelayout();
416 case Toolkit::TextField::Property::SCROLL_THRESHOLD:
418 const float threshold = value.Get<float>();
419 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField %p SCROLL_THRESHOLD %f\n", impl.mController.Get(), threshold);
421 impl.mDecorator->SetScrollThreshold(threshold);
424 case Toolkit::TextField::Property::SCROLL_SPEED:
426 const float speed = value.Get<float>();
427 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField %p SCROLL_SPEED %f\n", impl.mController.Get(), speed);
429 impl.mDecorator->SetScrollSpeed(speed);
432 case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT:
434 const std::string filename = GetImageFileNameFromPropertyValue(value);
438 impl.mDecorator->SetHandleImage(LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, filename);
439 impl.RequestTextRelayout();
443 case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT:
445 const std::string filename = GetImageFileNameFromPropertyValue(value);
449 impl.mDecorator->SetHandleImage(RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, filename);
450 impl.RequestTextRelayout();
454 case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
456 const std::string filename = GetImageFileNameFromPropertyValue(value);
460 impl.mDecorator->SetHandleImage(LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, filename);
461 impl.RequestTextRelayout();
465 case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
467 const std::string filename = GetImageFileNameFromPropertyValue(value);
471 impl.mDecorator->SetHandleImage(RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, filename);
472 impl.RequestTextRelayout();
476 case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
478 const std::string filename = GetImageFileNameFromPropertyValue(value);
482 impl.mDecorator->SetHandleImage(LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, filename);
483 impl.RequestTextRelayout();
487 case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
489 const std::string filename = GetImageFileNameFromPropertyValue(value);
493 impl.mDecorator->SetHandleImage(RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, filename);
494 impl.RequestTextRelayout();
498 case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR:
500 const Vector4 color = value.Get<Vector4>();
501 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);
503 impl.mDecorator->SetHighlightColor(color);
504 impl.RequestTextRelayout();
507 case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
509 const Rect<int> box = value.Get<Rect<int> >();
510 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);
512 impl.mDecorator->SetBoundingBox(box);
513 impl.RequestTextRelayout();
516 case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS:
518 const Property::Map* map = value.GetMap();
521 impl.mInputMethodOptions.ApplyProperty(*map);
523 impl.mController->SetInputModePassword(impl.mInputMethodOptions.IsPassword());
525 Toolkit::Control control = Toolkit::KeyInputFocusManager::Get().GetCurrentFocusControl();
526 if(control == textField)
528 impl.mInputMethodContext.ApplyOptions(impl.mInputMethodOptions);
532 case Toolkit::TextField::Property::INPUT_COLOR:
534 const Vector4 inputColor = value.Get<Vector4>();
535 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);
537 impl.mController->SetInputColor(inputColor);
540 case Toolkit::TextField::Property::ENABLE_MARKUP:
542 const bool enableMarkup = value.Get<bool>();
543 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p ENABLE_MARKUP %d\n", impl.mController.Get(), enableMarkup);
545 impl.mController->SetMarkupProcessorEnabled(enableMarkup);
548 case Toolkit::TextField::Property::INPUT_FONT_FAMILY:
550 const std::string& fontFamily = value.Get<std::string>();
551 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p INPUT_FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str());
552 impl.mController->SetInputFontFamily(fontFamily);
555 case Toolkit::TextField::Property::INPUT_FONT_STYLE:
557 SetFontStyleProperty(impl.mController, value, Text::FontStyle::INPUT);
560 case Toolkit::TextField::Property::INPUT_POINT_SIZE:
562 const float pointSize = value.Get<float>();
563 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p INPUT_POINT_SIZE %f\n", impl.mController.Get(), pointSize);
564 impl.mController->SetInputFontPointSize(pointSize);
567 case Toolkit::TextField::Property::UNDERLINE:
569 const bool update = SetUnderlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
572 impl.mRenderer.Reset();
576 case Toolkit::TextField::Property::INPUT_UNDERLINE:
578 const bool update = SetUnderlineProperties(impl.mController, value, Text::EffectStyle::INPUT);
581 impl.mRenderer.Reset();
585 case Toolkit::TextField::Property::SHADOW:
587 const bool update = SetShadowProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
590 impl.mRenderer.Reset();
594 case Toolkit::TextField::Property::INPUT_SHADOW:
596 const bool update = SetShadowProperties(impl.mController, value, Text::EffectStyle::INPUT);
599 impl.mRenderer.Reset();
603 case Toolkit::TextField::Property::EMBOSS:
605 const bool update = SetEmbossProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
608 impl.mRenderer.Reset();
612 case Toolkit::TextField::Property::INPUT_EMBOSS:
614 const bool update = SetEmbossProperties(impl.mController, value, Text::EffectStyle::INPUT);
617 impl.mRenderer.Reset();
621 case Toolkit::TextField::Property::OUTLINE:
623 const bool update = SetOutlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
626 impl.mRenderer.Reset();
630 case Toolkit::TextField::Property::INPUT_OUTLINE:
632 const bool update = SetOutlineProperties(impl.mController, value, Text::EffectStyle::INPUT);
635 impl.mRenderer.Reset();
639 case Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS:
641 const Property::Map* map = value.GetMap();
644 impl.mController->SetHiddenInputOption(*map);
648 case Toolkit::TextField::Property::PIXEL_SIZE:
650 const float pixelSize = value.Get<float>();
651 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p PIXEL_SIZE %f\n", impl.mController.Get(), pixelSize);
653 if(!Equals(impl.mController->GetDefaultFontSize(Text::Controller::PIXEL_SIZE), pixelSize))
655 impl.mController->SetDefaultFontSize(pixelSize, Text::Controller::PIXEL_SIZE);
659 case Toolkit::TextField::Property::ENABLE_SELECTION:
661 const bool enableSelection = value.Get<bool>();
662 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p ENABLE_SELECTION %d\n", impl.mController.Get(), enableSelection);
663 impl.mController->SetSelectionEnabled(enableSelection);
666 case Toolkit::TextField::Property::PLACEHOLDER:
668 const Property::Map* map = value.GetMap();
671 impl.mController->SetPlaceholderProperty(*map);
675 case Toolkit::TextField::Property::ELLIPSIS:
677 const bool ellipsis = value.Get<bool>();
678 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p ELLIPSIS %d\n", impl.mController.Get(), ellipsis);
680 impl.mController->SetTextElideEnabled(ellipsis);
683 case Toolkit::DevelTextField::Property::ENABLE_SHIFT_SELECTION:
685 const bool shiftSelection = value.Get<bool>();
686 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p ENABLE_SHIFT_SELECTION %d\n", impl.mController.Get(), shiftSelection);
688 impl.mController->SetShiftSelectionEnabled(shiftSelection);
691 case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE:
693 const bool grabHandleEnabled = value.Get<bool>();
694 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p ENABLE_GRAB_HANDLE %d\n", impl.mController.Get(), grabHandleEnabled);
696 impl.mController->SetGrabHandleEnabled(grabHandleEnabled);
699 case Toolkit::DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
701 impl.mController->SetMatchLayoutDirection(value.Get<bool>() ? DevelText::MatchLayoutDirection::LOCALE : DevelText::MatchLayoutDirection::CONTENTS);
704 case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP:
706 const bool grabHandlePopupEnabled = value.Get<bool>();
707 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p ENABLE_GRAB_HANDLE_POPUP %d\n", impl.mController.Get(), grabHandlePopupEnabled);
709 impl.mController->SetGrabHandlePopupEnabled(grabHandlePopupEnabled);
712 case Toolkit::DevelTextField::Property::BACKGROUND:
714 const Vector4 backgroundColor = value.Get<Vector4>();
715 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);
717 impl.mController->SetBackgroundEnabled(true);
718 impl.mController->SetBackgroundColor(backgroundColor);
721 case Toolkit::DevelTextField::Property::SELECTED_TEXT_START:
723 uint32_t start = static_cast<uint32_t>(value.Get<int>());
724 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p SELECTED_TEXT_START %d\n", impl.mController.Get(), start);
725 impl.SetTextSelectionRange(&start, nullptr);
728 case Toolkit::DevelTextField::Property::SELECTED_TEXT_END:
730 uint32_t end = static_cast<uint32_t>(value.Get<int>());
731 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p SELECTED_TEXT_END %d\n", impl.mController.Get(), end);
732 impl.SetTextSelectionRange(nullptr, &end);
735 case Toolkit::DevelTextField::Property::ENABLE_EDITING:
737 const bool editable = value.Get<bool>();
738 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p ENABLE_EDITING %d\n", impl.mController.Get(), editable);
739 impl.SetEditable(editable);
742 case Toolkit::DevelTextField::Property::FONT_SIZE_SCALE:
744 const float scale = value.Get<float>();
745 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p FONT_SIZE_SCALE %f\n", impl.mController.Get(), scale);
747 if(!Equals(impl.mController->GetFontSizeScale(), scale))
749 impl.mController->SetFontSizeScale(scale);
753 case Toolkit::DevelTextField::Property::PRIMARY_CURSOR_POSITION:
755 uint32_t position = static_cast<uint32_t>(value.Get<int>());
756 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p PRIMARY_CURSOR_POSITION %d\n", impl.mController.Get(), position);
757 if(impl.mController->SetPrimaryCursorPosition(position, impl.HasKeyInputFocus()))
759 impl.SetKeyInputFocus();
763 case Toolkit::DevelTextField::Property::GRAB_HANDLE_COLOR:
765 const Vector4 color = value.Get<Vector4>();
766 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p GRAB_HANDLE_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a);
768 impl.mDecorator->SetHandleColor(color);
769 impl.RequestTextRelayout();
772 case Toolkit::DevelTextField::Property::INPUT_FILTER:
774 const Property::Map* map = value.GetMap();
777 impl.mController->SetInputFilterOption(*map);
781 case Toolkit::DevelTextField::Property::ELLIPSIS_POSITION:
783 DevelText::EllipsisPosition::Type ellipsisPositionType(static_cast<DevelText::EllipsisPosition::Type>(-1)); // Set to invalid value to ensure a valid mode does get set
784 if(GetEllipsisPositionTypeEnumeration(value, ellipsisPositionType))
786 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p EllipsisPosition::Type %d\n", impl.mController.Get(), ellipsisPositionType);
787 impl.mController->SetEllipsisPosition(ellipsisPositionType);
795 Property::Value TextField::GetProperty(BaseObject* object, Property::Index index)
797 Property::Value value;
799 Toolkit::TextField textField = Toolkit::TextField::DownCast(Dali::BaseHandle(object));
803 TextField& impl(GetImpl(textField));
804 DALI_ASSERT_DEBUG(impl.mController && "No text contoller");
805 DALI_ASSERT_DEBUG(impl.mDecorator && "No text decorator");
809 case Toolkit::DevelTextField::Property::RENDERING_BACKEND:
811 value = impl.mRenderingBackend;
814 case Toolkit::TextField::Property::TEXT:
817 impl.mController->GetText(text);
818 DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p returning text: %s\n", impl.mController.Get(), text.c_str());
822 case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
825 impl.mController->GetPlaceholderText(Controller::PLACEHOLDER_TYPE_INACTIVE, text);
829 case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED:
832 impl.mController->GetPlaceholderText(Controller::PLACEHOLDER_TYPE_ACTIVE, text);
836 case Toolkit::TextField::Property::FONT_FAMILY:
838 value = impl.mController->GetDefaultFontFamily();
841 case Toolkit::TextField::Property::FONT_STYLE:
843 GetFontStyleProperty(impl.mController, value, Text::FontStyle::DEFAULT);
846 case Toolkit::TextField::Property::POINT_SIZE:
848 value = impl.mController->GetDefaultFontSize(Text::Controller::POINT_SIZE);
851 case Toolkit::TextField::Property::MAX_LENGTH:
853 value = impl.mController->GetMaximumNumberOfCharacters();
856 case Toolkit::TextField::Property::EXCEED_POLICY:
858 value = impl.mExceedPolicy;
861 case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
863 const char* name = Text::GetHorizontalAlignmentString(impl.mController->GetHorizontalAlignment());
867 value = std::string(name);
871 case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
873 const char* name = Text::GetVerticalAlignmentString(impl.mController->GetVerticalAlignment());
877 value = std::string(name);
881 case Toolkit::TextField::Property::TEXT_COLOR:
883 value = impl.mController->GetDefaultColor();
886 case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR:
888 value = impl.mController->GetPlaceholderTextColor();
891 case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
893 value = impl.mDecorator->GetColor(PRIMARY_CURSOR);
896 case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
898 value = impl.mDecorator->GetColor(SECONDARY_CURSOR);
901 case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
903 value = impl.mController->GetEnableCursorBlink();
906 case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
908 value = impl.mDecorator->GetCursorBlinkInterval();
911 case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
913 value = impl.mDecorator->GetCursorBlinkDuration();
916 case Toolkit::TextField::Property::CURSOR_WIDTH:
918 value = impl.mDecorator->GetCursorWidth();
921 case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
923 value = impl.mDecorator->GetHandleImage(GRAB_HANDLE, HANDLE_IMAGE_RELEASED);
926 case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE:
928 value = impl.mDecorator->GetHandleImage(GRAB_HANDLE, HANDLE_IMAGE_PRESSED);
931 case Toolkit::TextField::Property::SCROLL_THRESHOLD:
933 value = impl.mDecorator->GetScrollThreshold();
936 case Toolkit::TextField::Property::SCROLL_SPEED:
938 value = impl.mDecorator->GetScrollSpeed();
941 case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT:
943 impl.GetHandleImagePropertyValue(value, LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED);
946 case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT:
948 impl.GetHandleImagePropertyValue(value, RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED);
951 case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
953 impl.GetHandleImagePropertyValue(value, LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED);
956 case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
958 impl.GetHandleImagePropertyValue(value, RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED);
961 case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
963 impl.GetHandleImagePropertyValue(value, LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED);
966 case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
968 impl.GetHandleImagePropertyValue(value, RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED);
971 case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR:
973 value = impl.mDecorator->GetHighlightColor();
976 case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
978 Rect<int> boundingBox;
979 impl.mDecorator->GetBoundingBox(boundingBox);
983 case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS:
986 impl.mInputMethodOptions.RetrieveProperty(map);
990 case Toolkit::TextField::Property::INPUT_COLOR:
992 value = impl.mController->GetInputColor();
995 case Toolkit::TextField::Property::ENABLE_MARKUP:
997 value = impl.mController->IsMarkupProcessorEnabled();
1000 case Toolkit::TextField::Property::INPUT_FONT_FAMILY:
1002 value = impl.mController->GetInputFontFamily();
1005 case Toolkit::TextField::Property::INPUT_FONT_STYLE:
1007 GetFontStyleProperty(impl.mController, value, Text::FontStyle::INPUT);
1010 case Toolkit::TextField::Property::INPUT_POINT_SIZE:
1012 value = impl.mController->GetInputFontPointSize();
1015 case Toolkit::TextField::Property::UNDERLINE:
1017 GetUnderlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
1020 case Toolkit::TextField::Property::INPUT_UNDERLINE:
1022 GetUnderlineProperties(impl.mController, value, Text::EffectStyle::INPUT);
1025 case Toolkit::TextField::Property::SHADOW:
1027 GetShadowProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
1030 case Toolkit::TextField::Property::INPUT_SHADOW:
1032 GetShadowProperties(impl.mController, value, Text::EffectStyle::INPUT);
1035 case Toolkit::TextField::Property::EMBOSS:
1037 GetEmbossProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
1040 case Toolkit::TextField::Property::INPUT_EMBOSS:
1042 GetEmbossProperties(impl.mController, value, Text::EffectStyle::INPUT);
1045 case Toolkit::TextField::Property::OUTLINE:
1047 GetOutlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
1050 case Toolkit::TextField::Property::INPUT_OUTLINE:
1052 GetOutlineProperties(impl.mController, value, Text::EffectStyle::INPUT);
1055 case Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS:
1058 impl.mController->GetHiddenInputOption(map);
1062 case Toolkit::TextField::Property::PIXEL_SIZE:
1064 value = impl.mController->GetDefaultFontSize(Text::Controller::PIXEL_SIZE);
1067 case Toolkit::TextField::Property::ENABLE_SELECTION:
1069 value = impl.mController->IsSelectionEnabled();
1072 case Toolkit::TextField::Property::PLACEHOLDER:
1075 impl.mController->GetPlaceholderProperty(map);
1079 case Toolkit::TextField::Property::ELLIPSIS:
1081 value = impl.mController->IsTextElideEnabled();
1084 case Toolkit::DevelTextField::Property::ENABLE_SHIFT_SELECTION:
1086 value = impl.mController->IsShiftSelectionEnabled();
1089 case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE:
1091 value = impl.mController->IsGrabHandleEnabled();
1094 case Toolkit::DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
1096 value = impl.mController->GetMatchLayoutDirection() != DevelText::MatchLayoutDirection::CONTENTS;
1099 case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP:
1101 value = impl.mController->IsGrabHandlePopupEnabled();
1104 case Toolkit::DevelTextField::Property::BACKGROUND:
1106 value = impl.mController->GetBackgroundColor();
1109 case Toolkit::DevelTextField::Property::SELECTED_TEXT:
1111 value = impl.mController->GetSelectedText();
1114 case Toolkit::DevelTextField::Property::SELECTED_TEXT_START:
1116 Uint32Pair range = impl.GetTextSelectionRange();
1117 value = static_cast<int>(range.first);
1120 case Toolkit::DevelTextField::Property::SELECTED_TEXT_END:
1122 Uint32Pair range = impl.GetTextSelectionRange();
1123 value = static_cast<int>(range.second);
1126 case Toolkit::DevelTextField::Property::ENABLE_EDITING:
1128 value = impl.IsEditable();
1131 case Toolkit::DevelTextField::Property::FONT_SIZE_SCALE:
1133 value = impl.mController->GetFontSizeScale();
1136 case Toolkit::DevelTextField::Property::PRIMARY_CURSOR_POSITION:
1138 value = static_cast<int>(impl.mController->GetPrimaryCursorPosition());
1141 case Toolkit::DevelTextField::Property::GRAB_HANDLE_COLOR:
1143 value = impl.mDecorator->GetHandleColor();
1146 case Toolkit::DevelTextField::Property::INPUT_FILTER:
1149 impl.mController->GetInputFilterOption(map);
1153 case Toolkit::DevelTextField::Property::ELLIPSIS_POSITION:
1155 value = impl.mController->GetEllipsisPosition();
1164 void TextField::SelectWholeText()
1166 if(mController && mController->IsShowingRealText())
1168 mController->SelectWholeText();
1173 void TextField::SelectNone()
1175 if(mController && mController->IsShowingRealText())
1177 mController->SelectNone();
1181 void TextField::SelectText(const uint32_t start, const uint32_t end)
1183 if(mController && mController->IsShowingRealText())
1185 mController->SelectText(start, end);
1190 string TextField::GetSelectedText() const
1192 string selectedText = "";
1193 if(mController && mController->IsShowingRealText())
1195 selectedText = mController->GetSelectedText();
1197 return selectedText;
1200 void TextField::SetTextSelectionRange(const uint32_t* start, const uint32_t* end)
1202 if(mController && mController->IsShowingRealText())
1204 mController->SetTextSelectionRange(start, end);
1209 Uint32Pair TextField::GetTextSelectionRange() const
1212 if(mController && mController->IsShowingRealText())
1214 range = mController->GetTextSelectionRange();
1219 string TextField::CopyText()
1221 string copiedText = "";
1222 if(mController && mController->IsShowingRealText())
1224 copiedText = mController->CopyText();
1229 string TextField::CutText()
1231 string cutText = "";
1232 if(mController && mController->IsShowingRealText())
1234 cutText = mController->CutText();
1239 void TextField::PasteText()
1243 SetKeyInputFocus(); //Giving focus to the field that was passed to the PasteText in case the passed field (current field) doesn't have focus.
1244 mController->PasteText();
1248 InputMethodContext TextField::GetInputMethodContext()
1250 return mInputMethodContext;
1253 bool TextField::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
1255 Dali::BaseHandle handle(object);
1257 bool connected(true);
1258 Toolkit::TextField field = Toolkit::TextField::DownCast(handle);
1260 if(0 == strcmp(signalName.c_str(), SIGNAL_TEXT_CHANGED))
1262 field.TextChangedSignal().Connect(tracker, functor);
1264 else if(0 == strcmp(signalName.c_str(), SIGNAL_MAX_LENGTH_REACHED))
1266 field.MaxLengthReachedSignal().Connect(tracker, functor);
1268 else if(0 == strcmp(signalName.c_str(), SIGNAL_INPUT_STYLE_CHANGED))
1270 field.InputStyleChangedSignal().Connect(tracker, functor);
1272 else if(0 == strcmp(signalName.c_str(), SIGNAL_ANCHOR_CLICKED))
1276 Internal::TextField& fieldImpl(GetImpl(field));
1277 fieldImpl.AnchorClickedSignal().Connect(tracker, functor);
1280 else if(0 == strcmp(signalName.c_str(), SIGNAL_CURSOR_POSITION_CHANGED))
1284 Internal::TextField& fieldImpl(GetImpl(field));
1285 fieldImpl.CursorPositionChangedSignal().Connect(tracker, functor);
1288 else if(0 == strcmp(signalName.c_str(), SIGNAL_INPUT_FILTERED))
1292 Internal::TextField& fieldImpl(GetImpl(field));
1293 fieldImpl.InputFilteredSignal().Connect(tracker, functor);
1296 else if(0 == strcmp(signalName.c_str(), SIGNAL_SELECTION_CHANGED))
1300 Internal::TextField& fieldImpl(GetImpl(field));
1301 fieldImpl.SelectionChangedSignal().Connect(tracker, functor);
1306 // signalName does not match any signal
1313 Toolkit::TextField::TextChangedSignalType& TextField::TextChangedSignal()
1315 return mTextChangedSignal;
1318 Toolkit::TextField::MaxLengthReachedSignalType& TextField::MaxLengthReachedSignal()
1320 return mMaxLengthReachedSignal;
1323 Toolkit::TextField::InputStyleChangedSignalType& TextField::InputStyleChangedSignal()
1325 return mInputStyleChangedSignal;
1328 DevelTextField::AnchorClickedSignalType& TextField::AnchorClickedSignal()
1330 return mAnchorClickedSignal;
1333 DevelTextField::CursorPositionChangedSignalType& TextField::CursorPositionChangedSignal()
1335 return mCursorPositionChangedSignal;
1338 DevelTextField::InputFilteredSignalType& TextField::InputFilteredSignal()
1340 return mInputFilteredSignal;
1343 DevelTextField::SelectionChangedSignalType& TextField::SelectionChangedSignal()
1345 return mSelectionChangedSignal;
1348 void TextField::OnInitialize()
1350 Actor self = Self();
1352 mController = Text::Controller::New(this, this, this, this);
1354 // When using the vector-based rendering, the size of the GLyphs are different
1355 TextAbstraction::GlyphType glyphType = (DevelText::RENDERING_VECTOR_BASED == mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH;
1356 mController->SetGlyphType(glyphType);
1358 mDecorator = Text::Decorator::New(*mController,
1361 mInputMethodContext = InputMethodContext::New(self);
1363 mController->GetLayoutEngine().SetLayout(Layout::Engine::SINGLE_LINE_BOX);
1365 // Enables the text input.
1366 mController->EnableTextInput(mDecorator, mInputMethodContext);
1368 // Enables the horizontal scrolling after the text input has been enabled.
1369 mController->SetHorizontalScrollEnabled(true);
1371 // Disables the vertical scrolling.
1372 mController->SetVerticalScrollEnabled(false);
1374 // Disable the smooth handle panning.
1375 mController->SetSmoothHandlePanEnabled(false);
1377 mController->SetNoTextDoubleTapAction(Controller::NoTextTap::HIGHLIGHT);
1378 mController->SetNoTextLongPressAction(Controller::NoTextTap::HIGHLIGHT);
1380 // Sets layoutDirection value
1381 Dali::Stage stage = Dali::Stage::GetCurrent();
1382 Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>(stage.GetRootLayer().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
1383 mController->SetLayoutDirection(layoutDirection);
1385 self.LayoutDirectionChangedSignal().Connect(this, &TextField::OnLayoutDirectionChanged);
1387 // Forward input events to controller
1388 EnableGestureDetection(static_cast<GestureType::Value>(GestureType::TAP | GestureType::PAN | GestureType::LONG_PRESS));
1389 GetTapGestureDetector().SetMaximumTapsRequired(2);
1391 self.TouchedSignal().Connect(this, &TextField::OnTouched);
1393 // Set BoundingBox to stage size if not already set.
1394 Rect<int> boundingBox;
1395 mDecorator->GetBoundingBox(boundingBox);
1397 if(boundingBox.IsEmpty())
1399 Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
1400 mDecorator->SetBoundingBox(Rect<int>(0.0f, 0.0f, stageSize.width, stageSize.height));
1403 // Flip vertically the 'left' selection handle
1404 mDecorator->FlipHandleVertically(LEFT_SELECTION_HANDLE, true);
1406 // Fill-parent area by default
1407 self.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH);
1408 self.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT);
1409 self.OnSceneSignal().Connect(this, &TextField::OnSceneConnect);
1411 //Enable highightability
1412 self.SetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, true);
1414 DevelControl::SetInputMethodContext(*this, mInputMethodContext);
1416 if(Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy)
1421 DevelControl::SetAccessibilityConstructor(self, [](Dali::Actor actor) {
1422 return std::unique_ptr<Dali::Accessibility::Accessible>(
1423 new AccessibleImpl(actor, Dali::Accessibility::Role::ENTRY));
1427 void TextField::OnStyleChange(Toolkit::StyleManager styleManager, StyleChange::Type change)
1429 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField::OnStyleChange\n");
1433 case StyleChange::DEFAULT_FONT_CHANGE:
1435 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField::OnStyleChange DEFAULT_FONT_CHANGE\n");
1436 const std::string& newFont = GetImpl(styleManager).GetDefaultFontFamily();
1437 // Property system did not set the font so should update it.
1438 mController->UpdateAfterFontChange(newFont);
1443 case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
1445 GetImpl(styleManager).ApplyThemeStyle(Toolkit::Control(GetOwner()));
1449 case StyleChange::THEME_CHANGE:
1451 // Nothing to do, let control base class handle this
1456 // Up call to Control
1457 Control::OnStyleChange(styleManager, change);
1460 Vector3 TextField::GetNaturalSize()
1463 padding = Self().GetProperty<Extents>(Toolkit::Control::Property::PADDING);
1465 Vector3 naturalSize = mController->GetNaturalSize();
1466 naturalSize.width += (padding.start + padding.end);
1467 naturalSize.height += (padding.top + padding.bottom);
1472 float TextField::GetHeightForWidth(float width)
1475 padding = Self().GetProperty<Extents>(Toolkit::Control::Property::PADDING);
1476 return mController->GetHeightForWidth(width) + padding.top + padding.bottom;
1479 void TextField::ResizeActor(Actor& actor, const Vector2& size)
1481 if(actor.GetProperty<Vector3>(Dali::Actor::Property::SIZE).GetVectorXY() != size)
1483 actor.SetProperty(Actor::Property::SIZE, size);
1487 void TextField::OnRelayout(const Vector2& size, RelayoutContainer& container)
1489 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField OnRelayout\n");
1491 Actor self = Self();
1494 padding = self.GetProperty<Extents>(Toolkit::Control::Property::PADDING);
1496 Vector2 contentSize(size.x - (padding.start + padding.end), size.y - (padding.top + padding.bottom));
1498 // Support Right-To-Left of padding
1499 Dali::LayoutDirection::Type layoutDirection = mController->GetLayoutDirection(self);
1501 if(Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection)
1503 std::swap(padding.start, padding.end);
1508 mStencil.SetProperty(Actor::Property::POSITION, Vector2(padding.start, padding.top));
1509 ResizeActor(mStencil, contentSize);
1513 mActiveLayer.SetProperty(Actor::Property::POSITION, Vector2(padding.start, padding.top));
1514 ResizeActor(mActiveLayer, contentSize);
1517 // If there is text changed, callback is called.
1520 EmitTextChangedSignal();
1523 const Text::Controller::UpdateTextType updateTextType = mController->Relayout(contentSize, layoutDirection);
1525 if((Text::Controller::NONE_UPDATED != updateTextType) ||
1528 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField::OnRelayout %p Displaying new contents\n", mController.Get());
1531 (Text::Controller::NONE_UPDATED != (Text::Controller::DECORATOR_UPDATED & updateTextType)))
1533 mDecorator->Relayout(contentSize);
1538 mRenderer = Backend::Get().NewRenderer(mRenderingBackend);
1541 RenderText(updateTextType);
1544 if(mCursorPositionChanged)
1546 EmitCursorPositionChangedSignal();
1549 if(mSelectionChanged)
1551 EmitSelectionChangedSignal();
1554 // The text-field emits signals when the input style changes. These changes of style are
1555 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1556 // can't be emitted during the size negotiation as the callbacks may update the UI.
1557 // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1558 if(!mController->IsInputStyleChangedSignalsQueueEmpty())
1560 if(Adaptor::IsAvailable())
1562 Adaptor& adaptor = Adaptor::Get();
1564 if(NULL == mIdleCallback)
1566 // @note: The callback manager takes the ownership of the callback object.
1567 mIdleCallback = MakeCallback(this, &TextField::OnIdleSignal);
1568 adaptor.AddIdle(mIdleCallback, false);
1574 Text::ControllerPtr TextField::GetTextController()
1579 void TextField::RenderText(Text::Controller::UpdateTextType updateTextType)
1581 Actor renderableActor;
1583 if(Text::Controller::NONE_UPDATED != (Text::Controller::MODEL_UPDATED & updateTextType))
1587 Dali::Toolkit::TextField handle = Dali::Toolkit::TextField(GetOwner());
1589 renderableActor = mRenderer->Render(mController->GetView(),
1591 Property::INVALID_INDEX, // Animatable property not supported
1593 DepthIndex::CONTENT);
1596 if(renderableActor != mRenderableActor)
1598 UnparentAndReset(mBackgroundActor);
1599 UnparentAndReset(mRenderableActor);
1600 mRenderableActor = renderableActor;
1602 if(mRenderableActor)
1604 mBackgroundActor = mController->CreateBackgroundActor();
1609 if(mRenderableActor)
1611 const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition();
1613 float renderableActorPositionX, renderableActorPositionY;
1617 renderableActorPositionX = scrollOffset.x + mAlignmentOffset;
1618 renderableActorPositionY = scrollOffset.y;
1623 padding = Self().GetProperty<Extents>(Toolkit::Control::Property::PADDING);
1625 // Support Right-To-Left of padding
1626 Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>(Self().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
1627 if(Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection)
1629 std::swap(padding.start, padding.end);
1632 renderableActorPositionX = scrollOffset.x + mAlignmentOffset + padding.start;
1633 renderableActorPositionY = scrollOffset.y + padding.top;
1636 mRenderableActor.SetProperty(Actor::Property::POSITION, Vector2(renderableActorPositionX, renderableActorPositionY));
1638 // Make sure the actors are parented correctly with/without clipping
1639 Actor self = mStencil ? mStencil : Self();
1641 Actor highlightActor;
1643 for(std::vector<Actor>::iterator it = mClippingDecorationActors.begin(),
1644 endIt = mClippingDecorationActors.end();
1649 it->LowerToBottom();
1651 if(it->GetProperty<std::string>(Dali::Actor::Property::NAME) == "HighlightActor")
1653 highlightActor = *it;
1656 mClippingDecorationActors.clear();
1658 self.Add(mRenderableActor);
1660 if(mBackgroundActor)
1662 if(mDecorator && mDecorator->IsHighlightVisible())
1664 self.Add(mBackgroundActor);
1665 mBackgroundActor.SetProperty(Actor::Property::POSITION, Vector2(renderableActorPositionX, renderableActorPositionY)); // In text field's coords.
1666 mBackgroundActor.LowerBelow(highlightActor);
1670 mRenderableActor.Add(mBackgroundActor);
1671 mBackgroundActor.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f)); // In renderable actor's coords.
1672 mBackgroundActor.LowerToBottom();
1678 void TextField::OnKeyInputFocusGained()
1680 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField::OnKeyInputFocusGained %p\n", mController.Get());
1681 if(mInputMethodContext && IsEditable())
1683 // All input panel properties, such as layout, return key type, and input hint, should be set before input panel activates (or shows).
1684 mInputMethodContext.ApplyOptions(mInputMethodOptions);
1685 mInputMethodContext.NotifyTextInputMultiLine(false);
1687 mInputMethodContext.StatusChangedSignal().Connect(this, &TextField::KeyboardStatusChanged);
1689 mInputMethodContext.EventReceivedSignal().Connect(this, &TextField::OnInputMethodContextEvent);
1691 // Notify that the text editing start.
1692 mInputMethodContext.Activate();
1694 // When window gain lost focus, the inputMethodContext is deactivated. Thus when window gain focus again, the inputMethodContext must be activated.
1695 mInputMethodContext.SetRestoreAfterFocusLost(true);
1697 ClipboardEventNotifier notifier(ClipboardEventNotifier::Get());
1701 notifier.ContentSelectedSignal().Connect(this, &TextField::OnClipboardTextSelected);
1704 mController->KeyboardFocusGainEvent(); // Called in the case of no virtual keyboard to trigger this event
1706 EmitKeyInputFocusSignal(true); // Calls back into the Control hence done last.
1709 void TextField::OnKeyInputFocusLost()
1711 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField:OnKeyInputFocusLost %p\n", mController.Get());
1712 if(mInputMethodContext)
1714 mInputMethodContext.StatusChangedSignal().Disconnect(this, &TextField::KeyboardStatusChanged);
1715 // The text editing is finished. Therefore the inputMethodContext don't have restore activation.
1716 mInputMethodContext.SetRestoreAfterFocusLost(false);
1718 // Notify that the text editing finish.
1719 mInputMethodContext.Deactivate();
1721 mInputMethodContext.EventReceivedSignal().Disconnect(this, &TextField::OnInputMethodContextEvent);
1723 ClipboardEventNotifier notifier(ClipboardEventNotifier::Get());
1727 notifier.ContentSelectedSignal().Disconnect(this, &TextField::OnClipboardTextSelected);
1730 mController->KeyboardFocusLostEvent();
1732 EmitKeyInputFocusSignal(false); // Calls back into the Control hence done last.
1735 bool TextField::OnAccessibilityActivated()
1741 void TextField::OnTap(const TapGesture& gesture)
1743 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField::OnTap %p\n", mController.Get());
1744 if(mInputMethodContext && IsEditable())
1746 mInputMethodContext.Activate();
1748 // Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures
1750 padding = Self().GetProperty<Extents>(Toolkit::Control::Property::PADDING);
1751 const Vector2& localPoint = gesture.GetLocalPoint();
1752 mController->TapEvent(gesture.GetNumberOfTaps(), localPoint.x - padding.start, localPoint.y - padding.top);
1753 mController->AnchorEvent(localPoint.x - padding.start, localPoint.y - padding.top);
1758 void TextField::OnPan(const PanGesture& gesture)
1760 mController->PanEvent(gesture.GetState(), gesture.GetDisplacement());
1763 void TextField::OnLongPress(const LongPressGesture& gesture)
1765 if(mInputMethodContext && IsEditable())
1767 mInputMethodContext.Activate();
1770 padding = Self().GetProperty<Extents>(Toolkit::Control::Property::PADDING);
1771 const Vector2& localPoint = gesture.GetLocalPoint();
1772 mController->LongPressEvent(gesture.GetState(), localPoint.x - padding.start, localPoint.y - padding.top);
1777 bool TextField::OnKeyEvent(const KeyEvent& event)
1779 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField::OnKeyEvent %p keyCode %d\n", mController.Get(), event.GetKeyCode());
1781 if(Dali::DALI_KEY_ESCAPE == event.GetKeyCode() && mController->ShouldClearFocusOnEscape())
1783 // Make sure ClearKeyInputFocus when only key is up
1784 if(event.GetState() == KeyEvent::UP)
1786 ClearKeyInputFocus();
1791 else if(Dali::DevelKey::DALI_KEY_RETURN == event.GetKeyCode())
1793 // Do nothing when enter is comming.
1797 return mController->KeyEvent(event);
1800 void TextField::RequestTextRelayout()
1805 bool TextField::IsEditable() const
1807 return mController->IsEditable();
1810 void TextField::SetEditable(bool editable)
1812 mController->SetEditable(editable);
1813 if(mInputMethodContext && !editable)
1815 mInputMethodContext.Deactivate();
1819 void TextField::TextInserted(unsigned int position, unsigned int length, const std::string& content)
1821 if(Accessibility::IsUp())
1823 Control::Impl::GetAccessibilityObject(Self())->EmitTextInserted(position, length, content);
1827 void TextField::TextDeleted(unsigned int position, unsigned int length, const std::string& content)
1829 if(Accessibility::IsUp())
1831 Control::Impl::GetAccessibilityObject(Self())->EmitTextDeleted(position, length, content);
1835 void TextField::CursorPositionChanged(unsigned int oldPosition, unsigned int newPosition)
1837 if(Accessibility::IsUp())
1839 Control::Impl::GetAccessibilityObject(Self())->EmitTextCursorMoved(newPosition);
1842 if((oldPosition != newPosition) && !mCursorPositionChanged)
1844 mCursorPositionChanged = true;
1845 mOldPosition = oldPosition;
1849 void TextField::TextChanged(bool immediate)
1851 if(immediate) // Emits TextChangedSignal immediately
1853 EmitTextChangedSignal();
1857 mTextChanged = true;
1861 void TextField::EmitTextChangedSignal()
1863 Dali::Toolkit::TextField handle(GetOwner());
1864 mTextChangedSignal.Emit(handle);
1865 mTextChanged = false;
1868 void TextField::MaxLengthReached()
1870 Dali::Toolkit::TextField handle(GetOwner());
1871 mMaxLengthReachedSignal.Emit(handle);
1874 void TextField::InputStyleChanged(Text::InputStyle::Mask inputStyleMask)
1876 Dali::Toolkit::TextField handle(GetOwner());
1878 Toolkit::TextField::InputStyle::Mask fieldInputStyleMask = Toolkit::TextField::InputStyle::NONE;
1880 if(InputStyle::NONE != static_cast<InputStyle::Mask>(inputStyleMask & InputStyle::INPUT_COLOR))
1882 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>(fieldInputStyleMask | Toolkit::TextField::InputStyle::COLOR);
1884 if(InputStyle::NONE != static_cast<InputStyle::Mask>(inputStyleMask & InputStyle::INPUT_FONT_FAMILY))
1886 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>(fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_FAMILY);
1888 if(InputStyle::NONE != static_cast<InputStyle::Mask>(inputStyleMask & InputStyle::INPUT_POINT_SIZE))
1890 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>(fieldInputStyleMask | Toolkit::TextField::InputStyle::POINT_SIZE);
1892 if(InputStyle::NONE != static_cast<InputStyle::Mask>(inputStyleMask & InputStyle::INPUT_FONT_WEIGHT))
1894 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>(fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_STYLE);
1896 if(InputStyle::NONE != static_cast<InputStyle::Mask>(inputStyleMask & InputStyle::INPUT_FONT_WIDTH))
1898 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>(fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_STYLE);
1900 if(InputStyle::NONE != static_cast<InputStyle::Mask>(inputStyleMask & InputStyle::INPUT_FONT_SLANT))
1902 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>(fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_STYLE);
1904 if(InputStyle::NONE != static_cast<InputStyle::Mask>(inputStyleMask & InputStyle::INPUT_UNDERLINE))
1906 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>(fieldInputStyleMask | Toolkit::TextField::InputStyle::UNDERLINE);
1908 if(InputStyle::NONE != static_cast<InputStyle::Mask>(inputStyleMask & InputStyle::INPUT_SHADOW))
1910 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>(fieldInputStyleMask | Toolkit::TextField::InputStyle::SHADOW);
1912 if(InputStyle::NONE != static_cast<InputStyle::Mask>(inputStyleMask & InputStyle::INPUT_EMBOSS))
1914 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>(fieldInputStyleMask | Toolkit::TextField::InputStyle::EMBOSS);
1916 if(InputStyle::NONE != static_cast<InputStyle::Mask>(inputStyleMask & InputStyle::INPUT_OUTLINE))
1918 fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>(fieldInputStyleMask | Toolkit::TextField::InputStyle::OUTLINE);
1921 mInputStyleChangedSignal.Emit(handle, fieldInputStyleMask);
1924 void TextField::AnchorClicked(const std::string& href)
1926 Dali::Toolkit::TextField handle(GetOwner());
1927 mAnchorClickedSignal.Emit(handle, href.c_str(), href.length());
1930 void TextField::EmitCursorPositionChangedSignal()
1932 Dali::Toolkit::TextField handle(GetOwner());
1933 mCursorPositionChangedSignal.Emit(handle, mOldPosition);
1934 mCursorPositionChanged = false;
1937 void TextField::InputFiltered(Toolkit::InputFilter::Property::Type type)
1939 Dali::Toolkit::TextField handle(GetOwner());
1940 mInputFilteredSignal.Emit(handle, type);
1943 void TextField::EmitSelectionChangedSignal()
1945 Dali::Toolkit::TextField handle(GetOwner());
1946 mSelectionChangedSignal.Emit(handle, mOldSelectionStart, mOldSelectionEnd);
1947 mSelectionChanged = false;
1950 void TextField::SelectionChanged(uint32_t oldStart, uint32_t oldEnd, uint32_t newStart, uint32_t newEnd)
1952 if(((oldStart != newStart) || (oldEnd != newEnd)) && !mSelectionChanged)
1954 mSelectionChanged = true;
1955 mOldSelectionStart = oldStart;
1956 mOldSelectionEnd = oldEnd;
1958 if(mOldSelectionStart > mOldSelectionEnd)
1961 uint32_t temp = mOldSelectionStart;
1962 mOldSelectionStart = mOldSelectionEnd;
1963 mOldSelectionEnd = temp;
1968 void TextField::AddDecoration(Actor& actor, bool needsClipping)
1974 mClippingDecorationActors.push_back(actor);
1978 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1979 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1981 mActiveLayer = actor;
1986 void TextField::GetControlBackgroundColor(Vector4& color) const
1988 Property::Value propValue = Self().GetProperty(Toolkit::Control::Property::BACKGROUND);
1989 Property::Map* resultMap = propValue.GetMap();
1991 Property::Value* colorValue = nullptr;
1992 if(resultMap && (colorValue = resultMap->Find(ColorVisual::Property::MIX_COLOR)))
1994 colorValue->Get(color);
1998 void TextField::OnSceneConnect(Dali::Actor actor)
2002 RenderText(static_cast<Text::Controller::UpdateTextType>(Text::Controller::MODEL_UPDATED | Text::Controller::DECORATOR_UPDATED));
2006 mHasBeenStaged = true;
2010 InputMethodContext::CallbackData TextField::OnInputMethodContextEvent(Dali::InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent)
2012 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField::OnInputMethodContextEvent %p eventName %d\n", mController.Get(), inputMethodContextEvent.eventName);
2013 return mController->OnInputMethodContextEvent(inputMethodContext, inputMethodContextEvent);
2016 void TextField::GetHandleImagePropertyValue(Property::Value& value, Text::HandleType handleType, Text::HandleImageType handleImageType)
2021 map[IMAGE_MAP_FILENAME_STRING] = mDecorator->GetHandleImage(handleType, handleImageType);
2026 void TextField::EnableClipping()
2030 // Creates an extra control to be used as stencil buffer.
2031 mStencil = Control::New();
2032 mStencil.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2033 mStencil.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2035 // Creates a background visual. Even if the color is transparent it updates the stencil.
2036 mStencil.SetProperty(Toolkit::Control::Property::BACKGROUND,
2037 Property::Map().Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR).Add(ColorVisual::Property::MIX_COLOR, Color::TRANSPARENT));
2039 // Enable the clipping property.
2040 mStencil.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
2041 mStencil.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
2043 Self().Add(mStencil);
2047 void TextField::OnClipboardTextSelected(ClipboardEventNotifier& clipboard)
2049 mController->PasteClipboardItemEvent();
2052 void TextField::KeyboardStatusChanged(bool keyboardShown)
2054 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField::KeyboardStatusChanged %p keyboardShown %d\n", mController.Get(), keyboardShown);
2056 // Just hide the grab handle when keyboard is hidden.
2059 mController->KeyboardFocusLostEvent();
2063 mController->KeyboardFocusGainEvent(); // Initially called by OnKeyInputFocusGained
2067 void TextField::OnSceneConnection(int depth)
2069 // Sets the depth to the visuals inside the text's decorator.
2070 mDecorator->SetTextDepth(depth);
2072 // The depth of the text renderer is set in the RenderText() called from OnRelayout().
2074 // Call the Control::OnSceneConnection() to set the depth of the background.
2075 Control::OnSceneConnection(depth);
2078 bool TextField::OnTouched(Actor actor, const TouchEvent& touch)
2083 void TextField::OnLayoutDirectionChanged(Actor actor, LayoutDirection::Type type)
2085 mController->ChangedLayoutDirection();
2088 void TextField::OnIdleSignal()
2090 // Emits the change of input style signals.
2091 mController->ProcessInputStyleChangedSignals();
2093 // Set the pointer to null as the callback manager deletes the callback after execute it.
2094 mIdleCallback = NULL;
2097 TextField::TextField()
2098 : Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT)),
2099 mIdleCallback(NULL),
2100 mAlignmentOffset(0.f),
2101 mRenderingBackend(DEFAULT_RENDERING_BACKEND),
2102 mExceedPolicy(Dali::Toolkit::TextField::EXCEED_POLICY_CLIP),
2103 mHasBeenStaged(false),
2104 mTextChanged(false),
2105 mCursorPositionChanged(false),
2106 mSelectionChanged(false)
2110 TextField::~TextField()
2112 UnparentAndReset(mStencil);
2114 if((NULL != mIdleCallback) && Adaptor::IsAvailable())
2116 Adaptor::Get().RemoveIdle(mIdleCallback);
2120 std::string TextField::AccessibleImpl::GetName()
2122 auto self = Toolkit::TextField::DownCast(Self());
2123 return self.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
2126 std::string TextField::AccessibleImpl::GetText(size_t startOffset, size_t endOffset)
2128 if(endOffset <= startOffset)
2133 auto self = Toolkit::TextField::DownCast(Self());
2134 auto text = self.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
2136 if(startOffset > text.size() || endOffset > text.size())
2141 return text.substr(startOffset, endOffset - startOffset);
2144 size_t TextField::AccessibleImpl::GetCharacterCount()
2146 auto self = Toolkit::TextField::DownCast(Self());
2147 auto text = self.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
2152 size_t TextField::AccessibleImpl::GetCursorOffset()
2154 auto self = Toolkit::TextField::DownCast(Self());
2155 return Dali::Toolkit::GetImpl(self).GetTextController()->GetCursorPosition();
2158 bool TextField::AccessibleImpl::SetCursorOffset(size_t offset)
2160 auto self = Toolkit::TextField::DownCast(Self());
2161 auto text = self.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
2162 if(offset > text.size())
2167 auto& selfImpl = Dali::Toolkit::GetImpl(self);
2168 selfImpl.GetTextController()->ResetCursorPosition(offset);
2169 selfImpl.RequestTextRelayout();
2174 Dali::Accessibility::Range TextField::AccessibleImpl::GetTextAtOffset(
2175 size_t offset, Dali::Accessibility::TextBoundary boundary)
2177 auto self = Toolkit::TextField::DownCast(Self());
2178 auto text = self.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
2179 auto textSize = text.size();
2181 auto range = Dali::Accessibility::Range{};
2185 case Dali::Accessibility::TextBoundary::CHARACTER:
2187 if(offset < textSize)
2189 range.content = text[offset];
2190 range.startOffset = offset;
2191 range.endOffset = offset + 1;
2195 case Dali::Accessibility::TextBoundary::WORD:
2196 case Dali::Accessibility::TextBoundary::LINE:
2198 auto textString = text.c_str();
2199 auto breaks = std::vector<char>(textSize, 0);
2201 if(boundary == Dali::Accessibility::TextBoundary::WORD)
2203 Accessibility::Accessible::FindWordSeparationsUtf8(reinterpret_cast<const utf8_t*>(textString), textSize, "", breaks.data());
2207 Accessibility::Accessible::FindLineSeparationsUtf8(reinterpret_cast<const utf8_t*>(textString), textSize, "", breaks.data());
2212 while(index < textSize && counter <= offset)
2217 while(breaks[index])
2225 if(boundary == Dali::Accessibility::TextBoundary::WORD)
2229 if(boundary == Dali::Accessibility::TextBoundary::LINE)
2235 if((counter > 0) && ((counter - 1) == offset))
2237 range.content = text.substr(start, index - start + 1);
2238 range.startOffset = start;
2239 range.endOffset = index + 1;
2242 if(boundary == Dali::Accessibility::TextBoundary::LINE)
2249 case Dali::Accessibility::TextBoundary::SENTENCE:
2251 /* not supported by default */
2254 case Dali::Accessibility::TextBoundary::PARAGRAPH:
2256 /* Paragraph is not supported by libunibreak library */
2266 Dali::Accessibility::Range TextField::AccessibleImpl::GetRangeOfSelection(size_t selectionIndex)
2268 // Since DALi supports only one selection indexes higher than 0 are ignored
2269 if(selectionIndex > 0)
2274 auto self = Toolkit::TextField::DownCast(Self());
2275 auto controller = Dali::Toolkit::GetImpl(self).GetTextController();
2276 std::string value{};
2277 controller->RetrieveSelection(value);
2278 auto indices = controller->GetSelectionIndexes();
2280 return {static_cast<size_t>(indices.first), static_cast<size_t>(indices.second), value};
2283 bool TextField::AccessibleImpl::RemoveSelection(size_t selectionIndex)
2285 // Since DALi supports only one selection indexes higher than 0 are ignored
2286 if(selectionIndex > 0)
2291 auto self = Toolkit::TextField::DownCast(Self());
2292 Dali::Toolkit::GetImpl(self).GetTextController()->SetSelection(0, 0);
2296 bool TextField::AccessibleImpl::SetRangeOfSelection(size_t selectionIndex, size_t startOffset, size_t endOffset)
2298 // Since DALi supports only one selection indexes higher than 0 are ignored
2299 if(selectionIndex > 0)
2304 auto self = Toolkit::TextField::DownCast(Self());
2305 Dali::Toolkit::GetImpl(self).GetTextController()->SetSelection(startOffset, endOffset);
2309 bool TextField::AccessibleImpl::CopyText(size_t startPosition, size_t endPosition)
2311 if(endPosition <= startPosition)
2316 auto self = Toolkit::TextField::DownCast(Self());
2317 auto text = self.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
2318 Dali::Toolkit::GetImpl(self).GetTextController()->CopyStringToClipboard(text.substr(startPosition, endPosition - startPosition));
2323 bool TextField::AccessibleImpl::CutText(size_t startPosition, size_t endPosition)
2325 if(endPosition <= startPosition)
2330 auto self = Toolkit::TextField::DownCast(Self());
2331 auto text = self.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
2332 Dali::Toolkit::GetImpl(self).GetTextController()->CopyStringToClipboard(text.substr(startPosition, endPosition - startPosition));
2334 self.SetProperty(Toolkit::TextField::Property::TEXT, text.substr(0, startPosition) + text.substr(endPosition));
2339 bool TextField::AccessibleImpl::DeleteText(size_t startPosition, size_t endPosition)
2341 if(endPosition <= startPosition)
2346 auto self = Toolkit::TextField::DownCast(Self());
2347 auto text = self.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
2349 self.SetProperty(Toolkit::TextField::Property::TEXT, text.substr(0, startPosition) + text.substr(endPosition));
2354 Dali::Accessibility::States TextField::AccessibleImpl::CalculateStates()
2356 using namespace Dali::Accessibility;
2358 auto states = DevelControl::AccessibleImpl::CalculateStates();
2360 states[State::EDITABLE] = true;
2361 states[State::FOCUSABLE] = true;
2363 Toolkit::Control focusControl = Toolkit::KeyInputFocusManager::Get().GetCurrentFocusControl();
2364 if(mSelf == focusControl)
2366 states[State::FOCUSED] = true;
2372 bool TextField::AccessibleImpl::InsertText(size_t startPosition, std::string text)
2374 auto self = Toolkit::TextField::DownCast(Self());
2375 auto insertedText = self.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
2377 insertedText.insert(startPosition, text);
2379 self.SetProperty(Toolkit::TextField::Property::TEXT, std::move(insertedText));
2384 bool TextField::AccessibleImpl::SetTextContents(std::string newContents)
2386 auto self = Toolkit::TextField::DownCast(Self());
2387 self.SetProperty(Toolkit::TextField::Property::TEXT, std::move(newContents));
2391 } // namespace Internal
2393 } // namespace Toolkit