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