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::DevelTextEditor::Property::VERTICAL_ALIGNMENT:
131 Toolkit::Text::VerticalAlignment::Type alignment(static_cast<Text::VerticalAlignment::Type>(-1)); // Set to invalid value to ensure a valid mode does get set
132 if(Text::GetVerticalAlignmentEnumeration(value, alignment))
134 impl.mController->SetVerticalAlignment(alignment);
135 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p VERTICAL_ALIGNMENT %d\n", impl.mController.Get(), alignment);
139 case Toolkit::TextEditor::Property::SCROLL_THRESHOLD:
141 const float threshold = value.Get<float>();
142 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p SCROLL_THRESHOLD %f\n", impl.mController.Get(), threshold);
144 impl.mDecorator->SetScrollThreshold(threshold);
147 case Toolkit::TextEditor::Property::SCROLL_SPEED:
149 const float speed = value.Get<float>();
150 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p SCROLL_SPEED %f\n", impl.mController.Get(), speed);
152 impl.mDecorator->SetScrollSpeed(speed);
155 case Toolkit::TextEditor::Property::PRIMARY_CURSOR_COLOR:
157 const Vector4& color = value.Get<Vector4>();
158 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);
160 impl.mDecorator->SetCursorColor(Toolkit::Text::PRIMARY_CURSOR, color);
161 impl.RequestTextRelayout();
164 case Toolkit::TextEditor::Property::SECONDARY_CURSOR_COLOR:
166 const Vector4& color = value.Get<Vector4>();
167 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);
169 impl.mDecorator->SetCursorColor(Toolkit::Text::SECONDARY_CURSOR, color);
170 impl.RequestTextRelayout();
173 case Toolkit::TextEditor::Property::ENABLE_CURSOR_BLINK:
175 const bool enable = value.Get<bool>();
176 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p ENABLE_CURSOR_BLINK %d\n", impl.mController.Get(), enable);
178 impl.mController->SetEnableCursorBlink(enable);
179 impl.RequestTextRelayout();
182 case Toolkit::TextEditor::Property::CURSOR_BLINK_INTERVAL:
184 const float interval = value.Get<float>();
185 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p CURSOR_BLINK_INTERVAL %f\n", impl.mController.Get(), interval);
187 impl.mDecorator->SetCursorBlinkInterval(interval);
190 case Toolkit::TextEditor::Property::CURSOR_BLINK_DURATION:
192 const float duration = value.Get<float>();
193 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p CURSOR_BLINK_DURATION %f\n", impl.mController.Get(), duration);
195 impl.mDecorator->SetCursorBlinkDuration(duration);
198 case Toolkit::TextEditor::Property::CURSOR_WIDTH:
200 const int width = value.Get<int>();
201 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p CURSOR_WIDTH %d\n", impl.mController.Get(), width);
203 impl.mDecorator->SetCursorWidth(width);
204 impl.mController->GetLayoutEngine().SetCursorWidth(width);
207 case Toolkit::TextEditor::Property::GRAB_HANDLE_IMAGE:
209 const std::string imageFileName = value.Get<std::string>();
210 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p GRAB_HANDLE_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str());
212 if(imageFileName.size())
214 impl.mDecorator->SetHandleImage(Toolkit::Text::GRAB_HANDLE, Toolkit::Text::HANDLE_IMAGE_RELEASED, imageFileName);
215 impl.RequestTextRelayout();
219 case Toolkit::TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE:
221 const std::string imageFileName = value.Get<std::string>();
222 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p GRAB_HANDLE_PRESSED_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str());
224 if(imageFileName.size())
226 impl.mDecorator->SetHandleImage(Toolkit::Text::GRAB_HANDLE, Toolkit::Text::HANDLE_IMAGE_PRESSED, imageFileName);
227 impl.RequestTextRelayout();
231 case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT:
233 const std::string filename = GetImageFileNameFromPropertyValue(value);
237 impl.mDecorator->SetHandleImage(Toolkit::Text::LEFT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_RELEASED, filename);
238 impl.RequestTextRelayout();
242 case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT:
244 const std::string filename = GetImageFileNameFromPropertyValue(value);
248 impl.mDecorator->SetHandleImage(Toolkit::Text::RIGHT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_RELEASED, filename);
249 impl.RequestTextRelayout();
253 case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
255 const std::string filename = GetImageFileNameFromPropertyValue(value);
259 impl.mDecorator->SetHandleImage(Toolkit::Text::LEFT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_PRESSED, filename);
260 impl.RequestTextRelayout();
264 case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
266 const std::string filename = GetImageFileNameFromPropertyValue(value);
270 impl.mDecorator->SetHandleImage(Toolkit::Text::RIGHT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_PRESSED, filename);
271 impl.RequestTextRelayout();
275 case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
277 const std::string filename = GetImageFileNameFromPropertyValue(value);
281 impl.mDecorator->SetHandleImage(Toolkit::Text::LEFT_SELECTION_HANDLE_MARKER,
282 Toolkit::Text::HANDLE_IMAGE_RELEASED,
284 impl.RequestTextRelayout();
288 case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
290 const std::string filename = GetImageFileNameFromPropertyValue(value);
294 impl.mDecorator->SetHandleImage(Toolkit::Text::RIGHT_SELECTION_HANDLE_MARKER,
295 Toolkit::Text::HANDLE_IMAGE_RELEASED,
297 impl.RequestTextRelayout();
301 case Toolkit::TextEditor::Property::SELECTION_HIGHLIGHT_COLOR:
303 const Vector4 color = value.Get<Vector4>();
304 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);
306 impl.mDecorator->SetHighlightColor(color);
307 impl.RequestTextRelayout();
310 case Toolkit::TextEditor::Property::DECORATION_BOUNDING_BOX:
312 const Rect<int>& box = value.Get<Rect<int> >();
313 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);
315 impl.mDecorator->SetBoundingBox(box);
316 impl.RequestTextRelayout();
319 case Toolkit::TextEditor::Property::ENABLE_MARKUP:
321 const bool enableMarkup = value.Get<bool>();
322 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p ENABLE_MARKUP %d\n", impl.mController.Get(), enableMarkup);
324 impl.mController->SetMarkupProcessorEnabled(enableMarkup);
325 CommonTextUtils::SynchronizeTextAnchorsInParent(textEditor, impl.mController, impl.mAnchorActors);
328 case Toolkit::TextEditor::Property::INPUT_COLOR:
330 const Vector4& inputColor = value.Get<Vector4>();
331 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);
333 impl.mController->SetInputColor(inputColor);
336 case Toolkit::TextEditor::Property::INPUT_FONT_FAMILY:
338 const std::string& fontFamily = value.Get<std::string>();
339 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p INPUT_FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str());
340 impl.mController->SetInputFontFamily(fontFamily);
343 case Toolkit::TextEditor::Property::INPUT_FONT_STYLE:
345 SetFontStyleProperty(impl.mController, value, Text::FontStyle::INPUT);
348 case Toolkit::TextEditor::Property::INPUT_POINT_SIZE:
350 const float pointSize = value.Get<float>();
351 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p INPUT_POINT_SIZE %f\n", impl.mController.Get(), pointSize);
352 impl.mController->SetInputFontPointSize(pointSize);
355 case Toolkit::TextEditor::Property::LINE_SPACING:
357 const float lineSpacing = value.Get<float>();
358 impl.mController->SetDefaultLineSpacing(lineSpacing);
359 impl.mRenderer.Reset();
362 case Toolkit::TextEditor::Property::INPUT_LINE_SPACING:
364 const float lineSpacing = value.Get<float>();
365 impl.mController->SetInputLineSpacing(lineSpacing);
366 impl.mRenderer.Reset();
369 case Toolkit::TextEditor::Property::UNDERLINE:
371 const bool update = SetUnderlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
374 impl.mRenderer.Reset();
378 case Toolkit::TextEditor::Property::INPUT_UNDERLINE:
380 const bool update = SetUnderlineProperties(impl.mController, value, Text::EffectStyle::INPUT);
383 impl.mRenderer.Reset();
387 case Toolkit::TextEditor::Property::SHADOW:
389 const bool update = SetShadowProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
392 impl.mRenderer.Reset();
396 case Toolkit::TextEditor::Property::INPUT_SHADOW:
398 const bool update = SetShadowProperties(impl.mController, value, Text::EffectStyle::INPUT);
401 impl.mRenderer.Reset();
405 case Toolkit::TextEditor::Property::EMBOSS:
407 const bool update = SetEmbossProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
410 impl.mRenderer.Reset();
414 case Toolkit::TextEditor::Property::INPUT_EMBOSS:
416 const bool update = SetEmbossProperties(impl.mController, value, Text::EffectStyle::INPUT);
419 impl.mRenderer.Reset();
423 case Toolkit::TextEditor::Property::OUTLINE:
425 const bool update = SetOutlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
428 impl.mRenderer.Reset();
432 case Toolkit::TextEditor::Property::INPUT_OUTLINE:
434 const bool update = SetOutlineProperties(impl.mController, value, Text::EffectStyle::INPUT);
437 impl.mRenderer.Reset();
441 case Toolkit::TextEditor::Property::SMOOTH_SCROLL:
443 const bool enable = value.Get<bool>();
444 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor SMOOTH_SCROLL %d\n", enable);
446 impl.mScrollAnimationEnabled = enable;
449 case Toolkit::TextEditor::Property::SMOOTH_SCROLL_DURATION:
451 const float duration = value.Get<float>();
452 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor SMOOTH_SCROLL_DURATION %f\n", duration);
454 impl.mScrollAnimationDuration = duration;
455 if(impl.mTextVerticalScroller)
457 impl.mTextVerticalScroller->SetDuration(duration);
461 case Toolkit::TextEditor::Property::ENABLE_SCROLL_BAR:
463 const bool enable = value.Get<bool>();
464 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor SHOW_SCROLL_BAR %d\n", enable);
466 impl.mScrollBarEnabled = enable;
469 case Toolkit::TextEditor::Property::SCROLL_BAR_SHOW_DURATION:
471 const float duration = value.Get<float>();
472 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor SCROLL_BAR_SHOW_DURATION %f\n", duration);
474 impl.mAnimationPeriod.delaySeconds = duration;
477 case Toolkit::TextEditor::Property::SCROLL_BAR_FADE_DURATION:
479 const float duration = value.Get<float>();
480 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor SCROLL_BAR_FADE_DURATION %f\n", duration);
482 impl.mAnimationPeriod.durationSeconds = duration;
485 case Toolkit::TextEditor::Property::PIXEL_SIZE:
487 const float pixelSize = value.Get<float>();
488 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p PIXEL_SIZE %f\n", impl.mController.Get(), pixelSize);
490 if(!Equals(impl.mController->GetDefaultFontSize(Text::Controller::PIXEL_SIZE), pixelSize))
492 impl.mController->SetDefaultFontSize(pixelSize, Text::Controller::PIXEL_SIZE);
496 case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT:
498 const std::string& text = value.Get<std::string>();
499 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor::OnPropertySet %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str());
501 impl.mController->SetPlaceholderText(Text::Controller::PLACEHOLDER_TYPE_INACTIVE, text);
504 case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR:
506 const Vector4& textColor = value.Get<Vector4>();
507 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);
509 if(impl.mController->GetPlaceholderTextColor() != textColor)
511 impl.mController->SetPlaceholderTextColor(textColor);
512 impl.mRenderer.Reset();
516 case Toolkit::TextEditor::Property::ENABLE_SELECTION:
518 const bool enableSelection = value.Get<bool>();
519 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p ENABLE_SELECTION %d\n", impl.mController.Get(), enableSelection);
520 impl.mController->SetSelectionEnabled(enableSelection);
523 case Toolkit::TextEditor::Property::PLACEHOLDER:
525 const Property::Map* map = value.GetMap();
528 impl.mController->SetPlaceholderProperty(*map);
532 case Toolkit::TextEditor::Property::LINE_WRAP_MODE:
534 Text::LineWrap::Mode lineWrapMode(static_cast<Text::LineWrap::Mode>(-1)); // Set to invalid value to ensure a valid mode does get set
535 if(Toolkit::Text::GetLineWrapModeEnumeration(value, lineWrapMode))
537 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p LineWrap::MODE %d\n", impl.mController.Get(), lineWrapMode);
538 impl.mController->SetLineWrapMode(lineWrapMode);
542 case Toolkit::DevelTextEditor::Property::ENABLE_SHIFT_SELECTION:
544 const bool shiftSelection = value.Get<bool>();
545 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p ENABLE_SHIFT_SELECTION %d\n", impl.mController.Get(), shiftSelection);
547 impl.mController->SetShiftSelectionEnabled(shiftSelection);
550 case Toolkit::DevelTextEditor::Property::ENABLE_GRAB_HANDLE:
552 const bool grabHandleEnabled = value.Get<bool>();
553 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p ENABLE_GRAB_HANDLE %d\n", impl.mController.Get(), grabHandleEnabled);
555 impl.mController->SetGrabHandleEnabled(grabHandleEnabled);
558 case Toolkit::DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
560 impl.mController->SetMatchLayoutDirection(value.Get<bool>() ? DevelText::MatchLayoutDirection::LOCALE : DevelText::MatchLayoutDirection::CONTENTS);
563 case Toolkit::DevelTextEditor::Property::MAX_LENGTH:
565 const int max = value.Get<int>();
566 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p MAX_LENGTH %d\n", impl.mController.Get(), max);
568 impl.mController->SetMaximumNumberOfCharacters(max);
571 case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_START:
573 uint32_t start = static_cast<uint32_t>(value.Get<int>());
574 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p SELECTED_TEXT_START %d\n", impl.mController.Get(), start);
575 impl.SetTextSelectionRange(&start, nullptr);
578 case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_END:
580 uint32_t end = static_cast<uint32_t>(value.Get<int>());
581 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p SELECTED_TEXT_END %d\n", impl.mController.Get(), end);
582 impl.SetTextSelectionRange(nullptr, &end);
585 case Toolkit::DevelTextEditor::Property::ENABLE_EDITING:
587 const bool editable = value.Get<bool>();
588 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p ENABLE_EDITING %d\n", impl.mController.Get(), editable);
589 impl.SetEditable(editable);
592 case Toolkit::DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION:
594 float horizontalScroll = value.Get<float>();
595 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p HORIZONTAL_SCROLL_POSITION %d\n", impl.mController.Get(), horizontalScroll);
596 if(horizontalScroll >= 0.0f)
598 impl.ScrollBy(Vector2(horizontalScroll - impl.GetHorizontalScrollPosition(), 0));
602 case Toolkit::DevelTextEditor::Property::VERTICAL_SCROLL_POSITION:
604 float verticalScroll = value.Get<float>();
605 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p VERTICAL_SCROLL_POSITION %d\n", impl.mController.Get(), verticalScroll);
606 if(verticalScroll >= 0.0f)
608 impl.ScrollBy(Vector2(0, verticalScroll - impl.GetVerticalScrollPosition()));
612 case Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE:
614 const float scale = value.Get<float>();
615 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p FONT_SIZE_SCALE %f\n", impl.mController.Get(), scale);
617 if(!Equals(impl.mController->GetFontSizeScale(), scale))
619 impl.mController->SetFontSizeScale(scale);
623 case Toolkit::DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE:
625 const bool enableFontSizeScale = value.Get<bool>();
626 if(!Equals(impl.mController->IsFontSizeScaleEnabled(), enableFontSizeScale))
628 impl.mController->SetFontSizeScaleEnabled(enableFontSizeScale);
632 case Toolkit::DevelTextEditor::Property::PRIMARY_CURSOR_POSITION:
634 uint32_t position = static_cast<uint32_t>(value.Get<int>());
635 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p PRIMARY_CURSOR_POSITION %d\n", impl.mController.Get(), position);
636 if(impl.mController->SetPrimaryCursorPosition(position, impl.HasKeyInputFocus()))
638 impl.SetKeyInputFocus();
642 case Toolkit::DevelTextEditor::Property::GRAB_HANDLE_COLOR:
644 const Vector4 color = value.Get<Vector4>();
645 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);
647 impl.mDecorator->SetHandleColor(color);
648 impl.RequestTextRelayout();
651 case Toolkit::DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP:
653 const bool grabHandlePopupEnabled = value.Get<bool>();
654 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p ENABLE_GRAB_HANDLE_POPUP %d\n", impl.mController.Get(), grabHandlePopupEnabled);
656 impl.mController->SetGrabHandlePopupEnabled(grabHandlePopupEnabled);
659 case Toolkit::DevelTextEditor::Property::INPUT_METHOD_SETTINGS:
661 const Property::Map* map = value.GetMap();
664 impl.mInputMethodOptions.ApplyProperty(*map);
666 impl.mController->SetInputModePassword(impl.mInputMethodOptions.IsPassword());
668 Toolkit::Control control = Toolkit::KeyInputFocusManager::Get().GetCurrentFocusControl();
669 if(control == textEditor)
671 impl.mInputMethodContext.ApplyOptions(impl.mInputMethodOptions);
675 case Toolkit::DevelTextEditor::Property::INPUT_FILTER:
677 const Property::Map* map = value.GetMap();
680 impl.mController->SetInputFilterOption(*map);
684 case Toolkit::DevelTextEditor::Property::ELLIPSIS:
686 const bool ellipsis = value.Get<bool>();
687 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p ELLIPSIS %d\n", impl.mController.Get(), ellipsis);
689 impl.mController->SetTextElideEnabled(ellipsis);
692 case Toolkit::DevelTextEditor::Property::ELLIPSIS_POSITION:
694 DevelText::EllipsisPosition::Type ellipsisPositionType(static_cast<DevelText::EllipsisPosition::Type>(-1)); // Set to invalid value to ensure a valid mode does get set
695 if(Text::GetEllipsisPositionTypeEnumeration(value, ellipsisPositionType))
697 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p EllipsisPosition::Type %d\n", impl.mController.Get(), ellipsisPositionType);
698 impl.mController->SetEllipsisPosition(ellipsisPositionType);
702 case Toolkit::DevelTextEditor::Property::MIN_LINE_SIZE:
704 const float minLineSize = value.Get<float>();
705 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p MIN_LINE_SIZE %f\n", impl.mController.Get(), minLineSize);
707 impl.mController->SetDefaultLineSize(minLineSize);
708 impl.mRenderer.Reset();
711 case Toolkit::DevelTextEditor::Property::STRIKETHROUGH:
713 const bool update = SetStrikethroughProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
716 impl.mRenderer.Reset();
720 case Toolkit::DevelTextEditor::Property::INPUT_STRIKETHROUGH:
722 const bool update = SetStrikethroughProperties(impl.mController, value, Text::EffectStyle::INPUT);
725 impl.mRenderer.Reset();
729 case Toolkit::DevelTextEditor::Property::CHARACTER_SPACING:
731 const float characterSpacing = value.Get<float>();
732 impl.mController->SetCharacterSpacing(characterSpacing);
733 impl.mRenderer.Reset();
736 case Toolkit::DevelTextEditor::Property::RELATIVE_LINE_SIZE:
738 const float relativeLineSize = value.Get<float>();
739 DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p RELATIVE_LINE_SIZE %f\n", impl.mController.Get(), relativeLineSize);
741 impl.mController->SetRelativeLineSize(relativeLineSize);
742 impl.mRenderer.Reset();
745 case Toolkit::DevelTextEditor::Property::SELECTION_POPUP_STYLE:
747 const Property::Map* map = value.GetMap();
750 impl.mDecorator->SetSelectionPopupStyle(*map);
757 Property::Value TextEditor::PropertyHandler::GetProperty(Toolkit::TextEditor textEditor, Property::Index index)
759 Property::Value value;
760 TextEditor& impl(GetImpl(textEditor));
761 DALI_ASSERT_DEBUG(impl.mController && "No text controller");
762 DALI_ASSERT_DEBUG(impl.mDecorator && "No text decorator");
766 case Toolkit::DevelTextEditor::Property::RENDERING_BACKEND:
768 value = impl.mRenderingBackend;
771 case Toolkit::TextEditor::Property::TEXT:
774 impl.mController->GetText(text);
775 DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p returning text: %s\n", impl.mController.Get(), text.c_str());
779 case Toolkit::TextEditor::Property::TEXT_COLOR:
781 value = impl.mController->GetDefaultColor();
784 case Toolkit::TextEditor::Property::FONT_FAMILY:
786 value = impl.mController->GetDefaultFontFamily();
789 case Toolkit::TextEditor::Property::FONT_STYLE:
791 GetFontStyleProperty(impl.mController, value, Text::FontStyle::DEFAULT);
794 case Toolkit::TextEditor::Property::POINT_SIZE:
796 value = impl.mController->GetDefaultFontSize(Text::Controller::POINT_SIZE);
799 case Toolkit::TextEditor::Property::HORIZONTAL_ALIGNMENT:
801 const char* name = Text::GetHorizontalAlignmentString(impl.mController->GetHorizontalAlignment());
804 value = std::string(name);
808 case Toolkit::DevelTextEditor::Property::VERTICAL_ALIGNMENT:
810 const char* name = Text::GetVerticalAlignmentString(impl.mController->GetVerticalAlignment());
814 value = std::string(name);
818 case Toolkit::TextEditor::Property::SCROLL_THRESHOLD:
820 value = impl.mDecorator->GetScrollThreshold();
823 case Toolkit::TextEditor::Property::SCROLL_SPEED:
825 value = impl.mDecorator->GetScrollSpeed();
828 case Toolkit::TextEditor::Property::PRIMARY_CURSOR_COLOR:
830 value = impl.mDecorator->GetColor(Text::PRIMARY_CURSOR);
833 case Toolkit::TextEditor::Property::SECONDARY_CURSOR_COLOR:
835 value = impl.mDecorator->GetColor(Text::SECONDARY_CURSOR);
838 case Toolkit::TextEditor::Property::ENABLE_CURSOR_BLINK:
840 value = impl.mController->GetEnableCursorBlink();
843 case Toolkit::TextEditor::Property::CURSOR_BLINK_INTERVAL:
845 value = impl.mDecorator->GetCursorBlinkInterval();
848 case Toolkit::TextEditor::Property::CURSOR_BLINK_DURATION:
850 value = impl.mDecorator->GetCursorBlinkDuration();
853 case Toolkit::TextEditor::Property::CURSOR_WIDTH:
855 value = impl.mDecorator->GetCursorWidth();
858 case Toolkit::TextEditor::Property::GRAB_HANDLE_IMAGE:
860 value = impl.mDecorator->GetHandleImage(Text::GRAB_HANDLE, Text::HANDLE_IMAGE_RELEASED);
863 case Toolkit::TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE:
865 value = impl.mDecorator->GetHandleImage(Text::GRAB_HANDLE, Text::HANDLE_IMAGE_PRESSED);
868 case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT:
870 impl.GetHandleImagePropertyValue(value, Text::LEFT_SELECTION_HANDLE, Text::HANDLE_IMAGE_RELEASED);
873 case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT:
875 impl.GetHandleImagePropertyValue(value, Text::RIGHT_SELECTION_HANDLE, Text::HANDLE_IMAGE_RELEASED);
878 case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
880 impl.GetHandleImagePropertyValue(value, Text::LEFT_SELECTION_HANDLE, Text::HANDLE_IMAGE_PRESSED);
883 case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
885 impl.GetHandleImagePropertyValue(value, Text::RIGHT_SELECTION_HANDLE, Text::HANDLE_IMAGE_PRESSED);
888 case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
890 impl.GetHandleImagePropertyValue(value, Text::LEFT_SELECTION_HANDLE_MARKER, Text::HANDLE_IMAGE_RELEASED);
893 case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
895 impl.GetHandleImagePropertyValue(value, Text::RIGHT_SELECTION_HANDLE_MARKER, Text::HANDLE_IMAGE_RELEASED);
898 case Toolkit::TextEditor::Property::SELECTION_HIGHLIGHT_COLOR:
900 value = impl.mDecorator->GetHighlightColor();
903 case Toolkit::TextEditor::Property::DECORATION_BOUNDING_BOX:
905 Rect<int> boundingBox;
906 impl.mDecorator->GetBoundingBox(boundingBox);
910 case Toolkit::TextEditor::Property::ENABLE_MARKUP:
912 value = impl.mController->IsMarkupProcessorEnabled();
915 case Toolkit::TextEditor::Property::INPUT_COLOR:
917 value = impl.mController->GetInputColor();
920 case Toolkit::TextEditor::Property::INPUT_FONT_FAMILY:
922 value = impl.mController->GetInputFontFamily();
925 case Toolkit::TextEditor::Property::INPUT_FONT_STYLE:
927 GetFontStyleProperty(impl.mController, value, Text::FontStyle::INPUT);
930 case Toolkit::TextEditor::Property::INPUT_POINT_SIZE:
932 value = impl.mController->GetInputFontPointSize();
935 case Toolkit::TextEditor::Property::LINE_SPACING:
937 value = impl.mController->GetDefaultLineSpacing();
940 case Toolkit::TextEditor::Property::INPUT_LINE_SPACING:
942 value = impl.mController->GetInputLineSpacing();
945 case Toolkit::TextEditor::Property::UNDERLINE:
947 GetUnderlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
950 case Toolkit::TextEditor::Property::INPUT_UNDERLINE:
952 GetUnderlineProperties(impl.mController, value, Text::EffectStyle::INPUT);
955 case Toolkit::TextEditor::Property::SHADOW:
957 GetShadowProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
960 case Toolkit::TextEditor::Property::INPUT_SHADOW:
962 GetShadowProperties(impl.mController, value, Text::EffectStyle::INPUT);
965 case Toolkit::TextEditor::Property::EMBOSS:
967 GetEmbossProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
970 case Toolkit::TextEditor::Property::INPUT_EMBOSS:
972 GetEmbossProperties(impl.mController, value, Text::EffectStyle::INPUT);
975 case Toolkit::TextEditor::Property::OUTLINE:
977 GetOutlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
980 case Toolkit::TextEditor::Property::INPUT_OUTLINE:
982 GetOutlineProperties(impl.mController, value, Text::EffectStyle::INPUT);
985 case Toolkit::TextEditor::Property::SMOOTH_SCROLL:
987 value = impl.mScrollAnimationEnabled;
990 case Toolkit::TextEditor::Property::SMOOTH_SCROLL_DURATION:
992 value = impl.mScrollAnimationDuration;
995 case Toolkit::TextEditor::Property::ENABLE_SCROLL_BAR:
997 value = impl.mScrollBarEnabled;
1000 case Toolkit::TextEditor::Property::SCROLL_BAR_SHOW_DURATION:
1002 value = impl.mAnimationPeriod.delaySeconds;
1005 case Toolkit::TextEditor::Property::SCROLL_BAR_FADE_DURATION:
1007 value = impl.mAnimationPeriod.durationSeconds;
1010 case Toolkit::TextEditor::Property::PIXEL_SIZE:
1012 value = impl.mController->GetDefaultFontSize(Text::Controller::PIXEL_SIZE);
1015 case Toolkit::TextEditor::Property::LINE_COUNT:
1017 float width = textEditor.GetProperty(Actor::Property::SIZE_WIDTH).Get<float>();
1018 value = impl.mController->GetLineCount(width);
1021 case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT:
1024 impl.mController->GetPlaceholderText(Text::Controller::PLACEHOLDER_TYPE_INACTIVE, text);
1028 case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR:
1030 value = impl.mController->GetPlaceholderTextColor();
1033 case Toolkit::TextEditor::Property::ENABLE_SELECTION:
1035 value = impl.mController->IsSelectionEnabled();
1038 case Toolkit::TextEditor::Property::PLACEHOLDER:
1041 impl.mController->GetPlaceholderProperty(map);
1045 case Toolkit::TextEditor::Property::LINE_WRAP_MODE:
1047 value = impl.mController->GetLineWrapMode();
1050 case Toolkit::DevelTextEditor::Property::STRIKETHROUGH:
1052 GetStrikethroughProperties(impl.mController, value, Text::EffectStyle::DEFAULT);
1055 case Toolkit::DevelTextEditor::Property::INPUT_STRIKETHROUGH:
1057 GetStrikethroughProperties(impl.mController, value, Text::EffectStyle::INPUT);
1060 case Toolkit::DevelTextEditor::Property::ENABLE_SHIFT_SELECTION:
1062 value = impl.mController->IsShiftSelectionEnabled();
1065 case Toolkit::DevelTextEditor::Property::ENABLE_GRAB_HANDLE:
1067 value = impl.mController->IsGrabHandleEnabled();
1070 case Toolkit::DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
1072 value = impl.mController->GetMatchLayoutDirection() != DevelText::MatchLayoutDirection::CONTENTS;
1075 case Toolkit::DevelTextEditor::Property::MAX_LENGTH:
1077 value = impl.mController->GetMaximumNumberOfCharacters();
1080 case Toolkit::DevelTextEditor::Property::SELECTED_TEXT:
1082 value = impl.mController->GetSelectedText();
1085 case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_START:
1087 Uint32Pair range = impl.GetTextSelectionRange();
1088 value = static_cast<int>(range.first);
1091 case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_END:
1093 Uint32Pair range = impl.GetTextSelectionRange();
1094 value = static_cast<int>(range.second);
1097 case Toolkit::DevelTextEditor::Property::ENABLE_EDITING:
1099 value = impl.IsEditable();
1102 case Toolkit::DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION:
1104 value = impl.GetHorizontalScrollPosition();
1107 case Toolkit::DevelTextEditor::Property::VERTICAL_SCROLL_POSITION:
1109 value = impl.GetVerticalScrollPosition();
1112 case Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE:
1114 value = impl.mController->GetFontSizeScale();
1117 case Toolkit::DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE:
1119 value = impl.mController->IsFontSizeScaleEnabled();
1122 case Toolkit::DevelTextEditor::Property::PRIMARY_CURSOR_POSITION:
1124 value = static_cast<int>(impl.mController->GetPrimaryCursorPosition());
1127 case Toolkit::DevelTextEditor::Property::GRAB_HANDLE_COLOR:
1129 value = impl.mDecorator->GetHandleColor();
1132 case Toolkit::DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP:
1134 value = impl.mController->IsGrabHandlePopupEnabled();
1137 case Toolkit::DevelTextEditor::Property::INPUT_METHOD_SETTINGS:
1140 impl.mInputMethodOptions.RetrieveProperty(map);
1144 case Toolkit::DevelTextEditor::Property::INPUT_FILTER:
1147 impl.mController->GetInputFilterOption(map);
1151 case Toolkit::DevelTextEditor::Property::ELLIPSIS:
1153 value = impl.mController->IsTextElideEnabled();
1156 case Toolkit::DevelTextEditor::Property::ELLIPSIS_POSITION:
1158 value = impl.mController->GetEllipsisPosition();
1161 case Toolkit::DevelTextEditor::Property::MIN_LINE_SIZE:
1163 value = impl.mController->GetDefaultLineSize();
1166 case Toolkit::DevelTextEditor::Property::CHARACTER_SPACING:
1168 value = impl.mController->GetCharacterSpacing();
1171 case Toolkit::DevelTextEditor::Property::RELATIVE_LINE_SIZE:
1173 value = impl.mController->GetRelativeLineSize();
1176 case Toolkit::DevelTextEditor::Property::SELECTION_POPUP_STYLE:
1179 impl.mDecorator->GetSelectionPopupStyle(map);
1187 } // namespace Dali::Toolkit::Internal