[dali_2.1.0] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-controls / text-field-property-handler.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include <dali-toolkit/internal/controls/text-controls/text-field-property-handler.h>
18 #include <dali-toolkit/internal/controls/text-controls/common-text-utils.h>
19
20 #include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
21 #include <dali-toolkit/devel-api/text/rendering-backend.h>
22
23 #include <dali-toolkit/internal/text/decorator/text-decorator.h>
24 #include <dali-toolkit/internal/text/text-controller.h>
25 #include <dali-toolkit/internal/text/text-effects-style.h>
26 #include <dali-toolkit/internal/text/text-enumerations-impl.h>
27 #include <dali-toolkit/internal/text/text-font-style.h>
28 #include <dali-toolkit/public-api/text/text-enumerations.h>
29 #include <dali/integration-api/debug.h>
30
31 #if defined(DEBUG_ENABLED)
32 extern Debug::Filter* gTextFieldLogFilter;
33 #endif
34
35 namespace Dali::Toolkit::Internal
36 {
37 const char* const TextField::PropertyHandler::IMAGE_MAP_FILENAME_STRING{"filename"};
38
39 /// Retrieves a filename from a value that is a Property::Map
40 std::string TextField::PropertyHandler::GetImageFileNameFromPropertyValue(const Property::Value& value)
41 {
42   std::string          filename;
43   const Property::Map* map = value.GetMap();
44   if(map)
45   {
46     const Property::Value* filenameValue = map->Find(TextField::PropertyHandler::IMAGE_MAP_FILENAME_STRING);
47     if(filenameValue)
48     {
49       filenameValue->Get(filename);
50     }
51   }
52   return filename;
53 }
54
55 void TextField::PropertyHandler::SetProperty(Toolkit::TextField textField, Property::Index index, const Property::Value& value)
56 {
57   TextField& impl(GetImpl(textField));
58   DALI_ASSERT_DEBUG(impl.mController && "No text controller");
59   DALI_ASSERT_DEBUG(impl.mDecorator && "No text decorator");
60
61   switch(index)
62   {
63     case Toolkit::DevelTextField::Property::RENDERING_BACKEND:
64     {
65       int backend = value.Get<int>();
66       DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p RENDERING_BACKEND %d\n", impl.mController.Get(), backend);
67
68 #ifndef ENABLE_VECTOR_BASED_TEXT_RENDERING
69       if(DevelText::RENDERING_VECTOR_BASED == backend)
70       {
71         backend = TextAbstraction::BITMAP_GLYPH; // Fallback to bitmap-based rendering
72       }
73 #endif
74       if(impl.mRenderingBackend != backend)
75       {
76         impl.mRenderingBackend = backend;
77         impl.mRenderer.Reset();
78
79         // When using the vector-based rendering, the size of the GLyphs are different
80         TextAbstraction::GlyphType glyphType = (DevelText::RENDERING_VECTOR_BASED == impl.mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH;
81         impl.mController->SetGlyphType(glyphType);
82       }
83       break;
84     }
85     case Toolkit::TextField::Property::TEXT:
86     {
87       const std::string& text = value.Get<std::string>();
88       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p TEXT %s\n", impl.mController.Get(), text.c_str());
89
90       impl.mController->SetText(text);
91       break;
92     }
93
94     case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
95     {
96       const std::string& text = value.Get<std::string>();
97       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str());
98
99       impl.mController->SetPlaceholderText(Text::Controller::PLACEHOLDER_TYPE_INACTIVE, text);
100       break;
101     }
102     case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED:
103     {
104       const std::string& text = value.Get<std::string>();
105       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_FOCUSED %s\n", impl.mController.Get(), text.c_str());
106
107       impl.mController->SetPlaceholderText(Text::Controller::PLACEHOLDER_TYPE_ACTIVE, text);
108       break;
109     }
110     case Toolkit::TextField::Property::FONT_FAMILY:
111     {
112       const std::string& fontFamily = value.Get<std::string>();
113       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str());
114       impl.mController->SetDefaultFontFamily(fontFamily);
115       break;
116     }
117     case Toolkit::TextField::Property::FONT_STYLE:
118     {
119       SetFontStyleProperty(impl.mController, value, Text::FontStyle::DEFAULT);
120       break;
121     }
122     case Toolkit::TextField::Property::POINT_SIZE:
123     {
124       const float pointSize = value.Get<float>();
125       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p POINT_SIZE %f\n", impl.mController.Get(), pointSize);
126
127       if(!Equals(impl.mController->GetDefaultFontSize(Text::Controller::POINT_SIZE), pointSize))
128       {
129         impl.mController->SetDefaultFontSize(pointSize, Text::Controller::POINT_SIZE);
130       }
131       break;
132     }
133     case Toolkit::TextField::Property::MAX_LENGTH:
134     {
135       const int max = value.Get<int>();
136       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p MAX_LENGTH %d\n", impl.mController.Get(), max);
137
138       impl.mController->SetMaximumNumberOfCharacters(max);
139       break;
140     }
141     case Toolkit::TextField::Property::EXCEED_POLICY:
142     {
143       impl.mExceedPolicy = value.Get<int>();
144
145       if(Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == impl.mExceedPolicy)
146       {
147         impl.EnableClipping();
148       }
149       else
150       {
151         UnparentAndReset(impl.mStencil);
152       }
153       impl.RequestTextRelayout();
154       break;
155     }
156
157     case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
158     {
159       Text::HorizontalAlignment::Type alignment(static_cast<Text::HorizontalAlignment::Type>(-1)); // Set to invalid value to ensure a valid mode does get set
160       if(Text::GetHorizontalAlignmentEnumeration(value, alignment))
161       {
162         DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p HORIZONTAL_ALIGNMENT %d\n", impl.mController.Get(), alignment);
163         impl.mController->SetHorizontalAlignment(alignment);
164       }
165       break;
166     }
167     case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
168     {
169       Toolkit::Text::VerticalAlignment::Type alignment(static_cast<Text::VerticalAlignment::Type>(-1)); // Set to invalid value to ensure a valid mode does get set
170       if(Text::GetVerticalAlignmentEnumeration(value, alignment))
171       {
172         impl.mController->SetVerticalAlignment(alignment);
173         DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p VERTICAL_ALIGNMENT %d\n", impl.mController.Get(), alignment);
174       }
175       break;
176     }
177     case Toolkit::TextField::Property::TEXT_COLOR:
178     {
179       const Vector4& textColor = value.Get<Vector4>();
180       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a);
181
182       if(impl.mController->GetDefaultColor() != textColor)
183       {
184         impl.mController->SetDefaultColor(textColor);
185         impl.mController->SetInputColor(textColor);
186         impl.mRenderer.Reset();
187       }
188       break;
189     }
190     case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR:
191     {
192       const Vector4& textColor = value.Get<Vector4>();
193       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a);
194
195       if(impl.mController->GetPlaceholderTextColor() != textColor)
196       {
197         impl.mController->SetPlaceholderTextColor(textColor);
198         impl.mRenderer.Reset();
199       }
200       break;
201     }
202     case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
203     {
204       const Vector4& color = value.Get<Vector4>();
205       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p PRIMARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a);
206
207       impl.mDecorator->SetCursorColor(Toolkit::Text::PRIMARY_CURSOR, color);
208       impl.RequestTextRelayout();
209       break;
210     }
211     case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
212     {
213       const Vector4& color = value.Get<Vector4>();
214       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p SECONDARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a);
215
216       impl.mDecorator->SetCursorColor(Toolkit::Text::SECONDARY_CURSOR, color);
217       impl.RequestTextRelayout();
218       break;
219     }
220     case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
221     {
222       const bool enable = value.Get<bool>();
223       DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p ENABLE_CURSOR_BLINK %d\n", impl.mController.Get(), enable);
224
225       impl.mController->SetEnableCursorBlink(enable);
226       impl.RequestTextRelayout();
227       break;
228     }
229     case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
230     {
231       const float interval = value.Get<float>();
232       DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_INTERVAL %f\n", impl.mController.Get(), interval);
233
234       impl.mDecorator->SetCursorBlinkInterval(interval);
235       break;
236     }
237     case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
238     {
239       const float duration = value.Get<float>();
240       DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_DURATION %f\n", impl.mController.Get(), duration);
241
242       impl.mDecorator->SetCursorBlinkDuration(duration);
243       break;
244     }
245     case Toolkit::TextField::Property::CURSOR_WIDTH:
246     {
247       const int width = value.Get<int>();
248       DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p CURSOR_WIDTH %d\n", impl.mController.Get(), width);
249
250       impl.mDecorator->SetCursorWidth(width);
251       impl.mController->GetLayoutEngine().SetCursorWidth(width);
252       break;
253     }
254     case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
255     {
256       const std::string imageFileName = value.Get<std::string>();
257       DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str());
258
259       if(imageFileName.size())
260       {
261         impl.mDecorator->SetHandleImage(Toolkit::Text::GRAB_HANDLE, Toolkit::Text::HANDLE_IMAGE_RELEASED, imageFileName);
262         impl.RequestTextRelayout();
263       }
264       break;
265     }
266     case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE:
267     {
268       const std::string imageFileName = value.Get<std::string>();
269       DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_PRESSED_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str());
270
271       if(imageFileName.size())
272       {
273         impl.mDecorator->SetHandleImage(Toolkit::Text::GRAB_HANDLE, Toolkit::Text::HANDLE_IMAGE_PRESSED, imageFileName);
274         impl.RequestTextRelayout();
275       }
276       break;
277     }
278     case Toolkit::TextField::Property::SCROLL_THRESHOLD:
279     {
280       const float threshold = value.Get<float>();
281       DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p SCROLL_THRESHOLD %f\n", impl.mController.Get(), threshold);
282
283       impl.mDecorator->SetScrollThreshold(threshold);
284       break;
285     }
286     case Toolkit::TextField::Property::SCROLL_SPEED:
287     {
288       const float speed = value.Get<float>();
289       DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p SCROLL_SPEED %f\n", impl.mController.Get(), speed);
290
291       impl.mDecorator->SetScrollSpeed(speed);
292       break;
293     }
294     case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT:
295     {
296       const std::string filename = GetImageFileNameFromPropertyValue(value);
297
298       if(filename.size())
299       {
300         impl.mDecorator->SetHandleImage(Toolkit::Text::LEFT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_RELEASED, filename);
301         impl.RequestTextRelayout();
302       }
303       break;
304     }
305     case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT:
306     {
307       const std::string filename = GetImageFileNameFromPropertyValue(value);
308
309       if(filename.size())
310       {
311         impl.mDecorator->SetHandleImage(Toolkit::Text::RIGHT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_RELEASED, filename);
312         impl.RequestTextRelayout();
313       }
314       break;
315     }
316     case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
317     {
318       const std::string filename = GetImageFileNameFromPropertyValue(value);
319
320       if(filename.size())
321       {
322         impl.mDecorator->SetHandleImage(Toolkit::Text::LEFT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_PRESSED, filename);
323         impl.RequestTextRelayout();
324       }
325       break;
326     }
327     case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
328     {
329       const std::string filename = GetImageFileNameFromPropertyValue(value);
330
331       if(filename.size())
332       {
333         impl.mDecorator->SetHandleImage(Toolkit::Text::RIGHT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_PRESSED, filename);
334         impl.RequestTextRelayout();
335       }
336       break;
337     }
338     case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
339     {
340       const std::string filename = GetImageFileNameFromPropertyValue(value);
341
342       if(filename.size())
343       {
344         impl.mDecorator->SetHandleImage(Toolkit::Text::LEFT_SELECTION_HANDLE_MARKER,
345                                         Toolkit::Text::HANDLE_IMAGE_RELEASED,
346                                         filename);
347         impl.RequestTextRelayout();
348       }
349       break;
350     }
351     case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
352     {
353       const std::string filename = GetImageFileNameFromPropertyValue(value);
354
355       if(filename.size())
356       {
357         impl.mDecorator->SetHandleImage(Toolkit::Text::RIGHT_SELECTION_HANDLE_MARKER,
358                                         Toolkit::Text::HANDLE_IMAGE_RELEASED,
359                                         filename);
360         impl.RequestTextRelayout();
361       }
362       break;
363     }
364     case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR:
365     {
366       const Vector4 color = value.Get<Vector4>();
367       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p SELECTION_HIGHLIGHT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a);
368
369       impl.mDecorator->SetHighlightColor(color);
370       impl.RequestTextRelayout();
371       break;
372     }
373     case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
374     {
375       const Rect<int>& box = value.Get<Rect<int> >();
376       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p DECORATION_BOUNDING_BOX %d,%d %dx%d\n", impl.mController.Get(), box.x, box.y, box.width, box.height);
377
378       impl.mDecorator->SetBoundingBox(box);
379       impl.RequestTextRelayout();
380       break;
381     }
382     case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS:
383     {
384       const Property::Map* map = value.GetMap();
385       if(map)
386       {
387         impl.mInputMethodOptions.ApplyProperty(*map);
388       }
389       impl.mController->SetInputModePassword(impl.mInputMethodOptions.IsPassword());
390
391       Toolkit::Control control = Toolkit::KeyInputFocusManager::Get().GetCurrentFocusControl();
392       if(control == textField)
393       {
394         impl.mInputMethodContext.ApplyOptions(impl.mInputMethodOptions);
395       }
396       break;
397     }
398     case Toolkit::TextField::Property::INPUT_COLOR:
399     {
400       const Vector4& inputColor = value.Get<Vector4>();
401       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p INPUT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), inputColor.r, inputColor.g, inputColor.b, inputColor.a);
402
403       impl.mController->SetInputColor(inputColor);
404       break;
405     }
406     case Toolkit::TextField::Property::ENABLE_MARKUP:
407     {
408       const bool enableMarkup = value.Get<bool>();
409       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p ENABLE_MARKUP %d\n", impl.mController.Get(), enableMarkup);
410
411       impl.mController->SetMarkupProcessorEnabled(enableMarkup);
412       CommonTextUtils::SynchronizeTextAnchorsInParent(textField, impl.mController, impl.mAnchorActors);
413       break;
414     }
415     case Toolkit::TextField::Property::INPUT_FONT_FAMILY:
416     {
417       const std::string& fontFamily = value.Get<std::string>();
418       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p INPUT_FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str());
419       impl.mController->SetInputFontFamily(fontFamily);
420       break;
421     }
422     case Toolkit::TextField::Property::INPUT_FONT_STYLE:
423     {
424       SetFontStyleProperty(impl.mController, value, Text::FontStyle::INPUT);
425       break;
426     }
427     case Toolkit::TextField::Property::INPUT_POINT_SIZE:
428     {
429       const float pointSize = value.Get<float>();
430       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p INPUT_POINT_SIZE %f\n", impl.mController.Get(), pointSize);
431       impl.mController->SetInputFontPointSize(pointSize);
432       break;
433     }
434     case Toolkit::TextField::Property::UNDERLINE:
435     {
436       const bool update = SetUnderlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
437       if(update)
438       {
439         impl.mRenderer.Reset();
440       }
441       break;
442     }
443     case Toolkit::TextField::Property::INPUT_UNDERLINE:
444     {
445       const bool update = SetUnderlineProperties(impl.mController, value, Text::EffectStyle::INPUT);
446       if(update)
447       {
448         impl.mRenderer.Reset();
449       }
450       break;
451     }
452     case Toolkit::TextField::Property::SHADOW:
453     {
454       const bool update = SetShadowProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
455       if(update)
456       {
457         impl.mRenderer.Reset();
458       }
459       break;
460     }
461     case Toolkit::TextField::Property::INPUT_SHADOW:
462     {
463       const bool update = SetShadowProperties(impl.mController, value, Text::EffectStyle::INPUT);
464       if(update)
465       {
466         impl.mRenderer.Reset();
467       }
468       break;
469     }
470     case Toolkit::TextField::Property::EMBOSS:
471     {
472       const bool update = SetEmbossProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
473       if(update)
474       {
475         impl.mRenderer.Reset();
476       }
477       break;
478     }
479     case Toolkit::TextField::Property::INPUT_EMBOSS:
480     {
481       const bool update = SetEmbossProperties(impl.mController, value, Text::EffectStyle::INPUT);
482       if(update)
483       {
484         impl.mRenderer.Reset();
485       }
486       break;
487     }
488     case Toolkit::TextField::Property::OUTLINE:
489     {
490       const bool update = SetOutlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
491       if(update)
492       {
493         impl.mRenderer.Reset();
494       }
495       break;
496     }
497     case Toolkit::TextField::Property::INPUT_OUTLINE:
498     {
499       const bool update = SetOutlineProperties(impl.mController, value, Text::EffectStyle::INPUT);
500       if(update)
501       {
502         impl.mRenderer.Reset();
503       }
504       break;
505     }
506     case Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS:
507     {
508       const Property::Map* map = value.GetMap();
509       if(map)
510       {
511         impl.mController->SetHiddenInputOption(*map);
512         auto mode = map->Find(Toolkit::HiddenInput::Property::MODE);
513         if(mode && (mode->Get<int>() != Toolkit::HiddenInput::Mode::HIDE_NONE))
514         {
515           textField.SetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_ROLE, Accessibility::Role::PASSWORD_TEXT);
516         }
517         else
518         {
519           textField.SetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_ROLE, Accessibility::Role::ENTRY);
520         }
521       }
522       break;
523     }
524     case Toolkit::TextField::Property::PIXEL_SIZE:
525     {
526       const float pixelSize = value.Get<float>();
527       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p PIXEL_SIZE %f\n", impl.mController.Get(), pixelSize);
528
529       if(!Equals(impl.mController->GetDefaultFontSize(Text::Controller::PIXEL_SIZE), pixelSize))
530       {
531         impl.mController->SetDefaultFontSize(pixelSize, Text::Controller::PIXEL_SIZE);
532       }
533       break;
534     }
535     case Toolkit::TextField::Property::ENABLE_SELECTION:
536     {
537       const bool enableSelection = value.Get<bool>();
538       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p ENABLE_SELECTION %d\n", impl.mController.Get(), enableSelection);
539       impl.mController->SetSelectionEnabled(enableSelection);
540       break;
541     }
542     case Toolkit::TextField::Property::PLACEHOLDER:
543     {
544       const Property::Map* map = value.GetMap();
545       if(map)
546       {
547         impl.mController->SetPlaceholderProperty(*map);
548       }
549       break;
550     }
551     case Toolkit::TextField::Property::ELLIPSIS:
552     {
553       const bool ellipsis = value.Get<bool>();
554       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p ELLIPSIS %d\n", impl.mController.Get(), ellipsis);
555
556       impl.mController->SetTextElideEnabled(ellipsis);
557       break;
558     }
559     case Toolkit::DevelTextField::Property::ENABLE_SHIFT_SELECTION:
560     {
561       const bool shiftSelection = value.Get<bool>();
562       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p ENABLE_SHIFT_SELECTION %d\n", impl.mController.Get(), shiftSelection);
563
564       impl.mController->SetShiftSelectionEnabled(shiftSelection);
565       break;
566     }
567     case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE:
568     {
569       const bool grabHandleEnabled = value.Get<bool>();
570       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p ENABLE_GRAB_HANDLE %d\n", impl.mController.Get(), grabHandleEnabled);
571
572       impl.mController->SetGrabHandleEnabled(grabHandleEnabled);
573       break;
574     }
575     case Toolkit::DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
576     {
577       impl.mController->SetMatchLayoutDirection(value.Get<bool>() ? DevelText::MatchLayoutDirection::LOCALE : DevelText::MatchLayoutDirection::CONTENTS);
578       break;
579     }
580     case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP:
581     {
582       const bool grabHandlePopupEnabled = value.Get<bool>();
583       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p ENABLE_GRAB_HANDLE_POPUP %d\n", impl.mController.Get(), grabHandlePopupEnabled);
584
585       impl.mController->SetGrabHandlePopupEnabled(grabHandlePopupEnabled);
586       break;
587     }
588     case Toolkit::DevelTextField::Property::BACKGROUND:
589     {
590       const Vector4 backgroundColor = value.Get<Vector4>();
591       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p BACKGROUND %f,%f,%f,%f\n", impl.mController.Get(), backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a);
592
593       impl.mController->SetBackgroundEnabled(true);
594       impl.mController->SetBackgroundColor(backgroundColor);
595       break;
596     }
597     case Toolkit::DevelTextField::Property::SELECTED_TEXT_START:
598     {
599       uint32_t start = static_cast<uint32_t>(value.Get<int>());
600       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p SELECTED_TEXT_START %d\n", impl.mController.Get(), start);
601       impl.SetTextSelectionRange(&start, nullptr);
602       break;
603     }
604     case Toolkit::DevelTextField::Property::SELECTED_TEXT_END:
605     {
606       uint32_t end = static_cast<uint32_t>(value.Get<int>());
607       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p SELECTED_TEXT_END %d\n", impl.mController.Get(), end);
608       impl.SetTextSelectionRange(nullptr, &end);
609       break;
610     }
611     case Toolkit::DevelTextField::Property::ENABLE_EDITING:
612     {
613       const bool editable = value.Get<bool>();
614       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p ENABLE_EDITING %d\n", impl.mController.Get(), editable);
615       impl.SetEditable(editable);
616       break;
617     }
618     case Toolkit::DevelTextField::Property::FONT_SIZE_SCALE:
619     {
620       const float scale = value.Get<float>();
621       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p FONT_SIZE_SCALE %f\n", impl.mController.Get(), scale);
622
623       if(!Equals(impl.mController->GetFontSizeScale(), scale))
624       {
625         impl.mController->SetFontSizeScale(scale);
626       }
627       break;
628     }
629     case Toolkit::DevelTextField::Property::PRIMARY_CURSOR_POSITION:
630     {
631       uint32_t position = static_cast<uint32_t>(value.Get<int>());
632       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p PRIMARY_CURSOR_POSITION %d\n", impl.mController.Get(), position);
633       if(impl.mController->SetPrimaryCursorPosition(position, impl.HasKeyInputFocus()))
634       {
635         impl.SetKeyInputFocus();
636       }
637       break;
638     }
639     case Toolkit::DevelTextField::Property::GRAB_HANDLE_COLOR:
640     {
641       const Vector4 color = value.Get<Vector4>();
642       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p GRAB_HANDLE_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a);
643
644       impl.mDecorator->SetHandleColor(color);
645       impl.RequestTextRelayout();
646       break;
647     }
648
649     case Toolkit::DevelTextField::Property::INPUT_FILTER:
650     {
651       const Property::Map* map = value.GetMap();
652       if(map)
653       {
654         impl.mController->SetInputFilterOption(*map);
655       }
656       break;
657     }
658     case Toolkit::DevelTextField::Property::ELLIPSIS_POSITION:
659     {
660       DevelText::EllipsisPosition::Type ellipsisPositionType(static_cast<DevelText::EllipsisPosition::Type>(-1)); // Set to invalid value to ensure a valid mode does get set
661       if(Text::GetEllipsisPositionTypeEnumeration(value, ellipsisPositionType))
662       {
663         DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p EllipsisPosition::Type %d\n", impl.mController.Get(), ellipsisPositionType);
664         impl.mController->SetEllipsisPosition(ellipsisPositionType);
665       }
666       break;
667     }
668   }
669 }
670
671 Property::Value TextField::PropertyHandler::GetProperty(Toolkit::TextField textField, Property::Index index)
672 {
673   Property::Value value;
674   TextField&      impl(GetImpl(textField));
675   DALI_ASSERT_DEBUG(impl.mController && "No text controller");
676   DALI_ASSERT_DEBUG(impl.mDecorator && "No text decorator");
677
678   switch(index)
679   {
680     case Toolkit::DevelTextField::Property::RENDERING_BACKEND:
681     {
682       value = impl.mRenderingBackend;
683       break;
684     }
685     case Toolkit::TextField::Property::TEXT:
686     {
687       std::string text;
688       impl.mController->GetText(text);
689       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p returning text: %s\n", impl.mController.Get(), text.c_str());
690       value = text;
691       break;
692     }
693     case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
694     {
695       std::string text;
696       impl.mController->GetPlaceholderText(Text::Controller::PLACEHOLDER_TYPE_INACTIVE, text);
697       value = text;
698       break;
699     }
700     case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED:
701     {
702       std::string text;
703       impl.mController->GetPlaceholderText(Text::Controller::PLACEHOLDER_TYPE_ACTIVE, text);
704       value = text;
705       break;
706     }
707     case Toolkit::TextField::Property::FONT_FAMILY:
708     {
709       value = impl.mController->GetDefaultFontFamily();
710       break;
711     }
712     case Toolkit::TextField::Property::FONT_STYLE:
713     {
714       GetFontStyleProperty(impl.mController, value, Text::FontStyle::DEFAULT);
715       break;
716     }
717     case Toolkit::TextField::Property::POINT_SIZE:
718     {
719       value = impl.mController->GetDefaultFontSize(Text::Controller::POINT_SIZE);
720       break;
721     }
722     case Toolkit::TextField::Property::MAX_LENGTH:
723     {
724       value = impl.mController->GetMaximumNumberOfCharacters();
725       break;
726     }
727     case Toolkit::TextField::Property::EXCEED_POLICY:
728     {
729       value = impl.mExceedPolicy;
730       break;
731     }
732     case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
733     {
734       const char* name = Text::GetHorizontalAlignmentString(impl.mController->GetHorizontalAlignment());
735       if(name)
736       {
737         value = std::string(name);
738       }
739       break;
740     }
741     case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
742     {
743       const char* name = Text::GetVerticalAlignmentString(impl.mController->GetVerticalAlignment());
744
745       if(name)
746       {
747         value = std::string(name);
748       }
749       break;
750     }
751     case Toolkit::TextField::Property::TEXT_COLOR:
752     {
753       value = impl.mController->GetDefaultColor();
754       break;
755     }
756     case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR:
757     {
758       value = impl.mController->GetPlaceholderTextColor();
759       break;
760     }
761     case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
762     {
763       value = impl.mDecorator->GetColor(Text::PRIMARY_CURSOR);
764       break;
765     }
766     case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
767     {
768       value = impl.mDecorator->GetColor(Text::SECONDARY_CURSOR);
769       break;
770     }
771     case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
772     {
773       value = impl.mController->GetEnableCursorBlink();
774       break;
775     }
776     case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
777     {
778       value = impl.mDecorator->GetCursorBlinkInterval();
779       break;
780     }
781     case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
782     {
783       value = impl.mDecorator->GetCursorBlinkDuration();
784       break;
785     }
786     case Toolkit::TextField::Property::CURSOR_WIDTH:
787     {
788       value = impl.mDecorator->GetCursorWidth();
789       break;
790     }
791     case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
792     {
793       value = impl.mDecorator->GetHandleImage(Text::GRAB_HANDLE, Text::HANDLE_IMAGE_RELEASED);
794       break;
795     }
796     case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE:
797     {
798       value = impl.mDecorator->GetHandleImage(Text::GRAB_HANDLE, Text::HANDLE_IMAGE_PRESSED);
799       break;
800     }
801     case Toolkit::TextField::Property::SCROLL_THRESHOLD:
802     {
803       value = impl.mDecorator->GetScrollThreshold();
804       break;
805     }
806     case Toolkit::TextField::Property::SCROLL_SPEED:
807     {
808       value = impl.mDecorator->GetScrollSpeed();
809       break;
810     }
811     case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT:
812     {
813       impl.GetHandleImagePropertyValue(value, Text::LEFT_SELECTION_HANDLE, Text::HANDLE_IMAGE_RELEASED);
814       break;
815     }
816     case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT:
817     {
818       impl.GetHandleImagePropertyValue(value, Text::RIGHT_SELECTION_HANDLE, Text::HANDLE_IMAGE_RELEASED);
819       break;
820     }
821     case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
822     {
823       impl.GetHandleImagePropertyValue(value, Text::LEFT_SELECTION_HANDLE, Text::HANDLE_IMAGE_PRESSED);
824       break;
825     }
826     case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
827     {
828       impl.GetHandleImagePropertyValue(value, Text::RIGHT_SELECTION_HANDLE, Text::HANDLE_IMAGE_PRESSED);
829       break;
830     }
831     case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
832     {
833       impl.GetHandleImagePropertyValue(value, Text::LEFT_SELECTION_HANDLE_MARKER, Text::HANDLE_IMAGE_RELEASED);
834       break;
835     }
836     case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
837     {
838       impl.GetHandleImagePropertyValue(value, Text::RIGHT_SELECTION_HANDLE_MARKER, Text::HANDLE_IMAGE_RELEASED);
839       break;
840     }
841     case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR:
842     {
843       value = impl.mDecorator->GetHighlightColor();
844       break;
845     }
846     case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
847     {
848       Rect<int> boundingBox;
849       impl.mDecorator->GetBoundingBox(boundingBox);
850       value = boundingBox;
851       break;
852     }
853     case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS:
854     {
855       Property::Map map;
856       impl.mInputMethodOptions.RetrieveProperty(map);
857       value = map;
858       break;
859     }
860     case Toolkit::TextField::Property::INPUT_COLOR:
861     {
862       value = impl.mController->GetInputColor();
863       break;
864     }
865     case Toolkit::TextField::Property::ENABLE_MARKUP:
866     {
867       value = impl.mController->IsMarkupProcessorEnabled();
868       break;
869     }
870     case Toolkit::TextField::Property::INPUT_FONT_FAMILY:
871     {
872       value = impl.mController->GetInputFontFamily();
873       break;
874     }
875     case Toolkit::TextField::Property::INPUT_FONT_STYLE:
876     {
877       GetFontStyleProperty(impl.mController, value, Text::FontStyle::INPUT);
878       break;
879     }
880     case Toolkit::TextField::Property::INPUT_POINT_SIZE:
881     {
882       value = impl.mController->GetInputFontPointSize();
883       break;
884     }
885     case Toolkit::TextField::Property::UNDERLINE:
886     {
887       GetUnderlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
888       break;
889     }
890     case Toolkit::TextField::Property::INPUT_UNDERLINE:
891     {
892       GetUnderlineProperties(impl.mController, value, Text::EffectStyle::INPUT);
893       break;
894     }
895     case Toolkit::TextField::Property::SHADOW:
896     {
897       GetShadowProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
898       break;
899     }
900     case Toolkit::TextField::Property::INPUT_SHADOW:
901     {
902       GetShadowProperties(impl.mController, value, Text::EffectStyle::INPUT);
903       break;
904     }
905     case Toolkit::TextField::Property::EMBOSS:
906     {
907       GetEmbossProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
908       break;
909     }
910     case Toolkit::TextField::Property::INPUT_EMBOSS:
911     {
912       GetEmbossProperties(impl.mController, value, Text::EffectStyle::INPUT);
913       break;
914     }
915     case Toolkit::TextField::Property::OUTLINE:
916     {
917       GetOutlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
918       break;
919     }
920     case Toolkit::TextField::Property::INPUT_OUTLINE:
921     {
922       GetOutlineProperties(impl.mController, value, Text::EffectStyle::INPUT);
923       break;
924     }
925     case Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS:
926     {
927       Property::Map map;
928       impl.mController->GetHiddenInputOption(map);
929       value = map;
930       break;
931     }
932     case Toolkit::TextField::Property::PIXEL_SIZE:
933     {
934       value = impl.mController->GetDefaultFontSize(Text::Controller::PIXEL_SIZE);
935       break;
936     }
937     case Toolkit::TextField::Property::ENABLE_SELECTION:
938     {
939       value = impl.mController->IsSelectionEnabled();
940       break;
941     }
942     case Toolkit::TextField::Property::PLACEHOLDER:
943     {
944       Property::Map map;
945       impl.mController->GetPlaceholderProperty(map);
946       value = map;
947       break;
948     }
949     case Toolkit::TextField::Property::ELLIPSIS:
950     {
951       value = impl.mController->IsTextElideEnabled();
952       break;
953     }
954     case Toolkit::DevelTextField::Property::ENABLE_SHIFT_SELECTION:
955     {
956       value = impl.mController->IsShiftSelectionEnabled();
957       break;
958     }
959     case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE:
960     {
961       value = impl.mController->IsGrabHandleEnabled();
962       break;
963     }
964     case Toolkit::DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
965     {
966       value = impl.mController->GetMatchLayoutDirection() != DevelText::MatchLayoutDirection::CONTENTS;
967       break;
968     }
969     case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP:
970     {
971       value = impl.mController->IsGrabHandlePopupEnabled();
972       break;
973     }
974     case Toolkit::DevelTextField::Property::BACKGROUND:
975     {
976       value = impl.mController->GetBackgroundColor();
977       break;
978     }
979     case Toolkit::DevelTextField::Property::SELECTED_TEXT:
980     {
981       value = impl.mController->GetSelectedText();
982       break;
983     }
984     case Toolkit::DevelTextField::Property::SELECTED_TEXT_START:
985     {
986       Uint32Pair range = impl.GetTextSelectionRange();
987       value            = static_cast<int>(range.first);
988       break;
989     }
990     case Toolkit::DevelTextField::Property::SELECTED_TEXT_END:
991     {
992       Uint32Pair range = impl.GetTextSelectionRange();
993       value            = static_cast<int>(range.second);
994       break;
995     }
996     case Toolkit::DevelTextField::Property::ENABLE_EDITING:
997     {
998       value = impl.IsEditable();
999       break;
1000     }
1001     case Toolkit::DevelTextField::Property::FONT_SIZE_SCALE:
1002     {
1003       value = impl.mController->GetFontSizeScale();
1004       break;
1005     }
1006     case Toolkit::DevelTextField::Property::PRIMARY_CURSOR_POSITION:
1007     {
1008       value = static_cast<int>(impl.mController->GetPrimaryCursorPosition());
1009       break;
1010     }
1011     case Toolkit::DevelTextField::Property::GRAB_HANDLE_COLOR:
1012     {
1013       value = impl.mDecorator->GetHandleColor();
1014       break;
1015     }
1016     case Toolkit::DevelTextField::Property::INPUT_FILTER:
1017     {
1018       Property::Map map;
1019       impl.mController->GetInputFilterOption(map);
1020       value = map;
1021       break;
1022     }
1023     case Toolkit::DevelTextField::Property::ELLIPSIS_POSITION:
1024     {
1025       value = impl.mController->GetEllipsisPosition();
1026       break;
1027     }
1028   } //switch
1029   return value;
1030 }
1031
1032 } // namespace Dali::Toolkit::Internal