2 * Copyright (c) 2022 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/common-text-utils.h>
18 #include <dali-toolkit/internal/controls/text-controls/text-editor-property-handler.h>
20 #include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.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* gTextEditorLogFilter;
34 namespace Dali::Toolkit::Internal
36 const char* const TextEditor::PropertyHandler::IMAGE_MAP_FILENAME_STRING{"filename"};
38 /// Retrieves a filename from a value that is a Property::Map
39 std::string TextEditor::PropertyHandler::GetImageFileNameFromPropertyValue(const Property::Value& value)
42 const Property::Map* map = value.GetMap();
45 const Property::Value* filenameValue = map->Find(TextEditor::PropertyHandler::IMAGE_MAP_FILENAME_STRING);
48 filenameValue->Get(filename);
54 void TextEditor::PropertyHandler::SetProperty(Toolkit::TextEditor textEditor, Property::Index index, const Property::Value& value)
56 TextEditor& impl(GetImpl(textEditor));
57 DALI_ASSERT_DEBUG(impl.mController && "No text controller");
58 DALI_ASSERT_DEBUG(impl.mDecorator && "No text decorator");
62 case Toolkit::DevelTextEditor::Property::RENDERING_BACKEND:
64 int backend = value.Get<int>();
65 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p RENDERING_BACKEND %d\n", impl.mController.Get(), backend);
67 if(impl.mRenderingBackend != backend)
69 impl.mRenderingBackend = backend;
70 impl.mRenderer.Reset();
71 impl.RequestTextRelayout();
75 case Toolkit::TextEditor::Property::TEXT:
77 const std::string& text = value.Get<std::string>();
78 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p TEXT %s\n", impl.mController.Get(), text.c_str());
80 impl.mController->SetText(text);
83 case Toolkit::TextEditor::Property::TEXT_COLOR:
85 const Vector4& textColor = value.Get<Vector4>();
86 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a);
88 if(impl.mController->GetDefaultColor() != textColor)
90 impl.mController->SetDefaultColor(textColor);
91 impl.mController->SetInputColor(textColor);
92 impl.mRenderer.Reset();
96 case Toolkit::TextEditor::Property::FONT_FAMILY:
98 const std::string& fontFamily = value.Get<std::string>();
99 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str());
100 impl.mController->SetDefaultFontFamily(fontFamily);
103 case Toolkit::TextEditor::Property::FONT_STYLE:
105 SetFontStyleProperty(impl.mController, value, Text::FontStyle::DEFAULT);
108 case Toolkit::TextEditor::Property::POINT_SIZE:
110 const float pointSize = value.Get<float>();
111 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p POINT_SIZE %f\n", impl.mController.Get(), pointSize);
113 if(!Equals(impl.mController->GetDefaultFontSize(Text::Controller::POINT_SIZE), pointSize))
115 impl.mController->SetDefaultFontSize(pointSize, Text::Controller::POINT_SIZE);
119 case Toolkit::TextEditor::Property::HORIZONTAL_ALIGNMENT:
121 Text::HorizontalAlignment::Type alignment(static_cast<Text::HorizontalAlignment::Type>(-1)); // Set to invalid value to ensure a valid mode does get set
122 if(Text::GetHorizontalAlignmentEnumeration(value, alignment))
124 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p HORIZONTAL_ALIGNMENT %d\n", impl.mController.Get(), alignment);
125 impl.mController->SetHorizontalAlignment(alignment);
129 case Toolkit::TextEditor::Property::SCROLL_THRESHOLD:
131 const float threshold = value.Get<float>();
132 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p SCROLL_THRESHOLD %f\n", impl.mController.Get(), threshold);
134 impl.mDecorator->SetScrollThreshold(threshold);
137 case Toolkit::TextEditor::Property::SCROLL_SPEED:
139 const float speed = value.Get<float>();
140 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p SCROLL_SPEED %f\n", impl.mController.Get(), speed);
142 impl.mDecorator->SetScrollSpeed(speed);
145 case Toolkit::TextEditor::Property::PRIMARY_CURSOR_COLOR:
147 const Vector4& color = value.Get<Vector4>();
148 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p PRIMARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a);
150 impl.mDecorator->SetCursorColor(Toolkit::Text::PRIMARY_CURSOR, color);
151 impl.RequestTextRelayout();
154 case Toolkit::TextEditor::Property::SECONDARY_CURSOR_COLOR:
156 const Vector4& color = value.Get<Vector4>();
157 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p SECONDARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a);
159 impl.mDecorator->SetCursorColor(Toolkit::Text::SECONDARY_CURSOR, color);
160 impl.RequestTextRelayout();
163 case Toolkit::TextEditor::Property::ENABLE_CURSOR_BLINK:
165 const bool enable = value.Get<bool>();
166 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p ENABLE_CURSOR_BLINK %d\n", impl.mController.Get(), enable);
168 impl.mController->SetEnableCursorBlink(enable);
169 impl.RequestTextRelayout();
172 case Toolkit::TextEditor::Property::CURSOR_BLINK_INTERVAL:
174 const float interval = value.Get<float>();
175 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p CURSOR_BLINK_INTERVAL %f\n", impl.mController.Get(), interval);
177 impl.mDecorator->SetCursorBlinkInterval(interval);
180 case Toolkit::TextEditor::Property::CURSOR_BLINK_DURATION:
182 const float duration = value.Get<float>();
183 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p CURSOR_BLINK_DURATION %f\n", impl.mController.Get(), duration);
185 impl.mDecorator->SetCursorBlinkDuration(duration);
188 case Toolkit::TextEditor::Property::CURSOR_WIDTH:
190 const int width = value.Get<int>();
191 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p CURSOR_WIDTH %d\n", impl.mController.Get(), width);
193 impl.mDecorator->SetCursorWidth(width);
194 impl.mController->GetLayoutEngine().SetCursorWidth(width);
197 case Toolkit::TextEditor::Property::GRAB_HANDLE_IMAGE:
199 const std::string imageFileName = value.Get<std::string>();
200 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p GRAB_HANDLE_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str());
202 if(imageFileName.size())
204 impl.mDecorator->SetHandleImage(Toolkit::Text::GRAB_HANDLE, Toolkit::Text::HANDLE_IMAGE_RELEASED, imageFileName);
205 impl.RequestTextRelayout();
209 case Toolkit::TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE:
211 const std::string imageFileName = value.Get<std::string>();
212 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p GRAB_HANDLE_PRESSED_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str());
214 if(imageFileName.size())
216 impl.mDecorator->SetHandleImage(Toolkit::Text::GRAB_HANDLE, Toolkit::Text::HANDLE_IMAGE_PRESSED, imageFileName);
217 impl.RequestTextRelayout();
221 case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT:
223 const std::string filename = GetImageFileNameFromPropertyValue(value);
227 impl.mDecorator->SetHandleImage(Toolkit::Text::LEFT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_RELEASED, filename);
228 impl.RequestTextRelayout();
232 case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT:
234 const std::string filename = GetImageFileNameFromPropertyValue(value);
238 impl.mDecorator->SetHandleImage(Toolkit::Text::RIGHT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_RELEASED, filename);
239 impl.RequestTextRelayout();
243 case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
245 const std::string filename = GetImageFileNameFromPropertyValue(value);
249 impl.mDecorator->SetHandleImage(Toolkit::Text::LEFT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_PRESSED, filename);
250 impl.RequestTextRelayout();
254 case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
256 const std::string filename = GetImageFileNameFromPropertyValue(value);
260 impl.mDecorator->SetHandleImage(Toolkit::Text::RIGHT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_PRESSED, filename);
261 impl.RequestTextRelayout();
265 case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
267 const std::string filename = GetImageFileNameFromPropertyValue(value);
271 impl.mDecorator->SetHandleImage(Toolkit::Text::LEFT_SELECTION_HANDLE_MARKER,
272 Toolkit::Text::HANDLE_IMAGE_RELEASED,
274 impl.RequestTextRelayout();
278 case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
280 const std::string filename = GetImageFileNameFromPropertyValue(value);
284 impl.mDecorator->SetHandleImage(Toolkit::Text::RIGHT_SELECTION_HANDLE_MARKER,
285 Toolkit::Text::HANDLE_IMAGE_RELEASED,
287 impl.RequestTextRelayout();
291 case Toolkit::TextEditor::Property::SELECTION_HIGHLIGHT_COLOR:
293 const Vector4 color = value.Get<Vector4>();
294 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p SELECTION_HIGHLIGHT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a);
296 impl.mDecorator->SetHighlightColor(color);
297 impl.RequestTextRelayout();
300 case Toolkit::TextEditor::Property::DECORATION_BOUNDING_BOX:
302 const Rect<int>& box = value.Get<Rect<int> >();
303 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p DECORATION_BOUNDING_BOX %d,%d %dx%d\n", impl.mController.Get(), box.x, box.y, box.width, box.height);
305 impl.mDecorator->SetBoundingBox(box);
306 impl.RequestTextRelayout();
309 case Toolkit::TextEditor::Property::ENABLE_MARKUP:
311 const bool enableMarkup = value.Get<bool>();
312 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p ENABLE_MARKUP %d\n", impl.mController.Get(), enableMarkup);
314 impl.mController->SetMarkupProcessorEnabled(enableMarkup);
315 CommonTextUtils::SynchronizeTextAnchorsInParent(textEditor, impl.mController, impl.mAnchorActors);
318 case Toolkit::TextEditor::Property::INPUT_COLOR:
320 const Vector4& inputColor = value.Get<Vector4>();
321 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p INPUT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), inputColor.r, inputColor.g, inputColor.b, inputColor.a);
323 impl.mController->SetInputColor(inputColor);
326 case Toolkit::TextEditor::Property::INPUT_FONT_FAMILY:
328 const std::string& fontFamily = value.Get<std::string>();
329 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p INPUT_FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str());
330 impl.mController->SetInputFontFamily(fontFamily);
333 case Toolkit::TextEditor::Property::INPUT_FONT_STYLE:
335 SetFontStyleProperty(impl.mController, value, Text::FontStyle::INPUT);
338 case Toolkit::TextEditor::Property::INPUT_POINT_SIZE:
340 const float pointSize = value.Get<float>();
341 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p INPUT_POINT_SIZE %f\n", impl.mController.Get(), pointSize);
342 impl.mController->SetInputFontPointSize(pointSize);
345 case Toolkit::TextEditor::Property::LINE_SPACING:
347 const float lineSpacing = value.Get<float>();
348 impl.mController->SetDefaultLineSpacing(lineSpacing);
349 impl.mRenderer.Reset();
352 case Toolkit::TextEditor::Property::INPUT_LINE_SPACING:
354 const float lineSpacing = value.Get<float>();
355 impl.mController->SetInputLineSpacing(lineSpacing);
356 impl.mRenderer.Reset();
359 case Toolkit::TextEditor::Property::UNDERLINE:
361 const bool update = SetUnderlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
364 impl.mRenderer.Reset();
368 case Toolkit::TextEditor::Property::INPUT_UNDERLINE:
370 const bool update = SetUnderlineProperties(impl.mController, value, Text::EffectStyle::INPUT);
373 impl.mRenderer.Reset();
377 case Toolkit::TextEditor::Property::SHADOW:
379 const bool update = SetShadowProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
382 impl.mRenderer.Reset();
386 case Toolkit::TextEditor::Property::INPUT_SHADOW:
388 const bool update = SetShadowProperties(impl.mController, value, Text::EffectStyle::INPUT);
391 impl.mRenderer.Reset();
395 case Toolkit::TextEditor::Property::EMBOSS:
397 const bool update = SetEmbossProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
400 impl.mRenderer.Reset();
404 case Toolkit::TextEditor::Property::INPUT_EMBOSS:
406 const bool update = SetEmbossProperties(impl.mController, value, Text::EffectStyle::INPUT);
409 impl.mRenderer.Reset();
413 case Toolkit::TextEditor::Property::OUTLINE:
415 const bool update = SetOutlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
418 impl.mRenderer.Reset();
422 case Toolkit::TextEditor::Property::INPUT_OUTLINE:
424 const bool update = SetOutlineProperties(impl.mController, value, Text::EffectStyle::INPUT);
427 impl.mRenderer.Reset();
431 case Toolkit::TextEditor::Property::SMOOTH_SCROLL:
433 const bool enable = value.Get<bool>();
434 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor SMOOTH_SCROLL %d\n", enable);
436 impl.mScrollAnimationEnabled = enable;
439 case Toolkit::TextEditor::Property::SMOOTH_SCROLL_DURATION:
441 const float duration = value.Get<float>();
442 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor SMOOTH_SCROLL_DURATION %f\n", duration);
444 impl.mScrollAnimationDuration = duration;
445 if(impl.mTextVerticalScroller)
447 impl.mTextVerticalScroller->SetDuration(duration);
451 case Toolkit::TextEditor::Property::ENABLE_SCROLL_BAR:
453 const bool enable = value.Get<bool>();
454 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor SHOW_SCROLL_BAR %d\n", enable);
456 impl.mScrollBarEnabled = enable;
459 case Toolkit::TextEditor::Property::SCROLL_BAR_SHOW_DURATION:
461 const float duration = value.Get<float>();
462 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor SCROLL_BAR_SHOW_DURATION %f\n", duration);
464 impl.mAnimationPeriod.delaySeconds = duration;
467 case Toolkit::TextEditor::Property::SCROLL_BAR_FADE_DURATION:
469 const float duration = value.Get<float>();
470 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor SCROLL_BAR_FADE_DURATION %f\n", duration);
472 impl.mAnimationPeriod.durationSeconds = duration;
475 case Toolkit::TextEditor::Property::PIXEL_SIZE:
477 const float pixelSize = value.Get<float>();
478 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p PIXEL_SIZE %f\n", impl.mController.Get(), pixelSize);
480 if(!Equals(impl.mController->GetDefaultFontSize(Text::Controller::PIXEL_SIZE), pixelSize))
482 impl.mController->SetDefaultFontSize(pixelSize, Text::Controller::PIXEL_SIZE);
486 case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT:
488 const std::string& text = value.Get<std::string>();
489 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor::OnPropertySet %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str());
491 impl.mController->SetPlaceholderText(Text::Controller::PLACEHOLDER_TYPE_INACTIVE, text);
494 case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR:
496 const Vector4& textColor = value.Get<Vector4>();
497 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p PLACEHOLDER_TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a);
499 if(impl.mController->GetPlaceholderTextColor() != textColor)
501 impl.mController->SetPlaceholderTextColor(textColor);
502 impl.mRenderer.Reset();
506 case Toolkit::TextEditor::Property::ENABLE_SELECTION:
508 const bool enableSelection = value.Get<bool>();
509 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p ENABLE_SELECTION %d\n", impl.mController.Get(), enableSelection);
510 impl.mController->SetSelectionEnabled(enableSelection);
513 case Toolkit::TextEditor::Property::PLACEHOLDER:
515 const Property::Map* map = value.GetMap();
518 impl.mController->SetPlaceholderProperty(*map);
522 case Toolkit::TextEditor::Property::LINE_WRAP_MODE:
524 Text::LineWrap::Mode lineWrapMode(static_cast<Text::LineWrap::Mode>(-1)); // Set to invalid value to ensure a valid mode does get set
525 if(Toolkit::Text::GetLineWrapModeEnumeration(value, lineWrapMode))
527 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p LineWrap::MODE %d\n", impl.mController.Get(), lineWrapMode);
528 impl.mController->SetLineWrapMode(lineWrapMode);
532 case Toolkit::DevelTextEditor::Property::ENABLE_SHIFT_SELECTION:
534 const bool shiftSelection = value.Get<bool>();
535 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p ENABLE_SHIFT_SELECTION %d\n", impl.mController.Get(), shiftSelection);
537 impl.mController->SetShiftSelectionEnabled(shiftSelection);
540 case Toolkit::DevelTextEditor::Property::ENABLE_GRAB_HANDLE:
542 const bool grabHandleEnabled = value.Get<bool>();
543 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p ENABLE_GRAB_HANDLE %d\n", impl.mController.Get(), grabHandleEnabled);
545 impl.mController->SetGrabHandleEnabled(grabHandleEnabled);
548 case Toolkit::DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
550 impl.mController->SetMatchLayoutDirection(value.Get<bool>() ? DevelText::MatchLayoutDirection::LOCALE : DevelText::MatchLayoutDirection::CONTENTS);
553 case Toolkit::DevelTextEditor::Property::MAX_LENGTH:
555 const int max = value.Get<int>();
556 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p MAX_LENGTH %d\n", impl.mController.Get(), max);
558 impl.mController->SetMaximumNumberOfCharacters(max);
561 case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_START:
563 uint32_t start = static_cast<uint32_t>(value.Get<int>());
564 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p SELECTED_TEXT_START %d\n", impl.mController.Get(), start);
565 impl.SetTextSelectionRange(&start, nullptr);
568 case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_END:
570 uint32_t end = static_cast<uint32_t>(value.Get<int>());
571 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p SELECTED_TEXT_END %d\n", impl.mController.Get(), end);
572 impl.SetTextSelectionRange(nullptr, &end);
575 case Toolkit::DevelTextEditor::Property::ENABLE_EDITING:
577 const bool editable = value.Get<bool>();
578 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p ENABLE_EDITING %d\n", impl.mController.Get(), editable);
579 impl.SetEditable(editable);
582 case Toolkit::DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION:
584 float horizontalScroll = value.Get<float>();
585 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p HORIZONTAL_SCROLL_POSITION %d\n", impl.mController.Get(), horizontalScroll);
586 if(horizontalScroll >= 0.0f)
588 impl.ScrollBy(Vector2(horizontalScroll - impl.GetHorizontalScrollPosition(), 0));
592 case Toolkit::DevelTextEditor::Property::VERTICAL_SCROLL_POSITION:
594 float verticalScroll = value.Get<float>();
595 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p VERTICAL_SCROLL_POSITION %d\n", impl.mController.Get(), verticalScroll);
596 if(verticalScroll >= 0.0f)
598 impl.ScrollBy(Vector2(0, verticalScroll - impl.GetVerticalScrollPosition()));
602 case Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE:
604 const float scale = value.Get<float>();
605 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p FONT_SIZE_SCALE %f\n", impl.mController.Get(), scale);
607 if(!Equals(impl.mController->GetFontSizeScale(), scale))
609 impl.mController->SetFontSizeScale(scale);
613 case Toolkit::DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE:
615 const bool enableFontSizeScale = value.Get<bool>();
616 if(!Equals(impl.mController->IsFontSizeScaleEnabled(), enableFontSizeScale))
618 impl.mController->SetFontSizeScaleEnabled(enableFontSizeScale);
622 case Toolkit::DevelTextEditor::Property::PRIMARY_CURSOR_POSITION:
624 uint32_t position = static_cast<uint32_t>(value.Get<int>());
625 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p PRIMARY_CURSOR_POSITION %d\n", impl.mController.Get(), position);
626 if(impl.mController->SetPrimaryCursorPosition(position, impl.HasKeyInputFocus()))
628 impl.SetKeyInputFocus();
632 case Toolkit::DevelTextEditor::Property::GRAB_HANDLE_COLOR:
634 const Vector4 color = value.Get<Vector4>();
635 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p GRAB_HANDLE_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a);
637 impl.mDecorator->SetHandleColor(color);
638 impl.RequestTextRelayout();
641 case Toolkit::DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP:
643 const bool grabHandlePopupEnabled = value.Get<bool>();
644 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p ENABLE_GRAB_HANDLE_POPUP %d\n", impl.mController.Get(), grabHandlePopupEnabled);
646 impl.mController->SetGrabHandlePopupEnabled(grabHandlePopupEnabled);
649 case Toolkit::DevelTextEditor::Property::INPUT_METHOD_SETTINGS:
651 const Property::Map* map = value.GetMap();
654 impl.mInputMethodOptions.ApplyProperty(*map);
656 impl.mController->SetInputModePassword(impl.mInputMethodOptions.IsPassword());
658 Toolkit::Control control = Toolkit::KeyInputFocusManager::Get().GetCurrentFocusControl();
659 if(control == textEditor)
661 impl.mInputMethodContext.ApplyOptions(impl.mInputMethodOptions);
665 case Toolkit::DevelTextEditor::Property::INPUT_FILTER:
667 const Property::Map* map = value.GetMap();
670 impl.mController->SetInputFilterOption(*map);
674 case Toolkit::DevelTextEditor::Property::ELLIPSIS:
676 const bool ellipsis = value.Get<bool>();
677 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p ELLIPSIS %d\n", impl.mController.Get(), ellipsis);
679 impl.mController->SetTextElideEnabled(ellipsis);
682 case Toolkit::DevelTextEditor::Property::ELLIPSIS_POSITION:
684 DevelText::EllipsisPosition::Type ellipsisPositionType(static_cast<DevelText::EllipsisPosition::Type>(-1)); // Set to invalid value to ensure a valid mode does get set
685 if(Text::GetEllipsisPositionTypeEnumeration(value, ellipsisPositionType))
687 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p EllipsisPosition::Type %d\n", impl.mController.Get(), ellipsisPositionType);
688 impl.mController->SetEllipsisPosition(ellipsisPositionType);
692 case Toolkit::DevelTextEditor::Property::MIN_LINE_SIZE:
694 const float minLineSize = value.Get<float>();
695 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p MIN_LINE_SIZE %f\n", impl.mController.Get(), minLineSize);
697 impl.mController->SetDefaultLineSize(minLineSize);
698 impl.mRenderer.Reset();
701 case Toolkit::DevelTextEditor::Property::STRIKETHROUGH:
703 const bool update = SetStrikethroughProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
706 impl.mRenderer.Reset();
710 case Toolkit::DevelTextEditor::Property::INPUT_STRIKETHROUGH:
712 const bool update = SetStrikethroughProperties(impl.mController, value, Text::EffectStyle::INPUT);
715 impl.mRenderer.Reset();
719 case Toolkit::DevelTextEditor::Property::CHARACTER_SPACING:
721 const float characterSpacing = value.Get<float>();
722 impl.mController->SetCharacterSpacing(characterSpacing);
723 impl.mRenderer.Reset();
726 case Toolkit::DevelTextEditor::Property::RELATIVE_LINE_SIZE:
728 const float relativeLineSize = value.Get<float>();
729 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p RELATIVE_LINE_SIZE %f\n", impl.mController.Get(), relativeLineSize);
731 impl.mController->SetRelativeLineSize(relativeLineSize);
732 impl.mRenderer.Reset();
738 Property::Value TextEditor::PropertyHandler::GetProperty(Toolkit::TextEditor textEditor, Property::Index index)
740 Property::Value value;
741 TextEditor& impl(GetImpl(textEditor));
742 DALI_ASSERT_DEBUG(impl.mController && "No text controller");
743 DALI_ASSERT_DEBUG(impl.mDecorator && "No text decorator");
747 case Toolkit::DevelTextEditor::Property::RENDERING_BACKEND:
749 value = impl.mRenderingBackend;
752 case Toolkit::TextEditor::Property::TEXT:
755 impl.mController->GetText(text);
756 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p returning text: %s\n", impl.mController.Get(), text.c_str());
760 case Toolkit::TextEditor::Property::TEXT_COLOR:
762 value = impl.mController->GetDefaultColor();
765 case Toolkit::TextEditor::Property::FONT_FAMILY:
767 value = impl.mController->GetDefaultFontFamily();
770 case Toolkit::TextEditor::Property::FONT_STYLE:
772 GetFontStyleProperty(impl.mController, value, Text::FontStyle::DEFAULT);
775 case Toolkit::TextEditor::Property::POINT_SIZE:
777 value = impl.mController->GetDefaultFontSize(Text::Controller::POINT_SIZE);
780 case Toolkit::TextEditor::Property::HORIZONTAL_ALIGNMENT:
782 const char* name = Text::GetHorizontalAlignmentString(impl.mController->GetHorizontalAlignment());
785 value = std::string(name);
789 case Toolkit::TextEditor::Property::SCROLL_THRESHOLD:
791 value = impl.mDecorator->GetScrollThreshold();
794 case Toolkit::TextEditor::Property::SCROLL_SPEED:
796 value = impl.mDecorator->GetScrollSpeed();
799 case Toolkit::TextEditor::Property::PRIMARY_CURSOR_COLOR:
801 value = impl.mDecorator->GetColor(Text::PRIMARY_CURSOR);
804 case Toolkit::TextEditor::Property::SECONDARY_CURSOR_COLOR:
806 value = impl.mDecorator->GetColor(Text::SECONDARY_CURSOR);
809 case Toolkit::TextEditor::Property::ENABLE_CURSOR_BLINK:
811 value = impl.mController->GetEnableCursorBlink();
814 case Toolkit::TextEditor::Property::CURSOR_BLINK_INTERVAL:
816 value = impl.mDecorator->GetCursorBlinkInterval();
819 case Toolkit::TextEditor::Property::CURSOR_BLINK_DURATION:
821 value = impl.mDecorator->GetCursorBlinkDuration();
824 case Toolkit::TextEditor::Property::CURSOR_WIDTH:
826 value = impl.mDecorator->GetCursorWidth();
829 case Toolkit::TextEditor::Property::GRAB_HANDLE_IMAGE:
831 value = impl.mDecorator->GetHandleImage(Text::GRAB_HANDLE, Text::HANDLE_IMAGE_RELEASED);
834 case Toolkit::TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE:
836 value = impl.mDecorator->GetHandleImage(Text::GRAB_HANDLE, Text::HANDLE_IMAGE_PRESSED);
839 case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT:
841 impl.GetHandleImagePropertyValue(value, Text::LEFT_SELECTION_HANDLE, Text::HANDLE_IMAGE_RELEASED);
844 case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT:
846 impl.GetHandleImagePropertyValue(value, Text::RIGHT_SELECTION_HANDLE, Text::HANDLE_IMAGE_RELEASED);
849 case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
851 impl.GetHandleImagePropertyValue(value, Text::LEFT_SELECTION_HANDLE, Text::HANDLE_IMAGE_PRESSED);
854 case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
856 impl.GetHandleImagePropertyValue(value, Text::RIGHT_SELECTION_HANDLE, Text::HANDLE_IMAGE_PRESSED);
859 case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
861 impl.GetHandleImagePropertyValue(value, Text::LEFT_SELECTION_HANDLE_MARKER, Text::HANDLE_IMAGE_RELEASED);
864 case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
866 impl.GetHandleImagePropertyValue(value, Text::RIGHT_SELECTION_HANDLE_MARKER, Text::HANDLE_IMAGE_RELEASED);
869 case Toolkit::TextEditor::Property::SELECTION_HIGHLIGHT_COLOR:
871 value = impl.mDecorator->GetHighlightColor();
874 case Toolkit::TextEditor::Property::DECORATION_BOUNDING_BOX:
876 Rect<int> boundingBox;
877 impl.mDecorator->GetBoundingBox(boundingBox);
881 case Toolkit::TextEditor::Property::ENABLE_MARKUP:
883 value = impl.mController->IsMarkupProcessorEnabled();
886 case Toolkit::TextEditor::Property::INPUT_COLOR:
888 value = impl.mController->GetInputColor();
891 case Toolkit::TextEditor::Property::INPUT_FONT_FAMILY:
893 value = impl.mController->GetInputFontFamily();
896 case Toolkit::TextEditor::Property::INPUT_FONT_STYLE:
898 GetFontStyleProperty(impl.mController, value, Text::FontStyle::INPUT);
901 case Toolkit::TextEditor::Property::INPUT_POINT_SIZE:
903 value = impl.mController->GetInputFontPointSize();
906 case Toolkit::TextEditor::Property::LINE_SPACING:
908 value = impl.mController->GetDefaultLineSpacing();
911 case Toolkit::TextEditor::Property::INPUT_LINE_SPACING:
913 value = impl.mController->GetInputLineSpacing();
916 case Toolkit::TextEditor::Property::UNDERLINE:
918 GetUnderlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
921 case Toolkit::TextEditor::Property::INPUT_UNDERLINE:
923 GetUnderlineProperties(impl.mController, value, Text::EffectStyle::INPUT);
926 case Toolkit::TextEditor::Property::SHADOW:
928 GetShadowProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
931 case Toolkit::TextEditor::Property::INPUT_SHADOW:
933 GetShadowProperties(impl.mController, value, Text::EffectStyle::INPUT);
936 case Toolkit::TextEditor::Property::EMBOSS:
938 GetEmbossProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
941 case Toolkit::TextEditor::Property::INPUT_EMBOSS:
943 GetEmbossProperties(impl.mController, value, Text::EffectStyle::INPUT);
946 case Toolkit::TextEditor::Property::OUTLINE:
948 GetOutlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
951 case Toolkit::TextEditor::Property::INPUT_OUTLINE:
953 GetOutlineProperties(impl.mController, value, Text::EffectStyle::INPUT);
956 case Toolkit::TextEditor::Property::SMOOTH_SCROLL:
958 value = impl.mScrollAnimationEnabled;
961 case Toolkit::TextEditor::Property::SMOOTH_SCROLL_DURATION:
963 value = impl.mScrollAnimationDuration;
966 case Toolkit::TextEditor::Property::ENABLE_SCROLL_BAR:
968 value = impl.mScrollBarEnabled;
971 case Toolkit::TextEditor::Property::SCROLL_BAR_SHOW_DURATION:
973 value = impl.mAnimationPeriod.delaySeconds;
976 case Toolkit::TextEditor::Property::SCROLL_BAR_FADE_DURATION:
978 value = impl.mAnimationPeriod.durationSeconds;
981 case Toolkit::TextEditor::Property::PIXEL_SIZE:
983 value = impl.mController->GetDefaultFontSize(Text::Controller::PIXEL_SIZE);
986 case Toolkit::TextEditor::Property::LINE_COUNT:
988 float width = textEditor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
989 value = impl.mController->GetLineCount(width);
992 case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT:
995 impl.mController->GetPlaceholderText(Text::Controller::PLACEHOLDER_TYPE_INACTIVE, text);
999 case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR:
1001 value = impl.mController->GetPlaceholderTextColor();
1004 case Toolkit::TextEditor::Property::ENABLE_SELECTION:
1006 value = impl.mController->IsSelectionEnabled();
1009 case Toolkit::TextEditor::Property::PLACEHOLDER:
1012 impl.mController->GetPlaceholderProperty(map);
1016 case Toolkit::TextEditor::Property::LINE_WRAP_MODE:
1018 value = impl.mController->GetLineWrapMode();
1021 case Toolkit::DevelTextEditor::Property::STRIKETHROUGH:
1023 GetStrikethroughProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
1026 case Toolkit::DevelTextEditor::Property::INPUT_STRIKETHROUGH:
1028 GetStrikethroughProperties(impl.mController, value, Text::EffectStyle::INPUT);
1031 case Toolkit::DevelTextEditor::Property::ENABLE_SHIFT_SELECTION:
1033 value = impl.mController->IsShiftSelectionEnabled();
1036 case Toolkit::DevelTextEditor::Property::ENABLE_GRAB_HANDLE:
1038 value = impl.mController->IsGrabHandleEnabled();
1041 case Toolkit::DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
1043 value = impl.mController->GetMatchLayoutDirection() != DevelText::MatchLayoutDirection::CONTENTS;
1046 case Toolkit::DevelTextEditor::Property::MAX_LENGTH:
1048 value = impl.mController->GetMaximumNumberOfCharacters();
1051 case Toolkit::DevelTextEditor::Property::SELECTED_TEXT:
1053 value = impl.mController->GetSelectedText();
1056 case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_START:
1058 Uint32Pair range = impl.GetTextSelectionRange();
1059 value = static_cast<int>(range.first);
1062 case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_END:
1064 Uint32Pair range = impl.GetTextSelectionRange();
1065 value = static_cast<int>(range.second);
1068 case Toolkit::DevelTextEditor::Property::ENABLE_EDITING:
1070 value = impl.IsEditable();
1073 case Toolkit::DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION:
1075 value = impl.GetHorizontalScrollPosition();
1078 case Toolkit::DevelTextEditor::Property::VERTICAL_SCROLL_POSITION:
1080 value = impl.GetVerticalScrollPosition();
1083 case Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE:
1085 value = impl.mController->GetFontSizeScale();
1088 case Toolkit::DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE:
1090 value = impl.mController->IsFontSizeScaleEnabled();
1093 case Toolkit::DevelTextEditor::Property::PRIMARY_CURSOR_POSITION:
1095 value = static_cast<int>(impl.mController->GetPrimaryCursorPosition());
1098 case Toolkit::DevelTextEditor::Property::GRAB_HANDLE_COLOR:
1100 value = impl.mDecorator->GetHandleColor();
1103 case Toolkit::DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP:
1105 value = impl.mController->IsGrabHandlePopupEnabled();
1108 case Toolkit::DevelTextEditor::Property::INPUT_METHOD_SETTINGS:
1111 impl.mInputMethodOptions.RetrieveProperty(map);
1115 case Toolkit::DevelTextEditor::Property::INPUT_FILTER:
1118 impl.mController->GetInputFilterOption(map);
1122 case Toolkit::DevelTextEditor::Property::ELLIPSIS:
1124 value = impl.mController->IsTextElideEnabled();
1127 case Toolkit::DevelTextEditor::Property::ELLIPSIS_POSITION:
1129 value = impl.mController->GetEllipsisPosition();
1132 case Toolkit::DevelTextEditor::Property::MIN_LINE_SIZE:
1134 value = impl.mController->GetDefaultLineSize();
1137 case Toolkit::DevelTextEditor::Property::CHARACTER_SPACING:
1139 value = impl.mController->GetCharacterSpacing();
1142 case Toolkit::DevelTextEditor::Property::RELATIVE_LINE_SIZE:
1144 value = impl.mController->GetRelativeLineSize();
1151 } // namespace Dali::Toolkit::Internal