From: Heeyong Song Date: Wed, 3 Nov 2021 05:27:34 +0000 (+0000) Subject: Merge "Fix text constraint issue" into devel/master X-Git-Tag: dali_2.0.51~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=2b6e7d59a00075e2f83eedee483e3544a7af7f3d;hp=37cb9a8e7c94ea7153434d6b0b87a6f08bb9191f Merge "Fix text constraint issue" into devel/master --- diff --git a/dali-toolkit/internal/controls/text-controls/common-text-utils.cpp b/dali-toolkit/internal/controls/text-controls/common-text-utils.cpp new file mode 100644 index 0000000..7331f3e --- /dev/null +++ b/dali-toolkit/internal/controls/text-controls/common-text-utils.cpp @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include +#include + +namespace Dali::Toolkit::Internal +{ +void CommonTextUtils::RenderText( + Actor textActor, + Text::RendererPtr renderer, + Text::ControllerPtr controller, + Text::DecoratorPtr decorator, + float alignmentOffset, + Actor& renderableActor, + Actor& backgroundActor, + Toolkit::Control& stencil, + std::vector& clippingDecorationActors, + Text::Controller::UpdateTextType updateTextType) +{ + Actor newRenderableActor; + + if(Text::Controller::NONE_UPDATED != (Text::Controller::MODEL_UPDATED & updateTextType)) + { + if(renderer) + { + newRenderableActor = renderer->Render(controller->GetView(), + textActor, + Property::INVALID_INDEX, // Animatable property not supported + alignmentOffset, + DepthIndex::CONTENT); + } + + if(renderableActor != newRenderableActor) + { + UnparentAndReset(backgroundActor); + UnparentAndReset(renderableActor); + renderableActor = newRenderableActor; + + if(renderableActor) + { + backgroundActor = controller->CreateBackgroundActor(); + } + } + } + + if(renderableActor) + { + const Vector2& scrollOffset = controller->GetTextModel()->GetScrollPosition(); + + float renderableActorPositionX, renderableActorPositionY; + + if(stencil) + { + renderableActorPositionX = scrollOffset.x + alignmentOffset; + renderableActorPositionY = scrollOffset.y; + } + else + { + Extents padding; + padding = textActor.GetProperty(Toolkit::Control::Property::PADDING); + + // Support Right-To-Left of padding + Dali::LayoutDirection::Type layoutDirection = static_cast(textActor.GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get()); + if(Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection) + { + std::swap(padding.start, padding.end); + } + + renderableActorPositionX = scrollOffset.x + alignmentOffset + padding.start; + renderableActorPositionY = scrollOffset.y + padding.top; + } + + renderableActor.SetProperty(Actor::Property::POSITION, Vector2(renderableActorPositionX, renderableActorPositionY)); + + // Make sure the actors are parented correctly with/without clipping + Actor self = stencil ? stencil : textActor; + + Actor highlightActor; + + for(std::vector::iterator it = clippingDecorationActors.begin(), + endIt = clippingDecorationActors.end(); + it != endIt; + ++it) + { + self.Add(*it); + it->LowerToBottom(); + + if(it->GetProperty(Dali::Actor::Property::NAME) == "HighlightActor") + { + highlightActor = *it; + } + } + clippingDecorationActors.clear(); + + self.Add(renderableActor); + + if(backgroundActor) + { + if(decorator && decorator->IsHighlightVisible()) + { + self.Add(backgroundActor); + backgroundActor.SetProperty(Actor::Property::POSITION, Vector2(renderableActorPositionX, renderableActorPositionY)); // In text field's coords. + backgroundActor.LowerBelow(highlightActor); + } + else + { + renderableActor.Add(backgroundActor); + backgroundActor.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f)); // In renderable actor's coords. + backgroundActor.LowerToBottom(); + } + } + } +} + +} // namespace Dali::Toolkit::Internal diff --git a/dali-toolkit/internal/controls/text-controls/common-text-utils.h b/dali-toolkit/internal/controls/text-controls/common-text-utils.h new file mode 100644 index 0000000..f2eaba7 --- /dev/null +++ b/dali-toolkit/internal/controls/text-controls/common-text-utils.h @@ -0,0 +1,62 @@ +#ifndef DALI_TOOLKIT_INTERNAL_TEXT_CONTROLS_COMMON_TEXT_UTILS_H +#define DALI_TOOLKIT_INTERNAL_TEXT_CONTROLS_COMMON_TEXT_UTILS_H + +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include + +#include + +namespace Dali::Toolkit::Internal +{ +class CommonTextUtils +{ +public: + /** + * Common method to render text, setting up background, foreground actors with decorators/stencil. + * @param[in] textActor The TextEditor or TextField + * @param[in] renderer pointer to the text renderer + * @param[in] controller pointer to the text controller + * @param[in] decorator pointer to the text decorator + * @param[in] alignmentOffset Alignment offset + * @param[in,out] renderableActor Actor for rendering text + * @param[in,out] backgroundActor Actor for rendering background + * @param[in,out] stencil Clipping actor + * @param[in,out] clippingDecorationActors Clipping decoration actors + * @param[in] updateTextType How the text has been updated + */ + static void RenderText( + Actor textActor, + Text::RendererPtr renderer, + Text::ControllerPtr controller, + Text::DecoratorPtr decorator, + float alignmentOffset, + Actor& renderableActor, + Actor& backgroundActor, + Toolkit::Control& stencil, + std::vector& clippingDecorationActors, + Text::Controller::UpdateTextType updateTextType); +}; + +} // namespace Dali::Toolkit::Internal + +#endif //DALI_TOOLKIT_INTERNAL_TEXT_CONTROLS_COMMON_TEXT_UTILS_H diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp index 0bdc8c1..0259471 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -31,11 +32,12 @@ #include // INTERNAL INCLUDES -#include #include #include #include #include +#include +#include #include #include #include @@ -48,6 +50,10 @@ using namespace Dali::Toolkit::Text; +#if defined(DEBUG_ENABLED) +Debug::Filter* gTextEditorLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_CONTROLS"); +#endif + namespace Dali { namespace Toolkit @@ -56,10 +62,6 @@ namespace Internal { namespace // unnamed namespace { -#if defined(DEBUG_ENABLED) -Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_CONTROLS"); -#endif - const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::DevelText::DEFAULT_RENDERING_BACKEND; const float DEFAULT_SCROLL_SPEED = 1200.f; ///< The default scroll speed for the text editor in pixels/second. } // unnamed namespace @@ -165,22 +167,55 @@ DALI_SIGNAL_REGISTRATION(Toolkit, TextEditor, "selectionCleared", SIGNAL_SE DALI_TYPE_REGISTRATION_END() // clang-format on -const char* const IMAGE_MAP_FILENAME_STRING = "filename"; - -/// Retrieves a filename from a value that is a Property::Map -std::string GetImageFileNameFromPropertyValue(const Property::Value& value) +Toolkit::TextEditor::InputStyle::Mask ConvertInputStyle(Text::InputStyle::Mask inputStyleMask) { - std::string filename; - const Property::Map* map = value.GetMap(); - if(map) + Toolkit::TextEditor::InputStyle::Mask editorInputStyleMask = Toolkit::TextEditor::InputStyle::NONE; + + if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_COLOR)) { - const Property::Value* filenameValue = map->Find(IMAGE_MAP_FILENAME_STRING); - if(filenameValue) - { - filenameValue->Get(filename); - } + editorInputStyleMask = static_cast(editorInputStyleMask | Toolkit::TextEditor::InputStyle::COLOR); + } + if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_FONT_FAMILY)) + { + editorInputStyleMask = static_cast(editorInputStyleMask | Toolkit::TextEditor::InputStyle::FONT_FAMILY); + } + if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_POINT_SIZE)) + { + editorInputStyleMask = static_cast(editorInputStyleMask | Toolkit::TextEditor::InputStyle::POINT_SIZE); + } + if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_FONT_WEIGHT)) + { + editorInputStyleMask = static_cast(editorInputStyleMask | Toolkit::TextEditor::InputStyle::FONT_STYLE); + } + if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_FONT_WIDTH)) + { + editorInputStyleMask = static_cast(editorInputStyleMask | Toolkit::TextEditor::InputStyle::FONT_STYLE); + } + if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_FONT_SLANT)) + { + editorInputStyleMask = static_cast(editorInputStyleMask | Toolkit::TextEditor::InputStyle::FONT_STYLE); + } + if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_LINE_SPACING)) + { + editorInputStyleMask = static_cast(editorInputStyleMask | Toolkit::TextEditor::InputStyle::LINE_SPACING); + } + if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_UNDERLINE)) + { + editorInputStyleMask = static_cast(editorInputStyleMask | Toolkit::TextEditor::InputStyle::UNDERLINE); + } + if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_SHADOW)) + { + editorInputStyleMask = static_cast(editorInputStyleMask | Toolkit::TextEditor::InputStyle::SHADOW); } - return filename; + if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_EMBOSS)) + { + editorInputStyleMask = static_cast(editorInputStyleMask | Toolkit::TextEditor::InputStyle::EMBOSS); + } + if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_OUTLINE)) + { + editorInputStyleMask = static_cast(editorInputStyleMask | Toolkit::TextEditor::InputStyle::OUTLINE); + } + return editorInputStyleMask; } } // namespace @@ -195,652 +230,21 @@ Toolkit::TextEditor TextEditor::New() // Second-phase init of the implementation // This can only be done after the CustomActor connection has been made... - impl->Initialize(); - - return handle; -} - -void TextEditor::SetProperty(BaseObject* object, Property::Index index, const Property::Value& value) -{ - Toolkit::TextEditor textEditor = Toolkit::TextEditor::DownCast(Dali::BaseHandle(object)); - - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor SetProperty\n"); - - if(textEditor) - { - TextEditor& impl(GetImpl(textEditor)); - DALI_ASSERT_DEBUG(impl.mController && "No text contoller"); - DALI_ASSERT_DEBUG(impl.mDecorator && "No text decorator"); - - switch(index) - { - case Toolkit::DevelTextEditor::Property::RENDERING_BACKEND: - { - int backend = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor %p RENDERING_BACKEND %d\n", impl.mController.Get(), backend); - - if(impl.mRenderingBackend != backend) - { - impl.mRenderingBackend = backend; - impl.mRenderer.Reset(); - impl.RequestTextRelayout(); - } - break; - } - case Toolkit::TextEditor::Property::TEXT: - { - const std::string& text = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p TEXT %s\n", impl.mController.Get(), text.c_str()); - - impl.mController->SetText(text); - break; - } - case Toolkit::TextEditor::Property::TEXT_COLOR: - { - const Vector4& textColor = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a); - - if(impl.mController->GetDefaultColor() != textColor) - { - impl.mController->SetDefaultColor(textColor); - impl.mController->SetInputColor(textColor); - impl.mRenderer.Reset(); - } - break; - } - case Toolkit::TextEditor::Property::FONT_FAMILY: - { - const std::string& fontFamily = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str()); - impl.mController->SetDefaultFontFamily(fontFamily); - break; - } - case Toolkit::TextEditor::Property::FONT_STYLE: - { - SetFontStyleProperty(impl.mController, value, Text::FontStyle::DEFAULT); - break; - } - case Toolkit::TextEditor::Property::POINT_SIZE: - { - const float pointSize = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p POINT_SIZE %f\n", impl.mController.Get(), pointSize); - - if(!Equals(impl.mController->GetDefaultFontSize(Text::Controller::POINT_SIZE), pointSize)) - { - impl.mController->SetDefaultFontSize(pointSize, Text::Controller::POINT_SIZE); - } - break; - } - case Toolkit::TextEditor::Property::HORIZONTAL_ALIGNMENT: - { - Text::HorizontalAlignment::Type alignment(static_cast(-1)); // Set to invalid value to ensure a valid mode does get set - if(Text::GetHorizontalAlignmentEnumeration(value, alignment)) - { - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p HORIZONTAL_ALIGNMENT %d\n", impl.mController.Get(), alignment); - impl.mController->SetHorizontalAlignment(alignment); - } - break; - } - case Toolkit::TextEditor::Property::SCROLL_THRESHOLD: - { - const float threshold = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor %p SCROLL_THRESHOLD %f\n", impl.mController.Get(), threshold); - - impl.mDecorator->SetScrollThreshold(threshold); - break; - } - case Toolkit::TextEditor::Property::SCROLL_SPEED: - { - const float speed = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor %p SCROLL_SPEED %f\n", impl.mController.Get(), speed); - - impl.mDecorator->SetScrollSpeed(speed); - break; - } - case Toolkit::TextEditor::Property::PRIMARY_CURSOR_COLOR: - { - const Vector4& color = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p PRIMARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a); - - impl.mDecorator->SetCursorColor(PRIMARY_CURSOR, color); - impl.RequestTextRelayout(); - break; - } - case Toolkit::TextEditor::Property::SECONDARY_CURSOR_COLOR: - { - const Vector4& color = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p SECONDARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a); - - impl.mDecorator->SetCursorColor(SECONDARY_CURSOR, color); - impl.RequestTextRelayout(); - break; - } - case Toolkit::TextEditor::Property::ENABLE_CURSOR_BLINK: - { - const bool enable = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor %p ENABLE_CURSOR_BLINK %d\n", impl.mController.Get(), enable); - - impl.mController->SetEnableCursorBlink(enable); - impl.RequestTextRelayout(); - break; - } - case Toolkit::TextEditor::Property::CURSOR_BLINK_INTERVAL: - { - const float interval = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor %p CURSOR_BLINK_INTERVAL %f\n", impl.mController.Get(), interval); - - impl.mDecorator->SetCursorBlinkInterval(interval); - break; - } - case Toolkit::TextEditor::Property::CURSOR_BLINK_DURATION: - { - const float duration = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor %p CURSOR_BLINK_DURATION %f\n", impl.mController.Get(), duration); - - impl.mDecorator->SetCursorBlinkDuration(duration); - break; - } - case Toolkit::TextEditor::Property::CURSOR_WIDTH: - { - const int width = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor %p CURSOR_WIDTH %d\n", impl.mController.Get(), width); - - impl.mDecorator->SetCursorWidth(width); - impl.mController->GetLayoutEngine().SetCursorWidth(width); - break; - } - case Toolkit::TextEditor::Property::GRAB_HANDLE_IMAGE: - { - const std::string imageFileName = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor %p GRAB_HANDLE_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str()); - - if(imageFileName.size()) - { - impl.mDecorator->SetHandleImage(GRAB_HANDLE, HANDLE_IMAGE_RELEASED, imageFileName); - impl.RequestTextRelayout(); - } - break; - } - case Toolkit::TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE: - { - const std::string imageFileName = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor %p GRAB_HANDLE_PRESSED_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str()); - - if(imageFileName.size()) - { - impl.mDecorator->SetHandleImage(GRAB_HANDLE, HANDLE_IMAGE_PRESSED, imageFileName); - impl.RequestTextRelayout(); - } - break; - } - case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT: - { - const std::string filename = GetImageFileNameFromPropertyValue(value); - - if(filename.size()) - { - impl.mDecorator->SetHandleImage(LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, filename); - impl.RequestTextRelayout(); - } - break; - } - case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT: - { - const std::string filename = GetImageFileNameFromPropertyValue(value); - - if(filename.size()) - { - impl.mDecorator->SetHandleImage(RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, filename); - impl.RequestTextRelayout(); - } - break; - } - case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT: - { - const std::string filename = GetImageFileNameFromPropertyValue(value); - - if(filename.size()) - { - impl.mDecorator->SetHandleImage(LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, filename); - impl.RequestTextRelayout(); - } - break; - } - case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT: - { - const std::string filename = GetImageFileNameFromPropertyValue(value); - - if(filename.size()) - { - impl.mDecorator->SetHandleImage(RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, filename); - impl.RequestTextRelayout(); - } - break; - } - case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT: - { - const std::string filename = GetImageFileNameFromPropertyValue(value); - - if(filename.size()) - { - impl.mDecorator->SetHandleImage(LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, filename); - impl.RequestTextRelayout(); - } - break; - } - case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT: - { - const std::string filename = GetImageFileNameFromPropertyValue(value); - - if(filename.size()) - { - impl.mDecorator->SetHandleImage(RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, filename); - impl.RequestTextRelayout(); - } - break; - } - case Toolkit::TextEditor::Property::SELECTION_HIGHLIGHT_COLOR: - { - const Vector4 color = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p SELECTION_HIGHLIGHT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a); - - impl.mDecorator->SetHighlightColor(color); - impl.RequestTextRelayout(); - break; - } - case Toolkit::TextEditor::Property::DECORATION_BOUNDING_BOX: - { - const Rect& box = value.Get >(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p DECORATION_BOUNDING_BOX %d,%d %dx%d\n", impl.mController.Get(), box.x, box.y, box.width, box.height); - - impl.mDecorator->SetBoundingBox(box); - impl.RequestTextRelayout(); - break; - } - case Toolkit::TextEditor::Property::ENABLE_MARKUP: - { - const bool enableMarkup = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p ENABLE_MARKUP %d\n", impl.mController.Get(), enableMarkup); - - impl.mController->SetMarkupProcessorEnabled(enableMarkup); - break; - } - case Toolkit::TextEditor::Property::INPUT_COLOR: - { - const Vector4& inputColor = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p INPUT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), inputColor.r, inputColor.g, inputColor.b, inputColor.a); - - impl.mController->SetInputColor(inputColor); - break; - } - case Toolkit::TextEditor::Property::INPUT_FONT_FAMILY: - { - const std::string& fontFamily = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p INPUT_FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str()); - impl.mController->SetInputFontFamily(fontFamily); - break; - } - case Toolkit::TextEditor::Property::INPUT_FONT_STYLE: - { - SetFontStyleProperty(impl.mController, value, Text::FontStyle::INPUT); - break; - } - case Toolkit::TextEditor::Property::INPUT_POINT_SIZE: - { - const float pointSize = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p INPUT_POINT_SIZE %f\n", impl.mController.Get(), pointSize); - impl.mController->SetInputFontPointSize(pointSize); - break; - } - case Toolkit::TextEditor::Property::LINE_SPACING: - { - const float lineSpacing = value.Get(); - impl.mController->SetDefaultLineSpacing(lineSpacing); - impl.mRenderer.Reset(); - break; - } - case Toolkit::TextEditor::Property::INPUT_LINE_SPACING: - { - const float lineSpacing = value.Get(); - impl.mController->SetInputLineSpacing(lineSpacing); - impl.mRenderer.Reset(); - break; - } - case Toolkit::TextEditor::Property::UNDERLINE: - { - const bool update = SetUnderlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT); - if(update) - { - impl.mRenderer.Reset(); - } - break; - } - case Toolkit::TextEditor::Property::INPUT_UNDERLINE: - { - const bool update = SetUnderlineProperties(impl.mController, value, Text::EffectStyle::INPUT); - if(update) - { - impl.mRenderer.Reset(); - } - break; - } - case Toolkit::TextEditor::Property::SHADOW: - { - const bool update = SetShadowProperties(impl.mController, value, Text::EffectStyle::DEFAULT); - if(update) - { - impl.mRenderer.Reset(); - } - break; - } - case Toolkit::TextEditor::Property::INPUT_SHADOW: - { - const bool update = SetShadowProperties(impl.mController, value, Text::EffectStyle::INPUT); - if(update) - { - impl.mRenderer.Reset(); - } - break; - } - case Toolkit::TextEditor::Property::EMBOSS: - { - const bool update = SetEmbossProperties(impl.mController, value, Text::EffectStyle::DEFAULT); - if(update) - { - impl.mRenderer.Reset(); - } - break; - } - case Toolkit::TextEditor::Property::INPUT_EMBOSS: - { - const bool update = SetEmbossProperties(impl.mController, value, Text::EffectStyle::INPUT); - if(update) - { - impl.mRenderer.Reset(); - } - break; - } - case Toolkit::TextEditor::Property::OUTLINE: - { - const bool update = SetOutlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT); - if(update) - { - impl.mRenderer.Reset(); - } - break; - } - case Toolkit::TextEditor::Property::INPUT_OUTLINE: - { - const bool update = SetOutlineProperties(impl.mController, value, Text::EffectStyle::INPUT); - if(update) - { - impl.mRenderer.Reset(); - } - break; - } - case Toolkit::TextEditor::Property::SMOOTH_SCROLL: - { - const bool enable = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor SMOOTH_SCROLL %d\n", enable); - - impl.mScrollAnimationEnabled = enable; - break; - } - case Toolkit::TextEditor::Property::SMOOTH_SCROLL_DURATION: - { - const float duration = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor SMOOTH_SCROLL_DURATION %f\n", duration); - - impl.mScrollAnimationDuration = duration; - if(impl.mTextVerticalScroller) - { - impl.mTextVerticalScroller->SetDuration(duration); - } - break; - } - case Toolkit::TextEditor::Property::ENABLE_SCROLL_BAR: - { - const bool enable = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor SHOW_SCROLL_BAR %d\n", enable); - - impl.mScrollBarEnabled = enable; - break; - } - case Toolkit::TextEditor::Property::SCROLL_BAR_SHOW_DURATION: - { - const float duration = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor SCROLL_BAR_SHOW_DURATION %f\n", duration); - - impl.mAnimationPeriod.delaySeconds = duration; - break; - } - case Toolkit::TextEditor::Property::SCROLL_BAR_FADE_DURATION: - { - const float duration = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor SCROLL_BAR_FADE_DURATION %f\n", duration); - - impl.mAnimationPeriod.durationSeconds = duration; - break; - } - case Toolkit::TextEditor::Property::PIXEL_SIZE: - { - const float pixelSize = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p PIXEL_SIZE %f\n", impl.mController.Get(), pixelSize); - - if(!Equals(impl.mController->GetDefaultFontSize(Text::Controller::PIXEL_SIZE), pixelSize)) - { - impl.mController->SetDefaultFontSize(pixelSize, Text::Controller::PIXEL_SIZE); - } - break; - } - case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT: - { - const std::string& text = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor::OnPropertySet %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str()); - - impl.mController->SetPlaceholderText(Controller::PLACEHOLDER_TYPE_INACTIVE, text); - break; - } - case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR: - { - const Vector4& textColor = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p PLACEHOLDER_TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a); - - if(impl.mController->GetPlaceholderTextColor() != textColor) - { - impl.mController->SetPlaceholderTextColor(textColor); - impl.mRenderer.Reset(); - } - break; - } - case Toolkit::TextEditor::Property::ENABLE_SELECTION: - { - const bool enableSelection = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p ENABLE_SELECTION %d\n", impl.mController.Get(), enableSelection); - impl.mController->SetSelectionEnabled(enableSelection); - break; - } - case Toolkit::TextEditor::Property::PLACEHOLDER: - { - const Property::Map* map = value.GetMap(); - if(map) - { - impl.mController->SetPlaceholderProperty(*map); - } - break; - } - case Toolkit::TextEditor::Property::LINE_WRAP_MODE: - { - Text::LineWrap::Mode lineWrapMode(static_cast(-1)); // Set to invalid value to ensure a valid mode does get set - if(GetLineWrapModeEnumeration(value, lineWrapMode)) - { - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p LineWrap::MODE %d\n", impl.mController.Get(), lineWrapMode); - impl.mController->SetLineWrapMode(lineWrapMode); - } - break; - } - case Toolkit::DevelTextEditor::Property::ENABLE_SHIFT_SELECTION: - { - const bool shiftSelection = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p ENABLE_SHIFT_SELECTION %d\n", impl.mController.Get(), shiftSelection); - - impl.mController->SetShiftSelectionEnabled(shiftSelection); - break; - } - case Toolkit::DevelTextEditor::Property::ENABLE_GRAB_HANDLE: - { - const bool grabHandleEnabled = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p ENABLE_GRAB_HANDLE %d\n", impl.mController.Get(), grabHandleEnabled); - - impl.mController->SetGrabHandleEnabled(grabHandleEnabled); - break; - } - case Toolkit::DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION: - { - impl.mController->SetMatchLayoutDirection(value.Get() ? DevelText::MatchLayoutDirection::LOCALE : DevelText::MatchLayoutDirection::CONTENTS); - break; - } - case Toolkit::DevelTextEditor::Property::MAX_LENGTH: - { - const int max = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p MAX_LENGTH %d\n", impl.mController.Get(), max); - - impl.mController->SetMaximumNumberOfCharacters(max); - break; - } - case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_START: - { - uint32_t start = static_cast(value.Get()); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p SELECTED_TEXT_START %d\n", impl.mController.Get(), start); - impl.SetTextSelectionRange(&start, nullptr); - break; - } - case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_END: - { - uint32_t end = static_cast(value.Get()); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p SELECTED_TEXT_END %d\n", impl.mController.Get(), end); - impl.SetTextSelectionRange(nullptr, &end); - break; - } - case Toolkit::DevelTextEditor::Property::ENABLE_EDITING: - { - const bool editable = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p ENABLE_EDITING %d\n", impl.mController.Get(), editable); - impl.SetEditable(editable); - break; - } - case Toolkit::DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION: - { - float horizontalScroll = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p HORIZONTAL_SCROLL_POSITION %d\n", impl.mController.Get(), horizontalScroll); - if(horizontalScroll >= 0.0f) - { - impl.ScrollBy(Vector2(horizontalScroll - impl.GetHorizontalScrollPosition(), 0)); - } - break; - } - case Toolkit::DevelTextEditor::Property::VERTICAL_SCROLL_POSITION: - { - float verticalScroll = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p VERTICAL_SCROLL_POSITION %d\n", impl.mController.Get(), verticalScroll); - if(verticalScroll >= 0.0f) - { - impl.ScrollBy(Vector2(0, verticalScroll - impl.GetVerticalScrollPosition())); - } - break; - } - case Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE: - { - const float scale = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p FONT_SIZE_SCALE %f\n", impl.mController.Get(), scale); - - if(!Equals(impl.mController->GetFontSizeScale(), scale)) - { - impl.mController->SetFontSizeScale(scale); - } - break; - } - case Toolkit::DevelTextEditor::Property::PRIMARY_CURSOR_POSITION: - { - uint32_t position = static_cast(value.Get()); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p PRIMARY_CURSOR_POSITION %d\n", impl.mController.Get(), position); - if(impl.mController->SetPrimaryCursorPosition(position, impl.HasKeyInputFocus())) - { - impl.SetKeyInputFocus(); - } - break; - } - case Toolkit::DevelTextEditor::Property::GRAB_HANDLE_COLOR: - { - const Vector4 color = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p GRAB_HANDLE_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a); - - impl.mDecorator->SetHandleColor(color); - impl.RequestTextRelayout(); - break; - } - case Toolkit::DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP: - { - const bool grabHandlePopupEnabled = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p ENABLE_GRAB_HANDLE_POPUP %d\n", impl.mController.Get(), grabHandlePopupEnabled); - - impl.mController->SetGrabHandlePopupEnabled(grabHandlePopupEnabled); - break; - } - case Toolkit::DevelTextEditor::Property::INPUT_METHOD_SETTINGS: - { - const Property::Map* map = value.GetMap(); - if(map) - { - impl.mInputMethodOptions.ApplyProperty(*map); - } - impl.mController->SetInputModePassword(impl.mInputMethodOptions.IsPassword()); - - Toolkit::Control control = Toolkit::KeyInputFocusManager::Get().GetCurrentFocusControl(); - if(control == textEditor) - { - impl.mInputMethodContext.ApplyOptions(impl.mInputMethodOptions); - } - break; - } - case Toolkit::DevelTextEditor::Property::INPUT_FILTER: - { - const Property::Map* map = value.GetMap(); - if(map) - { - impl.mController->SetInputFilterOption(*map); - } - break; - } - case Toolkit::DevelTextEditor::Property::ELLIPSIS: - { - const bool ellipsis = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p ELLIPSIS %d\n", impl.mController.Get(), ellipsis); + impl->Initialize(); - impl.mController->SetTextElideEnabled(ellipsis); - break; - } - case Toolkit::DevelTextEditor::Property::ELLIPSIS_POSITION: - { - DevelText::EllipsisPosition::Type ellipsisPositionType(static_cast(-1)); // Set to invalid value to ensure a valid mode does get set - if(GetEllipsisPositionTypeEnumeration(value, ellipsisPositionType)) - { - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p EllipsisPosition::Type %d\n", impl.mController.Get(), ellipsisPositionType); - impl.mController->SetEllipsisPosition(ellipsisPositionType); - } - break; - } - case Toolkit::DevelTextEditor::Property::MIN_LINE_SIZE: - { - const float minLineSize = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor %p MIN_LINE_SIZE %f\n", impl.mController.Get(), minLineSize); + return handle; +} - impl.mController->SetDefaultLineSize(minLineSize); - impl.mRenderer.Reset(); - break; - } - } // switch - } // texteditor +void TextEditor::SetProperty(BaseObject* object, Property::Index index, const Property::Value& value) +{ + Toolkit::TextEditor textEditor = Toolkit::TextEditor::DownCast(Dali::BaseHandle(object)); + + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor SetProperty\n"); + + if(textEditor) + { + PropertyHandler::SetProperty(textEditor, index, value); + } } Property::Value TextEditor::GetProperty(BaseObject* object, Property::Index index) @@ -851,390 +255,8 @@ Property::Value TextEditor::GetProperty(BaseObject* object, Property::Index inde if(textEditor) { - TextEditor& impl(GetImpl(textEditor)); - DALI_ASSERT_DEBUG(impl.mController && "No text contoller"); - DALI_ASSERT_DEBUG(impl.mDecorator && "No text decorator"); - - switch(index) - { - case Toolkit::DevelTextEditor::Property::RENDERING_BACKEND: - { - value = impl.mRenderingBackend; - break; - } - case Toolkit::TextEditor::Property::TEXT: - { - std::string text; - impl.mController->GetText(text); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p returning text: %s\n", impl.mController.Get(), text.c_str()); - value = text; - break; - } - case Toolkit::TextEditor::Property::TEXT_COLOR: - { - value = impl.mController->GetDefaultColor(); - break; - } - case Toolkit::TextEditor::Property::FONT_FAMILY: - { - value = impl.mController->GetDefaultFontFamily(); - break; - } - case Toolkit::TextEditor::Property::FONT_STYLE: - { - GetFontStyleProperty(impl.mController, value, Text::FontStyle::DEFAULT); - break; - } - case Toolkit::TextEditor::Property::POINT_SIZE: - { - value = impl.mController->GetDefaultFontSize(Text::Controller::POINT_SIZE); - break; - } - case Toolkit::TextEditor::Property::HORIZONTAL_ALIGNMENT: - { - const char* name = GetHorizontalAlignmentString(impl.mController->GetHorizontalAlignment()); - if(name) - { - value = std::string(name); - } - break; - } - case Toolkit::TextEditor::Property::SCROLL_THRESHOLD: - { - value = impl.mDecorator->GetScrollThreshold(); - break; - } - case Toolkit::TextEditor::Property::SCROLL_SPEED: - { - value = impl.mDecorator->GetScrollSpeed(); - break; - } - case Toolkit::TextEditor::Property::PRIMARY_CURSOR_COLOR: - { - value = impl.mDecorator->GetColor(PRIMARY_CURSOR); - break; - } - case Toolkit::TextEditor::Property::SECONDARY_CURSOR_COLOR: - { - value = impl.mDecorator->GetColor(SECONDARY_CURSOR); - break; - } - case Toolkit::TextEditor::Property::ENABLE_CURSOR_BLINK: - { - value = impl.mController->GetEnableCursorBlink(); - break; - } - case Toolkit::TextEditor::Property::CURSOR_BLINK_INTERVAL: - { - value = impl.mDecorator->GetCursorBlinkInterval(); - break; - } - case Toolkit::TextEditor::Property::CURSOR_BLINK_DURATION: - { - value = impl.mDecorator->GetCursorBlinkDuration(); - break; - } - case Toolkit::TextEditor::Property::CURSOR_WIDTH: - { - value = impl.mDecorator->GetCursorWidth(); - break; - } - case Toolkit::TextEditor::Property::GRAB_HANDLE_IMAGE: - { - value = impl.mDecorator->GetHandleImage(GRAB_HANDLE, HANDLE_IMAGE_RELEASED); - break; - } - case Toolkit::TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE: - { - value = impl.mDecorator->GetHandleImage(GRAB_HANDLE, HANDLE_IMAGE_PRESSED); - break; - } - case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT: - { - impl.GetHandleImagePropertyValue(value, LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED); - break; - } - case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT: - { - impl.GetHandleImagePropertyValue(value, RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED); - break; - } - case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT: - { - impl.GetHandleImagePropertyValue(value, LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED); - break; - } - case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT: - { - impl.GetHandleImagePropertyValue(value, RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED); - break; - } - case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT: - { - impl.GetHandleImagePropertyValue(value, LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED); - break; - } - case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT: - { - impl.GetHandleImagePropertyValue(value, RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED); - break; - } - case Toolkit::TextEditor::Property::SELECTION_HIGHLIGHT_COLOR: - { - value = impl.mDecorator->GetHighlightColor(); - break; - } - case Toolkit::TextEditor::Property::DECORATION_BOUNDING_BOX: - { - Rect boundingBox; - impl.mDecorator->GetBoundingBox(boundingBox); - value = boundingBox; - break; - } - case Toolkit::TextEditor::Property::ENABLE_MARKUP: - { - value = impl.mController->IsMarkupProcessorEnabled(); - break; - } - case Toolkit::TextEditor::Property::INPUT_COLOR: - { - value = impl.mController->GetInputColor(); - break; - } - case Toolkit::TextEditor::Property::INPUT_FONT_FAMILY: - { - value = impl.mController->GetInputFontFamily(); - break; - } - case Toolkit::TextEditor::Property::INPUT_FONT_STYLE: - { - GetFontStyleProperty(impl.mController, value, Text::FontStyle::INPUT); - break; - } - case Toolkit::TextEditor::Property::INPUT_POINT_SIZE: - { - value = impl.mController->GetInputFontPointSize(); - break; - } - case Toolkit::TextEditor::Property::LINE_SPACING: - { - value = impl.mController->GetDefaultLineSpacing(); - break; - } - case Toolkit::TextEditor::Property::INPUT_LINE_SPACING: - { - value = impl.mController->GetInputLineSpacing(); - break; - } - case Toolkit::TextEditor::Property::UNDERLINE: - { - GetUnderlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT); - break; - } - case Toolkit::TextEditor::Property::INPUT_UNDERLINE: - { - GetUnderlineProperties(impl.mController, value, Text::EffectStyle::INPUT); - break; - } - case Toolkit::TextEditor::Property::SHADOW: - { - GetShadowProperties(impl.mController, value, Text::EffectStyle::DEFAULT); - break; - } - case Toolkit::TextEditor::Property::INPUT_SHADOW: - { - GetShadowProperties(impl.mController, value, Text::EffectStyle::INPUT); - break; - } - case Toolkit::TextEditor::Property::EMBOSS: - { - GetEmbossProperties(impl.mController, value, Text::EffectStyle::DEFAULT); - break; - } - case Toolkit::TextEditor::Property::INPUT_EMBOSS: - { - GetEmbossProperties(impl.mController, value, Text::EffectStyle::INPUT); - break; - } - case Toolkit::TextEditor::Property::OUTLINE: - { - GetOutlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT); - break; - } - case Toolkit::TextEditor::Property::INPUT_OUTLINE: - { - GetOutlineProperties(impl.mController, value, Text::EffectStyle::INPUT); - break; - } - case Toolkit::TextEditor::Property::SMOOTH_SCROLL: - { - value = impl.mScrollAnimationEnabled; - break; - } - case Toolkit::TextEditor::Property::SMOOTH_SCROLL_DURATION: - { - value = impl.mScrollAnimationDuration; - break; - } - case Toolkit::TextEditor::Property::ENABLE_SCROLL_BAR: - { - value = impl.mScrollBarEnabled; - break; - } - case Toolkit::TextEditor::Property::SCROLL_BAR_SHOW_DURATION: - { - value = impl.mAnimationPeriod.delaySeconds; - break; - } - case Toolkit::TextEditor::Property::SCROLL_BAR_FADE_DURATION: - { - value = impl.mAnimationPeriod.durationSeconds; - break; - } - case Toolkit::TextEditor::Property::PIXEL_SIZE: - { - value = impl.mController->GetDefaultFontSize(Text::Controller::PIXEL_SIZE); - break; - } - case Toolkit::TextEditor::Property::LINE_COUNT: - { - float width = textEditor.GetProperty(Actor::Property::SIZE_WIDTH).Get(); - value = impl.mController->GetLineCount(width); - break; - } - case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT: - { - std::string text; - impl.mController->GetPlaceholderText(Controller::PLACEHOLDER_TYPE_INACTIVE, text); - value = text; - break; - } - case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR: - { - value = impl.mController->GetPlaceholderTextColor(); - break; - } - case Toolkit::TextEditor::Property::ENABLE_SELECTION: - { - value = impl.mController->IsSelectionEnabled(); - break; - } - case Toolkit::TextEditor::Property::PLACEHOLDER: - { - Property::Map map; - impl.mController->GetPlaceholderProperty(map); - value = map; - break; - } - case Toolkit::TextEditor::Property::LINE_WRAP_MODE: - { - value = impl.mController->GetLineWrapMode(); - break; - } - case Toolkit::DevelTextEditor::Property::ENABLE_SHIFT_SELECTION: - { - value = impl.mController->IsShiftSelectionEnabled(); - break; - } - case Toolkit::DevelTextEditor::Property::ENABLE_GRAB_HANDLE: - { - value = impl.mController->IsGrabHandleEnabled(); - break; - } - case Toolkit::DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION: - { - value = impl.mController->GetMatchLayoutDirection() != DevelText::MatchLayoutDirection::CONTENTS; - break; - } - case Toolkit::DevelTextEditor::Property::MAX_LENGTH: - { - value = impl.mController->GetMaximumNumberOfCharacters(); - break; - } - case Toolkit::DevelTextEditor::Property::SELECTED_TEXT: - { - value = impl.mController->GetSelectedText(); - break; - } - case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_START: - { - Uint32Pair range = impl.GetTextSelectionRange(); - value = static_cast(range.first); - break; - } - case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_END: - { - Uint32Pair range = impl.GetTextSelectionRange(); - value = static_cast(range.second); - break; - } - case Toolkit::DevelTextEditor::Property::ENABLE_EDITING: - { - value = impl.IsEditable(); - break; - } - case Toolkit::DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION: - { - value = impl.GetHorizontalScrollPosition(); - break; - } - case Toolkit::DevelTextEditor::Property::VERTICAL_SCROLL_POSITION: - { - value = impl.GetVerticalScrollPosition(); - break; - } - case Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE: - { - value = impl.mController->GetFontSizeScale(); - break; - } - case Toolkit::DevelTextEditor::Property::PRIMARY_CURSOR_POSITION: - { - value = static_cast(impl.mController->GetPrimaryCursorPosition()); - break; - } - case Toolkit::DevelTextEditor::Property::GRAB_HANDLE_COLOR: - { - value = impl.mDecorator->GetHandleColor(); - break; - } - case Toolkit::DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP: - { - value = impl.mController->IsGrabHandlePopupEnabled(); - break; - } - case Toolkit::DevelTextEditor::Property::INPUT_METHOD_SETTINGS: - { - Property::Map map; - impl.mInputMethodOptions.RetrieveProperty(map); - value = map; - break; - } - case Toolkit::DevelTextEditor::Property::INPUT_FILTER: - { - Property::Map map; - impl.mController->GetInputFilterOption(map); - value = map; - break; - } - case Toolkit::DevelTextEditor::Property::ELLIPSIS: - { - value = impl.mController->IsTextElideEnabled(); - break; - } - case Toolkit::DevelTextEditor::Property::ELLIPSIS_POSITION: - { - value = impl.mController->GetEllipsisPosition(); - break; - } - case Toolkit::DevelTextEditor::Property::MIN_LINE_SIZE: - { - value = impl.mController->GetDefaultLineSize(); - break; - } - } //switch + value = PropertyHandler::GetProperty(textEditor, index); } - return value; } @@ -1550,13 +572,13 @@ void TextEditor::OnInitialize() void TextEditor::OnStyleChange(Toolkit::StyleManager styleManager, StyleChange::Type change) { - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor::OnStyleChange\n"); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor::OnStyleChange\n"); switch(change) { case StyleChange::DEFAULT_FONT_CHANGE: { - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor::OnStyleChange DEFAULT_FONT_CHANGE\n"); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor::OnStyleChange DEFAULT_FONT_CHANGE\n"); const std::string& newFont = GetImpl(styleManager).GetDefaultFontFamily(); // Property system did not set the font so should update it. mController->UpdateAfterFontChange(newFont); @@ -1610,7 +632,7 @@ void TextEditor::ResizeActor(Actor& actor, const Vector2& size) void TextEditor::OnRelayout(const Vector2& size, RelayoutContainer& container) { - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor OnRelayout\n"); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor OnRelayout\n"); Actor self = Self(); @@ -1649,7 +671,7 @@ void TextEditor::OnRelayout(const Vector2& size, RelayoutContainer& container) if((Text::Controller::NONE_UPDATED != updateTextType) || !mRenderer) { - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor::OnRelayout %p Displaying new contents\n", mController.Get()); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor::OnRelayout %p Displaying new contents\n", mController.Get()); if(mDecorator && (Text::Controller::NONE_UPDATED != (Text::Controller::DECORATOR_UPDATED & updateTextType))) @@ -1702,100 +724,9 @@ void TextEditor::OnRelayout(const Vector2& size, RelayoutContainer& container) void TextEditor::RenderText(Text::Controller::UpdateTextType updateTextType) { - Actor renderableActor; - - if(Text::Controller::NONE_UPDATED != (Text::Controller::MODEL_UPDATED & updateTextType)) - { - if(mRenderer) - { - Dali::Toolkit::TextEditor handle = Dali::Toolkit::TextEditor(GetOwner()); - - renderableActor = mRenderer->Render(mController->GetView(), - handle, - Property::INVALID_INDEX, // Animatable property not supported - mAlignmentOffset, - DepthIndex::CONTENT); - } - - if(renderableActor != mRenderableActor) - { - UnparentAndReset(mBackgroundActor); - UnparentAndReset(mRenderableActor); - mRenderableActor = renderableActor; - - if(mRenderableActor) - { - mBackgroundActor = mController->CreateBackgroundActor(); - } - } - } - + CommonTextUtils::RenderText(Self(), mRenderer, mController, mDecorator, mAlignmentOffset, mRenderableActor, mBackgroundActor, mStencil, mClippingDecorationActors, updateTextType); if(mRenderableActor) { - const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition(); - - float renderableActorPositionX, renderableActorPositionY; - - if(mStencil) - { - renderableActorPositionX = scrollOffset.x + mAlignmentOffset; - renderableActorPositionY = scrollOffset.y; - } - else - { - Extents padding; - padding = Self().GetProperty(Toolkit::Control::Property::PADDING); - - // Support Right-To-Left of padding - Dali::LayoutDirection::Type layoutDirection = static_cast(Self().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get()); - if(Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection) - { - std::swap(padding.start, padding.end); - } - - renderableActorPositionX = scrollOffset.x + mAlignmentOffset + padding.start; - renderableActorPositionY = scrollOffset.y + padding.top; - } - - mRenderableActor.SetProperty(Actor::Property::POSITION, Vector2(renderableActorPositionX, renderableActorPositionY)); - // Make sure the actors are parented correctly with/without clipping - Actor self = mStencil ? mStencil : Self(); - - Actor highlightActor; - - for(std::vector::iterator it = mClippingDecorationActors.begin(), - endIt = mClippingDecorationActors.end(); - it != endIt; - ++it) - { - self.Add(*it); - it->LowerToBottom(); - - if(it->GetProperty(Dali::Actor::Property::NAME) == "HighlightActor") - { - highlightActor = *it; - } - } - mClippingDecorationActors.clear(); - - self.Add(mRenderableActor); - - if(mBackgroundActor) - { - if(mDecorator && mDecorator->IsHighlightVisible()) - { - self.Add(mBackgroundActor); - mBackgroundActor.SetProperty(Actor::Property::POSITION, Vector2(renderableActorPositionX, renderableActorPositionY)); // In text field's coords. - mBackgroundActor.LowerBelow(highlightActor); - } - else - { - mRenderableActor.Add(mBackgroundActor); - mBackgroundActor.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f)); // In renderable actor's coords. - mBackgroundActor.LowerToBottom(); - } - } - ApplyScrollPosition(); } UpdateScrollBar(); @@ -1803,7 +734,7 @@ void TextEditor::RenderText(Text::Controller::UpdateTextType updateTextType) void TextEditor::OnKeyInputFocusGained() { - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor::OnKeyInputFocusGained %p\n", mController.Get()); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor::OnKeyInputFocusGained %p\n", mController.Get()); if(mInputMethodContext && IsEditable()) { // All input panel properties, such as layout, return key type, and input hint, should be set before input panel activates (or shows). @@ -1834,7 +765,7 @@ void TextEditor::OnKeyInputFocusGained() void TextEditor::OnKeyInputFocusLost() { - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor:OnKeyInputFocusLost %p\n", mController.Get()); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor:OnKeyInputFocusLost %p\n", mController.Get()); if(mInputMethodContext) { mInputMethodContext.StatusChangedSignal().Disconnect(this, &TextEditor::KeyboardStatusChanged); @@ -1867,7 +798,7 @@ bool TextEditor::OnAccessibilityActivated() void TextEditor::OnTap(const TapGesture& gesture) { - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor::OnTap %p\n", mController.Get()); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor::OnTap %p\n", mController.Get()); if(mInputMethodContext && IsEditable()) { mInputMethodContext.Activate(); @@ -1903,7 +834,7 @@ void TextEditor::OnLongPress(const LongPressGesture& gesture) bool TextEditor::OnKeyEvent(const KeyEvent& event) { - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor::OnKeyEvent %p keyCode %d\n", mController.Get(), event.GetKeyCode()); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor::OnKeyEvent %p keyCode %d\n", mController.Get(), event.GetKeyCode()); if(Dali::DALI_KEY_ESCAPE == event.GetKeyCode() && mController->ShouldClearFocusOnEscape()) { @@ -1982,55 +913,7 @@ void TextEditor::MaxLengthReached() void TextEditor::InputStyleChanged(Text::InputStyle::Mask inputStyleMask) { Dali::Toolkit::TextEditor handle(GetOwner()); - - Toolkit::TextEditor::InputStyle::Mask editorInputStyleMask = Toolkit::TextEditor::InputStyle::NONE; - - if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_COLOR)) - { - editorInputStyleMask = static_cast(editorInputStyleMask | Toolkit::TextEditor::InputStyle::COLOR); - } - if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_FONT_FAMILY)) - { - editorInputStyleMask = static_cast(editorInputStyleMask | Toolkit::TextEditor::InputStyle::FONT_FAMILY); - } - if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_POINT_SIZE)) - { - editorInputStyleMask = static_cast(editorInputStyleMask | Toolkit::TextEditor::InputStyle::POINT_SIZE); - } - if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_FONT_WEIGHT)) - { - editorInputStyleMask = static_cast(editorInputStyleMask | Toolkit::TextEditor::InputStyle::FONT_STYLE); - } - if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_FONT_WIDTH)) - { - editorInputStyleMask = static_cast(editorInputStyleMask | Toolkit::TextEditor::InputStyle::FONT_STYLE); - } - if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_FONT_SLANT)) - { - editorInputStyleMask = static_cast(editorInputStyleMask | Toolkit::TextEditor::InputStyle::FONT_STYLE); - } - if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_LINE_SPACING)) - { - editorInputStyleMask = static_cast(editorInputStyleMask | Toolkit::TextEditor::InputStyle::LINE_SPACING); - } - if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_UNDERLINE)) - { - editorInputStyleMask = static_cast(editorInputStyleMask | Toolkit::TextEditor::InputStyle::UNDERLINE); - } - if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_SHADOW)) - { - editorInputStyleMask = static_cast(editorInputStyleMask | Toolkit::TextEditor::InputStyle::SHADOW); - } - if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_EMBOSS)) - { - editorInputStyleMask = static_cast(editorInputStyleMask | Toolkit::TextEditor::InputStyle::EMBOSS); - } - if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_OUTLINE)) - { - editorInputStyleMask = static_cast(editorInputStyleMask | Toolkit::TextEditor::InputStyle::OUTLINE); - } - - mInputStyleChangedSignal.Emit(handle, editorInputStyleMask); + mInputStyleChangedSignal.Emit(handle, ConvertInputStyle(inputStyleMask)); } void TextEditor::AnchorClicked(const std::string& href) @@ -2248,7 +1131,7 @@ void TextEditor::OnSceneConnect(Dali::Actor actor) InputMethodContext::CallbackData TextEditor::OnInputMethodContextEvent(Dali::InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent) { - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor::OnInputMethodContextEvent %p eventName %d\n", mController.Get(), inputMethodContextEvent.eventName); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor::OnInputMethodContextEvent %p eventName %d\n", mController.Get(), inputMethodContextEvent.eventName); return mController->OnInputMethodContextEvent(inputMethodContext, inputMethodContextEvent); } @@ -2257,8 +1140,9 @@ void TextEditor::GetHandleImagePropertyValue(Property::Value& value, Text::Handl if(mDecorator) { Property::Map map; - map[IMAGE_MAP_FILENAME_STRING] = mDecorator->GetHandleImage(handleType, handleImageType); - value = map; + map[TextEditor::PropertyHandler::IMAGE_MAP_FILENAME_STRING] = mDecorator->GetHandleImage(handleType, handleImageType); + + value = map; } } @@ -2269,7 +1153,7 @@ void TextEditor::OnClipboardTextSelected(ClipboardEventNotifier& clipboard) void TextEditor::KeyboardStatusChanged(bool keyboardShown) { - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor::KeyboardStatusChanged %p keyboardShown %d\n", mController.Get(), keyboardShown); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor::KeyboardStatusChanged %p keyboardShown %d\n", mController.Get(), keyboardShown); // Just hide the grab handle when keyboard is hidden. if(!keyboardShown) diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.h b/dali-toolkit/internal/controls/text-controls/text-editor-impl.h index bc28781..8c5d7be 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.h @@ -522,6 +522,8 @@ private: // Data uint32_t mOldSelectionStart; uint32_t mOldSelectionEnd; + struct PropertyHandler; + /** * @brief This structure is to connect TextEditor with Accessible functions. */ diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-property-handler.cpp b/dali-toolkit/internal/controls/text-controls/text-editor-property-handler.cpp new file mode 100644 index 0000000..62dfbda --- /dev/null +++ b/dali-toolkit/internal/controls/text-controls/text-editor-property-handler.cpp @@ -0,0 +1,1081 @@ +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#if defined(DEBUG_ENABLED) +extern Debug::Filter* gTextEditorLogFilter; +#endif + +namespace Dali::Toolkit::Internal +{ +const char* const TextEditor::PropertyHandler::IMAGE_MAP_FILENAME_STRING{"filename"}; + +/// Retrieves a filename from a value that is a Property::Map +std::string TextEditor::PropertyHandler::GetImageFileNameFromPropertyValue(const Property::Value& value) +{ + std::string filename; + const Property::Map* map = value.GetMap(); + if(map) + { + const Property::Value* filenameValue = map->Find(TextEditor::PropertyHandler::IMAGE_MAP_FILENAME_STRING); + if(filenameValue) + { + filenameValue->Get(filename); + } + } + return filename; +} + +void TextEditor::PropertyHandler::SetProperty(Toolkit::TextEditor textEditor, Property::Index index, const Property::Value& value) +{ + TextEditor& impl(GetImpl(textEditor)); + DALI_ASSERT_DEBUG(impl.mController && "No text controller"); + DALI_ASSERT_DEBUG(impl.mDecorator && "No text decorator"); + + switch(index) + { + case Toolkit::DevelTextEditor::Property::RENDERING_BACKEND: + { + int backend = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p RENDERING_BACKEND %d\n", impl.mController.Get(), backend); + + if(impl.mRenderingBackend != backend) + { + impl.mRenderingBackend = backend; + impl.mRenderer.Reset(); + impl.RequestTextRelayout(); + } + break; + } + case Toolkit::TextEditor::Property::TEXT: + { + const std::string& text = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p TEXT %s\n", impl.mController.Get(), text.c_str()); + + impl.mController->SetText(text); + break; + } + case Toolkit::TextEditor::Property::TEXT_COLOR: + { + const Vector4& textColor = value.Get(); + 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); + + if(impl.mController->GetDefaultColor() != textColor) + { + impl.mController->SetDefaultColor(textColor); + impl.mController->SetInputColor(textColor); + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::FONT_FAMILY: + { + const std::string& fontFamily = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str()); + impl.mController->SetDefaultFontFamily(fontFamily); + break; + } + case Toolkit::TextEditor::Property::FONT_STYLE: + { + SetFontStyleProperty(impl.mController, value, Text::FontStyle::DEFAULT); + break; + } + case Toolkit::TextEditor::Property::POINT_SIZE: + { + const float pointSize = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p POINT_SIZE %f\n", impl.mController.Get(), pointSize); + + if(!Equals(impl.mController->GetDefaultFontSize(Text::Controller::POINT_SIZE), pointSize)) + { + impl.mController->SetDefaultFontSize(pointSize, Text::Controller::POINT_SIZE); + } + break; + } + case Toolkit::TextEditor::Property::HORIZONTAL_ALIGNMENT: + { + Text::HorizontalAlignment::Type alignment(static_cast(-1)); // Set to invalid value to ensure a valid mode does get set + if(Text::GetHorizontalAlignmentEnumeration(value, alignment)) + { + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p HORIZONTAL_ALIGNMENT %d\n", impl.mController.Get(), alignment); + impl.mController->SetHorizontalAlignment(alignment); + } + break; + } + case Toolkit::TextEditor::Property::SCROLL_THRESHOLD: + { + const float threshold = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p SCROLL_THRESHOLD %f\n", impl.mController.Get(), threshold); + + impl.mDecorator->SetScrollThreshold(threshold); + break; + } + case Toolkit::TextEditor::Property::SCROLL_SPEED: + { + const float speed = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p SCROLL_SPEED %f\n", impl.mController.Get(), speed); + + impl.mDecorator->SetScrollSpeed(speed); + break; + } + case Toolkit::TextEditor::Property::PRIMARY_CURSOR_COLOR: + { + const Vector4& color = value.Get(); + 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); + + impl.mDecorator->SetCursorColor(Toolkit::Text::PRIMARY_CURSOR, color); + impl.RequestTextRelayout(); + break; + } + case Toolkit::TextEditor::Property::SECONDARY_CURSOR_COLOR: + { + const Vector4& color = value.Get(); + 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); + + impl.mDecorator->SetCursorColor(Toolkit::Text::SECONDARY_CURSOR, color); + impl.RequestTextRelayout(); + break; + } + case Toolkit::TextEditor::Property::ENABLE_CURSOR_BLINK: + { + const bool enable = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p ENABLE_CURSOR_BLINK %d\n", impl.mController.Get(), enable); + + impl.mController->SetEnableCursorBlink(enable); + impl.RequestTextRelayout(); + break; + } + case Toolkit::TextEditor::Property::CURSOR_BLINK_INTERVAL: + { + const float interval = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p CURSOR_BLINK_INTERVAL %f\n", impl.mController.Get(), interval); + + impl.mDecorator->SetCursorBlinkInterval(interval); + break; + } + case Toolkit::TextEditor::Property::CURSOR_BLINK_DURATION: + { + const float duration = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p CURSOR_BLINK_DURATION %f\n", impl.mController.Get(), duration); + + impl.mDecorator->SetCursorBlinkDuration(duration); + break; + } + case Toolkit::TextEditor::Property::CURSOR_WIDTH: + { + const int width = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p CURSOR_WIDTH %d\n", impl.mController.Get(), width); + + impl.mDecorator->SetCursorWidth(width); + impl.mController->GetLayoutEngine().SetCursorWidth(width); + break; + } + case Toolkit::TextEditor::Property::GRAB_HANDLE_IMAGE: + { + const std::string imageFileName = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p GRAB_HANDLE_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str()); + + if(imageFileName.size()) + { + impl.mDecorator->SetHandleImage(Toolkit::Text::GRAB_HANDLE, Toolkit::Text::HANDLE_IMAGE_RELEASED, imageFileName); + impl.RequestTextRelayout(); + } + break; + } + case Toolkit::TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE: + { + const std::string imageFileName = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p GRAB_HANDLE_PRESSED_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str()); + + if(imageFileName.size()) + { + impl.mDecorator->SetHandleImage(Toolkit::Text::GRAB_HANDLE, Toolkit::Text::HANDLE_IMAGE_PRESSED, imageFileName); + impl.RequestTextRelayout(); + } + break; + } + case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT: + { + const std::string filename = GetImageFileNameFromPropertyValue(value); + + if(filename.size()) + { + impl.mDecorator->SetHandleImage(Toolkit::Text::LEFT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_RELEASED, filename); + impl.RequestTextRelayout(); + } + break; + } + case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT: + { + const std::string filename = GetImageFileNameFromPropertyValue(value); + + if(filename.size()) + { + impl.mDecorator->SetHandleImage(Toolkit::Text::RIGHT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_RELEASED, filename); + impl.RequestTextRelayout(); + } + break; + } + case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT: + { + const std::string filename = GetImageFileNameFromPropertyValue(value); + + if(filename.size()) + { + impl.mDecorator->SetHandleImage(Toolkit::Text::LEFT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_PRESSED, filename); + impl.RequestTextRelayout(); + } + break; + } + case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT: + { + const std::string filename = GetImageFileNameFromPropertyValue(value); + + if(filename.size()) + { + impl.mDecorator->SetHandleImage(Toolkit::Text::RIGHT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_PRESSED, filename); + impl.RequestTextRelayout(); + } + break; + } + case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT: + { + const std::string filename = GetImageFileNameFromPropertyValue(value); + + if(filename.size()) + { + impl.mDecorator->SetHandleImage(Toolkit::Text::LEFT_SELECTION_HANDLE_MARKER, + Toolkit::Text::HANDLE_IMAGE_RELEASED, + filename); + impl.RequestTextRelayout(); + } + break; + } + case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT: + { + const std::string filename = GetImageFileNameFromPropertyValue(value); + + if(filename.size()) + { + impl.mDecorator->SetHandleImage(Toolkit::Text::RIGHT_SELECTION_HANDLE_MARKER, + Toolkit::Text::HANDLE_IMAGE_RELEASED, + filename); + impl.RequestTextRelayout(); + } + break; + } + case Toolkit::TextEditor::Property::SELECTION_HIGHLIGHT_COLOR: + { + const Vector4 color = value.Get(); + 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); + + impl.mDecorator->SetHighlightColor(color); + impl.RequestTextRelayout(); + break; + } + case Toolkit::TextEditor::Property::DECORATION_BOUNDING_BOX: + { + const Rect& box = value.Get >(); + 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); + + impl.mDecorator->SetBoundingBox(box); + impl.RequestTextRelayout(); + break; + } + case Toolkit::TextEditor::Property::ENABLE_MARKUP: + { + const bool enableMarkup = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p ENABLE_MARKUP %d\n", impl.mController.Get(), enableMarkup); + + impl.mController->SetMarkupProcessorEnabled(enableMarkup); + break; + } + case Toolkit::TextEditor::Property::INPUT_COLOR: + { + const Vector4& inputColor = value.Get(); + 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); + + impl.mController->SetInputColor(inputColor); + break; + } + case Toolkit::TextEditor::Property::INPUT_FONT_FAMILY: + { + const std::string& fontFamily = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p INPUT_FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str()); + impl.mController->SetInputFontFamily(fontFamily); + break; + } + case Toolkit::TextEditor::Property::INPUT_FONT_STYLE: + { + SetFontStyleProperty(impl.mController, value, Text::FontStyle::INPUT); + break; + } + case Toolkit::TextEditor::Property::INPUT_POINT_SIZE: + { + const float pointSize = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p INPUT_POINT_SIZE %f\n", impl.mController.Get(), pointSize); + impl.mController->SetInputFontPointSize(pointSize); + break; + } + case Toolkit::TextEditor::Property::LINE_SPACING: + { + const float lineSpacing = value.Get(); + impl.mController->SetDefaultLineSpacing(lineSpacing); + impl.mRenderer.Reset(); + break; + } + case Toolkit::TextEditor::Property::INPUT_LINE_SPACING: + { + const float lineSpacing = value.Get(); + impl.mController->SetInputLineSpacing(lineSpacing); + impl.mRenderer.Reset(); + break; + } + case Toolkit::TextEditor::Property::UNDERLINE: + { + const bool update = SetUnderlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT); + if(update) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::INPUT_UNDERLINE: + { + const bool update = SetUnderlineProperties(impl.mController, value, Text::EffectStyle::INPUT); + if(update) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::SHADOW: + { + const bool update = SetShadowProperties(impl.mController, value, Text::EffectStyle::DEFAULT); + if(update) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::INPUT_SHADOW: + { + const bool update = SetShadowProperties(impl.mController, value, Text::EffectStyle::INPUT); + if(update) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::EMBOSS: + { + const bool update = SetEmbossProperties(impl.mController, value, Text::EffectStyle::DEFAULT); + if(update) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::INPUT_EMBOSS: + { + const bool update = SetEmbossProperties(impl.mController, value, Text::EffectStyle::INPUT); + if(update) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::OUTLINE: + { + const bool update = SetOutlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT); + if(update) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::INPUT_OUTLINE: + { + const bool update = SetOutlineProperties(impl.mController, value, Text::EffectStyle::INPUT); + if(update) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::SMOOTH_SCROLL: + { + const bool enable = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor SMOOTH_SCROLL %d\n", enable); + + impl.mScrollAnimationEnabled = enable; + break; + } + case Toolkit::TextEditor::Property::SMOOTH_SCROLL_DURATION: + { + const float duration = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor SMOOTH_SCROLL_DURATION %f\n", duration); + + impl.mScrollAnimationDuration = duration; + if(impl.mTextVerticalScroller) + { + impl.mTextVerticalScroller->SetDuration(duration); + } + break; + } + case Toolkit::TextEditor::Property::ENABLE_SCROLL_BAR: + { + const bool enable = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor SHOW_SCROLL_BAR %d\n", enable); + + impl.mScrollBarEnabled = enable; + break; + } + case Toolkit::TextEditor::Property::SCROLL_BAR_SHOW_DURATION: + { + const float duration = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor SCROLL_BAR_SHOW_DURATION %f\n", duration); + + impl.mAnimationPeriod.delaySeconds = duration; + break; + } + case Toolkit::TextEditor::Property::SCROLL_BAR_FADE_DURATION: + { + const float duration = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor SCROLL_BAR_FADE_DURATION %f\n", duration); + + impl.mAnimationPeriod.durationSeconds = duration; + break; + } + case Toolkit::TextEditor::Property::PIXEL_SIZE: + { + const float pixelSize = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p PIXEL_SIZE %f\n", impl.mController.Get(), pixelSize); + + if(!Equals(impl.mController->GetDefaultFontSize(Text::Controller::PIXEL_SIZE), pixelSize)) + { + impl.mController->SetDefaultFontSize(pixelSize, Text::Controller::PIXEL_SIZE); + } + break; + } + case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT: + { + const std::string& text = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor::OnPropertySet %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str()); + + impl.mController->SetPlaceholderText(Text::Controller::PLACEHOLDER_TYPE_INACTIVE, text); + break; + } + case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR: + { + const Vector4& textColor = value.Get(); + 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); + + if(impl.mController->GetPlaceholderTextColor() != textColor) + { + impl.mController->SetPlaceholderTextColor(textColor); + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::ENABLE_SELECTION: + { + const bool enableSelection = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p ENABLE_SELECTION %d\n", impl.mController.Get(), enableSelection); + impl.mController->SetSelectionEnabled(enableSelection); + break; + } + case Toolkit::TextEditor::Property::PLACEHOLDER: + { + const Property::Map* map = value.GetMap(); + if(map) + { + impl.mController->SetPlaceholderProperty(*map); + } + break; + } + case Toolkit::TextEditor::Property::LINE_WRAP_MODE: + { + Text::LineWrap::Mode lineWrapMode(static_cast(-1)); // Set to invalid value to ensure a valid mode does get set + if(Toolkit::Text::GetLineWrapModeEnumeration(value, lineWrapMode)) + { + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p LineWrap::MODE %d\n", impl.mController.Get(), lineWrapMode); + impl.mController->SetLineWrapMode(lineWrapMode); + } + break; + } + case Toolkit::DevelTextEditor::Property::ENABLE_SHIFT_SELECTION: + { + const bool shiftSelection = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p ENABLE_SHIFT_SELECTION %d\n", impl.mController.Get(), shiftSelection); + + impl.mController->SetShiftSelectionEnabled(shiftSelection); + break; + } + case Toolkit::DevelTextEditor::Property::ENABLE_GRAB_HANDLE: + { + const bool grabHandleEnabled = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p ENABLE_GRAB_HANDLE %d\n", impl.mController.Get(), grabHandleEnabled); + + impl.mController->SetGrabHandleEnabled(grabHandleEnabled); + break; + } + case Toolkit::DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION: + { + impl.mController->SetMatchLayoutDirection(value.Get() ? DevelText::MatchLayoutDirection::LOCALE : DevelText::MatchLayoutDirection::CONTENTS); + break; + } + case Toolkit::DevelTextEditor::Property::MAX_LENGTH: + { + const int max = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p MAX_LENGTH %d\n", impl.mController.Get(), max); + + impl.mController->SetMaximumNumberOfCharacters(max); + break; + } + case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_START: + { + uint32_t start = static_cast(value.Get()); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p SELECTED_TEXT_START %d\n", impl.mController.Get(), start); + impl.SetTextSelectionRange(&start, nullptr); + break; + } + case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_END: + { + uint32_t end = static_cast(value.Get()); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p SELECTED_TEXT_END %d\n", impl.mController.Get(), end); + impl.SetTextSelectionRange(nullptr, &end); + break; + } + case Toolkit::DevelTextEditor::Property::ENABLE_EDITING: + { + const bool editable = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p ENABLE_EDITING %d\n", impl.mController.Get(), editable); + impl.SetEditable(editable); + break; + } + case Toolkit::DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION: + { + float horizontalScroll = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p HORIZONTAL_SCROLL_POSITION %d\n", impl.mController.Get(), horizontalScroll); + if(horizontalScroll >= 0.0f) + { + impl.ScrollBy(Vector2(horizontalScroll - impl.GetHorizontalScrollPosition(), 0)); + } + break; + } + case Toolkit::DevelTextEditor::Property::VERTICAL_SCROLL_POSITION: + { + float verticalScroll = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p VERTICAL_SCROLL_POSITION %d\n", impl.mController.Get(), verticalScroll); + if(verticalScroll >= 0.0f) + { + impl.ScrollBy(Vector2(0, verticalScroll - impl.GetVerticalScrollPosition())); + } + break; + } + case Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE: + { + const float scale = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p FONT_SIZE_SCALE %f\n", impl.mController.Get(), scale); + + if(!Equals(impl.mController->GetFontSizeScale(), scale)) + { + impl.mController->SetFontSizeScale(scale); + } + break; + } + case Toolkit::DevelTextEditor::Property::PRIMARY_CURSOR_POSITION: + { + uint32_t position = static_cast(value.Get()); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p PRIMARY_CURSOR_POSITION %d\n", impl.mController.Get(), position); + if(impl.mController->SetPrimaryCursorPosition(position, impl.HasKeyInputFocus())) + { + impl.SetKeyInputFocus(); + } + break; + } + case Toolkit::DevelTextEditor::Property::GRAB_HANDLE_COLOR: + { + const Vector4 color = value.Get(); + 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); + + impl.mDecorator->SetHandleColor(color); + impl.RequestTextRelayout(); + break; + } + case Toolkit::DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP: + { + const bool grabHandlePopupEnabled = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p ENABLE_GRAB_HANDLE_POPUP %d\n", impl.mController.Get(), grabHandlePopupEnabled); + + impl.mController->SetGrabHandlePopupEnabled(grabHandlePopupEnabled); + break; + } + case Toolkit::DevelTextEditor::Property::INPUT_METHOD_SETTINGS: + { + const Property::Map* map = value.GetMap(); + if(map) + { + impl.mInputMethodOptions.ApplyProperty(*map); + } + impl.mController->SetInputModePassword(impl.mInputMethodOptions.IsPassword()); + + Toolkit::Control control = Toolkit::KeyInputFocusManager::Get().GetCurrentFocusControl(); + if(control == textEditor) + { + impl.mInputMethodContext.ApplyOptions(impl.mInputMethodOptions); + } + break; + } + case Toolkit::DevelTextEditor::Property::INPUT_FILTER: + { + const Property::Map* map = value.GetMap(); + if(map) + { + impl.mController->SetInputFilterOption(*map); + } + break; + } + case Toolkit::DevelTextEditor::Property::ELLIPSIS: + { + const bool ellipsis = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p ELLIPSIS %d\n", impl.mController.Get(), ellipsis); + + impl.mController->SetTextElideEnabled(ellipsis); + break; + } + case Toolkit::DevelTextEditor::Property::ELLIPSIS_POSITION: + { + DevelText::EllipsisPosition::Type ellipsisPositionType(static_cast(-1)); // Set to invalid value to ensure a valid mode does get set + if(Text::GetEllipsisPositionTypeEnumeration(value, ellipsisPositionType)) + { + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p EllipsisPosition::Type %d\n", impl.mController.Get(), ellipsisPositionType); + impl.mController->SetEllipsisPosition(ellipsisPositionType); + } + break; + } + case Toolkit::DevelTextEditor::Property::MIN_LINE_SIZE: + { + const float minLineSize = value.Get(); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor %p MIN_LINE_SIZE %f\n", impl.mController.Get(), minLineSize); + + impl.mController->SetDefaultLineSize(minLineSize); + impl.mRenderer.Reset(); + break; + } + } +} + +Property::Value TextEditor::PropertyHandler::GetProperty(Toolkit::TextEditor textEditor, Property::Index index) +{ + Property::Value value; + TextEditor& impl(GetImpl(textEditor)); + DALI_ASSERT_DEBUG(impl.mController && "No text controller"); + DALI_ASSERT_DEBUG(impl.mDecorator && "No text decorator"); + + switch(index) + { + case Toolkit::DevelTextEditor::Property::RENDERING_BACKEND: + { + value = impl.mRenderingBackend; + break; + } + case Toolkit::TextEditor::Property::TEXT: + { + std::string text; + impl.mController->GetText(text); + DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p returning text: %s\n", impl.mController.Get(), text.c_str()); + value = text; + break; + } + case Toolkit::TextEditor::Property::TEXT_COLOR: + { + value = impl.mController->GetDefaultColor(); + break; + } + case Toolkit::TextEditor::Property::FONT_FAMILY: + { + value = impl.mController->GetDefaultFontFamily(); + break; + } + case Toolkit::TextEditor::Property::FONT_STYLE: + { + GetFontStyleProperty(impl.mController, value, Text::FontStyle::DEFAULT); + break; + } + case Toolkit::TextEditor::Property::POINT_SIZE: + { + value = impl.mController->GetDefaultFontSize(Text::Controller::POINT_SIZE); + break; + } + case Toolkit::TextEditor::Property::HORIZONTAL_ALIGNMENT: + { + const char* name = Text::GetHorizontalAlignmentString(impl.mController->GetHorizontalAlignment()); + if(name) + { + value = std::string(name); + } + break; + } + case Toolkit::TextEditor::Property::SCROLL_THRESHOLD: + { + value = impl.mDecorator->GetScrollThreshold(); + break; + } + case Toolkit::TextEditor::Property::SCROLL_SPEED: + { + value = impl.mDecorator->GetScrollSpeed(); + break; + } + case Toolkit::TextEditor::Property::PRIMARY_CURSOR_COLOR: + { + value = impl.mDecorator->GetColor(Text::PRIMARY_CURSOR); + break; + } + case Toolkit::TextEditor::Property::SECONDARY_CURSOR_COLOR: + { + value = impl.mDecorator->GetColor(Text::SECONDARY_CURSOR); + break; + } + case Toolkit::TextEditor::Property::ENABLE_CURSOR_BLINK: + { + value = impl.mController->GetEnableCursorBlink(); + break; + } + case Toolkit::TextEditor::Property::CURSOR_BLINK_INTERVAL: + { + value = impl.mDecorator->GetCursorBlinkInterval(); + break; + } + case Toolkit::TextEditor::Property::CURSOR_BLINK_DURATION: + { + value = impl.mDecorator->GetCursorBlinkDuration(); + break; + } + case Toolkit::TextEditor::Property::CURSOR_WIDTH: + { + value = impl.mDecorator->GetCursorWidth(); + break; + } + case Toolkit::TextEditor::Property::GRAB_HANDLE_IMAGE: + { + value = impl.mDecorator->GetHandleImage(Text::GRAB_HANDLE, Text::HANDLE_IMAGE_RELEASED); + break; + } + case Toolkit::TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE: + { + value = impl.mDecorator->GetHandleImage(Text::GRAB_HANDLE, Text::HANDLE_IMAGE_PRESSED); + break; + } + case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT: + { + impl.GetHandleImagePropertyValue(value, Text::LEFT_SELECTION_HANDLE, Text::HANDLE_IMAGE_RELEASED); + break; + } + case Toolkit::TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT: + { + impl.GetHandleImagePropertyValue(value, Text::RIGHT_SELECTION_HANDLE, Text::HANDLE_IMAGE_RELEASED); + break; + } + case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT: + { + impl.GetHandleImagePropertyValue(value, Text::LEFT_SELECTION_HANDLE, Text::HANDLE_IMAGE_PRESSED); + break; + } + case Toolkit::TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT: + { + impl.GetHandleImagePropertyValue(value, Text::RIGHT_SELECTION_HANDLE, Text::HANDLE_IMAGE_PRESSED); + break; + } + case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT: + { + impl.GetHandleImagePropertyValue(value, Text::LEFT_SELECTION_HANDLE_MARKER, Text::HANDLE_IMAGE_RELEASED); + break; + } + case Toolkit::TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT: + { + impl.GetHandleImagePropertyValue(value, Text::RIGHT_SELECTION_HANDLE_MARKER, Text::HANDLE_IMAGE_RELEASED); + break; + } + case Toolkit::TextEditor::Property::SELECTION_HIGHLIGHT_COLOR: + { + value = impl.mDecorator->GetHighlightColor(); + break; + } + case Toolkit::TextEditor::Property::DECORATION_BOUNDING_BOX: + { + Rect boundingBox; + impl.mDecorator->GetBoundingBox(boundingBox); + value = boundingBox; + break; + } + case Toolkit::TextEditor::Property::ENABLE_MARKUP: + { + value = impl.mController->IsMarkupProcessorEnabled(); + break; + } + case Toolkit::TextEditor::Property::INPUT_COLOR: + { + value = impl.mController->GetInputColor(); + break; + } + case Toolkit::TextEditor::Property::INPUT_FONT_FAMILY: + { + value = impl.mController->GetInputFontFamily(); + break; + } + case Toolkit::TextEditor::Property::INPUT_FONT_STYLE: + { + GetFontStyleProperty(impl.mController, value, Text::FontStyle::INPUT); + break; + } + case Toolkit::TextEditor::Property::INPUT_POINT_SIZE: + { + value = impl.mController->GetInputFontPointSize(); + break; + } + case Toolkit::TextEditor::Property::LINE_SPACING: + { + value = impl.mController->GetDefaultLineSpacing(); + break; + } + case Toolkit::TextEditor::Property::INPUT_LINE_SPACING: + { + value = impl.mController->GetInputLineSpacing(); + break; + } + case Toolkit::TextEditor::Property::UNDERLINE: + { + GetUnderlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT); + break; + } + case Toolkit::TextEditor::Property::INPUT_UNDERLINE: + { + GetUnderlineProperties(impl.mController, value, Text::EffectStyle::INPUT); + break; + } + case Toolkit::TextEditor::Property::SHADOW: + { + GetShadowProperties(impl.mController, value, Text::EffectStyle::DEFAULT); + break; + } + case Toolkit::TextEditor::Property::INPUT_SHADOW: + { + GetShadowProperties(impl.mController, value, Text::EffectStyle::INPUT); + break; + } + case Toolkit::TextEditor::Property::EMBOSS: + { + GetEmbossProperties(impl.mController, value, Text::EffectStyle::DEFAULT); + break; + } + case Toolkit::TextEditor::Property::INPUT_EMBOSS: + { + GetEmbossProperties(impl.mController, value, Text::EffectStyle::INPUT); + break; + } + case Toolkit::TextEditor::Property::OUTLINE: + { + GetOutlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT); + break; + } + case Toolkit::TextEditor::Property::INPUT_OUTLINE: + { + GetOutlineProperties(impl.mController, value, Text::EffectStyle::INPUT); + break; + } + case Toolkit::TextEditor::Property::SMOOTH_SCROLL: + { + value = impl.mScrollAnimationEnabled; + break; + } + case Toolkit::TextEditor::Property::SMOOTH_SCROLL_DURATION: + { + value = impl.mScrollAnimationDuration; + break; + } + case Toolkit::TextEditor::Property::ENABLE_SCROLL_BAR: + { + value = impl.mScrollBarEnabled; + break; + } + case Toolkit::TextEditor::Property::SCROLL_BAR_SHOW_DURATION: + { + value = impl.mAnimationPeriod.delaySeconds; + break; + } + case Toolkit::TextEditor::Property::SCROLL_BAR_FADE_DURATION: + { + value = impl.mAnimationPeriod.durationSeconds; + break; + } + case Toolkit::TextEditor::Property::PIXEL_SIZE: + { + value = impl.mController->GetDefaultFontSize(Text::Controller::PIXEL_SIZE); + break; + } + case Toolkit::TextEditor::Property::LINE_COUNT: + { + float width = textEditor.GetProperty(Actor::Property::SIZE_WIDTH).Get(); + value = impl.mController->GetLineCount(width); + break; + } + case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT: + { + std::string text; + impl.mController->GetPlaceholderText(Text::Controller::PLACEHOLDER_TYPE_INACTIVE, text); + value = text; + break; + } + case Toolkit::DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR: + { + value = impl.mController->GetPlaceholderTextColor(); + break; + } + case Toolkit::TextEditor::Property::ENABLE_SELECTION: + { + value = impl.mController->IsSelectionEnabled(); + break; + } + case Toolkit::TextEditor::Property::PLACEHOLDER: + { + Property::Map map; + impl.mController->GetPlaceholderProperty(map); + value = map; + break; + } + case Toolkit::TextEditor::Property::LINE_WRAP_MODE: + { + value = impl.mController->GetLineWrapMode(); + break; + } + case Toolkit::DevelTextEditor::Property::ENABLE_SHIFT_SELECTION: + { + value = impl.mController->IsShiftSelectionEnabled(); + break; + } + case Toolkit::DevelTextEditor::Property::ENABLE_GRAB_HANDLE: + { + value = impl.mController->IsGrabHandleEnabled(); + break; + } + case Toolkit::DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION: + { + value = impl.mController->GetMatchLayoutDirection() != DevelText::MatchLayoutDirection::CONTENTS; + break; + } + case Toolkit::DevelTextEditor::Property::MAX_LENGTH: + { + value = impl.mController->GetMaximumNumberOfCharacters(); + break; + } + case Toolkit::DevelTextEditor::Property::SELECTED_TEXT: + { + value = impl.mController->GetSelectedText(); + break; + } + case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_START: + { + Uint32Pair range = impl.GetTextSelectionRange(); + value = static_cast(range.first); + break; + } + case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_END: + { + Uint32Pair range = impl.GetTextSelectionRange(); + value = static_cast(range.second); + break; + } + case Toolkit::DevelTextEditor::Property::ENABLE_EDITING: + { + value = impl.IsEditable(); + break; + } + case Toolkit::DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION: + { + value = impl.GetHorizontalScrollPosition(); + break; + } + case Toolkit::DevelTextEditor::Property::VERTICAL_SCROLL_POSITION: + { + value = impl.GetVerticalScrollPosition(); + break; + } + case Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE: + { + value = impl.mController->GetFontSizeScale(); + break; + } + case Toolkit::DevelTextEditor::Property::PRIMARY_CURSOR_POSITION: + { + value = static_cast(impl.mController->GetPrimaryCursorPosition()); + break; + } + case Toolkit::DevelTextEditor::Property::GRAB_HANDLE_COLOR: + { + value = impl.mDecorator->GetHandleColor(); + break; + } + case Toolkit::DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP: + { + value = impl.mController->IsGrabHandlePopupEnabled(); + break; + } + case Toolkit::DevelTextEditor::Property::INPUT_METHOD_SETTINGS: + { + Property::Map map; + impl.mInputMethodOptions.RetrieveProperty(map); + value = map; + break; + } + case Toolkit::DevelTextEditor::Property::INPUT_FILTER: + { + Property::Map map; + impl.mController->GetInputFilterOption(map); + value = map; + break; + } + case Toolkit::DevelTextEditor::Property::ELLIPSIS: + { + value = impl.mController->IsTextElideEnabled(); + break; + } + case Toolkit::DevelTextEditor::Property::ELLIPSIS_POSITION: + { + value = impl.mController->GetEllipsisPosition(); + break; + } + case Toolkit::DevelTextEditor::Property::MIN_LINE_SIZE: + { + value = impl.mController->GetDefaultLineSize(); + break; + } + } //switch + return value; +} + +} // namespace Dali::Toolkit::Internal diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-property-handler.h b/dali-toolkit/internal/controls/text-controls/text-editor-property-handler.h new file mode 100644 index 0000000..2664f4d --- /dev/null +++ b/dali-toolkit/internal/controls/text-controls/text-editor-property-handler.h @@ -0,0 +1,61 @@ +#ifndef DALI_TOOLKIT_INTERNAL_TEXT_EDITOR_PROPERTY_HANDLER_H +#define DALI_TOOLKIT_INTERNAL_TEXT_EDITOR_PROPERTY_HANDLER_H + +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +namespace Dali::Toolkit::Internal +{ +/** + * Class to manage properties for the TextEditor + */ +struct TextEditor::PropertyHandler +{ + static const char* const IMAGE_MAP_FILENAME_STRING; //<<< "filename" key for image map + + /** + * Set properties on the text editor / controller / decorator + * + * @param[in] textEditor The handle for the text editor + * @param[in] index The property index of the property to set + * @param[in] value The value to set + */ + static void SetProperty(Toolkit::TextEditor textEditor, Property::Index index, const Property::Value& value); + + /** + * Get properties from the text editor / controller / decorator + * + * @param[in] textEditor The handle for the text editor + * @param[in] index The property index of the property to set + * @return the value + */ + static Property::Value GetProperty(Toolkit::TextEditor textEditor, Property::Index index); + +private: + /** + * Method to extract "filename" value from a Property::Map + * + * @param[in] The property value containing the Property::Map + * @return The resulting "filename" value if present + */ + static std::string GetImageFileNameFromPropertyValue(const Property::Value& value); +}; + +} // namespace Dali::Toolkit::Internal + +#endif //DALI_TOOLKIT_INTERNAL_TEXT_EDITOR_PROPERTY_HANDLER_H diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index 32beca1..fe01e46 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -24,17 +24,19 @@ #include #include #include +#include #include #include #include #include // INTERNAL INCLUDES -#include #include #include #include #include +#include +#include #include #include #include @@ -48,6 +50,10 @@ using namespace Dali::Toolkit::Text; +#if defined(DEBUG_ENABLED) +Debug::Filter* gTextFieldLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_CONTROLS"); +#endif + namespace Dali { namespace Toolkit @@ -56,10 +62,6 @@ namespace Internal { namespace // unnamed namespace { -#if defined(DEBUG_ENABLED) -Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_CONTROLS"); -#endif - const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::DevelText::DEFAULT_RENDERING_BACKEND; } // unnamed namespace @@ -152,22 +154,51 @@ DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "selectionCleared", SIGNAL_SEL DALI_TYPE_REGISTRATION_END() // clang-format on -const char* const IMAGE_MAP_FILENAME_STRING = "filename"; - -/// Retrieves a filename from a value that is a Property::Map -std::string GetImageFileNameFromPropertyValue(const Property::Value& value) +Toolkit::TextField::InputStyle::Mask ConvertInputStyle(Text::InputStyle::Mask inputStyleMask) { - std::string filename; - const Property::Map* map = value.GetMap(); - if(map) + Toolkit::TextField::InputStyle::Mask fieldInputStyleMask = Toolkit::TextField::InputStyle::NONE; + + if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_COLOR)) { - const Property::Value* filenameValue = map->Find(IMAGE_MAP_FILENAME_STRING); - if(filenameValue) - { - filenameValue->Get(filename); - } + fieldInputStyleMask = static_cast(fieldInputStyleMask | Toolkit::TextField::InputStyle::COLOR); + } + if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_FONT_FAMILY)) + { + fieldInputStyleMask = static_cast(fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_FAMILY); + } + if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_POINT_SIZE)) + { + fieldInputStyleMask = static_cast(fieldInputStyleMask | Toolkit::TextField::InputStyle::POINT_SIZE); + } + if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_FONT_WEIGHT)) + { + fieldInputStyleMask = static_cast(fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_STYLE); + } + if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_FONT_WIDTH)) + { + fieldInputStyleMask = static_cast(fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_STYLE); + } + if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_FONT_SLANT)) + { + fieldInputStyleMask = static_cast(fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_STYLE); + } + if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_UNDERLINE)) + { + fieldInputStyleMask = static_cast(fieldInputStyleMask | Toolkit::TextField::InputStyle::UNDERLINE); + } + if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_SHADOW)) + { + fieldInputStyleMask = static_cast(fieldInputStyleMask | Toolkit::TextField::InputStyle::SHADOW); + } + if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_EMBOSS)) + { + fieldInputStyleMask = static_cast(fieldInputStyleMask | Toolkit::TextField::InputStyle::EMBOSS); + } + if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_OUTLINE)) + { + fieldInputStyleMask = static_cast(fieldInputStyleMask | Toolkit::TextField::InputStyle::OUTLINE); } - return filename; + return fieldInputStyleMask; } } // namespace @@ -191,606 +222,12 @@ void TextField::SetProperty(BaseObject* object, Property::Index index, const Pro { Toolkit::TextField textField = Toolkit::TextField::DownCast(Dali::BaseHandle(object)); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField SetProperty\n"); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField SetProperty\n"); if(textField) { - TextField& impl(GetImpl(textField)); - DALI_ASSERT_DEBUG(impl.mController && "No text contoller"); - DALI_ASSERT_DEBUG(impl.mDecorator && "No text decorator"); - - switch(index) - { - case Toolkit::DevelTextField::Property::RENDERING_BACKEND: - { - int backend = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField %p RENDERING_BACKEND %d\n", impl.mController.Get(), backend); - -#ifndef ENABLE_VECTOR_BASED_TEXT_RENDERING - if(DevelText::RENDERING_VECTOR_BASED == backend) - { - backend = TextAbstraction::BITMAP_GLYPH; // Fallback to bitmap-based rendering - } -#endif - if(impl.mRenderingBackend != backend) - { - impl.mRenderingBackend = backend; - impl.mRenderer.Reset(); - - // When using the vector-based rendering, the size of the GLyphs are different - TextAbstraction::GlyphType glyphType = (DevelText::RENDERING_VECTOR_BASED == impl.mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH; - impl.mController->SetGlyphType(glyphType); - } - break; - } - case Toolkit::TextField::Property::TEXT: - { - const std::string& text = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p TEXT %s\n", impl.mController.Get(), text.c_str()); - - impl.mController->SetText(text); - break; - } - case Toolkit::TextField::Property::PLACEHOLDER_TEXT: - { - const std::string& text = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str()); - - impl.mController->SetPlaceholderText(Controller::PLACEHOLDER_TYPE_INACTIVE, text); - break; - } - case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED: - { - const std::string& text = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_FOCUSED %s\n", impl.mController.Get(), text.c_str()); - - impl.mController->SetPlaceholderText(Controller::PLACEHOLDER_TYPE_ACTIVE, text); - break; - } - case Toolkit::TextField::Property::FONT_FAMILY: - { - const std::string& fontFamily = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str()); - impl.mController->SetDefaultFontFamily(fontFamily); - break; - } - case Toolkit::TextField::Property::FONT_STYLE: - { - SetFontStyleProperty(impl.mController, value, Text::FontStyle::DEFAULT); - break; - } - case Toolkit::TextField::Property::POINT_SIZE: - { - const float pointSize = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p POINT_SIZE %f\n", impl.mController.Get(), pointSize); - - if(!Equals(impl.mController->GetDefaultFontSize(Text::Controller::POINT_SIZE), pointSize)) - { - impl.mController->SetDefaultFontSize(pointSize, Text::Controller::POINT_SIZE); - } - break; - } - case Toolkit::TextField::Property::MAX_LENGTH: - { - const int max = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p MAX_LENGTH %d\n", impl.mController.Get(), max); - - impl.mController->SetMaximumNumberOfCharacters(max); - break; - } - case Toolkit::TextField::Property::EXCEED_POLICY: - { - impl.mExceedPolicy = value.Get(); - - if(Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == impl.mExceedPolicy) - { - impl.EnableClipping(); - } - else - { - UnparentAndReset(impl.mStencil); - } - impl.RequestTextRelayout(); - break; - } - case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT: - { - Text::HorizontalAlignment::Type alignment(static_cast(-1)); // Set to invalid value to ensure a valid mode does get set - if(GetHorizontalAlignmentEnumeration(value, alignment)) - { - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p HORIZONTAL_ALIGNMENT %d\n", impl.mController.Get(), alignment); - impl.mController->SetHorizontalAlignment(alignment); - } - break; - } - case Toolkit::TextField::Property::VERTICAL_ALIGNMENT: - { - Toolkit::Text::VerticalAlignment::Type alignment(static_cast(-1)); // Set to invalid value to ensure a valid mode does get set - if(GetVerticalAlignmentEnumeration(value, alignment)) - { - impl.mController->SetVerticalAlignment(alignment); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p VERTICAL_ALIGNMENT %d\n", impl.mController.Get(), alignment); - } - break; - } - case Toolkit::TextField::Property::TEXT_COLOR: - { - const Vector4& textColor = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a); - - if(impl.mController->GetDefaultColor() != textColor) - { - impl.mController->SetDefaultColor(textColor); - impl.mController->SetInputColor(textColor); - impl.mRenderer.Reset(); - } - break; - } - case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR: - { - const Vector4& textColor = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a); - - if(impl.mController->GetPlaceholderTextColor() != textColor) - { - impl.mController->SetPlaceholderTextColor(textColor); - impl.mRenderer.Reset(); - } - break; - } - case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR: - { - const Vector4& color = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p PRIMARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a); - - impl.mDecorator->SetCursorColor(PRIMARY_CURSOR, color); - impl.RequestTextRelayout(); - break; - } - case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR: - { - const Vector4& color = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p SECONDARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a); - - impl.mDecorator->SetCursorColor(SECONDARY_CURSOR, color); - impl.RequestTextRelayout(); - break; - } - case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK: - { - const bool enable = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField %p ENABLE_CURSOR_BLINK %d\n", impl.mController.Get(), enable); - - impl.mController->SetEnableCursorBlink(enable); - impl.RequestTextRelayout(); - break; - } - case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL: - { - const float interval = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_INTERVAL %f\n", impl.mController.Get(), interval); - - impl.mDecorator->SetCursorBlinkInterval(interval); - break; - } - case Toolkit::TextField::Property::CURSOR_BLINK_DURATION: - { - const float duration = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_DURATION %f\n", impl.mController.Get(), duration); - - impl.mDecorator->SetCursorBlinkDuration(duration); - break; - } - case Toolkit::TextField::Property::CURSOR_WIDTH: - { - const int width = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField %p CURSOR_WIDTH %d\n", impl.mController.Get(), width); - - impl.mDecorator->SetCursorWidth(width); - impl.mController->GetLayoutEngine().SetCursorWidth(width); - break; - } - case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE: - { - const std::string imageFileName = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str()); - - if(imageFileName.size()) - { - impl.mDecorator->SetHandleImage(GRAB_HANDLE, HANDLE_IMAGE_RELEASED, imageFileName); - impl.RequestTextRelayout(); - } - break; - } - case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE: - { - const std::string imageFileName = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_PRESSED_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str()); - - if(imageFileName.size()) - { - impl.mDecorator->SetHandleImage(GRAB_HANDLE, HANDLE_IMAGE_PRESSED, imageFileName); - impl.RequestTextRelayout(); - } - break; - } - case Toolkit::TextField::Property::SCROLL_THRESHOLD: - { - const float threshold = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField %p SCROLL_THRESHOLD %f\n", impl.mController.Get(), threshold); - - impl.mDecorator->SetScrollThreshold(threshold); - break; - } - case Toolkit::TextField::Property::SCROLL_SPEED: - { - const float speed = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField %p SCROLL_SPEED %f\n", impl.mController.Get(), speed); - - impl.mDecorator->SetScrollSpeed(speed); - break; - } - case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT: - { - const std::string filename = GetImageFileNameFromPropertyValue(value); - - if(filename.size()) - { - impl.mDecorator->SetHandleImage(LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, filename); - impl.RequestTextRelayout(); - } - break; - } - case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT: - { - const std::string filename = GetImageFileNameFromPropertyValue(value); - - if(filename.size()) - { - impl.mDecorator->SetHandleImage(RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, filename); - impl.RequestTextRelayout(); - } - break; - } - case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT: - { - const std::string filename = GetImageFileNameFromPropertyValue(value); - - if(filename.size()) - { - impl.mDecorator->SetHandleImage(LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, filename); - impl.RequestTextRelayout(); - } - break; - } - case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT: - { - const std::string filename = GetImageFileNameFromPropertyValue(value); - - if(filename.size()) - { - impl.mDecorator->SetHandleImage(RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, filename); - impl.RequestTextRelayout(); - } - break; - } - case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT: - { - const std::string filename = GetImageFileNameFromPropertyValue(value); - - if(filename.size()) - { - impl.mDecorator->SetHandleImage(LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, filename); - impl.RequestTextRelayout(); - } - break; - } - case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT: - { - const std::string filename = GetImageFileNameFromPropertyValue(value); - - if(filename.size()) - { - impl.mDecorator->SetHandleImage(RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, filename); - impl.RequestTextRelayout(); - } - break; - } - case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR: - { - const Vector4 color = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p SELECTION_HIGHLIGHT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a); - - impl.mDecorator->SetHighlightColor(color); - impl.RequestTextRelayout(); - break; - } - case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX: - { - const Rect box = value.Get >(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p DECORATION_BOUNDING_BOX %d,%d %dx%d\n", impl.mController.Get(), box.x, box.y, box.width, box.height); - - impl.mDecorator->SetBoundingBox(box); - impl.RequestTextRelayout(); - break; - } - case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS: - { - const Property::Map* map = value.GetMap(); - if(map) - { - impl.mInputMethodOptions.ApplyProperty(*map); - } - impl.mController->SetInputModePassword(impl.mInputMethodOptions.IsPassword()); - - Toolkit::Control control = Toolkit::KeyInputFocusManager::Get().GetCurrentFocusControl(); - if(control == textField) - { - impl.mInputMethodContext.ApplyOptions(impl.mInputMethodOptions); - } - break; - } - case Toolkit::TextField::Property::INPUT_COLOR: - { - const Vector4 inputColor = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p INPUT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), inputColor.r, inputColor.g, inputColor.b, inputColor.a); - - impl.mController->SetInputColor(inputColor); - break; - } - case Toolkit::TextField::Property::ENABLE_MARKUP: - { - const bool enableMarkup = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p ENABLE_MARKUP %d\n", impl.mController.Get(), enableMarkup); - - impl.mController->SetMarkupProcessorEnabled(enableMarkup); - break; - } - case Toolkit::TextField::Property::INPUT_FONT_FAMILY: - { - const std::string& fontFamily = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p INPUT_FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str()); - impl.mController->SetInputFontFamily(fontFamily); - break; - } - case Toolkit::TextField::Property::INPUT_FONT_STYLE: - { - SetFontStyleProperty(impl.mController, value, Text::FontStyle::INPUT); - break; - } - case Toolkit::TextField::Property::INPUT_POINT_SIZE: - { - const float pointSize = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p INPUT_POINT_SIZE %f\n", impl.mController.Get(), pointSize); - impl.mController->SetInputFontPointSize(pointSize); - break; - } - case Toolkit::TextField::Property::UNDERLINE: - { - const bool update = SetUnderlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT); - if(update) - { - impl.mRenderer.Reset(); - } - break; - } - case Toolkit::TextField::Property::INPUT_UNDERLINE: - { - const bool update = SetUnderlineProperties(impl.mController, value, Text::EffectStyle::INPUT); - if(update) - { - impl.mRenderer.Reset(); - } - break; - } - case Toolkit::TextField::Property::SHADOW: - { - const bool update = SetShadowProperties(impl.mController, value, Text::EffectStyle::DEFAULT); - if(update) - { - impl.mRenderer.Reset(); - } - break; - } - case Toolkit::TextField::Property::INPUT_SHADOW: - { - const bool update = SetShadowProperties(impl.mController, value, Text::EffectStyle::INPUT); - if(update) - { - impl.mRenderer.Reset(); - } - break; - } - case Toolkit::TextField::Property::EMBOSS: - { - const bool update = SetEmbossProperties(impl.mController, value, Text::EffectStyle::DEFAULT); - if(update) - { - impl.mRenderer.Reset(); - } - break; - } - case Toolkit::TextField::Property::INPUT_EMBOSS: - { - const bool update = SetEmbossProperties(impl.mController, value, Text::EffectStyle::INPUT); - if(update) - { - impl.mRenderer.Reset(); - } - break; - } - case Toolkit::TextField::Property::OUTLINE: - { - const bool update = SetOutlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT); - if(update) - { - impl.mRenderer.Reset(); - } - break; - } - case Toolkit::TextField::Property::INPUT_OUTLINE: - { - const bool update = SetOutlineProperties(impl.mController, value, Text::EffectStyle::INPUT); - if(update) - { - impl.mRenderer.Reset(); - } - break; - } - case Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS: - { - const Property::Map* map = value.GetMap(); - if(map) - { - impl.mController->SetHiddenInputOption(*map); - } - break; - } - case Toolkit::TextField::Property::PIXEL_SIZE: - { - const float pixelSize = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p PIXEL_SIZE %f\n", impl.mController.Get(), pixelSize); - - if(!Equals(impl.mController->GetDefaultFontSize(Text::Controller::PIXEL_SIZE), pixelSize)) - { - impl.mController->SetDefaultFontSize(pixelSize, Text::Controller::PIXEL_SIZE); - } - break; - } - case Toolkit::TextField::Property::ENABLE_SELECTION: - { - const bool enableSelection = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p ENABLE_SELECTION %d\n", impl.mController.Get(), enableSelection); - impl.mController->SetSelectionEnabled(enableSelection); - break; - } - case Toolkit::TextField::Property::PLACEHOLDER: - { - const Property::Map* map = value.GetMap(); - if(map) - { - impl.mController->SetPlaceholderProperty(*map); - } - break; - } - case Toolkit::TextField::Property::ELLIPSIS: - { - const bool ellipsis = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p ELLIPSIS %d\n", impl.mController.Get(), ellipsis); - - impl.mController->SetTextElideEnabled(ellipsis); - break; - } - case Toolkit::DevelTextField::Property::ENABLE_SHIFT_SELECTION: - { - const bool shiftSelection = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p ENABLE_SHIFT_SELECTION %d\n", impl.mController.Get(), shiftSelection); - - impl.mController->SetShiftSelectionEnabled(shiftSelection); - break; - } - case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE: - { - const bool grabHandleEnabled = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p ENABLE_GRAB_HANDLE %d\n", impl.mController.Get(), grabHandleEnabled); - - impl.mController->SetGrabHandleEnabled(grabHandleEnabled); - break; - } - case Toolkit::DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION: - { - impl.mController->SetMatchLayoutDirection(value.Get() ? DevelText::MatchLayoutDirection::LOCALE : DevelText::MatchLayoutDirection::CONTENTS); - break; - } - case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP: - { - const bool grabHandlePopupEnabled = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p ENABLE_GRAB_HANDLE_POPUP %d\n", impl.mController.Get(), grabHandlePopupEnabled); - - impl.mController->SetGrabHandlePopupEnabled(grabHandlePopupEnabled); - break; - } - case Toolkit::DevelTextField::Property::BACKGROUND: - { - const Vector4 backgroundColor = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p BACKGROUND %f,%f,%f,%f\n", impl.mController.Get(), backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a); - - impl.mController->SetBackgroundEnabled(true); - impl.mController->SetBackgroundColor(backgroundColor); - break; - } - case Toolkit::DevelTextField::Property::SELECTED_TEXT_START: - { - uint32_t start = static_cast(value.Get()); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p SELECTED_TEXT_START %d\n", impl.mController.Get(), start); - impl.SetTextSelectionRange(&start, nullptr); - break; - } - case Toolkit::DevelTextField::Property::SELECTED_TEXT_END: - { - uint32_t end = static_cast(value.Get()); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p SELECTED_TEXT_END %d\n", impl.mController.Get(), end); - impl.SetTextSelectionRange(nullptr, &end); - break; - } - case Toolkit::DevelTextField::Property::ENABLE_EDITING: - { - const bool editable = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p ENABLE_EDITING %d\n", impl.mController.Get(), editable); - impl.SetEditable(editable); - break; - } - case Toolkit::DevelTextField::Property::FONT_SIZE_SCALE: - { - const float scale = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p FONT_SIZE_SCALE %f\n", impl.mController.Get(), scale); - - if(!Equals(impl.mController->GetFontSizeScale(), scale)) - { - impl.mController->SetFontSizeScale(scale); - } - break; - } - case Toolkit::DevelTextField::Property::PRIMARY_CURSOR_POSITION: - { - uint32_t position = static_cast(value.Get()); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p PRIMARY_CURSOR_POSITION %d\n", impl.mController.Get(), position); - if(impl.mController->SetPrimaryCursorPosition(position, impl.HasKeyInputFocus())) - { - impl.SetKeyInputFocus(); - } - break; - } - case Toolkit::DevelTextField::Property::GRAB_HANDLE_COLOR: - { - const Vector4 color = value.Get(); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p GRAB_HANDLE_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a); - - impl.mDecorator->SetHandleColor(color); - impl.RequestTextRelayout(); - break; - } - case Toolkit::DevelTextField::Property::INPUT_FILTER: - { - const Property::Map* map = value.GetMap(); - if(map) - { - impl.mController->SetInputFilterOption(*map); - } - break; - } - case Toolkit::DevelTextField::Property::ELLIPSIS_POSITION: - { - DevelText::EllipsisPosition::Type ellipsisPositionType(static_cast(-1)); // Set to invalid value to ensure a valid mode does get set - if(GetEllipsisPositionTypeEnumeration(value, ellipsisPositionType)) - { - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p EllipsisPosition::Type %d\n", impl.mController.Get(), ellipsisPositionType); - impl.mController->SetEllipsisPosition(ellipsisPositionType); - } - break; - } - } // switch - } // textfield + PropertyHandler::SetProperty(textField, index, value); + } } Property::Value TextField::GetProperty(BaseObject* object, Property::Index index) @@ -801,362 +238,7 @@ Property::Value TextField::GetProperty(BaseObject* object, Property::Index index if(textField) { - TextField& impl(GetImpl(textField)); - DALI_ASSERT_DEBUG(impl.mController && "No text contoller"); - DALI_ASSERT_DEBUG(impl.mDecorator && "No text decorator"); - - switch(index) - { - case Toolkit::DevelTextField::Property::RENDERING_BACKEND: - { - value = impl.mRenderingBackend; - break; - } - case Toolkit::TextField::Property::TEXT: - { - std::string text; - impl.mController->GetText(text); - DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p returning text: %s\n", impl.mController.Get(), text.c_str()); - value = text; - break; - } - case Toolkit::TextField::Property::PLACEHOLDER_TEXT: - { - std::string text; - impl.mController->GetPlaceholderText(Controller::PLACEHOLDER_TYPE_INACTIVE, text); - value = text; - break; - } - case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED: - { - std::string text; - impl.mController->GetPlaceholderText(Controller::PLACEHOLDER_TYPE_ACTIVE, text); - value = text; - break; - } - case Toolkit::TextField::Property::FONT_FAMILY: - { - value = impl.mController->GetDefaultFontFamily(); - break; - } - case Toolkit::TextField::Property::FONT_STYLE: - { - GetFontStyleProperty(impl.mController, value, Text::FontStyle::DEFAULT); - break; - } - case Toolkit::TextField::Property::POINT_SIZE: - { - value = impl.mController->GetDefaultFontSize(Text::Controller::POINT_SIZE); - break; - } - case Toolkit::TextField::Property::MAX_LENGTH: - { - value = impl.mController->GetMaximumNumberOfCharacters(); - break; - } - case Toolkit::TextField::Property::EXCEED_POLICY: - { - value = impl.mExceedPolicy; - break; - } - case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT: - { - const char* name = Text::GetHorizontalAlignmentString(impl.mController->GetHorizontalAlignment()); - - if(name) - { - value = std::string(name); - } - break; - } - case Toolkit::TextField::Property::VERTICAL_ALIGNMENT: - { - const char* name = Text::GetVerticalAlignmentString(impl.mController->GetVerticalAlignment()); - - if(name) - { - value = std::string(name); - } - break; - } - case Toolkit::TextField::Property::TEXT_COLOR: - { - value = impl.mController->GetDefaultColor(); - break; - } - case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR: - { - value = impl.mController->GetPlaceholderTextColor(); - break; - } - case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR: - { - value = impl.mDecorator->GetColor(PRIMARY_CURSOR); - break; - } - case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR: - { - value = impl.mDecorator->GetColor(SECONDARY_CURSOR); - break; - } - case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK: - { - value = impl.mController->GetEnableCursorBlink(); - break; - } - case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL: - { - value = impl.mDecorator->GetCursorBlinkInterval(); - break; - } - case Toolkit::TextField::Property::CURSOR_BLINK_DURATION: - { - value = impl.mDecorator->GetCursorBlinkDuration(); - break; - } - case Toolkit::TextField::Property::CURSOR_WIDTH: - { - value = impl.mDecorator->GetCursorWidth(); - break; - } - case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE: - { - value = impl.mDecorator->GetHandleImage(GRAB_HANDLE, HANDLE_IMAGE_RELEASED); - break; - } - case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE: - { - value = impl.mDecorator->GetHandleImage(GRAB_HANDLE, HANDLE_IMAGE_PRESSED); - break; - } - case Toolkit::TextField::Property::SCROLL_THRESHOLD: - { - value = impl.mDecorator->GetScrollThreshold(); - break; - } - case Toolkit::TextField::Property::SCROLL_SPEED: - { - value = impl.mDecorator->GetScrollSpeed(); - break; - } - case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT: - { - impl.GetHandleImagePropertyValue(value, LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED); - break; - } - case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT: - { - impl.GetHandleImagePropertyValue(value, RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED); - break; - } - case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT: - { - impl.GetHandleImagePropertyValue(value, LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED); - break; - } - case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT: - { - impl.GetHandleImagePropertyValue(value, RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED); - break; - } - case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT: - { - impl.GetHandleImagePropertyValue(value, LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED); - break; - } - case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT: - { - impl.GetHandleImagePropertyValue(value, RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED); - break; - } - case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR: - { - value = impl.mDecorator->GetHighlightColor(); - break; - } - case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX: - { - Rect boundingBox; - impl.mDecorator->GetBoundingBox(boundingBox); - value = boundingBox; - break; - } - case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS: - { - Property::Map map; - impl.mInputMethodOptions.RetrieveProperty(map); - value = map; - break; - } - case Toolkit::TextField::Property::INPUT_COLOR: - { - value = impl.mController->GetInputColor(); - break; - } - case Toolkit::TextField::Property::ENABLE_MARKUP: - { - value = impl.mController->IsMarkupProcessorEnabled(); - break; - } - case Toolkit::TextField::Property::INPUT_FONT_FAMILY: - { - value = impl.mController->GetInputFontFamily(); - break; - } - case Toolkit::TextField::Property::INPUT_FONT_STYLE: - { - GetFontStyleProperty(impl.mController, value, Text::FontStyle::INPUT); - break; - } - case Toolkit::TextField::Property::INPUT_POINT_SIZE: - { - value = impl.mController->GetInputFontPointSize(); - break; - } - case Toolkit::TextField::Property::UNDERLINE: - { - GetUnderlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT); - break; - } - case Toolkit::TextField::Property::INPUT_UNDERLINE: - { - GetUnderlineProperties(impl.mController, value, Text::EffectStyle::INPUT); - break; - } - case Toolkit::TextField::Property::SHADOW: - { - GetShadowProperties(impl.mController, value, Text::EffectStyle::DEFAULT); - break; - } - case Toolkit::TextField::Property::INPUT_SHADOW: - { - GetShadowProperties(impl.mController, value, Text::EffectStyle::INPUT); - break; - } - case Toolkit::TextField::Property::EMBOSS: - { - GetEmbossProperties(impl.mController, value, Text::EffectStyle::DEFAULT); - break; - } - case Toolkit::TextField::Property::INPUT_EMBOSS: - { - GetEmbossProperties(impl.mController, value, Text::EffectStyle::INPUT); - break; - } - case Toolkit::TextField::Property::OUTLINE: - { - GetOutlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT); - break; - } - case Toolkit::TextField::Property::INPUT_OUTLINE: - { - GetOutlineProperties(impl.mController, value, Text::EffectStyle::INPUT); - break; - } - case Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS: - { - Property::Map map; - impl.mController->GetHiddenInputOption(map); - value = map; - break; - } - case Toolkit::TextField::Property::PIXEL_SIZE: - { - value = impl.mController->GetDefaultFontSize(Text::Controller::PIXEL_SIZE); - break; - } - case Toolkit::TextField::Property::ENABLE_SELECTION: - { - value = impl.mController->IsSelectionEnabled(); - break; - } - case Toolkit::TextField::Property::PLACEHOLDER: - { - Property::Map map; - impl.mController->GetPlaceholderProperty(map); - value = map; - break; - } - case Toolkit::TextField::Property::ELLIPSIS: - { - value = impl.mController->IsTextElideEnabled(); - break; - } - case Toolkit::DevelTextField::Property::ENABLE_SHIFT_SELECTION: - { - value = impl.mController->IsShiftSelectionEnabled(); - break; - } - case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE: - { - value = impl.mController->IsGrabHandleEnabled(); - break; - } - case Toolkit::DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION: - { - value = impl.mController->GetMatchLayoutDirection() != DevelText::MatchLayoutDirection::CONTENTS; - break; - } - case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP: - { - value = impl.mController->IsGrabHandlePopupEnabled(); - break; - } - case Toolkit::DevelTextField::Property::BACKGROUND: - { - value = impl.mController->GetBackgroundColor(); - break; - } - case Toolkit::DevelTextField::Property::SELECTED_TEXT: - { - value = impl.mController->GetSelectedText(); - break; - } - case Toolkit::DevelTextField::Property::SELECTED_TEXT_START: - { - Uint32Pair range = impl.GetTextSelectionRange(); - value = static_cast(range.first); - break; - } - case Toolkit::DevelTextField::Property::SELECTED_TEXT_END: - { - Uint32Pair range = impl.GetTextSelectionRange(); - value = static_cast(range.second); - break; - } - case Toolkit::DevelTextField::Property::ENABLE_EDITING: - { - value = impl.IsEditable(); - break; - } - case Toolkit::DevelTextField::Property::FONT_SIZE_SCALE: - { - value = impl.mController->GetFontSizeScale(); - break; - } - case Toolkit::DevelTextField::Property::PRIMARY_CURSOR_POSITION: - { - value = static_cast(impl.mController->GetPrimaryCursorPosition()); - break; - } - case Toolkit::DevelTextField::Property::GRAB_HANDLE_COLOR: - { - value = impl.mDecorator->GetHandleColor(); - break; - } - case Toolkit::DevelTextField::Property::INPUT_FILTER: - { - Property::Map map; - impl.mController->GetInputFilterOption(map); - value = map; - break; - } - case Toolkit::DevelTextField::Property::ELLIPSIS_POSITION: - { - value = impl.mController->GetEllipsisPosition(); - break; - } - } //switch + value = PropertyHandler::GetProperty(textField, index); } return value; @@ -1441,13 +523,13 @@ void TextField::OnInitialize() void TextField::OnStyleChange(Toolkit::StyleManager styleManager, StyleChange::Type change) { - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField::OnStyleChange\n"); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField::OnStyleChange\n"); switch(change) { case StyleChange::DEFAULT_FONT_CHANGE: { - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField::OnStyleChange DEFAULT_FONT_CHANGE\n"); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField::OnStyleChange DEFAULT_FONT_CHANGE\n"); const std::string& newFont = GetImpl(styleManager).GetDefaultFontFamily(); // Property system did not set the font so should update it. mController->UpdateAfterFontChange(newFont); @@ -1501,7 +583,7 @@ void TextField::ResizeActor(Actor& actor, const Vector2& size) void TextField::OnRelayout(const Vector2& size, RelayoutContainer& container) { - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField OnRelayout\n"); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField OnRelayout\n"); Actor self = Self(); @@ -1540,7 +622,7 @@ void TextField::OnRelayout(const Vector2& size, RelayoutContainer& container) if((Text::Controller::NONE_UPDATED != updateTextType) || !mRenderer) { - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField::OnRelayout %p Displaying new contents\n", mController.Get()); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField::OnRelayout %p Displaying new contents\n", mController.Get()); if(mDecorator && (Text::Controller::NONE_UPDATED != (Text::Controller::DECORATOR_UPDATED & updateTextType))) @@ -1598,106 +680,12 @@ Text::ControllerPtr TextField::GetTextController() void TextField::RenderText(Text::Controller::UpdateTextType updateTextType) { - Actor renderableActor; - - if(Text::Controller::NONE_UPDATED != (Text::Controller::MODEL_UPDATED & updateTextType)) - { - if(mRenderer) - { - Dali::Toolkit::TextField handle = Dali::Toolkit::TextField(GetOwner()); - - renderableActor = mRenderer->Render(mController->GetView(), - handle, - Property::INVALID_INDEX, // Animatable property not supported - mAlignmentOffset, - DepthIndex::CONTENT); - } - - if(renderableActor != mRenderableActor) - { - UnparentAndReset(mBackgroundActor); - UnparentAndReset(mRenderableActor); - mRenderableActor = renderableActor; - - if(mRenderableActor) - { - mBackgroundActor = mController->CreateBackgroundActor(); - } - } - } - - if(mRenderableActor) - { - const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition(); - - float renderableActorPositionX, renderableActorPositionY; - - if(mStencil) - { - renderableActorPositionX = scrollOffset.x + mAlignmentOffset; - renderableActorPositionY = scrollOffset.y; - } - else - { - Extents padding; - padding = Self().GetProperty(Toolkit::Control::Property::PADDING); - - // Support Right-To-Left of padding - Dali::LayoutDirection::Type layoutDirection = static_cast(Self().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get()); - if(Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection) - { - std::swap(padding.start, padding.end); - } - - renderableActorPositionX = scrollOffset.x + mAlignmentOffset + padding.start; - renderableActorPositionY = scrollOffset.y + padding.top; - } - - mRenderableActor.SetProperty(Actor::Property::POSITION, Vector2(renderableActorPositionX, renderableActorPositionY)); - - // Make sure the actors are parented correctly with/without clipping - Actor self = mStencil ? mStencil : Self(); - - Actor highlightActor; - - for(std::vector::iterator it = mClippingDecorationActors.begin(), - endIt = mClippingDecorationActors.end(); - it != endIt; - ++it) - { - self.Add(*it); - it->LowerToBottom(); - - if(it->GetProperty(Dali::Actor::Property::NAME) == "HighlightActor") - { - highlightActor = *it; - } - } - mClippingDecorationActors.clear(); - - self.Add(mRenderableActor); - - if(mBackgroundActor) - { - if(mDecorator && mDecorator->IsHighlightVisible()) - { - self.Add(mBackgroundActor); - mBackgroundActor.SetProperty(Actor::Property::POSITION, Vector2(renderableActorPositionX, renderableActorPositionY)); // In text field's coords. - mBackgroundActor.LowerBelow(highlightActor); - } - else - { - mRenderableActor.Add(mBackgroundActor); - mBackgroundActor.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f)); // In renderable actor's coords. - mBackgroundActor.LowerToBottom(); - } - } - } + CommonTextUtils::RenderText(Self(), mRenderer, mController, mDecorator, mAlignmentOffset, mRenderableActor, mBackgroundActor, mStencil, mClippingDecorationActors, updateTextType); } void TextField::OnKeyInputFocusGained() { - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField::OnKeyInputFocusGained %p\n", mController.Get()); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField::OnKeyInputFocusGained %p\n", mController.Get()); if(mInputMethodContext && IsEditable()) { // All input panel properties, such as layout, return key type, and input hint, should be set before input panel activates (or shows). @@ -1728,7 +716,7 @@ void TextField::OnKeyInputFocusGained() void TextField::OnKeyInputFocusLost() { - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField:OnKeyInputFocusLost %p\n", mController.Get()); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField:OnKeyInputFocusLost %p\n", mController.Get()); if(mInputMethodContext) { mInputMethodContext.StatusChangedSignal().Disconnect(this, &TextField::KeyboardStatusChanged); @@ -1760,7 +748,7 @@ bool TextField::OnAccessibilityActivated() void TextField::OnTap(const TapGesture& gesture) { - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField::OnTap %p\n", mController.Get()); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField::OnTap %p\n", mController.Get()); if(mInputMethodContext && IsEditable()) { mInputMethodContext.Activate(); @@ -1796,7 +784,7 @@ void TextField::OnLongPress(const LongPressGesture& gesture) bool TextField::OnKeyEvent(const KeyEvent& event) { - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField::OnKeyEvent %p keyCode %d\n", mController.Get(), event.GetKeyCode()); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField::OnKeyEvent %p keyCode %d\n", mController.Get(), event.GetKeyCode()); if(Dali::DALI_KEY_ESCAPE == event.GetKeyCode() && mController->ShouldClearFocusOnEscape()) { @@ -1894,51 +882,7 @@ void TextField::MaxLengthReached() void TextField::InputStyleChanged(Text::InputStyle::Mask inputStyleMask) { Dali::Toolkit::TextField handle(GetOwner()); - - Toolkit::TextField::InputStyle::Mask fieldInputStyleMask = Toolkit::TextField::InputStyle::NONE; - - if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_COLOR)) - { - fieldInputStyleMask = static_cast(fieldInputStyleMask | Toolkit::TextField::InputStyle::COLOR); - } - if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_FONT_FAMILY)) - { - fieldInputStyleMask = static_cast(fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_FAMILY); - } - if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_POINT_SIZE)) - { - fieldInputStyleMask = static_cast(fieldInputStyleMask | Toolkit::TextField::InputStyle::POINT_SIZE); - } - if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_FONT_WEIGHT)) - { - fieldInputStyleMask = static_cast(fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_STYLE); - } - if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_FONT_WIDTH)) - { - fieldInputStyleMask = static_cast(fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_STYLE); - } - if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_FONT_SLANT)) - { - fieldInputStyleMask = static_cast(fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_STYLE); - } - if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_UNDERLINE)) - { - fieldInputStyleMask = static_cast(fieldInputStyleMask | Toolkit::TextField::InputStyle::UNDERLINE); - } - if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_SHADOW)) - { - fieldInputStyleMask = static_cast(fieldInputStyleMask | Toolkit::TextField::InputStyle::SHADOW); - } - if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_EMBOSS)) - { - fieldInputStyleMask = static_cast(fieldInputStyleMask | Toolkit::TextField::InputStyle::EMBOSS); - } - if(InputStyle::NONE != static_cast(inputStyleMask & InputStyle::INPUT_OUTLINE)) - { - fieldInputStyleMask = static_cast(fieldInputStyleMask | Toolkit::TextField::InputStyle::OUTLINE); - } - - mInputStyleChangedSignal.Emit(handle, fieldInputStyleMask); + mInputStyleChangedSignal.Emit(handle, ConvertInputStyle(inputStyleMask)); } void TextField::AnchorClicked(const std::string& href) @@ -2041,7 +985,7 @@ void TextField::OnSceneConnect(Dali::Actor actor) InputMethodContext::CallbackData TextField::OnInputMethodContextEvent(Dali::InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent) { - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField::OnInputMethodContextEvent %p eventName %d\n", mController.Get(), inputMethodContextEvent.eventName); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField::OnInputMethodContextEvent %p eventName %d\n", mController.Get(), inputMethodContextEvent.eventName); return mController->OnInputMethodContextEvent(inputMethodContext, inputMethodContextEvent); } @@ -2050,8 +994,9 @@ void TextField::GetHandleImagePropertyValue(Property::Value& value, Text::Handle if(mDecorator) { Property::Map map; - map[IMAGE_MAP_FILENAME_STRING] = mDecorator->GetHandleImage(handleType, handleImageType); - value = map; + map[PropertyHandler::IMAGE_MAP_FILENAME_STRING] = mDecorator->GetHandleImage(handleType, handleImageType); + + value = map; } } @@ -2083,7 +1028,7 @@ void TextField::OnClipboardTextSelected(ClipboardEventNotifier& clipboard) void TextField::KeyboardStatusChanged(bool keyboardShown) { - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField::KeyboardStatusChanged %p keyboardShown %d\n", mController.Get(), keyboardShown); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField::KeyboardStatusChanged %p keyboardShown %d\n", mController.Get(), keyboardShown); // Just hide the grab handle when keyboard is hidden. if(!keyboardShown) diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.h b/dali-toolkit/internal/controls/text-controls/text-field-impl.h index 0472aa8..b65e953 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.h @@ -470,6 +470,8 @@ private: // Data uint32_t mOldSelectionEnd; protected: + struct PropertyHandler; + /** * @brief This structure is to connect TextField with Accessible functions. */ diff --git a/dali-toolkit/internal/controls/text-controls/text-field-property-handler.cpp b/dali-toolkit/internal/controls/text-controls/text-field-property-handler.cpp new file mode 100644 index 0000000..04a5082 --- /dev/null +++ b/dali-toolkit/internal/controls/text-controls/text-field-property-handler.cpp @@ -0,0 +1,1021 @@ +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#if defined(DEBUG_ENABLED) +extern Debug::Filter* gTextFieldLogFilter; +#endif + +namespace Dali::Toolkit::Internal +{ +const char* const TextField::PropertyHandler::IMAGE_MAP_FILENAME_STRING{"filename"}; + +/// Retrieves a filename from a value that is a Property::Map +std::string TextField::PropertyHandler::GetImageFileNameFromPropertyValue(const Property::Value& value) +{ + std::string filename; + const Property::Map* map = value.GetMap(); + if(map) + { + const Property::Value* filenameValue = map->Find(TextField::PropertyHandler::IMAGE_MAP_FILENAME_STRING); + if(filenameValue) + { + filenameValue->Get(filename); + } + } + return filename; +} + +void TextField::PropertyHandler::SetProperty(Toolkit::TextField textField, Property::Index index, const Property::Value& value) +{ + TextField& impl(GetImpl(textField)); + DALI_ASSERT_DEBUG(impl.mController && "No text controller"); + DALI_ASSERT_DEBUG(impl.mDecorator && "No text decorator"); + + switch(index) + { + case Toolkit::DevelTextField::Property::RENDERING_BACKEND: + { + int backend = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p RENDERING_BACKEND %d\n", impl.mController.Get(), backend); + +#ifndef ENABLE_VECTOR_BASED_TEXT_RENDERING + if(DevelText::RENDERING_VECTOR_BASED == backend) + { + backend = TextAbstraction::BITMAP_GLYPH; // Fallback to bitmap-based rendering + } +#endif + if(impl.mRenderingBackend != backend) + { + impl.mRenderingBackend = backend; + impl.mRenderer.Reset(); + + // When using the vector-based rendering, the size of the GLyphs are different + TextAbstraction::GlyphType glyphType = (DevelText::RENDERING_VECTOR_BASED == impl.mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH; + impl.mController->SetGlyphType(glyphType); + } + break; + } + case Toolkit::TextField::Property::TEXT: + { + const std::string& text = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p TEXT %s\n", impl.mController.Get(), text.c_str()); + + impl.mController->SetText(text); + break; + } + + case Toolkit::TextField::Property::PLACEHOLDER_TEXT: + { + const std::string& text = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str()); + + impl.mController->SetPlaceholderText(Text::Controller::PLACEHOLDER_TYPE_INACTIVE, text); + break; + } + case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED: + { + const std::string& text = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_FOCUSED %s\n", impl.mController.Get(), text.c_str()); + + impl.mController->SetPlaceholderText(Text::Controller::PLACEHOLDER_TYPE_ACTIVE, text); + break; + } + case Toolkit::TextField::Property::FONT_FAMILY: + { + const std::string& fontFamily = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str()); + impl.mController->SetDefaultFontFamily(fontFamily); + break; + } + case Toolkit::TextField::Property::FONT_STYLE: + { + SetFontStyleProperty(impl.mController, value, Text::FontStyle::DEFAULT); + break; + } + case Toolkit::TextField::Property::POINT_SIZE: + { + const float pointSize = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p POINT_SIZE %f\n", impl.mController.Get(), pointSize); + + if(!Equals(impl.mController->GetDefaultFontSize(Text::Controller::POINT_SIZE), pointSize)) + { + impl.mController->SetDefaultFontSize(pointSize, Text::Controller::POINT_SIZE); + } + break; + } + case Toolkit::TextField::Property::MAX_LENGTH: + { + const int max = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p MAX_LENGTH %d\n", impl.mController.Get(), max); + + impl.mController->SetMaximumNumberOfCharacters(max); + break; + } + case Toolkit::TextField::Property::EXCEED_POLICY: + { + impl.mExceedPolicy = value.Get(); + + if(Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == impl.mExceedPolicy) + { + impl.EnableClipping(); + } + else + { + UnparentAndReset(impl.mStencil); + } + impl.RequestTextRelayout(); + break; + } + + case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT: + { + Text::HorizontalAlignment::Type alignment(static_cast(-1)); // Set to invalid value to ensure a valid mode does get set + if(Text::GetHorizontalAlignmentEnumeration(value, alignment)) + { + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p HORIZONTAL_ALIGNMENT %d\n", impl.mController.Get(), alignment); + impl.mController->SetHorizontalAlignment(alignment); + } + break; + } + case Toolkit::TextField::Property::VERTICAL_ALIGNMENT: + { + Toolkit::Text::VerticalAlignment::Type alignment(static_cast(-1)); // Set to invalid value to ensure a valid mode does get set + if(Text::GetVerticalAlignmentEnumeration(value, alignment)) + { + impl.mController->SetVerticalAlignment(alignment); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p VERTICAL_ALIGNMENT %d\n", impl.mController.Get(), alignment); + } + break; + } + case Toolkit::TextField::Property::TEXT_COLOR: + { + const Vector4& textColor = value.Get(); + 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); + + if(impl.mController->GetDefaultColor() != textColor) + { + impl.mController->SetDefaultColor(textColor); + impl.mController->SetInputColor(textColor); + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR: + { + const Vector4& textColor = value.Get(); + 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); + + if(impl.mController->GetPlaceholderTextColor() != textColor) + { + impl.mController->SetPlaceholderTextColor(textColor); + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR: + { + const Vector4& color = value.Get(); + 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); + + impl.mDecorator->SetCursorColor(Toolkit::Text::PRIMARY_CURSOR, color); + impl.RequestTextRelayout(); + break; + } + case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR: + { + const Vector4& color = value.Get(); + 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); + + impl.mDecorator->SetCursorColor(Toolkit::Text::SECONDARY_CURSOR, color); + impl.RequestTextRelayout(); + break; + } + case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK: + { + const bool enable = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p ENABLE_CURSOR_BLINK %d\n", impl.mController.Get(), enable); + + impl.mController->SetEnableCursorBlink(enable); + impl.RequestTextRelayout(); + break; + } + case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL: + { + const float interval = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_INTERVAL %f\n", impl.mController.Get(), interval); + + impl.mDecorator->SetCursorBlinkInterval(interval); + break; + } + case Toolkit::TextField::Property::CURSOR_BLINK_DURATION: + { + const float duration = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_DURATION %f\n", impl.mController.Get(), duration); + + impl.mDecorator->SetCursorBlinkDuration(duration); + break; + } + case Toolkit::TextField::Property::CURSOR_WIDTH: + { + const int width = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p CURSOR_WIDTH %d\n", impl.mController.Get(), width); + + impl.mDecorator->SetCursorWidth(width); + impl.mController->GetLayoutEngine().SetCursorWidth(width); + break; + } + case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE: + { + const std::string imageFileName = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str()); + + if(imageFileName.size()) + { + impl.mDecorator->SetHandleImage(Toolkit::Text::GRAB_HANDLE, Toolkit::Text::HANDLE_IMAGE_RELEASED, imageFileName); + impl.RequestTextRelayout(); + } + break; + } + case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE: + { + const std::string imageFileName = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_PRESSED_IMAGE %s\n", impl.mController.Get(), imageFileName.c_str()); + + if(imageFileName.size()) + { + impl.mDecorator->SetHandleImage(Toolkit::Text::GRAB_HANDLE, Toolkit::Text::HANDLE_IMAGE_PRESSED, imageFileName); + impl.RequestTextRelayout(); + } + break; + } + case Toolkit::TextField::Property::SCROLL_THRESHOLD: + { + const float threshold = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p SCROLL_THRESHOLD %f\n", impl.mController.Get(), threshold); + + impl.mDecorator->SetScrollThreshold(threshold); + break; + } + case Toolkit::TextField::Property::SCROLL_SPEED: + { + const float speed = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField %p SCROLL_SPEED %f\n", impl.mController.Get(), speed); + + impl.mDecorator->SetScrollSpeed(speed); + break; + } + case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT: + { + const std::string filename = GetImageFileNameFromPropertyValue(value); + + if(filename.size()) + { + impl.mDecorator->SetHandleImage(Toolkit::Text::LEFT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_RELEASED, filename); + impl.RequestTextRelayout(); + } + break; + } + case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT: + { + const std::string filename = GetImageFileNameFromPropertyValue(value); + + if(filename.size()) + { + impl.mDecorator->SetHandleImage(Toolkit::Text::RIGHT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_RELEASED, filename); + impl.RequestTextRelayout(); + } + break; + } + case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT: + { + const std::string filename = GetImageFileNameFromPropertyValue(value); + + if(filename.size()) + { + impl.mDecorator->SetHandleImage(Toolkit::Text::LEFT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_PRESSED, filename); + impl.RequestTextRelayout(); + } + break; + } + case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT: + { + const std::string filename = GetImageFileNameFromPropertyValue(value); + + if(filename.size()) + { + impl.mDecorator->SetHandleImage(Toolkit::Text::RIGHT_SELECTION_HANDLE, Toolkit::Text::HANDLE_IMAGE_PRESSED, filename); + impl.RequestTextRelayout(); + } + break; + } + case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT: + { + const std::string filename = GetImageFileNameFromPropertyValue(value); + + if(filename.size()) + { + impl.mDecorator->SetHandleImage(Toolkit::Text::LEFT_SELECTION_HANDLE_MARKER, + Toolkit::Text::HANDLE_IMAGE_RELEASED, + filename); + impl.RequestTextRelayout(); + } + break; + } + case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT: + { + const std::string filename = GetImageFileNameFromPropertyValue(value); + + if(filename.size()) + { + impl.mDecorator->SetHandleImage(Toolkit::Text::RIGHT_SELECTION_HANDLE_MARKER, + Toolkit::Text::HANDLE_IMAGE_RELEASED, + filename); + impl.RequestTextRelayout(); + } + break; + } + case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR: + { + const Vector4 color = value.Get(); + 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); + + impl.mDecorator->SetHighlightColor(color); + impl.RequestTextRelayout(); + break; + } + case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX: + { + const Rect& box = value.Get >(); + 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); + + impl.mDecorator->SetBoundingBox(box); + impl.RequestTextRelayout(); + break; + } + case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS: + { + const Property::Map* map = value.GetMap(); + if(map) + { + impl.mInputMethodOptions.ApplyProperty(*map); + } + impl.mController->SetInputModePassword(impl.mInputMethodOptions.IsPassword()); + + Toolkit::Control control = Toolkit::KeyInputFocusManager::Get().GetCurrentFocusControl(); + if(control == textField) + { + impl.mInputMethodContext.ApplyOptions(impl.mInputMethodOptions); + } + break; + } + case Toolkit::TextField::Property::INPUT_COLOR: + { + const Vector4& inputColor = value.Get(); + 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); + + impl.mController->SetInputColor(inputColor); + break; + } + case Toolkit::TextField::Property::ENABLE_MARKUP: + { + const bool enableMarkup = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p ENABLE_MARKUP %d\n", impl.mController.Get(), enableMarkup); + + impl.mController->SetMarkupProcessorEnabled(enableMarkup); + break; + } + case Toolkit::TextField::Property::INPUT_FONT_FAMILY: + { + const std::string& fontFamily = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p INPUT_FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str()); + impl.mController->SetInputFontFamily(fontFamily); + break; + } + case Toolkit::TextField::Property::INPUT_FONT_STYLE: + { + SetFontStyleProperty(impl.mController, value, Text::FontStyle::INPUT); + break; + } + case Toolkit::TextField::Property::INPUT_POINT_SIZE: + { + const float pointSize = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p INPUT_POINT_SIZE %f\n", impl.mController.Get(), pointSize); + impl.mController->SetInputFontPointSize(pointSize); + break; + } + case Toolkit::TextField::Property::UNDERLINE: + { + const bool update = SetUnderlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT); + if(update) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextField::Property::INPUT_UNDERLINE: + { + const bool update = SetUnderlineProperties(impl.mController, value, Text::EffectStyle::INPUT); + if(update) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextField::Property::SHADOW: + { + const bool update = SetShadowProperties(impl.mController, value, Text::EffectStyle::DEFAULT); + if(update) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextField::Property::INPUT_SHADOW: + { + const bool update = SetShadowProperties(impl.mController, value, Text::EffectStyle::INPUT); + if(update) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextField::Property::EMBOSS: + { + const bool update = SetEmbossProperties(impl.mController, value, Text::EffectStyle::DEFAULT); + if(update) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextField::Property::INPUT_EMBOSS: + { + const bool update = SetEmbossProperties(impl.mController, value, Text::EffectStyle::INPUT); + if(update) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextField::Property::OUTLINE: + { + const bool update = SetOutlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT); + if(update) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextField::Property::INPUT_OUTLINE: + { + const bool update = SetOutlineProperties(impl.mController, value, Text::EffectStyle::INPUT); + if(update) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS: + { + const Property::Map* map = value.GetMap(); + if(map) + { + impl.mController->SetHiddenInputOption(*map); + } + break; + } + case Toolkit::TextField::Property::PIXEL_SIZE: + { + const float pixelSize = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p PIXEL_SIZE %f\n", impl.mController.Get(), pixelSize); + + if(!Equals(impl.mController->GetDefaultFontSize(Text::Controller::PIXEL_SIZE), pixelSize)) + { + impl.mController->SetDefaultFontSize(pixelSize, Text::Controller::PIXEL_SIZE); + } + break; + } + case Toolkit::TextField::Property::ENABLE_SELECTION: + { + const bool enableSelection = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p ENABLE_SELECTION %d\n", impl.mController.Get(), enableSelection); + impl.mController->SetSelectionEnabled(enableSelection); + break; + } + case Toolkit::TextField::Property::PLACEHOLDER: + { + const Property::Map* map = value.GetMap(); + if(map) + { + impl.mController->SetPlaceholderProperty(*map); + } + break; + } + case Toolkit::TextField::Property::ELLIPSIS: + { + const bool ellipsis = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p ELLIPSIS %d\n", impl.mController.Get(), ellipsis); + + impl.mController->SetTextElideEnabled(ellipsis); + break; + } + case Toolkit::DevelTextField::Property::ENABLE_SHIFT_SELECTION: + { + const bool shiftSelection = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p ENABLE_SHIFT_SELECTION %d\n", impl.mController.Get(), shiftSelection); + + impl.mController->SetShiftSelectionEnabled(shiftSelection); + break; + } + case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE: + { + const bool grabHandleEnabled = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p ENABLE_GRAB_HANDLE %d\n", impl.mController.Get(), grabHandleEnabled); + + impl.mController->SetGrabHandleEnabled(grabHandleEnabled); + break; + } + case Toolkit::DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION: + { + impl.mController->SetMatchLayoutDirection(value.Get() ? DevelText::MatchLayoutDirection::LOCALE : DevelText::MatchLayoutDirection::CONTENTS); + break; + } + case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP: + { + const bool grabHandlePopupEnabled = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p ENABLE_GRAB_HANDLE_POPUP %d\n", impl.mController.Get(), grabHandlePopupEnabled); + + impl.mController->SetGrabHandlePopupEnabled(grabHandlePopupEnabled); + break; + } + case Toolkit::DevelTextField::Property::BACKGROUND: + { + const Vector4 backgroundColor = value.Get(); + 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); + + impl.mController->SetBackgroundEnabled(true); + impl.mController->SetBackgroundColor(backgroundColor); + break; + } + case Toolkit::DevelTextField::Property::SELECTED_TEXT_START: + { + uint32_t start = static_cast(value.Get()); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p SELECTED_TEXT_START %d\n", impl.mController.Get(), start); + impl.SetTextSelectionRange(&start, nullptr); + break; + } + case Toolkit::DevelTextField::Property::SELECTED_TEXT_END: + { + uint32_t end = static_cast(value.Get()); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p SELECTED_TEXT_END %d\n", impl.mController.Get(), end); + impl.SetTextSelectionRange(nullptr, &end); + break; + } + case Toolkit::DevelTextField::Property::ENABLE_EDITING: + { + const bool editable = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p ENABLE_EDITING %d\n", impl.mController.Get(), editable); + impl.SetEditable(editable); + break; + } + case Toolkit::DevelTextField::Property::FONT_SIZE_SCALE: + { + const float scale = value.Get(); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p FONT_SIZE_SCALE %f\n", impl.mController.Get(), scale); + + if(!Equals(impl.mController->GetFontSizeScale(), scale)) + { + impl.mController->SetFontSizeScale(scale); + } + break; + } + case Toolkit::DevelTextField::Property::PRIMARY_CURSOR_POSITION: + { + uint32_t position = static_cast(value.Get()); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p PRIMARY_CURSOR_POSITION %d\n", impl.mController.Get(), position); + if(impl.mController->SetPrimaryCursorPosition(position, impl.HasKeyInputFocus())) + { + impl.SetKeyInputFocus(); + } + break; + } + case Toolkit::DevelTextField::Property::GRAB_HANDLE_COLOR: + { + const Vector4 color = value.Get(); + 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); + + impl.mDecorator->SetHandleColor(color); + impl.RequestTextRelayout(); + break; + } + + case Toolkit::DevelTextField::Property::INPUT_FILTER: + { + const Property::Map* map = value.GetMap(); + if(map) + { + impl.mController->SetInputFilterOption(*map); + } + break; + } + case Toolkit::DevelTextField::Property::ELLIPSIS_POSITION: + { + DevelText::EllipsisPosition::Type ellipsisPositionType(static_cast(-1)); // Set to invalid value to ensure a valid mode does get set + if(Text::GetEllipsisPositionTypeEnumeration(value, ellipsisPositionType)) + { + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p EllipsisPosition::Type %d\n", impl.mController.Get(), ellipsisPositionType); + impl.mController->SetEllipsisPosition(ellipsisPositionType); + } + break; + } + } +} + +Property::Value TextField::PropertyHandler::GetProperty(Toolkit::TextField textField, Property::Index index) +{ + Property::Value value; + TextField& impl(GetImpl(textField)); + DALI_ASSERT_DEBUG(impl.mController && "No text controller"); + DALI_ASSERT_DEBUG(impl.mDecorator && "No text decorator"); + + switch(index) + { + case Toolkit::DevelTextField::Property::RENDERING_BACKEND: + { + value = impl.mRenderingBackend; + break; + } + case Toolkit::TextField::Property::TEXT: + { + std::string text; + impl.mController->GetText(text); + DALI_LOG_INFO(gTextFieldLogFilter, Debug::General, "TextField %p returning text: %s\n", impl.mController.Get(), text.c_str()); + value = text; + break; + } + case Toolkit::TextField::Property::PLACEHOLDER_TEXT: + { + std::string text; + impl.mController->GetPlaceholderText(Text::Controller::PLACEHOLDER_TYPE_INACTIVE, text); + value = text; + break; + } + case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED: + { + std::string text; + impl.mController->GetPlaceholderText(Text::Controller::PLACEHOLDER_TYPE_ACTIVE, text); + value = text; + break; + } + case Toolkit::TextField::Property::FONT_FAMILY: + { + value = impl.mController->GetDefaultFontFamily(); + break; + } + case Toolkit::TextField::Property::FONT_STYLE: + { + GetFontStyleProperty(impl.mController, value, Text::FontStyle::DEFAULT); + break; + } + case Toolkit::TextField::Property::POINT_SIZE: + { + value = impl.mController->GetDefaultFontSize(Text::Controller::POINT_SIZE); + break; + } + case Toolkit::TextField::Property::MAX_LENGTH: + { + value = impl.mController->GetMaximumNumberOfCharacters(); + break; + } + case Toolkit::TextField::Property::EXCEED_POLICY: + { + value = impl.mExceedPolicy; + break; + } + case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT: + { + const char* name = Text::GetHorizontalAlignmentString(impl.mController->GetHorizontalAlignment()); + if(name) + { + value = std::string(name); + } + break; + } + case Toolkit::TextField::Property::VERTICAL_ALIGNMENT: + { + const char* name = Text::GetVerticalAlignmentString(impl.mController->GetVerticalAlignment()); + + if(name) + { + value = std::string(name); + } + break; + } + case Toolkit::TextField::Property::TEXT_COLOR: + { + value = impl.mController->GetDefaultColor(); + break; + } + case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR: + { + value = impl.mController->GetPlaceholderTextColor(); + break; + } + case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR: + { + value = impl.mDecorator->GetColor(Text::PRIMARY_CURSOR); + break; + } + case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR: + { + value = impl.mDecorator->GetColor(Text::SECONDARY_CURSOR); + break; + } + case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK: + { + value = impl.mController->GetEnableCursorBlink(); + break; + } + case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL: + { + value = impl.mDecorator->GetCursorBlinkInterval(); + break; + } + case Toolkit::TextField::Property::CURSOR_BLINK_DURATION: + { + value = impl.mDecorator->GetCursorBlinkDuration(); + break; + } + case Toolkit::TextField::Property::CURSOR_WIDTH: + { + value = impl.mDecorator->GetCursorWidth(); + break; + } + case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE: + { + value = impl.mDecorator->GetHandleImage(Text::GRAB_HANDLE, Text::HANDLE_IMAGE_RELEASED); + break; + } + case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE: + { + value = impl.mDecorator->GetHandleImage(Text::GRAB_HANDLE, Text::HANDLE_IMAGE_PRESSED); + break; + } + case Toolkit::TextField::Property::SCROLL_THRESHOLD: + { + value = impl.mDecorator->GetScrollThreshold(); + break; + } + case Toolkit::TextField::Property::SCROLL_SPEED: + { + value = impl.mDecorator->GetScrollSpeed(); + break; + } + case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT: + { + impl.GetHandleImagePropertyValue(value, Text::LEFT_SELECTION_HANDLE, Text::HANDLE_IMAGE_RELEASED); + break; + } + case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT: + { + impl.GetHandleImagePropertyValue(value, Text::RIGHT_SELECTION_HANDLE, Text::HANDLE_IMAGE_RELEASED); + break; + } + case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT: + { + impl.GetHandleImagePropertyValue(value, Text::LEFT_SELECTION_HANDLE, Text::HANDLE_IMAGE_PRESSED); + break; + } + case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT: + { + impl.GetHandleImagePropertyValue(value, Text::RIGHT_SELECTION_HANDLE, Text::HANDLE_IMAGE_PRESSED); + break; + } + case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT: + { + impl.GetHandleImagePropertyValue(value, Text::LEFT_SELECTION_HANDLE_MARKER, Text::HANDLE_IMAGE_RELEASED); + break; + } + case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT: + { + impl.GetHandleImagePropertyValue(value, Text::RIGHT_SELECTION_HANDLE_MARKER, Text::HANDLE_IMAGE_RELEASED); + break; + } + case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR: + { + value = impl.mDecorator->GetHighlightColor(); + break; + } + case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX: + { + Rect boundingBox; + impl.mDecorator->GetBoundingBox(boundingBox); + value = boundingBox; + break; + } + case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS: + { + Property::Map map; + impl.mInputMethodOptions.RetrieveProperty(map); + value = map; + break; + } + case Toolkit::TextField::Property::INPUT_COLOR: + { + value = impl.mController->GetInputColor(); + break; + } + case Toolkit::TextField::Property::ENABLE_MARKUP: + { + value = impl.mController->IsMarkupProcessorEnabled(); + break; + } + case Toolkit::TextField::Property::INPUT_FONT_FAMILY: + { + value = impl.mController->GetInputFontFamily(); + break; + } + case Toolkit::TextField::Property::INPUT_FONT_STYLE: + { + GetFontStyleProperty(impl.mController, value, Text::FontStyle::INPUT); + break; + } + case Toolkit::TextField::Property::INPUT_POINT_SIZE: + { + value = impl.mController->GetInputFontPointSize(); + break; + } + case Toolkit::TextField::Property::UNDERLINE: + { + GetUnderlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT); + break; + } + case Toolkit::TextField::Property::INPUT_UNDERLINE: + { + GetUnderlineProperties(impl.mController, value, Text::EffectStyle::INPUT); + break; + } + case Toolkit::TextField::Property::SHADOW: + { + GetShadowProperties(impl.mController, value, Text::EffectStyle::DEFAULT); + break; + } + case Toolkit::TextField::Property::INPUT_SHADOW: + { + GetShadowProperties(impl.mController, value, Text::EffectStyle::INPUT); + break; + } + case Toolkit::TextField::Property::EMBOSS: + { + GetEmbossProperties(impl.mController, value, Text::EffectStyle::DEFAULT); + break; + } + case Toolkit::TextField::Property::INPUT_EMBOSS: + { + GetEmbossProperties(impl.mController, value, Text::EffectStyle::INPUT); + break; + } + case Toolkit::TextField::Property::OUTLINE: + { + GetOutlineProperties(impl.mController, value, Text::EffectStyle::DEFAULT); + break; + } + case Toolkit::TextField::Property::INPUT_OUTLINE: + { + GetOutlineProperties(impl.mController, value, Text::EffectStyle::INPUT); + break; + } + case Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS: + { + Property::Map map; + impl.mController->GetHiddenInputOption(map); + value = map; + break; + } + case Toolkit::TextField::Property::PIXEL_SIZE: + { + value = impl.mController->GetDefaultFontSize(Text::Controller::PIXEL_SIZE); + break; + } + case Toolkit::TextField::Property::ENABLE_SELECTION: + { + value = impl.mController->IsSelectionEnabled(); + break; + } + case Toolkit::TextField::Property::PLACEHOLDER: + { + Property::Map map; + impl.mController->GetPlaceholderProperty(map); + value = map; + break; + } + case Toolkit::TextField::Property::ELLIPSIS: + { + value = impl.mController->IsTextElideEnabled(); + break; + } + case Toolkit::DevelTextField::Property::ENABLE_SHIFT_SELECTION: + { + value = impl.mController->IsShiftSelectionEnabled(); + break; + } + case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE: + { + value = impl.mController->IsGrabHandleEnabled(); + break; + } + case Toolkit::DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION: + { + value = impl.mController->GetMatchLayoutDirection() != DevelText::MatchLayoutDirection::CONTENTS; + break; + } + case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP: + { + value = impl.mController->IsGrabHandlePopupEnabled(); + break; + } + case Toolkit::DevelTextField::Property::BACKGROUND: + { + value = impl.mController->GetBackgroundColor(); + break; + } + case Toolkit::DevelTextField::Property::SELECTED_TEXT: + { + value = impl.mController->GetSelectedText(); + break; + } + case Toolkit::DevelTextField::Property::SELECTED_TEXT_START: + { + Uint32Pair range = impl.GetTextSelectionRange(); + value = static_cast(range.first); + break; + } + case Toolkit::DevelTextField::Property::SELECTED_TEXT_END: + { + Uint32Pair range = impl.GetTextSelectionRange(); + value = static_cast(range.second); + break; + } + case Toolkit::DevelTextField::Property::ENABLE_EDITING: + { + value = impl.IsEditable(); + break; + } + case Toolkit::DevelTextField::Property::FONT_SIZE_SCALE: + { + value = impl.mController->GetFontSizeScale(); + break; + } + case Toolkit::DevelTextField::Property::PRIMARY_CURSOR_POSITION: + { + value = static_cast(impl.mController->GetPrimaryCursorPosition()); + break; + } + case Toolkit::DevelTextField::Property::GRAB_HANDLE_COLOR: + { + value = impl.mDecorator->GetHandleColor(); + break; + } + case Toolkit::DevelTextField::Property::INPUT_FILTER: + { + Property::Map map; + impl.mController->GetInputFilterOption(map); + value = map; + break; + } + case Toolkit::DevelTextField::Property::ELLIPSIS_POSITION: + { + value = impl.mController->GetEllipsisPosition(); + break; + } + } //switch + return value; +} + +} // namespace Dali::Toolkit::Internal diff --git a/dali-toolkit/internal/controls/text-controls/text-field-property-handler.h b/dali-toolkit/internal/controls/text-controls/text-field-property-handler.h new file mode 100644 index 0000000..f7b5c53 --- /dev/null +++ b/dali-toolkit/internal/controls/text-controls/text-field-property-handler.h @@ -0,0 +1,61 @@ +#ifndef DALI_TOOLKIT_INTERNAL_TEXT_FIELD_PROPERTY_HANDLER_H +#define DALI_TOOLKIT_INTERNAL_TEXT_FIELD_PROPERTY_HANDLER_H + +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +namespace Dali::Toolkit::Internal +{ +/** + * Class to manage properties for the TextField + */ +struct TextField::PropertyHandler +{ + static const char* const IMAGE_MAP_FILENAME_STRING; //<<< "filename" key for image map + + /** + * Set properties on the text field / controller / decorator + * + * @param[in] textField The handle for the text field + * @param[in] index The property index of the property to set + * @param[in] value The value to set + */ + static void SetProperty(Toolkit::TextField textField, Property::Index index, const Property::Value& value); + + /** + * Get properties from the text field / controller / decorator + * + * @param[in] textField The handle for the text field + * @param[in] index The property index of the property to set + * @return the value + */ + static Property::Value GetProperty(Toolkit::TextField textField, Property::Index index); + +private: + /** + * Method to extract "filename" value from a Property::Map + * + * @param[in] The property value containing the Property::Map + * @return The resulting "filename" value if present + */ + static std::string GetImageFileNameFromPropertyValue(const Property::Value& value); +}; + +} // namespace Dali::Toolkit::Internal + +#endif //DALI_TOOLKIT_INTERNAL_TEXT_FIELD_PROPERTY_HANDLER_H diff --git a/dali-toolkit/internal/file.list b/dali-toolkit/internal/file.list index 7fb8e01..e774545 100644 --- a/dali-toolkit/internal/file.list +++ b/dali-toolkit/internal/file.list @@ -100,8 +100,11 @@ SET( toolkit_src_files ${toolkit_src_dir}/controls/slider/slider-impl.cpp ${toolkit_src_dir}/controls/super-blur-view/super-blur-view-impl.cpp ${toolkit_src_dir}/controls/table-view/table-view-impl.cpp + ${toolkit_src_dir}/controls/text-controls/common-text-utils.cpp ${toolkit_src_dir}/controls/text-controls/text-editor-impl.cpp + ${toolkit_src_dir}/controls/text-controls/text-editor-property-handler.cpp ${toolkit_src_dir}/controls/text-controls/text-field-impl.cpp + ${toolkit_src_dir}/controls/text-controls/text-field-property-handler.cpp ${toolkit_src_dir}/controls/text-controls/text-label-impl.cpp ${toolkit_src_dir}/controls/text-controls/text-selection-popup-impl.cpp ${toolkit_src_dir}/controls/text-controls/text-selection-toolbar-impl.cpp