From: junsu choi Date: Mon, 8 Nov 2021 05:45:50 +0000 (+0000) Subject: Merge "CanvasView: Do ApplyNativeFragmentShader for NativeImage buffer" into devel... X-Git-Tag: dali_2.0.52~4 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=e8a0d6cffda02a66a542fe89240fb41bc7c08215;hp=aef39596b8bcef74f7ae970bc48773cc20ca46fe Merge "CanvasView: Do ApplyNativeFragmentShader for NativeImage buffer" into devel/master --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Transition.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Transition.cpp index ef1eb2c..0ead710 100755 --- a/automated-tests/src/dali-toolkit/utc-Dali-Transition.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Transition.cpp @@ -24,6 +24,8 @@ #include #include #include +#include +#include using namespace Dali; using namespace Dali::Toolkit; @@ -1186,3 +1188,82 @@ int UtcDaliTransitionBetweenControlPairWithTreeWithoutScaleInheritance(void) END_TEST; } + + +int UtcDaliMultipleTransitionAppearing(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliMultipleTransitionAppearing"); + + Control control = Control::New(); + control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + control.SetProperty(Actor::Property::POSITION, Vector3(100, 200, 0)); + control.SetProperty(Actor::Property::SIZE, Vector3(150, 150, 0)); + Property::Map controlProperty; + controlProperty.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR); + controlProperty.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f)); + control.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty); + + application.GetScene().Add(control); + + application.SendNotification(); + application.Render(20); + + DALI_TEST_EQUALS(1.0f, control.GetCurrentProperty(Actor::Property::OPACITY), TEST_LOCATION); + + TransitionSet transitionSet = TransitionSet::New(); + FadeTransition fade = FadeTransition::New(control, 0.5, TimePeriod(1.0f, 1.0f)); + fade.SetAppearingTransition(true); // set fade in + transitionSet.AddTransition(fade); + SlideTransition slide = SlideTransition::New(control, Dali::Toolkit::SlideTransitionDirection::BOTTOM, TimePeriod(0.5f, 1.0f)); + slide.SetAppearingTransition(true); // set slide + transitionSet.AddTransition(slide); + transitionSet.Play(); + + bool signalReceived(false); + TransitionFinishCheck finishCheck(signalReceived); + transitionSet.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(300); + + float currentOpacity = control.GetCurrentProperty(Actor::Property::OPACITY); + DALI_TEST_CHECK(currentOpacity == 0.0f); + + application.SendNotification(); + application.Render(400); + + currentOpacity = control.GetCurrentProperty(Actor::Property::OPACITY); + DALI_TEST_CHECK(currentOpacity == 0.5f); + + application.SendNotification(); + application.Render(500); + + currentOpacity = control.GetCurrentProperty(Actor::Property::OPACITY); + DALI_TEST_CHECK(currentOpacity > 0.5f && currentOpacity < 1.0f); + + application.SendNotification(); + application.Render(500); + + currentOpacity = control.GetCurrentProperty(Actor::Property::OPACITY); + DALI_TEST_CHECK(currentOpacity > 0.5f && currentOpacity < 1.0f); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + application.SendNotification(); + application.Render(500); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + + application.SendNotification(); + application.Render(20); + + DALI_TEST_EQUALS(1.0f, control.GetCurrentProperty(Actor::Property::OPACITY), TEST_LOCATION); + + END_TEST; +} 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..3229006 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 @@ -156,6 +159,7 @@ SET( toolkit_src_files ${toolkit_src_dir}/text/text-controller-event-handler.cpp ${toolkit_src_dir}/text/text-controller-impl.cpp ${toolkit_src_dir}/text/text-controller-impl-event-handler.cpp + ${toolkit_src_dir}/text/text-controller-impl-model-updater.cpp ${toolkit_src_dir}/text/text-controller-input-font-handler.cpp ${toolkit_src_dir}/text/text-controller-placeholder-handler.cpp ${toolkit_src_dir}/text/text-controller-relayouter.cpp diff --git a/dali-toolkit/internal/text/text-controller-impl-model-updater.cpp b/dali-toolkit/internal/text/text-controller-impl-model-updater.cpp new file mode 100644 index 0000000..1ce7516 --- /dev/null +++ b/dali-toolkit/internal/text/text-controller-impl-model-updater.cpp @@ -0,0 +1,589 @@ +/* + * 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. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Dali::Toolkit::Text +{ + +namespace +{ +#if defined(DEBUG_ENABLED) +Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_CONTROLS"); +#endif + +// The relative luminance of a color is defined as (L = 0.2126 * R + 0.7152 * G + 0.0722 * B) +// based on W3C Recommendations (https://www.w3.org/TR/WCAG20/) +constexpr float BRIGHTNESS_THRESHOLD = 0.179f; +constexpr float CONSTANT_R = 0.2126f; +constexpr float CONSTANT_G = 0.7152f; +constexpr float CONSTANT_B = 0.0722f; +constexpr Dali::Vector4 BLACK(0.f, 0.f, 0.f, 1.f); +constexpr Dali::Vector4 WHITE(1.f, 1.f, 1.f, 1.f); +constexpr Dali::Vector4 LIGHT_BLUE(0.75f, 0.96f, 1.f, 1.f); +constexpr Dali::Vector4 BACKGROUND_SUB4(0.58f, 0.87f, 0.96f, 1.f); +constexpr Dali::Vector4 BACKGROUND_SUB5(0.83f, 0.94f, 0.98f, 1.f); +constexpr Dali::Vector4 BACKGROUND_SUB6(1.f, 0.5f, 0.5f, 1.f); +constexpr Dali::Vector4 BACKGROUND_SUB7(1.f, 0.8f, 0.8f, 1.f); +} // namespace + +bool ControllerImplModelUpdater::Update(Controller::Impl& impl, OperationsMask operationsRequired) +{ + DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::UpdateModel\n"); + + // Calculate the operations to be done. + const OperationsMask operations = static_cast(impl.mOperationsPending & operationsRequired); + + if(Controller::NO_OPERATION == operations) + { + // Nothing to do if no operations are pending and required. + return false; + } + + Vector& srcCharacters = impl.mModel->mLogicalModel->mText; + Vector displayCharacters; + bool useHiddenText = false; + if(impl.mHiddenInput && impl.mEventData != nullptr && !impl.mEventData->mIsShowingPlaceholderText) + { + impl.mHiddenInput->Substitute(srcCharacters, displayCharacters); + useHiddenText = true; + } + + Vector& utf32Characters = useHiddenText ? displayCharacters : srcCharacters; + const Length numberOfCharacters = utf32Characters.Count(); + + // Index to the first character of the first paragraph to be updated. + CharacterIndex startIndex = 0u; + // Number of characters of the paragraphs to be removed. + Length paragraphCharacters = 0u; + + impl.CalculateTextUpdateIndices(paragraphCharacters); + + // Check whether the indices for updating the text is valid + if(numberOfCharacters > 0u && + (impl.mTextUpdateInfo.mParagraphCharacterIndex > numberOfCharacters || + impl.mTextUpdateInfo.mRequestedNumberOfCharacters > numberOfCharacters)) + { + std::string currentText; + Utf32ToUtf8(impl.mModel->mLogicalModel->mText.Begin(), numberOfCharacters, currentText); + + DALI_LOG_ERROR("Controller::Impl::UpdateModel: mTextUpdateInfo has invalid indices\n"); + DALI_LOG_ERROR("Number of characters: %d, current text is: %s\n", numberOfCharacters, currentText.c_str()); + + // Dump mTextUpdateInfo + DALI_LOG_ERROR("Dump mTextUpdateInfo:\n"); + DALI_LOG_ERROR(" mTextUpdateInfo.mCharacterIndex = %u\n", impl.mTextUpdateInfo.mCharacterIndex); + DALI_LOG_ERROR(" mTextUpdateInfo.mNumberOfCharactersToRemove = %u\n", impl.mTextUpdateInfo.mNumberOfCharactersToRemove); + DALI_LOG_ERROR(" mTextUpdateInfo.mNumberOfCharactersToAdd = %u\n", impl.mTextUpdateInfo.mNumberOfCharactersToAdd); + DALI_LOG_ERROR(" mTextUpdateInfo.mPreviousNumberOfCharacters = %u\n", impl.mTextUpdateInfo.mPreviousNumberOfCharacters); + DALI_LOG_ERROR(" mTextUpdateInfo.mParagraphCharacterIndex = %u\n", impl.mTextUpdateInfo.mParagraphCharacterIndex); + DALI_LOG_ERROR(" mTextUpdateInfo.mRequestedNumberOfCharacters = %u\n", impl.mTextUpdateInfo.mRequestedNumberOfCharacters); + DALI_LOG_ERROR(" mTextUpdateInfo.mStartGlyphIndex = %u\n", impl.mTextUpdateInfo.mStartGlyphIndex); + DALI_LOG_ERROR(" mTextUpdateInfo.mStartLineIndex = %u\n", impl.mTextUpdateInfo.mStartLineIndex); + DALI_LOG_ERROR(" mTextUpdateInfo.mEstimatedNumberOfLines = %u\n", impl.mTextUpdateInfo.mEstimatedNumberOfLines); + DALI_LOG_ERROR(" mTextUpdateInfo.mClearAll = %d\n", impl.mTextUpdateInfo.mClearAll); + DALI_LOG_ERROR(" mTextUpdateInfo.mFullRelayoutNeeded = %d\n", impl.mTextUpdateInfo.mFullRelayoutNeeded); + DALI_LOG_ERROR(" mTextUpdateInfo.mIsLastCharacterNewParagraph = %d\n", impl.mTextUpdateInfo.mIsLastCharacterNewParagraph); + + return false; + } + + startIndex = impl.mTextUpdateInfo.mParagraphCharacterIndex; + + if(impl.mTextUpdateInfo.mClearAll || + (0u != paragraphCharacters)) + { + impl.ClearModelData(startIndex, startIndex + ((paragraphCharacters > 0u) ? paragraphCharacters - 1u : 0u), operations); + } + + impl.mTextUpdateInfo.mClearAll = false; + + // Whether the model is updated. + bool updated = false; + + Vector& lineBreakInfo = impl.mModel->mLogicalModel->mLineBreakInfo; + const Length requestedNumberOfCharacters = impl.mTextUpdateInfo.mRequestedNumberOfCharacters; + + if(Controller::NO_OPERATION != (Controller::GET_LINE_BREAKS & operations)) + { + // Retrieves the line break info. The line break info is used to split the text in 'paragraphs' to + // calculate the bidirectional info for each 'paragraph'. + // It's also used to layout the text (where it should be a new line) or to shape the text (text in different lines + // is not shaped together). + lineBreakInfo.Resize(numberOfCharacters, TextAbstraction::LINE_NO_BREAK); + + SetLineBreakInfo(utf32Characters, + startIndex, + requestedNumberOfCharacters, + lineBreakInfo); + + if(impl.mModel->mLineWrapMode == ((Text::LineWrap::Mode)DevelText::LineWrap::HYPHENATION) || + impl.mModel->mLineWrapMode == ((Text::LineWrap::Mode)DevelText::LineWrap::MIXED)) + { + CharacterIndex end = startIndex + requestedNumberOfCharacters; + LineBreakInfo* lineBreakInfoBuffer = lineBreakInfo.Begin(); + + for(CharacterIndex index = startIndex; index < end; index++) + { + CharacterIndex wordEnd = index; + while((*(lineBreakInfoBuffer + wordEnd) != TextAbstraction::LINE_ALLOW_BREAK) && (*(lineBreakInfoBuffer + wordEnd) != TextAbstraction::LINE_MUST_BREAK)) + { + wordEnd++; + } + + if((wordEnd + 1) == end) // add last char + { + wordEnd++; + } + + Vector hyphens = GetWordHyphens(utf32Characters.Begin() + index, wordEnd - index, nullptr); + + for(CharacterIndex i = 0; i < (wordEnd - index); i++) + { + if(hyphens[i]) + { + *(lineBreakInfoBuffer + index + i) = TextAbstraction::LINE_HYPHENATION_BREAK; + } + } + + index = wordEnd; + } + } + + // Create the paragraph info. + impl.mModel->mLogicalModel->CreateParagraphInfo(startIndex, + requestedNumberOfCharacters); + updated = true; + } + + const bool getScripts = Controller::NO_OPERATION != (Controller::GET_SCRIPTS & operations); + const bool validateFonts = Controller::NO_OPERATION != (Controller::VALIDATE_FONTS & operations); + + Vector& scripts = impl.mModel->mLogicalModel->mScriptRuns; + Vector& validFonts = impl.mModel->mLogicalModel->mFontRuns; + + if(getScripts || validateFonts) + { + // Validates the fonts assigned by the application or assigns default ones. + // It makes sure all the characters are going to be rendered by the correct font. + MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get(); + + if(getScripts) + { + // Retrieves the scripts used in the text. + multilanguageSupport.SetScripts(utf32Characters, + startIndex, + requestedNumberOfCharacters, + scripts); + } + + if(validateFonts) + { + // Validate the fonts set through the mark-up string. + Vector& fontDescriptionRuns = impl.mModel->mLogicalModel->mFontDescriptionRuns; + + // Get the default font's description. + TextAbstraction::FontDescription defaultFontDescription; + TextAbstraction::PointSize26Dot6 defaultPointSize = TextAbstraction::FontClient::DEFAULT_POINT_SIZE * impl.mFontSizeScale; + + //Get the number of points per one unit of point-size + uint32_t numberOfPointsPerOneUnitOfPointSize = impl.mFontClient.GetNumberOfPointsPerOneUnitOfPointSize(); + + if(impl.IsShowingPlaceholderText() && impl.mEventData && (nullptr != impl.mEventData->mPlaceholderFont)) + { + // If the placeholder font is set specifically, only placeholder font is changed. + defaultFontDescription = impl.mEventData->mPlaceholderFont->mFontDescription; + if(impl.mEventData->mPlaceholderFont->sizeDefined) + { + defaultPointSize = impl.mEventData->mPlaceholderFont->mDefaultPointSize * impl.mFontSizeScale * numberOfPointsPerOneUnitOfPointSize; + } + } + else if(nullptr != impl.mFontDefaults) + { + // Set the normal font and the placeholder font. + defaultFontDescription = impl.mFontDefaults->mFontDescription; + + if(impl.mTextFitEnabled) + { + defaultPointSize = impl.mFontDefaults->mFitPointSize * numberOfPointsPerOneUnitOfPointSize; + } + else + { + defaultPointSize = impl.mFontDefaults->mDefaultPointSize * impl.mFontSizeScale * numberOfPointsPerOneUnitOfPointSize; + } + } + + // Validates the fonts. If there is a character with no assigned font it sets a default one. + // After this call, fonts are validated. + multilanguageSupport.ValidateFonts(utf32Characters, + scripts, + fontDescriptionRuns, + defaultFontDescription, + defaultPointSize, + startIndex, + requestedNumberOfCharacters, + validFonts); + } + updated = true; + } + + Vector mirroredUtf32Characters; + bool textMirrored = false; + const Length numberOfParagraphs = impl.mModel->mLogicalModel->mParagraphInfo.Count(); + if(Controller::NO_OPERATION != (Controller::BIDI_INFO & operations)) + { + Vector& bidirectionalInfo = impl.mModel->mLogicalModel->mBidirectionalParagraphInfo; + bidirectionalInfo.Reserve(numberOfParagraphs); + + // Calculates the bidirectional info for the whole paragraph if it contains right to left scripts. + SetBidirectionalInfo(utf32Characters, + scripts, + lineBreakInfo, + startIndex, + requestedNumberOfCharacters, + bidirectionalInfo, + (impl.mModel->mMatchLayoutDirection != DevelText::MatchLayoutDirection::CONTENTS), + impl.mLayoutDirection); + + if(0u != bidirectionalInfo.Count()) + { + // Only set the character directions if there is right to left characters. + Vector& directions = impl.mModel->mLogicalModel->mCharacterDirections; + GetCharactersDirection(bidirectionalInfo, + numberOfCharacters, + startIndex, + requestedNumberOfCharacters, + directions); + + // This paragraph has right to left text. Some characters may need to be mirrored. + // TODO: consider if the mirrored string can be stored as well. + + textMirrored = GetMirroredText(utf32Characters, + directions, + bidirectionalInfo, + startIndex, + requestedNumberOfCharacters, + mirroredUtf32Characters); + } + else + { + // There is no right to left characters. Clear the directions vector. + impl.mModel->mLogicalModel->mCharacterDirections.Clear(); + } + updated = true; + } + + Vector& glyphs = impl.mModel->mVisualModel->mGlyphs; + Vector& glyphsToCharactersMap = impl.mModel->mVisualModel->mGlyphsToCharacters; + Vector& charactersPerGlyph = impl.mModel->mVisualModel->mCharactersPerGlyph; + Vector newParagraphGlyphs; + newParagraphGlyphs.Reserve(numberOfParagraphs); + + const Length currentNumberOfGlyphs = glyphs.Count(); + if(Controller::NO_OPERATION != (Controller::SHAPE_TEXT & operations)) + { + const Vector& textToShape = textMirrored ? mirroredUtf32Characters : utf32Characters; + // Shapes the text. + ShapeText(textToShape, + lineBreakInfo, + scripts, + validFonts, + startIndex, + impl.mTextUpdateInfo.mStartGlyphIndex, + requestedNumberOfCharacters, + glyphs, + glyphsToCharactersMap, + charactersPerGlyph, + newParagraphGlyphs); + + // Create the 'number of glyphs' per character and the glyph to character conversion tables. + impl.mModel->mVisualModel->CreateGlyphsPerCharacterTable(startIndex, impl.mTextUpdateInfo.mStartGlyphIndex, requestedNumberOfCharacters); + impl.mModel->mVisualModel->CreateCharacterToGlyphTable(startIndex, impl.mTextUpdateInfo.mStartGlyphIndex, requestedNumberOfCharacters); + + updated = true; + } + + const Length numberOfGlyphs = glyphs.Count() - currentNumberOfGlyphs; + + if(Controller::NO_OPERATION != (Controller::GET_GLYPH_METRICS & operations)) + { + GlyphInfo* glyphsBuffer = glyphs.Begin(); + impl.mMetrics->GetGlyphMetrics(glyphsBuffer + impl.mTextUpdateInfo.mStartGlyphIndex, numberOfGlyphs); + + // Update the width and advance of all new paragraph characters. + for(Vector::ConstIterator it = newParagraphGlyphs.Begin(), endIt = newParagraphGlyphs.End(); it != endIt; ++it) + { + const GlyphIndex index = *it; + GlyphInfo& glyph = *(glyphsBuffer + index); + + glyph.xBearing = 0.f; + glyph.width = 0.f; + glyph.advance = 0.f; + } + updated = true; + } + + if((nullptr != impl.mEventData) && + impl.mEventData->mPreEditFlag && + (0u != impl.mModel->mVisualModel->mCharactersToGlyph.Count())) + { + Dali::InputMethodContext::PreEditAttributeDataContainer attrs; + impl.mEventData->mInputMethodContext.GetPreeditStyle(attrs); + Dali::InputMethodContext::PreeditStyle type = Dali::InputMethodContext::PreeditStyle::NONE; + + // Check the type of preedit and run it. + for(Dali::InputMethodContext::PreEditAttributeDataContainer::Iterator it = attrs.Begin(), endIt = attrs.End(); it != endIt; it++) + { + Dali::InputMethodContext::PreeditAttributeData attrData = *it; + DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::UpdateModel PreeditStyle type : %d start %d end %d \n", attrData.preeditType, attrData.startIndex, attrData.endIndex); + type = attrData.preeditType; + + // Check the number of commit characters for the start position. + unsigned int numberOfCommit = impl.mEventData->mPrimaryCursorPosition - impl.mEventData->mPreEditLength; + Length numberOfIndices = attrData.endIndex - attrData.startIndex; + + switch(type) + { + case Dali::InputMethodContext::PreeditStyle::UNDERLINE: + { + // Add the underline for the pre-edit text. + GlyphRun underlineRun; + underlineRun.glyphIndex = attrData.startIndex + numberOfCommit; + underlineRun.numberOfGlyphs = numberOfIndices; + impl.mModel->mVisualModel->mUnderlineRuns.PushBack(underlineRun); + + //Mark-up processor case + if(impl.mModel->mVisualModel->IsMarkupProcessorEnabled()) + { + impl.CopyUnderlinedFromLogicalToVisualModels(false); + } + break; + } + case Dali::InputMethodContext::PreeditStyle::REVERSE: + { + Vector4 textColor = impl.mModel->mVisualModel->GetTextColor(); + ColorRun backgroundColorRun; + backgroundColorRun.characterRun.characterIndex = attrData.startIndex + numberOfCommit; + backgroundColorRun.characterRun.numberOfCharacters = numberOfIndices; + backgroundColorRun.color = textColor; + impl.mModel->mLogicalModel->mBackgroundColorRuns.PushBack(backgroundColorRun); + + Vector4 backgroundColor = impl.mModel->mVisualModel->GetBackgroundColor(); + if(backgroundColor.a == 0) // There is no text background color. + { + // Try use the control's background color. + if(nullptr != impl.mEditableControlInterface) + { + impl.mEditableControlInterface->GetControlBackgroundColor(backgroundColor); + if(backgroundColor.a == 0) // There is no control background color. + { + // Determines black or white color according to text color. + // Based on W3C Recommendations (https://www.w3.org/TR/WCAG20/) + float L = CONSTANT_R * textColor.r + CONSTANT_G * textColor.g + CONSTANT_B * textColor.b; + backgroundColor = L > BRIGHTNESS_THRESHOLD ? BLACK : WHITE; + } + } + } + + Vector colorRuns; + colorRuns.Resize(1u); + ColorRun& colorRun = *(colorRuns.Begin()); + colorRun.color = backgroundColor; + colorRun.characterRun.characterIndex = attrData.startIndex + numberOfCommit; + colorRun.characterRun.numberOfCharacters = numberOfIndices; + impl.mModel->mLogicalModel->mColorRuns.PushBack(colorRun); + + //Mark-up processor case + if(impl.mModel->mVisualModel->IsMarkupProcessorEnabled()) + { + impl.CopyUnderlinedFromLogicalToVisualModels(false); + } + break; + } + case Dali::InputMethodContext::PreeditStyle::HIGHLIGHT: + { + ColorRun backgroundColorRun; + backgroundColorRun.characterRun.characterIndex = attrData.startIndex + numberOfCommit; + backgroundColorRun.characterRun.numberOfCharacters = numberOfIndices; + backgroundColorRun.color = LIGHT_BLUE; + impl.mModel->mLogicalModel->mBackgroundColorRuns.PushBack(backgroundColorRun); + + //Mark-up processor case + if(impl.mModel->mVisualModel->IsMarkupProcessorEnabled()) + { + impl.CopyUnderlinedFromLogicalToVisualModels(false); + } + break; + } + case Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_1: + { + // CUSTOM_PLATFORM_STYLE_1 should be drawn with background and underline together. + ColorRun backgroundColorRun; + backgroundColorRun.characterRun.characterIndex = attrData.startIndex + numberOfCommit; + backgroundColorRun.characterRun.numberOfCharacters = numberOfIndices; + backgroundColorRun.color = BACKGROUND_SUB4; + impl.mModel->mLogicalModel->mBackgroundColorRuns.PushBack(backgroundColorRun); + + GlyphRun underlineRun; + underlineRun.glyphIndex = attrData.startIndex + numberOfCommit; + underlineRun.numberOfGlyphs = numberOfIndices; + impl.mModel->mVisualModel->mUnderlineRuns.PushBack(underlineRun); + + //Mark-up processor case + if(impl.mModel->mVisualModel->IsMarkupProcessorEnabled()) + { + impl.CopyUnderlinedFromLogicalToVisualModels(false); + } + break; + } + case Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_2: + { + // CUSTOM_PLATFORM_STYLE_2 should be drawn with background and underline together. + ColorRun backgroundColorRun; + backgroundColorRun.characterRun.characterIndex = attrData.startIndex + numberOfCommit; + backgroundColorRun.characterRun.numberOfCharacters = numberOfIndices; + backgroundColorRun.color = BACKGROUND_SUB5; + impl.mModel->mLogicalModel->mBackgroundColorRuns.PushBack(backgroundColorRun); + + GlyphRun underlineRun; + underlineRun.glyphIndex = attrData.startIndex + numberOfCommit; + underlineRun.numberOfGlyphs = numberOfIndices; + impl.mModel->mVisualModel->mUnderlineRuns.PushBack(underlineRun); + + //Mark-up processor case + if(impl.mModel->mVisualModel->IsMarkupProcessorEnabled()) + { + impl.CopyUnderlinedFromLogicalToVisualModels(false); + } + break; + } + case Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_3: + { + // CUSTOM_PLATFORM_STYLE_3 should be drawn with background and underline together. + ColorRun backgroundColorRun; + backgroundColorRun.characterRun.characterIndex = attrData.startIndex + numberOfCommit; + backgroundColorRun.characterRun.numberOfCharacters = numberOfIndices; + backgroundColorRun.color = BACKGROUND_SUB6; + impl.mModel->mLogicalModel->mBackgroundColorRuns.PushBack(backgroundColorRun); + + GlyphRun underlineRun; + underlineRun.glyphIndex = attrData.startIndex + numberOfCommit; + underlineRun.numberOfGlyphs = numberOfIndices; + impl.mModel->mVisualModel->mUnderlineRuns.PushBack(underlineRun); + + //Mark-up processor case + if(impl.mModel->mVisualModel->IsMarkupProcessorEnabled()) + { + impl.CopyUnderlinedFromLogicalToVisualModels(false); + } + break; + } + case Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_4: + { + // CUSTOM_PLATFORM_STYLE_4 should be drawn with background and underline together. + ColorRun backgroundColorRun; + backgroundColorRun.characterRun.characterIndex = attrData.startIndex + numberOfCommit; + backgroundColorRun.characterRun.numberOfCharacters = numberOfIndices; + backgroundColorRun.color = BACKGROUND_SUB7; + impl.mModel->mLogicalModel->mBackgroundColorRuns.PushBack(backgroundColorRun); + + GlyphRun underlineRun; + underlineRun.glyphIndex = attrData.startIndex + numberOfCommit; + underlineRun.numberOfGlyphs = numberOfIndices; + impl.mModel->mVisualModel->mUnderlineRuns.PushBack(underlineRun); + + //Mark-up processor case + if(impl.mModel->mVisualModel->IsMarkupProcessorEnabled()) + { + impl.CopyUnderlinedFromLogicalToVisualModels(false); + } + break; + } + case Dali::InputMethodContext::PreeditStyle::NONE: + default: + { + break; + } + } + } + attrs.Clear(); + updated = true; + } + + if(Controller::NO_OPERATION != (Controller::COLOR & operations)) + { + // Set the color runs in glyphs. + SetColorSegmentationInfo(impl.mModel->mLogicalModel->mColorRuns, + impl.mModel->mVisualModel->mCharactersToGlyph, + impl.mModel->mVisualModel->mGlyphsPerCharacter, + startIndex, + impl.mTextUpdateInfo.mStartGlyphIndex, + requestedNumberOfCharacters, + impl.mModel->mVisualModel->mColors, + impl.mModel->mVisualModel->mColorIndices); + + // Set the background color runs in glyphs. + SetColorSegmentationInfo(impl.mModel->mLogicalModel->mBackgroundColorRuns, + impl.mModel->mVisualModel->mCharactersToGlyph, + impl.mModel->mVisualModel->mGlyphsPerCharacter, + startIndex, + impl.mTextUpdateInfo.mStartGlyphIndex, + requestedNumberOfCharacters, + impl.mModel->mVisualModel->mBackgroundColors, + impl.mModel->mVisualModel->mBackgroundColorIndices); + + updated = true; + } + + if((Controller::NO_OPERATION != (Controller::SHAPE_TEXT & operations)) && + !((nullptr != impl.mEventData) && + impl.mEventData->mPreEditFlag && + (0u != impl.mModel->mVisualModel->mCharactersToGlyph.Count()))) + { + //Mark-up processor case + if(impl.mModel->mVisualModel->IsMarkupProcessorEnabled()) + { + impl.CopyUnderlinedFromLogicalToVisualModels(true); + } + + updated = true; + } + + // The estimated number of lines. Used to avoid reallocations when layouting. + impl.mTextUpdateInfo.mEstimatedNumberOfLines = std::max(impl.mModel->mVisualModel->mLines.Count(), impl.mModel->mLogicalModel->mParagraphInfo.Count()); + + // Set the previous number of characters for the next time the text is updated. + impl.mTextUpdateInfo.mPreviousNumberOfCharacters = numberOfCharacters; + + return updated; +} + +} // namespace Dali::Toolkit::Text diff --git a/dali-toolkit/internal/text/text-controller-impl-model-updater.h b/dali-toolkit/internal/text/text-controller-impl-model-updater.h new file mode 100644 index 0000000..2c5dd8c --- /dev/null +++ b/dali-toolkit/internal/text/text-controller-impl-model-updater.h @@ -0,0 +1,46 @@ +#ifndef DALI_TOOLKIT_TEXT_CONTROLLER_IMPL_MODEL_UPDATER_H +#define DALI_TOOLKIT_TEXT_CONTROLLER_IMPL_MODEL_UPDATER_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. + * + */ + +// INTERNAL INCLUDES +#include + +namespace Dali::Toolkit::Text +{ + +/** + * Contains methods for updating the models in the TextController + */ +struct ControllerImplModelUpdater +{ + using OperationsMask = Controller::OperationsMask; + + /** + * @brief Updates the logical and visual models. Updates the style runs in the visual model when the text's styles changes. + * + * @param[in] impl A reference to the Controller::Impl class + * @param[in] operationsRequired The operations required + * @return true if mode has been modified. + */ + static bool Update(Controller::Impl& impl, OperationsMask operationsRequired); +}; + +} // namespace Dali::Toolkit::Text + +#endif // DALI_TOOLKIT_TEXT_CONTROLLER_IMPL_MODEL_UPDATER_H diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index 045fb8a..4b05496 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -25,16 +25,11 @@ // INTERNAL INCLUDES #include #include -#include #include -#include #include -#include -#include -#include -#include #include #include +#include #include #include #include @@ -60,28 +55,82 @@ struct BackgroundMesh Vector mIndices; ///< container of indices }; -// The relative luminance of a color is defined as (L = 0.2126 * R + 0.7152 * G + 0.0722 * B) -// based on W3C Recommendations (https://www.w3.org/TR/WCAG20/) -const float BRIGHTNESS_THRESHOLD = 0.179f; -const float CONSTANT_R = 0.2126f; -const float CONSTANT_G = 0.7152f; -const float CONSTANT_B = 0.0722f; -const Dali::Vector4 BLACK(0.f, 0.f, 0.f, 1.f); -const Dali::Vector4 WHITE(1.f, 1.f, 1.f, 1.f); -const Dali::Vector4 LIGHT_BLUE(0.75f, 0.96f, 1.f, 1.f); -const Dali::Vector4 BACKGROUND_SUB4(0.58f, 0.87f, 0.96f, 1.f); -const Dali::Vector4 BACKGROUND_SUB5(0.83f, 0.94f, 0.98f, 1.f); -const Dali::Vector4 BACKGROUND_SUB6(1.f, 0.5f, 0.5f, 1.f); -const Dali::Vector4 BACKGROUND_SUB7(1.f, 0.8f, 0.8f, 1.f); - } // namespace -namespace Dali +namespace Dali::Toolkit::Text { -namespace Toolkit + +namespace { -namespace Text + +void SetDefaultInputStyle(InputStyle& inputStyle, const FontDefaults* const fontDefaults, const Vector4& textColor) { + // Sets the default text's color. + inputStyle.textColor = textColor; + inputStyle.isDefaultColor = true; + + inputStyle.familyName.clear(); + inputStyle.weight = TextAbstraction::FontWeight::NORMAL; + inputStyle.width = TextAbstraction::FontWidth::NORMAL; + inputStyle.slant = TextAbstraction::FontSlant::NORMAL; + inputStyle.size = 0.f; + + inputStyle.lineSpacing = 0.f; + + inputStyle.underlineProperties.clear(); + inputStyle.shadowProperties.clear(); + inputStyle.embossProperties.clear(); + inputStyle.outlineProperties.clear(); + + inputStyle.isFamilyDefined = false; + inputStyle.isWeightDefined = false; + inputStyle.isWidthDefined = false; + inputStyle.isSlantDefined = false; + inputStyle.isSizeDefined = false; + + inputStyle.isLineSpacingDefined = false; + + inputStyle.isUnderlineDefined = false; + inputStyle.isShadowDefined = false; + inputStyle.isEmbossDefined = false; + inputStyle.isOutlineDefined = false; + + // Sets the default font's family name, weight, width, slant and size. + if(fontDefaults) + { + if(fontDefaults->familyDefined) + { + inputStyle.familyName = fontDefaults->mFontDescription.family; + inputStyle.isFamilyDefined = true; + } + + if(fontDefaults->weightDefined) + { + inputStyle.weight = fontDefaults->mFontDescription.weight; + inputStyle.isWeightDefined = true; + } + + if(fontDefaults->widthDefined) + { + inputStyle.width = fontDefaults->mFontDescription.width; + inputStyle.isWidthDefined = true; + } + + if(fontDefaults->slantDefined) + { + inputStyle.slant = fontDefaults->mFontDescription.slant; + inputStyle.isSlantDefined = true; + } + + if(fontDefaults->sizeDefined) + { + inputStyle.size = fontDefaults->mDefaultPointSize; + inputStyle.isSizeDefined = true; + } + } +} +} // unnamed Namespace + EventData::EventData(DecoratorPtr decorator, InputMethodContext& inputMethodContext) : mDecorator(decorator), mInputMethodContext(inputMethodContext), @@ -588,600 +637,12 @@ void Controller::Impl::ClearModelData(CharacterIndex startIndex, CharacterIndex bool Controller::Impl::UpdateModel(OperationsMask operationsRequired) { - DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::UpdateModel\n"); - - // Calculate the operations to be done. - const OperationsMask operations = static_cast(mOperationsPending & operationsRequired); - - if(NO_OPERATION == operations) - { - // Nothing to do if no operations are pending and required. - return false; - } - - Vector& srcCharacters = mModel->mLogicalModel->mText; - Vector displayCharacters; - bool useHiddenText = false; - if(mHiddenInput && mEventData != nullptr && !mEventData->mIsShowingPlaceholderText) - { - mHiddenInput->Substitute(srcCharacters, displayCharacters); - useHiddenText = true; - } - - Vector& utf32Characters = useHiddenText ? displayCharacters : srcCharacters; - const Length numberOfCharacters = utf32Characters.Count(); - - // Index to the first character of the first paragraph to be updated. - CharacterIndex startIndex = 0u; - // Number of characters of the paragraphs to be removed. - Length paragraphCharacters = 0u; - - CalculateTextUpdateIndices(paragraphCharacters); - - // Check whether the indices for updating the text is valid - if(numberOfCharacters > 0u && - (mTextUpdateInfo.mParagraphCharacterIndex > numberOfCharacters || - mTextUpdateInfo.mRequestedNumberOfCharacters > numberOfCharacters)) - { - std::string currentText; - Utf32ToUtf8(mModel->mLogicalModel->mText.Begin(), numberOfCharacters, currentText); - - DALI_LOG_ERROR("Controller::Impl::UpdateModel: mTextUpdateInfo has invalid indices\n"); - DALI_LOG_ERROR("Number of characters: %d, current text is: %s\n", numberOfCharacters, currentText.c_str()); - - // Dump mTextUpdateInfo - DALI_LOG_ERROR("Dump mTextUpdateInfo:\n"); - DALI_LOG_ERROR(" mTextUpdateInfo.mCharacterIndex = %u\n", mTextUpdateInfo.mCharacterIndex); - DALI_LOG_ERROR(" mTextUpdateInfo.mNumberOfCharactersToRemove = %u\n", mTextUpdateInfo.mNumberOfCharactersToRemove); - DALI_LOG_ERROR(" mTextUpdateInfo.mNumberOfCharactersToAdd = %u\n", mTextUpdateInfo.mNumberOfCharactersToAdd); - DALI_LOG_ERROR(" mTextUpdateInfo.mPreviousNumberOfCharacters = %u\n", mTextUpdateInfo.mPreviousNumberOfCharacters); - DALI_LOG_ERROR(" mTextUpdateInfo.mParagraphCharacterIndex = %u\n", mTextUpdateInfo.mParagraphCharacterIndex); - DALI_LOG_ERROR(" mTextUpdateInfo.mRequestedNumberOfCharacters = %u\n", mTextUpdateInfo.mRequestedNumberOfCharacters); - DALI_LOG_ERROR(" mTextUpdateInfo.mStartGlyphIndex = %u\n", mTextUpdateInfo.mStartGlyphIndex); - DALI_LOG_ERROR(" mTextUpdateInfo.mStartLineIndex = %u\n", mTextUpdateInfo.mStartLineIndex); - DALI_LOG_ERROR(" mTextUpdateInfo.mEstimatedNumberOfLines = %u\n", mTextUpdateInfo.mEstimatedNumberOfLines); - DALI_LOG_ERROR(" mTextUpdateInfo.mClearAll = %d\n", mTextUpdateInfo.mClearAll); - DALI_LOG_ERROR(" mTextUpdateInfo.mFullRelayoutNeeded = %d\n", mTextUpdateInfo.mFullRelayoutNeeded); - DALI_LOG_ERROR(" mTextUpdateInfo.mIsLastCharacterNewParagraph = %d\n", mTextUpdateInfo.mIsLastCharacterNewParagraph); - - return false; - } - - startIndex = mTextUpdateInfo.mParagraphCharacterIndex; - - if(mTextUpdateInfo.mClearAll || - (0u != paragraphCharacters)) - { - ClearModelData(startIndex, startIndex + ((paragraphCharacters > 0u) ? paragraphCharacters - 1u : 0u), operations); - } - - mTextUpdateInfo.mClearAll = false; - - // Whether the model is updated. - bool updated = false; - - Vector& lineBreakInfo = mModel->mLogicalModel->mLineBreakInfo; - const Length requestedNumberOfCharacters = mTextUpdateInfo.mRequestedNumberOfCharacters; - - if(NO_OPERATION != (GET_LINE_BREAKS & operations)) - { - // Retrieves the line break info. The line break info is used to split the text in 'paragraphs' to - // calculate the bidirectional info for each 'paragraph'. - // It's also used to layout the text (where it should be a new line) or to shape the text (text in different lines - // is not shaped together). - lineBreakInfo.Resize(numberOfCharacters, TextAbstraction::LINE_NO_BREAK); - - SetLineBreakInfo(utf32Characters, - startIndex, - requestedNumberOfCharacters, - lineBreakInfo); - - if(mModel->mLineWrapMode == ((Text::LineWrap::Mode)DevelText::LineWrap::HYPHENATION) || - mModel->mLineWrapMode == ((Text::LineWrap::Mode)DevelText::LineWrap::MIXED)) - { - CharacterIndex end = startIndex + requestedNumberOfCharacters; - LineBreakInfo* lineBreakInfoBuffer = lineBreakInfo.Begin(); - - for(CharacterIndex index = startIndex; index < end; index++) - { - CharacterIndex wordEnd = index; - while((*(lineBreakInfoBuffer + wordEnd) != TextAbstraction::LINE_ALLOW_BREAK) && (*(lineBreakInfoBuffer + wordEnd) != TextAbstraction::LINE_MUST_BREAK)) - { - wordEnd++; - } - - if((wordEnd + 1) == end) // add last char - { - wordEnd++; - } - - Vector hyphens = GetWordHyphens(utf32Characters.Begin() + index, wordEnd - index, nullptr); - - for(CharacterIndex i = 0; i < (wordEnd - index); i++) - { - if(hyphens[i]) - { - *(lineBreakInfoBuffer + index + i) = TextAbstraction::LINE_HYPHENATION_BREAK; - } - } - - index = wordEnd; - } - } - - // Create the paragraph info. - mModel->mLogicalModel->CreateParagraphInfo(startIndex, - requestedNumberOfCharacters); - updated = true; - } - - const bool getScripts = NO_OPERATION != (GET_SCRIPTS & operations); - const bool validateFonts = NO_OPERATION != (VALIDATE_FONTS & operations); - - Vector& scripts = mModel->mLogicalModel->mScriptRuns; - Vector& validFonts = mModel->mLogicalModel->mFontRuns; - - if(getScripts || validateFonts) - { - // Validates the fonts assigned by the application or assigns default ones. - // It makes sure all the characters are going to be rendered by the correct font. - MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get(); - - if(getScripts) - { - // Retrieves the scripts used in the text. - multilanguageSupport.SetScripts(utf32Characters, - startIndex, - requestedNumberOfCharacters, - scripts); - } - - if(validateFonts) - { - // Validate the fonts set through the mark-up string. - Vector& fontDescriptionRuns = mModel->mLogicalModel->mFontDescriptionRuns; - - // Get the default font's description. - TextAbstraction::FontDescription defaultFontDescription; - TextAbstraction::PointSize26Dot6 defaultPointSize = TextAbstraction::FontClient::DEFAULT_POINT_SIZE * mFontSizeScale; - - //Get the number of points per one unit of point-size - uint32_t numberOfPointsPerOneUnitOfPointSize = mFontClient.GetNumberOfPointsPerOneUnitOfPointSize(); - - if(IsShowingPlaceholderText() && mEventData && (nullptr != mEventData->mPlaceholderFont)) - { - // If the placeholder font is set specifically, only placeholder font is changed. - defaultFontDescription = mEventData->mPlaceholderFont->mFontDescription; - if(mEventData->mPlaceholderFont->sizeDefined) - { - defaultPointSize = mEventData->mPlaceholderFont->mDefaultPointSize * mFontSizeScale * numberOfPointsPerOneUnitOfPointSize; - } - } - else if(nullptr != mFontDefaults) - { - // Set the normal font and the placeholder font. - defaultFontDescription = mFontDefaults->mFontDescription; - - if(mTextFitEnabled) - { - defaultPointSize = mFontDefaults->mFitPointSize * numberOfPointsPerOneUnitOfPointSize; - } - else - { - defaultPointSize = mFontDefaults->mDefaultPointSize * mFontSizeScale * numberOfPointsPerOneUnitOfPointSize; - } - } - - // Validates the fonts. If there is a character with no assigned font it sets a default one. - // After this call, fonts are validated. - multilanguageSupport.ValidateFonts(utf32Characters, - scripts, - fontDescriptionRuns, - defaultFontDescription, - defaultPointSize, - startIndex, - requestedNumberOfCharacters, - validFonts); - } - updated = true; - } - - Vector mirroredUtf32Characters; - bool textMirrored = false; - const Length numberOfParagraphs = mModel->mLogicalModel->mParagraphInfo.Count(); - if(NO_OPERATION != (BIDI_INFO & operations)) - { - Vector& bidirectionalInfo = mModel->mLogicalModel->mBidirectionalParagraphInfo; - bidirectionalInfo.Reserve(numberOfParagraphs); - - // Calculates the bidirectional info for the whole paragraph if it contains right to left scripts. - SetBidirectionalInfo(utf32Characters, - scripts, - lineBreakInfo, - startIndex, - requestedNumberOfCharacters, - bidirectionalInfo, - (mModel->mMatchLayoutDirection != DevelText::MatchLayoutDirection::CONTENTS), - mLayoutDirection); - - if(0u != bidirectionalInfo.Count()) - { - // Only set the character directions if there is right to left characters. - Vector& directions = mModel->mLogicalModel->mCharacterDirections; - GetCharactersDirection(bidirectionalInfo, - numberOfCharacters, - startIndex, - requestedNumberOfCharacters, - directions); - - // This paragraph has right to left text. Some characters may need to be mirrored. - // TODO: consider if the mirrored string can be stored as well. - - textMirrored = GetMirroredText(utf32Characters, - directions, - bidirectionalInfo, - startIndex, - requestedNumberOfCharacters, - mirroredUtf32Characters); - } - else - { - // There is no right to left characters. Clear the directions vector. - mModel->mLogicalModel->mCharacterDirections.Clear(); - } - updated = true; - } - - Vector& glyphs = mModel->mVisualModel->mGlyphs; - Vector& glyphsToCharactersMap = mModel->mVisualModel->mGlyphsToCharacters; - Vector& charactersPerGlyph = mModel->mVisualModel->mCharactersPerGlyph; - Vector newParagraphGlyphs; - newParagraphGlyphs.Reserve(numberOfParagraphs); - - const Length currentNumberOfGlyphs = glyphs.Count(); - if(NO_OPERATION != (SHAPE_TEXT & operations)) - { - const Vector& textToShape = textMirrored ? mirroredUtf32Characters : utf32Characters; - // Shapes the text. - ShapeText(textToShape, - lineBreakInfo, - scripts, - validFonts, - startIndex, - mTextUpdateInfo.mStartGlyphIndex, - requestedNumberOfCharacters, - glyphs, - glyphsToCharactersMap, - charactersPerGlyph, - newParagraphGlyphs); - - // Create the 'number of glyphs' per character and the glyph to character conversion tables. - mModel->mVisualModel->CreateGlyphsPerCharacterTable(startIndex, mTextUpdateInfo.mStartGlyphIndex, requestedNumberOfCharacters); - mModel->mVisualModel->CreateCharacterToGlyphTable(startIndex, mTextUpdateInfo.mStartGlyphIndex, requestedNumberOfCharacters); - - updated = true; - } - - const Length numberOfGlyphs = glyphs.Count() - currentNumberOfGlyphs; - - if(NO_OPERATION != (GET_GLYPH_METRICS & operations)) - { - GlyphInfo* glyphsBuffer = glyphs.Begin(); - mMetrics->GetGlyphMetrics(glyphsBuffer + mTextUpdateInfo.mStartGlyphIndex, numberOfGlyphs); - - // Update the width and advance of all new paragraph characters. - for(Vector::ConstIterator it = newParagraphGlyphs.Begin(), endIt = newParagraphGlyphs.End(); it != endIt; ++it) - { - const GlyphIndex index = *it; - GlyphInfo& glyph = *(glyphsBuffer + index); - - glyph.xBearing = 0.f; - glyph.width = 0.f; - glyph.advance = 0.f; - } - updated = true; - } - - if((nullptr != mEventData) && - mEventData->mPreEditFlag && - (0u != mModel->mVisualModel->mCharactersToGlyph.Count())) - { - Dali::InputMethodContext::PreEditAttributeDataContainer attrs; - mEventData->mInputMethodContext.GetPreeditStyle(attrs); - Dali::InputMethodContext::PreeditStyle type = Dali::InputMethodContext::PreeditStyle::NONE; - - // Check the type of preedit and run it. - for(Dali::InputMethodContext::PreEditAttributeDataContainer::Iterator it = attrs.Begin(), endIt = attrs.End(); it != endIt; it++) - { - Dali::InputMethodContext::PreeditAttributeData attrData = *it; - DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::UpdateModel PreeditStyle type : %d start %d end %d \n", attrData.preeditType, attrData.startIndex, attrData.endIndex); - type = attrData.preeditType; - - // Check the number of commit characters for the start position. - unsigned int numberOfCommit = mEventData->mPrimaryCursorPosition - mEventData->mPreEditLength; - Length numberOfIndices = attrData.endIndex - attrData.startIndex; - - switch(type) - { - case Dali::InputMethodContext::PreeditStyle::UNDERLINE: - { - // Add the underline for the pre-edit text. - GlyphRun underlineRun; - underlineRun.glyphIndex = attrData.startIndex + numberOfCommit; - underlineRun.numberOfGlyphs = numberOfIndices; - mModel->mVisualModel->mUnderlineRuns.PushBack(underlineRun); - - //Mark-up processor case - if(mModel->mVisualModel->IsMarkupProcessorEnabled()) - { - CopyUnderlinedFromLogicalToVisualModels(false); - } - break; - } - case Dali::InputMethodContext::PreeditStyle::REVERSE: - { - Vector4 textColor = mModel->mVisualModel->GetTextColor(); - ColorRun backgroundColorRun; - backgroundColorRun.characterRun.characterIndex = attrData.startIndex + numberOfCommit; - backgroundColorRun.characterRun.numberOfCharacters = numberOfIndices; - backgroundColorRun.color = textColor; - mModel->mLogicalModel->mBackgroundColorRuns.PushBack(backgroundColorRun); - - Vector4 backgroundColor = mModel->mVisualModel->GetBackgroundColor(); - if(backgroundColor.a == 0) // There is no text background color. - { - // Try use the control's background color. - if(nullptr != mEditableControlInterface) - { - mEditableControlInterface->GetControlBackgroundColor(backgroundColor); - if(backgroundColor.a == 0) // There is no control background color. - { - // Determines black or white color according to text color. - // Based on W3C Recommendations (https://www.w3.org/TR/WCAG20/) - float L = CONSTANT_R * textColor.r + CONSTANT_G * textColor.g + CONSTANT_B * textColor.b; - backgroundColor = L > BRIGHTNESS_THRESHOLD ? BLACK : WHITE; - } - } - } - - Vector colorRuns; - colorRuns.Resize(1u); - ColorRun& colorRun = *(colorRuns.Begin()); - colorRun.color = backgroundColor; - colorRun.characterRun.characterIndex = attrData.startIndex + numberOfCommit; - colorRun.characterRun.numberOfCharacters = numberOfIndices; - mModel->mLogicalModel->mColorRuns.PushBack(colorRun); - - //Mark-up processor case - if(mModel->mVisualModel->IsMarkupProcessorEnabled()) - { - CopyUnderlinedFromLogicalToVisualModels(false); - } - break; - } - case Dali::InputMethodContext::PreeditStyle::HIGHLIGHT: - { - ColorRun backgroundColorRun; - backgroundColorRun.characterRun.characterIndex = attrData.startIndex + numberOfCommit; - backgroundColorRun.characterRun.numberOfCharacters = numberOfIndices; - backgroundColorRun.color = LIGHT_BLUE; - mModel->mLogicalModel->mBackgroundColorRuns.PushBack(backgroundColorRun); - - //Mark-up processor case - if(mModel->mVisualModel->IsMarkupProcessorEnabled()) - { - CopyUnderlinedFromLogicalToVisualModels(false); - } - break; - } - case Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_1: - { - // CUSTOM_PLATFORM_STYLE_1 should be drawn with background and underline together. - ColorRun backgroundColorRun; - backgroundColorRun.characterRun.characterIndex = attrData.startIndex + numberOfCommit; - backgroundColorRun.characterRun.numberOfCharacters = numberOfIndices; - backgroundColorRun.color = BACKGROUND_SUB4; - mModel->mLogicalModel->mBackgroundColorRuns.PushBack(backgroundColorRun); - - GlyphRun underlineRun; - underlineRun.glyphIndex = attrData.startIndex + numberOfCommit; - underlineRun.numberOfGlyphs = numberOfIndices; - mModel->mVisualModel->mUnderlineRuns.PushBack(underlineRun); - - //Mark-up processor case - if(mModel->mVisualModel->IsMarkupProcessorEnabled()) - { - CopyUnderlinedFromLogicalToVisualModels(false); - } - break; - } - case Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_2: - { - // CUSTOM_PLATFORM_STYLE_2 should be drawn with background and underline together. - ColorRun backgroundColorRun; - backgroundColorRun.characterRun.characterIndex = attrData.startIndex + numberOfCommit; - backgroundColorRun.characterRun.numberOfCharacters = numberOfIndices; - backgroundColorRun.color = BACKGROUND_SUB5; - mModel->mLogicalModel->mBackgroundColorRuns.PushBack(backgroundColorRun); - - GlyphRun underlineRun; - underlineRun.glyphIndex = attrData.startIndex + numberOfCommit; - underlineRun.numberOfGlyphs = numberOfIndices; - mModel->mVisualModel->mUnderlineRuns.PushBack(underlineRun); - - //Mark-up processor case - if(mModel->mVisualModel->IsMarkupProcessorEnabled()) - { - CopyUnderlinedFromLogicalToVisualModels(false); - } - break; - } - case Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_3: - { - // CUSTOM_PLATFORM_STYLE_3 should be drawn with background and underline together. - ColorRun backgroundColorRun; - backgroundColorRun.characterRun.characterIndex = attrData.startIndex + numberOfCommit; - backgroundColorRun.characterRun.numberOfCharacters = numberOfIndices; - backgroundColorRun.color = BACKGROUND_SUB6; - mModel->mLogicalModel->mBackgroundColorRuns.PushBack(backgroundColorRun); - - GlyphRun underlineRun; - underlineRun.glyphIndex = attrData.startIndex + numberOfCommit; - underlineRun.numberOfGlyphs = numberOfIndices; - mModel->mVisualModel->mUnderlineRuns.PushBack(underlineRun); - - //Mark-up processor case - if(mModel->mVisualModel->IsMarkupProcessorEnabled()) - { - CopyUnderlinedFromLogicalToVisualModels(false); - } - break; - } - case Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_4: - { - // CUSTOM_PLATFORM_STYLE_4 should be drawn with background and underline together. - ColorRun backgroundColorRun; - backgroundColorRun.characterRun.characterIndex = attrData.startIndex + numberOfCommit; - backgroundColorRun.characterRun.numberOfCharacters = numberOfIndices; - backgroundColorRun.color = BACKGROUND_SUB7; - mModel->mLogicalModel->mBackgroundColorRuns.PushBack(backgroundColorRun); - - GlyphRun underlineRun; - underlineRun.glyphIndex = attrData.startIndex + numberOfCommit; - underlineRun.numberOfGlyphs = numberOfIndices; - mModel->mVisualModel->mUnderlineRuns.PushBack(underlineRun); - - //Mark-up processor case - if(mModel->mVisualModel->IsMarkupProcessorEnabled()) - { - CopyUnderlinedFromLogicalToVisualModels(false); - } - break; - } - case Dali::InputMethodContext::PreeditStyle::NONE: - default: - { - break; - } - } - } - attrs.Clear(); - updated = true; - } - - if(NO_OPERATION != (COLOR & operations)) - { - // Set the color runs in glyphs. - SetColorSegmentationInfo(mModel->mLogicalModel->mColorRuns, - mModel->mVisualModel->mCharactersToGlyph, - mModel->mVisualModel->mGlyphsPerCharacter, - startIndex, - mTextUpdateInfo.mStartGlyphIndex, - requestedNumberOfCharacters, - mModel->mVisualModel->mColors, - mModel->mVisualModel->mColorIndices); - - // Set the background color runs in glyphs. - SetColorSegmentationInfo(mModel->mLogicalModel->mBackgroundColorRuns, - mModel->mVisualModel->mCharactersToGlyph, - mModel->mVisualModel->mGlyphsPerCharacter, - startIndex, - mTextUpdateInfo.mStartGlyphIndex, - requestedNumberOfCharacters, - mModel->mVisualModel->mBackgroundColors, - mModel->mVisualModel->mBackgroundColorIndices); - - updated = true; - } - - if((NO_OPERATION != (SHAPE_TEXT & operations)) && - !((nullptr != mEventData) && - mEventData->mPreEditFlag && - (0u != mModel->mVisualModel->mCharactersToGlyph.Count()))) - { - //Mark-up processor case - if(mModel->mVisualModel->IsMarkupProcessorEnabled()) - { - CopyUnderlinedFromLogicalToVisualModels(true); - } - - updated = true; - } - - // The estimated number of lines. Used to avoid reallocations when layouting. - mTextUpdateInfo.mEstimatedNumberOfLines = std::max(mModel->mVisualModel->mLines.Count(), mModel->mLogicalModel->mParagraphInfo.Count()); - - // Set the previous number of characters for the next time the text is updated. - mTextUpdateInfo.mPreviousNumberOfCharacters = numberOfCharacters; - - return updated; + return ControllerImplModelUpdater::Update(*this, operationsRequired); } void Controller::Impl::RetrieveDefaultInputStyle(InputStyle& inputStyle) { - // Sets the default text's color. - inputStyle.textColor = mTextColor; - inputStyle.isDefaultColor = true; - - inputStyle.familyName.clear(); - inputStyle.weight = TextAbstraction::FontWeight::NORMAL; - inputStyle.width = TextAbstraction::FontWidth::NORMAL; - inputStyle.slant = TextAbstraction::FontSlant::NORMAL; - inputStyle.size = 0.f; - - inputStyle.lineSpacing = 0.f; - - inputStyle.underlineProperties.clear(); - inputStyle.shadowProperties.clear(); - inputStyle.embossProperties.clear(); - inputStyle.outlineProperties.clear(); - - inputStyle.isFamilyDefined = false; - inputStyle.isWeightDefined = false; - inputStyle.isWidthDefined = false; - inputStyle.isSlantDefined = false; - inputStyle.isSizeDefined = false; - - inputStyle.isLineSpacingDefined = false; - - inputStyle.isUnderlineDefined = false; - inputStyle.isShadowDefined = false; - inputStyle.isEmbossDefined = false; - inputStyle.isOutlineDefined = false; - - // Sets the default font's family name, weight, width, slant and size. - if(mFontDefaults) - { - if(mFontDefaults->familyDefined) - { - inputStyle.familyName = mFontDefaults->mFontDescription.family; - inputStyle.isFamilyDefined = true; - } - - if(mFontDefaults->weightDefined) - { - inputStyle.weight = mFontDefaults->mFontDescription.weight; - inputStyle.isWeightDefined = true; - } - - if(mFontDefaults->widthDefined) - { - inputStyle.width = mFontDefaults->mFontDescription.width; - inputStyle.isWidthDefined = true; - } - - if(mFontDefaults->slantDefined) - { - inputStyle.slant = mFontDefaults->mFontDescription.slant; - inputStyle.isSlantDefined = true; - } - - if(mFontDefaults->sizeDefined) - { - inputStyle.size = mFontDefaults->mDefaultPointSize; - inputStyle.isSizeDefined = true; - } - } + SetDefaultInputStyle(inputStyle, mFontDefaults, mTextColor); } float Controller::Impl::GetDefaultFontLineHeight() @@ -2297,8 +1758,4 @@ void Controller::Impl::CopyUnderlinedFromLogicalToVisualModels(bool shouldClearP } } -} // namespace Text - -} // namespace Toolkit - -} // namespace Dali +} // namespace Dali::Toolkit::Text diff --git a/dali-toolkit/internal/text/text-controller-impl.h b/dali-toolkit/internal/text/text-controller-impl.h index 02fbff8..0c6297f 100644 --- a/dali-toolkit/internal/text/text-controller-impl.h +++ b/dali-toolkit/internal/text/text-controller-impl.h @@ -46,6 +46,7 @@ const float DEFAULT_FONT_SIZE_SCALE = 1.f; struct CursorInfo; struct FontDefaults; struct ControllerImplEventHandler; +struct ControllerImplModelUpdater; struct SelectionHandleController; class SelectableControlInterface; @@ -845,6 +846,7 @@ public: private: friend ControllerImplEventHandler; + friend ControllerImplModelUpdater; friend SelectionHandleController; }; diff --git a/dali-toolkit/internal/transition/transition-base-impl.cpp b/dali-toolkit/internal/transition/transition-base-impl.cpp index f8aed47..5ee926e 100644 --- a/dali-toolkit/internal/transition/transition-base-impl.cpp +++ b/dali-toolkit/internal/transition/transition-base-impl.cpp @@ -208,22 +208,18 @@ void TransitionBase::SetAnimation() return; } - // If this transition is not a transition from a Control to another Control - // and a transition effect to appear with delay, - // the mTarget should not be shown until delay seconds. - if(!IsPairTransition() && mIsAppearingTransition && mAnimation && mTimePeriod.delaySeconds > Dali::Math::MACHINE_EPSILON_10) - { - Dali::KeyFrames initialKeyframes = Dali::KeyFrames::New(); - initialKeyframes.Add(0.0f, OPACITY_TRANSPARENT); - initialKeyframes.Add(1.0f, OPACITY_TRANSPARENT); - mAnimation.AnimateBetween(Property(mTarget, Dali::Actor::Property::OPACITY), initialKeyframes, TimePeriod(mTimePeriod.delaySeconds)); - } - for(uint32_t i = 0; i < mStartPropertyMap.Count(); ++i) { Property::Value* finishValue = mFinishPropertyMap.Find(mStartPropertyMap.GetKeyAt(i).indexKey); if(finishValue) { + // If this transition is appearing transition, this property keeps start value during delay. + // If multiple transitions are applied to this Control and others run before this transition, + // this property should keep start value until this transition starts. + if(!IsPairTransition() && IsAppearingTransition() && mTimePeriod.delaySeconds > Dali::Math::MACHINE_EPSILON_10) + { + mTarget.SetProperty(mStartPropertyMap.GetKeyAt(i).indexKey, mStartPropertyMap.GetValue(i)); + } AnimateBetween(mTarget, mStartPropertyMap.GetKeyAt(i).indexKey, mStartPropertyMap.GetValue(i), *finishValue); } } diff --git a/dali-toolkit/internal/transition/transition-base-impl.h b/dali-toolkit/internal/transition/transition-base-impl.h index 409eb60..b194e52 100644 --- a/dali-toolkit/internal/transition/transition-base-impl.h +++ b/dali-toolkit/internal/transition/transition-base-impl.h @@ -101,6 +101,30 @@ public: mIsAppearingTransition = appearingTransition; } + /** + * @brief Returns whether this transition is appearing transition or not + */ + bool IsAppearingTransition() const + { + return mIsAppearingTransition; + } + + /** + * @brief Returns whether this transition is a transition from a Control to another Control or effect to appearing or disappearing. + */ + bool IsPairTransition() const + { + return mIsPairTransition; + } + + /** + * @brief Returns target which will be transition. + */ + const Dali::Toolkit::Control GetTarget() const + { + return mTarget; + } + protected: /** @@ -159,14 +183,6 @@ protected: } /** - * @brief Returns whether this transition is appearing transition or not - */ - bool IsAppearingTransition() const - { - return mIsAppearingTransition; - } - - /** * @brief Set whether this transition is a transition from a Control to another Control or effect to appearing or disappearing. * @param[in] pairTransition True if this transition is appearing transition. */ @@ -175,14 +191,6 @@ protected: mIsPairTransition = pairTransition; } - /** - * @brief Returns whether this transition is a transition from a Control to another Control or effect to appearing or disappearing. - */ - bool IsPairTransition() const - { - return mIsPairTransition; - } - protected: /** * Construct a new TransitionBase. diff --git a/dali-toolkit/internal/transition/transition-set-impl.cpp b/dali-toolkit/internal/transition/transition-set-impl.cpp index fd019b6..d1b16af 100644 --- a/dali-toolkit/internal/transition/transition-set-impl.cpp +++ b/dali-toolkit/internal/transition/transition-set-impl.cpp @@ -37,6 +37,13 @@ namespace // Signals static constexpr std::string_view SIGNAL_FINISHED = "finished"; +static constexpr float OPACITY_TRANSPARENT = 0.0f; + +float CustomAlphaFunction(float progress) +{ + return (progress >= 1.0f) ? 1.0f : 0.0f; +} + BaseHandle Create() { return Dali::Toolkit::TransitionSet::New(); @@ -117,9 +124,46 @@ void TransitionSet::TransitionPreProcess() void TransitionSet::TransitionStart() { + std::vector> minimumDelays; for(auto&& transition : mTransitions) { transition->Play(); + + // If target Control has appearing transition, the target will not be rendered during delay. + // And if the Control has multiple transitions, the target will not be rendered during minimum delay of the transitions. + // Here we can find minimum delay of each target. + if(!transition->IsPairTransition() && transition->IsAppearingTransition()) + { + bool found = false; + for(uint32_t index = 0; index < minimumDelays.size(); ++index) + { + if(minimumDelays[index].first == transition->GetTarget()) + { + minimumDelays[index].second = std::min(minimumDelays[index].second, transition->GetTimePeriod().delaySeconds); + found = true; + break; + } + } + if(!found) + { + minimumDelays.push_back(std::pair(transition->GetTarget(), transition->GetTimePeriod().delaySeconds)); + } + } + } + + // If the target has delay that is larger than 0, hide the target during minimum delay. + // The custom alpha function make the target hide just during delay. + for(auto&& delay : minimumDelays) + { + if(delay.second > Dali::Math::MACHINE_EPSILON_10) + { + Dali::KeyFrames initialKeyframes = Dali::KeyFrames::New(); + initialKeyframes.Add(0.0f, OPACITY_TRANSPARENT); + initialKeyframes.Add(1.0f, delay.first.GetProperty(Dali::Actor::Property::OPACITY)); + + AlphaFunction alpha(&CustomAlphaFunction); + mAnimation.AnimateBetween(Property(delay.first, Dali::Actor::Property::OPACITY), initialKeyframes, alpha, TimePeriod(delay.second)); + } } mAnimation.FinishedSignal().Connect(this, &TransitionSet::TransitionFinished); diff --git a/dali-toolkit/internal/visuals/text/text-visual.cpp b/dali-toolkit/internal/visuals/text/text-visual.cpp index 19ecb5c..a4903c5 100644 --- a/dali-toolkit/internal/visuals/text/text-visual.cpp +++ b/dali-toolkit/internal/visuals/text/text-visual.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include // INTERNAL HEADER @@ -240,6 +239,7 @@ TextVisual::TextVisual(VisualFactoryCache& factoryCache) mController(Text::Controller::New()), mTypesetter(Text::Typesetter::New(mController->GetTextModel())), mAnimatableTextColorPropertyIndex(Property::INVALID_INDEX), + mTextColorAnimatableIndex(Property::INVALID_INDEX), mRendererUpdateNeeded(false) { } @@ -291,23 +291,36 @@ void TextVisual::DoSetOnScene(Actor& actor) // Enable the pre-multiplied alpha to improve the text quality EnablePreMultipliedAlpha(true); - const Vector4& defaultColor = mController->GetTextModel()->GetDefaultColor(); - Dali::Property::Index shaderTextColorIndex = mImpl->mRenderer.RegisterProperty("uTextColorAnimatable", defaultColor); + const Vector4& defaultColor = mController->GetTextModel()->GetDefaultColor(); + if(mTextColorAnimatableIndex == Property::INVALID_INDEX) + { + mTextColorAnimatableIndex = mImpl->mRenderer.RegisterProperty("uTextColorAnimatable", defaultColor); + } + else + { + mImpl->mRenderer.SetProperty(mTextColorAnimatableIndex, defaultColor); + } if(mAnimatableTextColorPropertyIndex != Property::INVALID_INDEX) { // Create constraint for the animatable text's color Property with uTextColorAnimatable in the renderer. - if(shaderTextColorIndex != Property::INVALID_INDEX) + if(mTextColorAnimatableIndex != Property::INVALID_INDEX) { - Constraint colorConstraint = Constraint::New(mImpl->mRenderer, shaderTextColorIndex, TextColorConstraint); - colorConstraint.AddSource(Source(actor, mAnimatableTextColorPropertyIndex)); - colorConstraint.Apply(); - - // Make zero if the alpha value of text color is zero to skip rendering text - Constraint opacityConstraint = Constraint::New(mImpl->mRenderer, Dali::DevelRenderer::Property::OPACITY, OpacityConstraint); - opacityConstraint.AddSource(Source(actor, mAnimatableTextColorPropertyIndex)); - opacityConstraint.Apply(); + if(!mColorConstraint) + { + mColorConstraint = Constraint::New(mImpl->mRenderer, mTextColorAnimatableIndex, TextColorConstraint); + mColorConstraint.AddSource(Source(actor, mAnimatableTextColorPropertyIndex)); + } + mColorConstraint.Apply(); } + + // Make zero if the alpha value of text color is zero to skip rendering text + if(!mOpacityConstraint) + { + mOpacityConstraint = Constraint::New(mImpl->mRenderer, Dali::DevelRenderer::Property::OPACITY, OpacityConstraint); + mOpacityConstraint.AddSource(Source(actor, mAnimatableTextColorPropertyIndex)); + } + mOpacityConstraint.Apply(); } // Renderer needs textures and to be added to control @@ -335,6 +348,15 @@ void TextVisual::RemoveRenderer(Actor& actor) void TextVisual::DoSetOffScene(Actor& actor) { + if(mColorConstraint) + { + mColorConstraint.Remove(); + } + if(mOpacityConstraint) + { + mOpacityConstraint.Remove(); + } + RemoveRenderer(actor); // Resets the control handle. diff --git a/dali-toolkit/internal/visuals/text/text-visual.h b/dali-toolkit/internal/visuals/text/text-visual.h index 7ae5e4e..f9d6c79 100644 --- a/dali-toolkit/internal/visuals/text/text-visual.h +++ b/dali-toolkit/internal/visuals/text/text-visual.h @@ -19,6 +19,7 @@ */ // EXTERNAL INCLUDES +#include #include #include @@ -332,7 +333,10 @@ private: Text::ControllerPtr mController; ///< The text's controller. Text::TypesetterPtr mTypesetter; ///< The text's typesetter. WeakHandle mControl; ///< The control where the renderer is added. + Constraint mColorConstraint{}; ///< Color constraint + Constraint mOpacityConstraint{}; ///< Opacity constraint Property::Index mAnimatableTextColorPropertyIndex; ///< The index of animatable text color property registered by the control. + Property::Index mTextColorAnimatableIndex; ///< The index of uTextColorAnimatable property. bool mRendererUpdateNeeded : 1; ///< The flag to indicate whether the renderer needs to be updated. RendererContainer mRendererList; }; diff --git a/dali-toolkit/public-api/dali-toolkit-version.cpp b/dali-toolkit/public-api/dali-toolkit-version.cpp index 65c85c0..520ffcf 100644 --- a/dali-toolkit/public-api/dali-toolkit-version.cpp +++ b/dali-toolkit/public-api/dali-toolkit-version.cpp @@ -29,7 +29,7 @@ namespace Toolkit { const unsigned int TOOLKIT_MAJOR_VERSION = 2; const unsigned int TOOLKIT_MINOR_VERSION = 0; -const unsigned int TOOLKIT_MICRO_VERSION = 50; +const unsigned int TOOLKIT_MICRO_VERSION = 51; const char* const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__; #ifdef DEBUG_ENABLED diff --git a/packaging/dali-toolkit.spec b/packaging/dali-toolkit.spec index 2b96025..c572142 100644 --- a/packaging/dali-toolkit.spec +++ b/packaging/dali-toolkit.spec @@ -1,6 +1,6 @@ Name: dali2-toolkit Summary: Dali 3D engine Toolkit -Version: 2.0.50 +Version: 2.0.51 Release: 1 Group: System/Libraries License: Apache-2.0 and BSD-3-Clause and MIT