2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <dali-toolkit/internal/controls/text-controls/text-field-property-handler.h>
19 #include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
20 #include <dali-toolkit/devel-api/text/rendering-backend.h>
22 #include <dali-toolkit/internal/text/decorator/text-decorator.h>
23 #include <dali-toolkit/internal/text/text-controller.h>
24 #include <dali-toolkit/internal/text/text-effects-style.h>
25 #include <dali-toolkit/internal/text/text-enumerations-impl.h>
26 #include <dali-toolkit/internal/text/text-font-style.h>
27 #include <dali-toolkit/public-api/text/text-enumerations.h>
28 #include <dali/integration-api/debug.h>
30 #if defined(DEBUG_ENABLED)
31 extern Debug::Filter* gTextFieldLogFilter;
34 namespace Dali::Toolkit::Internal
36 const char* const TextField::PropertyHandler::IMAGE_MAP_FILENAME_STRING{"filename"};
38 /// Retrieves a filename from a value that is a Property::Map
39 std::string TextField::PropertyHandler::GetImageFileNameFromPropertyValue(const Property::Value& value)
42 const Property::Map* map = value.GetMap();
45 const Property::Value* filenameValue = map->Find(TextField::PropertyHandler::IMAGE_MAP_FILENAME_STRING);
48 filenameValue->Get(filename);
54 void TextField::PropertyHandler::SetProperty(Toolkit::TextField textField, Property::Index index, const Property::Value& value)
56 TextField& impl(GetImpl(textField));
57 DALI_ASSERT_DEBUG(impl.mController && "No text controller");
58 DALI_ASSERT_DEBUG(impl.mDecorator && "No text decorator");
62 case Toolkit::DevelTextField::Property::RENDERING_BACKEND:
64 int backend = value.Get<int>();
65 DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p RENDERING_BACKEND %d\n", impl.mController.Get(), backend);
67 #ifndef ENABLE_VECTOR_BASED_TEXT_RENDERING
68 if(DevelText::RENDERING_VECTOR_BASED == backend)
70 backend = TextAbstraction::BITMAP_GLYPH; // Fallback to bitmap-based rendering
73 if(impl.mRenderingBackend != backend)
75 impl.mRenderingBackend = backend;
76 impl.mRenderer.Reset();
78 // When using the vector-based rendering, the size of the GLyphs are different
79 TextAbstraction::GlyphType glyphType = (DevelText::RENDERING_VECTOR_BASED == impl.mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH;
80 impl.mController->SetGlyphType(glyphType);
84 case Toolkit::TextField::Property::TEXT:
86 const std::string& text = value.Get<std::string>();
87 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p TEXT %s\n", impl.mController.Get(), text.c_str());
89 impl.mController->SetText(text);
93 case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
95 const std::string& text = value.Get<std::string>();
96 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str());
98 impl.mController->SetPlaceholderText(Text::Controller::PLACEHOLDER_TYPE_INACTIVE, text);
101 case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED:
103 const std::string& text = value.Get<std::string>();
104 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_FOCUSED %s\n", impl.mController.Get(), text.c_str());
106 impl.mController->SetPlaceholderText(Text::Controller::PLACEHOLDER_TYPE_ACTIVE, text);
109 case Toolkit::TextField::Property::FONT_FAMILY:
111 const std::string& fontFamily = value.Get<std::string>();
112 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str());
113 impl.mController->SetDefaultFontFamily(fontFamily);
116 case Toolkit::TextField::Property::FONT_STYLE:
118 SetFontStyleProperty(impl.mController, value, Text::FontStyle::DEFAULT);
121 case Toolkit::TextField::Property::POINT_SIZE:
123 const float pointSize = value.Get<float>();
124 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p POINT_SIZE %f\n", impl.mController.Get(), pointSize);
126 if(!Equals(impl.mController->GetDefaultFontSize(Text::Controller::POINT_SIZE), pointSize))
128 impl.mController->SetDefaultFontSize(pointSize, Text::Controller::POINT_SIZE);
132 case Toolkit::TextField::Property::MAX_LENGTH:
134 const int max = value.Get<int>();
135 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p MAX_LENGTH %d\n", impl.mController.Get(), max);
137 impl.mController->SetMaximumNumberOfCharacters(max);
140 case Toolkit::TextField::Property::EXCEED_POLICY:
142 impl.mExceedPolicy = value.Get<int>();
144 if(Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == impl.mExceedPolicy)
146 impl.EnableClipping();
150 UnparentAndReset(impl.mStencil);
152 impl.RequestTextRelayout();
156 case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
158 Text::HorizontalAlignment::Type alignment(static_cast<Text::HorizontalAlignment::Type>(-1)); // Set to invalid value to ensure a valid mode does get set
159 if(Text::GetHorizontalAlignmentEnumeration(value, alignment))
161 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p HORIZONTAL_ALIGNMENT %d\n", impl.mController.Get(), alignment);
162 impl.mController->SetHorizontalAlignment(alignment);
166 case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
168 Toolkit::Text::VerticalAlignment::Type alignment(static_cast<Text::VerticalAlignment::Type>(-1)); // Set to invalid value to ensure a valid mode does get set
169 if(Text::GetVerticalAlignmentEnumeration(value, alignment))
171 impl.mController->SetVerticalAlignment(alignment);
172 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p VERTICAL_ALIGNMENT %d\n", impl.mController.Get(), alignment);
176 case Toolkit::TextField::Property::TEXT_COLOR:
178 const Vector4& textColor = value.Get<Vector4>();
179 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 if(impl.mController->GetDefaultColor() != textColor)
183 impl.mController->SetDefaultColor(textColor);
184 impl.mController->SetInputColor(textColor);
185 impl.mRenderer.Reset();
189 case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR:
191 const Vector4& textColor = value.Get<Vector4>();
192 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 if(impl.mController->GetPlaceholderTextColor() != textColor)
196 impl.mController->SetPlaceholderTextColor(textColor);
197 impl.mRenderer.Reset();
201 case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
203 const Vector4& color = value.Get<Vector4>();
204 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 impl.mDecorator->SetCursorColor(Toolkit::Text::PRIMARY_CURSOR, color);
207 impl.RequestTextRelayout();
210 case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
212 const Vector4& color = value.Get<Vector4>();
213 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 impl.mDecorator->SetCursorColor(Toolkit::Text::SECONDARY_CURSOR, color);
216 impl.RequestTextRelayout();
219 case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
221 const bool enable = value.Get<bool>();
222 DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p ENABLE_CURSOR_BLINK %d\n", impl.mController.Get(), enable);
224 impl.mController->SetEnableCursorBlink(enable);
225 impl.RequestTextRelayout();
228 case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
230 const float interval = value.Get<float>();
231 DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_INTERVAL %f\n", impl.mController.Get(), interval);
233 impl.mDecorator->SetCursorBlinkInterval(interval);
236 case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
238 const float duration = value.Get<float>();
239 DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_DURATION %f\n", impl.mController.Get(), duration);
241 impl.mDecorator->SetCursorBlinkDuration(duration);
244 case Toolkit::TextField::Property::CURSOR_WIDTH:
246 const int width = value.Get<int>();
247 DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p CURSOR_WIDTH %d\n", impl.mController.Get(), width);
249 impl.mDecorator->SetCursorWidth(width);
250 impl.mController->GetLayoutEngine().SetCursorWidth(width);
253 case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
255 const std::string imageFileName = value.Get<std::string>();
256 DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str());
258 if(imageFileName.size())
260 impl.mDecorator->SetHandleImage(Toolkit::Text::GRAB_HANDLE, Toolkit::Text::HANDLE_IMAGE_RELEASED, imageFileName);
261 impl.RequestTextRelayout();
265 case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE:
267 const std::string imageFileName = value.Get<std::string>();
268 DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_PRESSED_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str());
270 if(imageFileName.size())
272 impl.mDecorator->SetHandleImage(Toolkit::Text::GRAB_HANDLE, Toolkit::Text::HANDLE_IMAGE_PRESSED, imageFileName);
273 impl.RequestTextRelayout();
277 case Toolkit::TextField::Property::SCROLL_THRESHOLD:
279 const float threshold = value.Get<float>();
280 DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p SCROLL_THRESHOLD %f\n", impl.mController.Get(), threshold);
282 impl.mDecorator->SetScrollThreshold(threshold);
285 case Toolkit::TextField::Property::SCROLL_SPEED:
287 const float speed = value.Get<float>();
288 DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p SCROLL_SPEED %f\n", impl.mController.Get(), speed);
290 impl.mDecorator->SetScrollSpeed(speed);
293 case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT:
295 const std::string filename = GetImageFileNameFromPropertyValue(value);
299 impl.mDecorator->SetHandleImage(Toolkit::Text::LEFT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_RELEASED, filename);
300 impl.RequestTextRelayout();
304 case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT:
306 const std::string filename = GetImageFileNameFromPropertyValue(value);
310 impl.mDecorator->SetHandleImage(Toolkit::Text::RIGHT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_RELEASED, filename);
311 impl.RequestTextRelayout();
315 case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
317 const std::string filename = GetImageFileNameFromPropertyValue(value);
321 impl.mDecorator->SetHandleImage(Toolkit::Text::LEFT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_PRESSED, filename);
322 impl.RequestTextRelayout();
326 case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
328 const std::string filename = GetImageFileNameFromPropertyValue(value);
332 impl.mDecorator->SetHandleImage(Toolkit::Text::RIGHT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_PRESSED, filename);
333 impl.RequestTextRelayout();
337 case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
339 const std::string filename = GetImageFileNameFromPropertyValue(value);
343 impl.mDecorator->SetHandleImage(Toolkit::Text::LEFT_SELECTION_HANDLE_MARKER,
344 Toolkit::Text::HANDLE_IMAGE_RELEASED,
346 impl.RequestTextRelayout();
350 case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
352 const std::string filename = GetImageFileNameFromPropertyValue(value);
356 impl.mDecorator->SetHandleImage(Toolkit::Text::RIGHT_SELECTION_HANDLE_MARKER,
357 Toolkit::Text::HANDLE_IMAGE_RELEASED,
359 impl.RequestTextRelayout();
363 case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR:
365 const Vector4 color = value.Get<Vector4>();
366 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 impl.mDecorator->SetHighlightColor(color);
369 impl.RequestTextRelayout();
372 case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
374 const Rect<int>& box = value.Get<Rect<int> >();
375 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 impl.mDecorator->SetBoundingBox(box);
378 impl.RequestTextRelayout();
381 case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS:
383 const Property::Map* map = value.GetMap();
386 impl.mInputMethodOptions.ApplyProperty(*map);
388 impl.mController->SetInputModePassword(impl.mInputMethodOptions.IsPassword());
390 Toolkit::Control control = Toolkit::KeyInputFocusManager::Get().GetCurrentFocusControl();
391 if(control == textField)
393 impl.mInputMethodContext.ApplyOptions(impl.mInputMethodOptions);
397 case Toolkit::TextField::Property::INPUT_COLOR:
399 const Vector4& inputColor = value.Get<Vector4>();
400 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 impl.mController->SetInputColor(inputColor);
405 case Toolkit::TextField::Property::ENABLE_MARKUP:
407 const bool enableMarkup = value.Get<bool>();
408 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p ENABLE_MARKUP %d\n", impl.mController.Get(), enableMarkup);
410 impl.mController->SetMarkupProcessorEnabled(enableMarkup);
413 case Toolkit::TextField::Property::INPUT_FONT_FAMILY:
415 const std::string& fontFamily = value.Get<std::string>();
416 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p INPUT_FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str());
417 impl.mController->SetInputFontFamily(fontFamily);
420 case Toolkit::TextField::Property::INPUT_FONT_STYLE:
422 SetFontStyleProperty(impl.mController, value, Text::FontStyle::INPUT);
425 case Toolkit::TextField::Property::INPUT_POINT_SIZE:
427 const float pointSize = value.Get<float>();
428 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p INPUT_POINT_SIZE %f\n", impl.mController.Get(), pointSize);
429 impl.mController->SetInputFontPointSize(pointSize);
432 case Toolkit::TextField::Property::UNDERLINE:
434 const bool update = SetUnderlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
437 impl.mRenderer.Reset();
441 case Toolkit::TextField::Property::INPUT_UNDERLINE:
443 const bool update = SetUnderlineProperties(impl.mController, value, Text::EffectStyle::INPUT);
446 impl.mRenderer.Reset();
450 case Toolkit::TextField::Property::SHADOW:
452 const bool update = SetShadowProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
455 impl.mRenderer.Reset();
459 case Toolkit::TextField::Property::INPUT_SHADOW:
461 const bool update = SetShadowProperties(impl.mController, value, Text::EffectStyle::INPUT);
464 impl.mRenderer.Reset();
468 case Toolkit::TextField::Property::EMBOSS:
470 const bool update = SetEmbossProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
473 impl.mRenderer.Reset();
477 case Toolkit::TextField::Property::INPUT_EMBOSS:
479 const bool update = SetEmbossProperties(impl.mController, value, Text::EffectStyle::INPUT);
482 impl.mRenderer.Reset();
486 case Toolkit::TextField::Property::OUTLINE:
488 const bool update = SetOutlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
491 impl.mRenderer.Reset();
495 case Toolkit::TextField::Property::INPUT_OUTLINE:
497 const bool update = SetOutlineProperties(impl.mController, value, Text::EffectStyle::INPUT);
500 impl.mRenderer.Reset();
504 case Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS:
506 const Property::Map* map = value.GetMap();
509 impl.mController->SetHiddenInputOption(*map);
510 auto mode = map->Find(Toolkit::HiddenInput::Property::MODE);
511 if(mode && (mode->Get<int>() != Toolkit::HiddenInput::Mode::HIDE_NONE))
513 textField.SetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_ROLE, Accessibility::Role::PASSWORD_TEXT);
517 textField.SetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_ROLE, Accessibility::Role::ENTRY);
522 case Toolkit::TextField::Property::PIXEL_SIZE:
524 const float pixelSize = value.Get<float>();
525 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p PIXEL_SIZE %f\n", impl.mController.Get(), pixelSize);
527 if(!Equals(impl.mController->GetDefaultFontSize(Text::Controller::PIXEL_SIZE), pixelSize))
529 impl.mController->SetDefaultFontSize(pixelSize, Text::Controller::PIXEL_SIZE);
533 case Toolkit::TextField::Property::ENABLE_SELECTION:
535 const bool enableSelection = value.Get<bool>();
536 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p ENABLE_SELECTION %d\n", impl.mController.Get(), enableSelection);
537 impl.mController->SetSelectionEnabled(enableSelection);
540 case Toolkit::TextField::Property::PLACEHOLDER:
542 const Property::Map* map = value.GetMap();
545 impl.mController->SetPlaceholderProperty(*map);
549 case Toolkit::TextField::Property::ELLIPSIS:
551 const bool ellipsis = value.Get<bool>();
552 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p ELLIPSIS %d\n", impl.mController.Get(), ellipsis);
554 impl.mController->SetTextElideEnabled(ellipsis);
557 case Toolkit::DevelTextField::Property::ENABLE_SHIFT_SELECTION:
559 const bool shiftSelection = value.Get<bool>();
560 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p ENABLE_SHIFT_SELECTION %d\n", impl.mController.Get(), shiftSelection);
562 impl.mController->SetShiftSelectionEnabled(shiftSelection);
565 case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE:
567 const bool grabHandleEnabled = value.Get<bool>();
568 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p ENABLE_GRAB_HANDLE %d\n", impl.mController.Get(), grabHandleEnabled);
570 impl.mController->SetGrabHandleEnabled(grabHandleEnabled);
573 case Toolkit::DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
575 impl.mController->SetMatchLayoutDirection(value.Get<bool>() ? DevelText::MatchLayoutDirection::LOCALE : DevelText::MatchLayoutDirection::CONTENTS);
578 case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP:
580 const bool grabHandlePopupEnabled = value.Get<bool>();
581 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p ENABLE_GRAB_HANDLE_POPUP %d\n", impl.mController.Get(), grabHandlePopupEnabled);
583 impl.mController->SetGrabHandlePopupEnabled(grabHandlePopupEnabled);
586 case Toolkit::DevelTextField::Property::BACKGROUND:
588 const Vector4 backgroundColor = value.Get<Vector4>();
589 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);
591 impl.mController->SetBackgroundEnabled(true);
592 impl.mController->SetBackgroundColor(backgroundColor);
595 case Toolkit::DevelTextField::Property::SELECTED_TEXT_START:
597 uint32_t start = static_cast<uint32_t>(value.Get<int>());
598 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p SELECTED_TEXT_START %d\n", impl.mController.Get(), start);
599 impl.SetTextSelectionRange(&start, nullptr);
602 case Toolkit::DevelTextField::Property::SELECTED_TEXT_END:
604 uint32_t end = static_cast<uint32_t>(value.Get<int>());
605 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p SELECTED_TEXT_END %d\n", impl.mController.Get(), end);
606 impl.SetTextSelectionRange(nullptr, &end);
609 case Toolkit::DevelTextField::Property::ENABLE_EDITING:
611 const bool editable = value.Get<bool>();
612 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p ENABLE_EDITING %d\n", impl.mController.Get(), editable);
613 impl.SetEditable(editable);
616 case Toolkit::DevelTextField::Property::FONT_SIZE_SCALE:
618 const float scale = value.Get<float>();
619 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p FONT_SIZE_SCALE %f\n", impl.mController.Get(), scale);
621 if(!Equals(impl.mController->GetFontSizeScale(), scale))
623 impl.mController->SetFontSizeScale(scale);
627 case Toolkit::DevelTextField::Property::PRIMARY_CURSOR_POSITION:
629 uint32_t position = static_cast<uint32_t>(value.Get<int>());
630 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p PRIMARY_CURSOR_POSITION %d\n", impl.mController.Get(), position);
631 if(impl.mController->SetPrimaryCursorPosition(position, impl.HasKeyInputFocus()))
633 impl.SetKeyInputFocus();
637 case Toolkit::DevelTextField::Property::GRAB_HANDLE_COLOR:
639 const Vector4 color = value.Get<Vector4>();
640 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);
642 impl.mDecorator->SetHandleColor(color);
643 impl.RequestTextRelayout();
647 case Toolkit::DevelTextField::Property::INPUT_FILTER:
649 const Property::Map* map = value.GetMap();
652 impl.mController->SetInputFilterOption(*map);
656 case Toolkit::DevelTextField::Property::ELLIPSIS_POSITION:
658 DevelText::EllipsisPosition::Type ellipsisPositionType(static_cast<DevelText::EllipsisPosition::Type>(-1)); // Set to invalid value to ensure a valid mode does get set
659 if(Text::GetEllipsisPositionTypeEnumeration(value, ellipsisPositionType))
661 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p EllipsisPosition::Type %d\n", impl.mController.Get(), ellipsisPositionType);
662 impl.mController->SetEllipsisPosition(ellipsisPositionType);
669 Property::Value TextField::PropertyHandler::GetProperty(Toolkit::TextField textField, Property::Index index)
671 Property::Value value;
672 TextField& impl(GetImpl(textField));
673 DALI_ASSERT_DEBUG(impl.mController && "No text controller");
674 DALI_ASSERT_DEBUG(impl.mDecorator && "No text decorator");
678 case Toolkit::DevelTextField::Property::RENDERING_BACKEND:
680 value = impl.mRenderingBackend;
683 case Toolkit::TextField::Property::TEXT:
686 impl.mController->GetText(text);
687 DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p returning text: %s\n", impl.mController.Get(), text.c_str());
691 case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
694 impl.mController->GetPlaceholderText(Text::Controller::PLACEHOLDER_TYPE_INACTIVE, text);
698 case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED:
701 impl.mController->GetPlaceholderText(Text::Controller::PLACEHOLDER_TYPE_ACTIVE, text);
705 case Toolkit::TextField::Property::FONT_FAMILY:
707 value = impl.mController->GetDefaultFontFamily();
710 case Toolkit::TextField::Property::FONT_STYLE:
712 GetFontStyleProperty(impl.mController, value, Text::FontStyle::DEFAULT);
715 case Toolkit::TextField::Property::POINT_SIZE:
717 value = impl.mController->GetDefaultFontSize(Text::Controller::POINT_SIZE);
720 case Toolkit::TextField::Property::MAX_LENGTH:
722 value = impl.mController->GetMaximumNumberOfCharacters();
725 case Toolkit::TextField::Property::EXCEED_POLICY:
727 value = impl.mExceedPolicy;
730 case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
732 const char* name = Text::GetHorizontalAlignmentString(impl.mController->GetHorizontalAlignment());
735 value = std::string(name);
739 case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
741 const char* name = Text::GetVerticalAlignmentString(impl.mController->GetVerticalAlignment());
745 value = std::string(name);
749 case Toolkit::TextField::Property::TEXT_COLOR:
751 value = impl.mController->GetDefaultColor();
754 case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR:
756 value = impl.mController->GetPlaceholderTextColor();
759 case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
761 value = impl.mDecorator->GetColor(Text::PRIMARY_CURSOR);
764 case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
766 value = impl.mDecorator->GetColor(Text::SECONDARY_CURSOR);
769 case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
771 value = impl.mController->GetEnableCursorBlink();
774 case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
776 value = impl.mDecorator->GetCursorBlinkInterval();
779 case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
781 value = impl.mDecorator->GetCursorBlinkDuration();
784 case Toolkit::TextField::Property::CURSOR_WIDTH:
786 value = impl.mDecorator->GetCursorWidth();
789 case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
791 value = impl.mDecorator->GetHandleImage(Text::GRAB_HANDLE, Text::HANDLE_IMAGE_RELEASED);
794 case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE:
796 value = impl.mDecorator->GetHandleImage(Text::GRAB_HANDLE, Text::HANDLE_IMAGE_PRESSED);
799 case Toolkit::TextField::Property::SCROLL_THRESHOLD:
801 value = impl.mDecorator->GetScrollThreshold();
804 case Toolkit::TextField::Property::SCROLL_SPEED:
806 value = impl.mDecorator->GetScrollSpeed();
809 case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT:
811 impl.GetHandleImagePropertyValue(value, Text::LEFT_SELECTION_HANDLE, Text::HANDLE_IMAGE_RELEASED);
814 case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT:
816 impl.GetHandleImagePropertyValue(value, Text::RIGHT_SELECTION_HANDLE, Text::HANDLE_IMAGE_RELEASED);
819 case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
821 impl.GetHandleImagePropertyValue(value, Text::LEFT_SELECTION_HANDLE, Text::HANDLE_IMAGE_PRESSED);
824 case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
826 impl.GetHandleImagePropertyValue(value, Text::RIGHT_SELECTION_HANDLE, Text::HANDLE_IMAGE_PRESSED);
829 case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
831 impl.GetHandleImagePropertyValue(value, Text::LEFT_SELECTION_HANDLE_MARKER, Text::HANDLE_IMAGE_RELEASED);
834 case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
836 impl.GetHandleImagePropertyValue(value, Text::RIGHT_SELECTION_HANDLE_MARKER, Text::HANDLE_IMAGE_RELEASED);
839 case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR:
841 value = impl.mDecorator->GetHighlightColor();
844 case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
846 Rect<int> boundingBox;
847 impl.mDecorator->GetBoundingBox(boundingBox);
851 case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS:
854 impl.mInputMethodOptions.RetrieveProperty(map);
858 case Toolkit::TextField::Property::INPUT_COLOR:
860 value = impl.mController->GetInputColor();
863 case Toolkit::TextField::Property::ENABLE_MARKUP:
865 value = impl.mController->IsMarkupProcessorEnabled();
868 case Toolkit::TextField::Property::INPUT_FONT_FAMILY:
870 value = impl.mController->GetInputFontFamily();
873 case Toolkit::TextField::Property::INPUT_FONT_STYLE:
875 GetFontStyleProperty(impl.mController, value, Text::FontStyle::INPUT);
878 case Toolkit::TextField::Property::INPUT_POINT_SIZE:
880 value = impl.mController->GetInputFontPointSize();
883 case Toolkit::TextField::Property::UNDERLINE:
885 GetUnderlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
888 case Toolkit::TextField::Property::INPUT_UNDERLINE:
890 GetUnderlineProperties(impl.mController, value, Text::EffectStyle::INPUT);
893 case Toolkit::TextField::Property::SHADOW:
895 GetShadowProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
898 case Toolkit::TextField::Property::INPUT_SHADOW:
900 GetShadowProperties(impl.mController, value, Text::EffectStyle::INPUT);
903 case Toolkit::TextField::Property::EMBOSS:
905 GetEmbossProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
908 case Toolkit::TextField::Property::INPUT_EMBOSS:
910 GetEmbossProperties(impl.mController, value, Text::EffectStyle::INPUT);
913 case Toolkit::TextField::Property::OUTLINE:
915 GetOutlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
918 case Toolkit::TextField::Property::INPUT_OUTLINE:
920 GetOutlineProperties(impl.mController, value, Text::EffectStyle::INPUT);
923 case Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS:
926 impl.mController->GetHiddenInputOption(map);
930 case Toolkit::TextField::Property::PIXEL_SIZE:
932 value = impl.mController->GetDefaultFontSize(Text::Controller::PIXEL_SIZE);
935 case Toolkit::TextField::Property::ENABLE_SELECTION:
937 value = impl.mController->IsSelectionEnabled();
940 case Toolkit::TextField::Property::PLACEHOLDER:
943 impl.mController->GetPlaceholderProperty(map);
947 case Toolkit::TextField::Property::ELLIPSIS:
949 value = impl.mController->IsTextElideEnabled();
952 case Toolkit::DevelTextField::Property::ENABLE_SHIFT_SELECTION:
954 value = impl.mController->IsShiftSelectionEnabled();
957 case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE:
959 value = impl.mController->IsGrabHandleEnabled();
962 case Toolkit::DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
964 value = impl.mController->GetMatchLayoutDirection() != DevelText::MatchLayoutDirection::CONTENTS;
967 case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP:
969 value = impl.mController->IsGrabHandlePopupEnabled();
972 case Toolkit::DevelTextField::Property::BACKGROUND:
974 value = impl.mController->GetBackgroundColor();
977 case Toolkit::DevelTextField::Property::SELECTED_TEXT:
979 value = impl.mController->GetSelectedText();
982 case Toolkit::DevelTextField::Property::SELECTED_TEXT_START:
984 Uint32Pair range = impl.GetTextSelectionRange();
985 value = static_cast<int>(range.first);
988 case Toolkit::DevelTextField::Property::SELECTED_TEXT_END:
990 Uint32Pair range = impl.GetTextSelectionRange();
991 value = static_cast<int>(range.second);
994 case Toolkit::DevelTextField::Property::ENABLE_EDITING:
996 value = impl.IsEditable();
999 case Toolkit::DevelTextField::Property::FONT_SIZE_SCALE:
1001 value = impl.mController->GetFontSizeScale();
1004 case Toolkit::DevelTextField::Property::PRIMARY_CURSOR_POSITION:
1006 value = static_cast<int>(impl.mController->GetPrimaryCursorPosition());
1009 case Toolkit::DevelTextField::Property::GRAB_HANDLE_COLOR:
1011 value = impl.mDecorator->GetHandleColor();
1014 case Toolkit::DevelTextField::Property::INPUT_FILTER:
1017 impl.mController->GetInputFilterOption(map);
1021 case Toolkit::DevelTextField::Property::ELLIPSIS_POSITION:
1023 value = impl.mController->GetEllipsisPosition();
1030 } // namespace Dali::Toolkit::Internal