X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Ftext-controls%2Ftext-editor-impl.cpp;h=9b9e7d99624f1db746c07866997b97618bd80534;hb=HEAD;hp=8520498820706b251efa42090b2130eca84c2845;hpb=8bb7e3b2a7ae71aba865d5d552a767a7889fd4ee;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git 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 8520498..43a5884 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -161,6 +162,8 @@ DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "characterSpacin DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "relativeLineSize", FLOAT, RELATIVE_LINE_SIZE ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "verticalAlignment", STRING, VERTICAL_ALIGNMENT ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "selectionPopupStyle", MAP, SELECTION_POPUP_STYLE ) +DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "removeFrontInset", BOOLEAN, REMOVE_FRONT_INSET ) +DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "removeBackInset", BOOLEAN, REMOVE_BACK_INSET ) DALI_SIGNAL_REGISTRATION(Toolkit, TextEditor, "textChanged", SIGNAL_TEXT_CHANGED ) DALI_SIGNAL_REGISTRATION(Toolkit, TextEditor, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED ) @@ -233,10 +236,10 @@ Toolkit::TextEditor::InputStyle::Mask ConvertInputStyle(Text::InputStyle::Mask i } // namespace -Toolkit::TextEditor TextEditor::New() +Toolkit::TextEditor TextEditor::New(ControlBehaviour additionalBehaviour) { // Create the implementation, temporarily owned by this handle on stack - IntrusivePtr impl = new TextEditor(); + IntrusivePtr impl = new TextEditor(additionalBehaviour); // Pass ownership to CustomActor handle Toolkit::TextEditor handle(*impl); @@ -374,6 +377,16 @@ Rect TextEditor::GetCharacterBoundingRectangle(const uint32_t charIndex) return mController->GetCharacterBoundingRectangle(charIndex); } +int TextEditor::GetCharacterIndexAtPosition(float visualX, float visualY) const +{ + return mController->GetCharacterIndexAtPosition(visualX, visualY); +} + +Rect<> TextEditor::GetTextBoundingRectangle(uint32_t startIndex, uint32_t endIndex) const +{ + return mController->GetTextBoundingRectangle(startIndex, endIndex); +} + void TextEditor::SetSpannedText(const Text::Spanned& spannedText) { mController->SetSpannedText(spannedText); @@ -606,6 +619,7 @@ void TextEditor::OnInitialize() mStencil = Control::New(); mStencil.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); mStencil.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + mStencil.SetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN, true); // Creates a background visual. Even if the color is transparent it updates the stencil. mStencil.SetProperty(Toolkit::Control::Property::BACKGROUND, @@ -746,7 +760,9 @@ void TextEditor::OnRelayout(const Vector2& size, RelayoutContainer& container) } if(mCursorLayer) { - mCursorLayer.SetProperty(Actor::Property::POSITION, Vector2(padding.start, padding.top)); + // The cursor layer is added to the stencil in RenderText. + // Do not calculate the position because the stencil has already been resized excluding the padding size. + // There is no case where the text editor does not have a stencil. ResizeActor(mCursorLayer, contentSize); } @@ -766,7 +782,7 @@ void TextEditor::OnRelayout(const Vector2& size, RelayoutContainer& container) if(mDecorator && (Text::Controller::NONE_UPDATED != (Text::Controller::DECORATOR_UPDATED & updateTextType))) { - mDecorator->Relayout(contentSize); + mDecorator->Relayout(contentSize, container); } if(!mRenderer) @@ -803,17 +819,7 @@ void TextEditor::OnRelayout(const Vector2& size, RelayoutContainer& container) // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation. if(!mController->IsInputStyleChangedSignalsQueueEmpty()) { - if(Adaptor::IsAvailable()) - { - Adaptor& adaptor = Adaptor::Get(); - - if(NULL == mIdleCallback) - { - // @note: The callback manager takes the ownership of the callback object. - mIdleCallback = MakeCallback(this, &TextEditor::OnIdleSignal); - adaptor.AddIdle(mIdleCallback, false); - } - } + mController->RequestProcessInputStyleChangedSignals(); } } @@ -846,12 +852,6 @@ void TextEditor::OnKeyInputFocusGained() // When window gain lost focus, the InputMethodContext is deactivated. Thus when window gain focus again, the InputMethodContext must be activated. mInputMethodContext.SetRestoreAfterFocusLost(true); } - ClipboardEventNotifier notifier(ClipboardEventNotifier::Get()); - - if(notifier) - { - notifier.ContentSelectedSignal().Connect(this, &TextEditor::OnClipboardTextSelected); - } if(IsEditable() && mController->IsUserInteractionEnabled()) { @@ -876,12 +876,6 @@ void TextEditor::OnKeyInputFocusLost() mInputMethodContext.EventReceivedSignal().Disconnect(this, &TextEditor::OnInputMethodContextEvent); } - ClipboardEventNotifier notifier(ClipboardEventNotifier::Get()); - - if(notifier) - { - notifier.ContentSelectedSignal().Disconnect(this, &TextEditor::OnClipboardTextSelected); - } mController->KeyboardFocusLostEvent(); @@ -969,17 +963,29 @@ void TextEditor::RequestTextRelayout() void TextEditor::TextInserted(unsigned int position, unsigned int length, const std::string& content) { - GetAccessibleObject()->EmitTextInserted(position, length, content); + auto accessible = GetAccessibleObject(); + if(DALI_LIKELY(accessible) && accessible->IsHighlighted()) + { + accessible->EmitTextInserted(position, length, content); + } } void TextEditor::TextDeleted(unsigned int position, unsigned int length, const std::string& content) { - GetAccessibleObject()->EmitTextDeleted(position, length, content); + auto accessible = GetAccessibleObject(); + if(DALI_LIKELY(accessible) && accessible->IsHighlighted()) + { + accessible->EmitTextDeleted(position, length, content); + } } void TextEditor::CursorPositionChanged(unsigned int oldPosition, unsigned int newPosition) { - GetAccessibleObject()->EmitTextCursorMoved(newPosition); + auto accessible = GetAccessibleObject(); + if(DALI_LIKELY(accessible) && accessible->IsHighlighted()) + { + accessible->EmitTextCursorMoved(newPosition); + } if((oldPosition != newPosition) && !mCursorPositionChanged) { @@ -1237,7 +1243,7 @@ void TextEditor::UpdateScrollBar() void TextEditor::OnScrollIndicatorAnimationFinished(Animation& animation) { // If animation is successfully ended, then emit ScrollStateChangedSignal - if(animation.GetCurrentProgress() == 0.0f) + if(Dali::EqualsZero(animation.GetCurrentProgress())) { mScrollStarted = false; Dali::Toolkit::TextEditor handle(GetOwner()); @@ -1274,11 +1280,6 @@ void TextEditor::GetHandleImagePropertyValue(Property::Value& value, Text::Handl } } -void TextEditor::OnClipboardTextSelected(ClipboardEventNotifier& clipboard) -{ - mController->PasteClipboardItemEvent(); -} - void TextEditor::KeyboardStatusChanged(bool keyboardShown) { DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor::KeyboardStatusChanged %p keyboardShown %d\n", mController.Get(), keyboardShown); @@ -1310,15 +1311,6 @@ bool TextEditor::OnTouched(Actor actor, const TouchEvent& touch) return false; } -void TextEditor::OnIdleSignal() -{ - // Emits the change of input style signals. - mController->ProcessInputStyleChangedSignals(); - - // Set the pointer to null as the callback manager deletes the callback after execute it. - mIdleCallback = NULL; -} - void TextEditor::ApplyScrollPosition() { const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition(); @@ -1366,10 +1358,29 @@ void TextEditor::OnLayoutDirectionChanged(Actor actor, LayoutDirection::Type typ mController->ChangedLayoutDirection(); } -TextEditor::TextEditor() -: Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT)), +void TextEditor::SetRemoveFrontInset(bool remove) +{ + mController->SetRemoveFrontInset(remove); +} + +bool TextEditor::IsRemoveFrontInset() const +{ + return mController->IsRemoveFrontInset(); +} + +void TextEditor::SetRemoveBackInset(bool remove) +{ + mController->SetRemoveBackInset(remove); +} + +bool TextEditor::IsRemoveBackInset() const +{ + return mController->IsRemoveBackInset(); +} + +TextEditor::TextEditor(ControlBehaviour additionalBehaviour) +: Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT | additionalBehaviour)), mAnimationPeriod(0.0f, 0.0f), - mIdleCallback(NULL), mAlignmentOffset(0.f), mScrollAnimationDuration(0.f), mLineSpacing(0.f), @@ -1392,12 +1403,6 @@ TextEditor::TextEditor() TextEditor::~TextEditor() { UnparentAndReset(mStencil); - - if((NULL != mIdleCallback) && Adaptor::IsAvailable()) - { - // Removes the callback from the callback manager in case the text-editor is destroyed before the callback is executed. - Adaptor::Get().RemoveIdle(mIdleCallback); - } } std::string TextEditor::TextEditorAccessible::GetName() const