Extending Style - Adding Strikethrough
[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/common-text-utils.h>
18 #include <dali-toolkit/internal/controls/text-controls/text-field-property-handler.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     case Toolkit::DevelTextField::Property::STRIKETHROUGH:
669     {
670       const bool update = SetStrikethroughProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
671       if(update)
672       {
673         impl.mRenderer.Reset();
674       }
675       break;
676     }
677     case Toolkit::DevelTextField::Property::INPUT_STRIKETHROUGH:
678     {
679       const bool update = SetStrikethroughProperties(impl.mController, value, Text::EffectStyle::INPUT);
680       if(update)
681       {
682         impl.mRenderer.Reset();
683       }
684       break;
685     }
686   }
687 }
688
689 Property::Value TextField::PropertyHandler::GetProperty(Toolkit::TextField textField, Property::Index index)
690 {
691   Property::Value value;
692   TextField&      impl(GetImpl(textField));
693   DALI_ASSERT_DEBUG(impl.mController && "No text controller");
694   DALI_ASSERT_DEBUG(impl.mDecorator && "No text decorator");
695
696   switch(index)
697   {
698     case Toolkit::DevelTextField::Property::RENDERING_BACKEND:
699     {
700       value = impl.mRenderingBackend;
701       break;
702     }
703     case Toolkit::TextField::Property::TEXT:
704     {
705       std::string text;
706       impl.mController->GetText(text);
707       DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p returning text: %s\n", impl.mController.Get(), text.c_str());
708       value = text;
709       break;
710     }
711     case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
712     {
713       std::string text;
714       impl.mController->GetPlaceholderText(Text::Controller::PLACEHOLDER_TYPE_INACTIVE, text);
715       value = text;
716       break;
717     }
718     case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED:
719     {
720       std::string text;
721       impl.mController->GetPlaceholderText(Text::Controller::PLACEHOLDER_TYPE_ACTIVE, text);
722       value = text;
723       break;
724     }
725     case Toolkit::TextField::Property::FONT_FAMILY:
726     {
727       value = impl.mController->GetDefaultFontFamily();
728       break;
729     }
730     case Toolkit::TextField::Property::FONT_STYLE:
731     {
732       GetFontStyleProperty(impl.mController, value, Text::FontStyle::DEFAULT);
733       break;
734     }
735     case Toolkit::TextField::Property::POINT_SIZE:
736     {
737       value = impl.mController->GetDefaultFontSize(Text::Controller::POINT_SIZE);
738       break;
739     }
740     case Toolkit::TextField::Property::MAX_LENGTH:
741     {
742       value = impl.mController->GetMaximumNumberOfCharacters();
743       break;
744     }
745     case Toolkit::TextField::Property::EXCEED_POLICY:
746     {
747       value = impl.mExceedPolicy;
748       break;
749     }
750     case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
751     {
752       const char* name = Text::GetHorizontalAlignmentString(impl.mController->GetHorizontalAlignment());
753       if(name)
754       {
755         value = std::string(name);
756       }
757       break;
758     }
759     case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
760     {
761       const char* name = Text::GetVerticalAlignmentString(impl.mController->GetVerticalAlignment());
762
763       if(name)
764       {
765         value = std::string(name);
766       }
767       break;
768     }
769     case Toolkit::TextField::Property::TEXT_COLOR:
770     {
771       value = impl.mController->GetDefaultColor();
772       break;
773     }
774     case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR:
775     {
776       value = impl.mController->GetPlaceholderTextColor();
777       break;
778     }
779     case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
780     {
781       value = impl.mDecorator->GetColor(Text::PRIMARY_CURSOR);
782       break;
783     }
784     case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
785     {
786       value = impl.mDecorator->GetColor(Text::SECONDARY_CURSOR);
787       break;
788     }
789     case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
790     {
791       value = impl.mController->GetEnableCursorBlink();
792       break;
793     }
794     case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
795     {
796       value = impl.mDecorator->GetCursorBlinkInterval();
797       break;
798     }
799     case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
800     {
801       value = impl.mDecorator->GetCursorBlinkDuration();
802       break;
803     }
804     case Toolkit::TextField::Property::CURSOR_WIDTH:
805     {
806       value = impl.mDecorator->GetCursorWidth();
807       break;
808     }
809     case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
810     {
811       value = impl.mDecorator->GetHandleImage(Text::GRAB_HANDLE, Text::HANDLE_IMAGE_RELEASED);
812       break;
813     }
814     case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE:
815     {
816       value = impl.mDecorator->GetHandleImage(Text::GRAB_HANDLE, Text::HANDLE_IMAGE_PRESSED);
817       break;
818     }
819     case Toolkit::TextField::Property::SCROLL_THRESHOLD:
820     {
821       value = impl.mDecorator->GetScrollThreshold();
822       break;
823     }
824     case Toolkit::TextField::Property::SCROLL_SPEED:
825     {
826       value = impl.mDecorator->GetScrollSpeed();
827       break;
828     }
829     case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT:
830     {
831       impl.GetHandleImagePropertyValue(value, Text::LEFT_SELECTION_HANDLE, Text::HANDLE_IMAGE_RELEASED);
832       break;
833     }
834     case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT:
835     {
836       impl.GetHandleImagePropertyValue(value, Text::RIGHT_SELECTION_HANDLE, Text::HANDLE_IMAGE_RELEASED);
837       break;
838     }
839     case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
840     {
841       impl.GetHandleImagePropertyValue(value, Text::LEFT_SELECTION_HANDLE, Text::HANDLE_IMAGE_PRESSED);
842       break;
843     }
844     case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
845     {
846       impl.GetHandleImagePropertyValue(value, Text::RIGHT_SELECTION_HANDLE, Text::HANDLE_IMAGE_PRESSED);
847       break;
848     }
849     case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
850     {
851       impl.GetHandleImagePropertyValue(value, Text::LEFT_SELECTION_HANDLE_MARKER, Text::HANDLE_IMAGE_RELEASED);
852       break;
853     }
854     case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
855     {
856       impl.GetHandleImagePropertyValue(value, Text::RIGHT_SELECTION_HANDLE_MARKER, Text::HANDLE_IMAGE_RELEASED);
857       break;
858     }
859     case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR:
860     {
861       value = impl.mDecorator->GetHighlightColor();
862       break;
863     }
864     case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
865     {
866       Rect<int> boundingBox;
867       impl.mDecorator->GetBoundingBox(boundingBox);
868       value = boundingBox;
869       break;
870     }
871     case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS:
872     {
873       Property::Map map;
874       impl.mInputMethodOptions.RetrieveProperty(map);
875       value = map;
876       break;
877     }
878     case Toolkit::TextField::Property::INPUT_COLOR:
879     {
880       value = impl.mController->GetInputColor();
881       break;
882     }
883     case Toolkit::TextField::Property::ENABLE_MARKUP:
884     {
885       value = impl.mController->IsMarkupProcessorEnabled();
886       break;
887     }
888     case Toolkit::TextField::Property::INPUT_FONT_FAMILY:
889     {
890       value = impl.mController->GetInputFontFamily();
891       break;
892     }
893     case Toolkit::TextField::Property::INPUT_FONT_STYLE:
894     {
895       GetFontStyleProperty(impl.mController, value, Text::FontStyle::INPUT);
896       break;
897     }
898     case Toolkit::TextField::Property::INPUT_POINT_SIZE:
899     {
900       value = impl.mController->GetInputFontPointSize();
901       break;
902     }
903     case Toolkit::TextField::Property::UNDERLINE:
904     {
905       GetUnderlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
906       break;
907     }
908     case Toolkit::TextField::Property::INPUT_UNDERLINE:
909     {
910       GetUnderlineProperties(impl.mController, value, Text::EffectStyle::INPUT);
911       break;
912     }
913     case Toolkit::TextField::Property::SHADOW:
914     {
915       GetShadowProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
916       break;
917     }
918     case Toolkit::TextField::Property::INPUT_SHADOW:
919     {
920       GetShadowProperties(impl.mController, value, Text::EffectStyle::INPUT);
921       break;
922     }
923     case Toolkit::TextField::Property::EMBOSS:
924     {
925       GetEmbossProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
926       break;
927     }
928     case Toolkit::TextField::Property::INPUT_EMBOSS:
929     {
930       GetEmbossProperties(impl.mController, value, Text::EffectStyle::INPUT);
931       break;
932     }
933     case Toolkit::TextField::Property::OUTLINE:
934     {
935       GetOutlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
936       break;
937     }
938     case Toolkit::TextField::Property::INPUT_OUTLINE:
939     {
940       GetOutlineProperties(impl.mController, value, Text::EffectStyle::INPUT);
941       break;
942     }
943     case Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS:
944     {
945       Property::Map map;
946       impl.mController->GetHiddenInputOption(map);
947       value = map;
948       break;
949     }
950     case Toolkit::TextField::Property::PIXEL_SIZE:
951     {
952       value = impl.mController->GetDefaultFontSize(Text::Controller::PIXEL_SIZE);
953       break;
954     }
955     case Toolkit::TextField::Property::ENABLE_SELECTION:
956     {
957       value = impl.mController->IsSelectionEnabled();
958       break;
959     }
960     case Toolkit::TextField::Property::PLACEHOLDER:
961     {
962       Property::Map map;
963       impl.mController->GetPlaceholderProperty(map);
964       value = map;
965       break;
966     }
967     case Toolkit::TextField::Property::ELLIPSIS:
968     {
969       value = impl.mController->IsTextElideEnabled();
970       break;
971     }
972     case Toolkit::DevelTextField::Property::ENABLE_SHIFT_SELECTION:
973     {
974       value = impl.mController->IsShiftSelectionEnabled();
975       break;
976     }
977     case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE:
978     {
979       value = impl.mController->IsGrabHandleEnabled();
980       break;
981     }
982     case Toolkit::DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
983     {
984       value = impl.mController->GetMatchLayoutDirection() != DevelText::MatchLayoutDirection::CONTENTS;
985       break;
986     }
987     case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP:
988     {
989       value = impl.mController->IsGrabHandlePopupEnabled();
990       break;
991     }
992     case Toolkit::DevelTextField::Property::BACKGROUND:
993     {
994       value = impl.mController->GetBackgroundColor();
995       break;
996     }
997     case Toolkit::DevelTextField::Property::SELECTED_TEXT:
998     {
999       value = impl.mController->GetSelectedText();
1000       break;
1001     }
1002     case Toolkit::DevelTextField::Property::SELECTED_TEXT_START:
1003     {
1004       Uint32Pair range = impl.GetTextSelectionRange();
1005       value            = static_cast<int>(range.first);
1006       break;
1007     }
1008     case Toolkit::DevelTextField::Property::SELECTED_TEXT_END:
1009     {
1010       Uint32Pair range = impl.GetTextSelectionRange();
1011       value            = static_cast<int>(range.second);
1012       break;
1013     }
1014     case Toolkit::DevelTextField::Property::ENABLE_EDITING:
1015     {
1016       value = impl.IsEditable();
1017       break;
1018     }
1019     case Toolkit::DevelTextField::Property::FONT_SIZE_SCALE:
1020     {
1021       value = impl.mController->GetFontSizeScale();
1022       break;
1023     }
1024     case Toolkit::DevelTextField::Property::PRIMARY_CURSOR_POSITION:
1025     {
1026       value = static_cast<int>(impl.mController->GetPrimaryCursorPosition());
1027       break;
1028     }
1029     case Toolkit::DevelTextField::Property::GRAB_HANDLE_COLOR:
1030     {
1031       value = impl.mDecorator->GetHandleColor();
1032       break;
1033     }
1034     case Toolkit::DevelTextField::Property::INPUT_FILTER:
1035     {
1036       Property::Map map;
1037       impl.mController->GetInputFilterOption(map);
1038       value = map;
1039       break;
1040     }
1041     case Toolkit::DevelTextField::Property::ELLIPSIS_POSITION:
1042     {
1043       value = impl.mController->GetEllipsisPosition();
1044       break;
1045     }
1046     case Toolkit::DevelTextField::Property::STRIKETHROUGH:
1047     {
1048       GetStrikethroughProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
1049       break;
1050     }
1051     case Toolkit::DevelTextField::Property::INPUT_STRIKETHROUGH:
1052     {
1053       GetStrikethroughProperties(impl.mController, value, Text::EffectStyle::INPUT);
1054       break;
1055     }
1056   } //switch
1057   return value;
1058 }
1059
1060 } // namespace Dali::Toolkit::Internal