X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Ftext-controls%2Ftext-editor-impl.cpp;h=ea5f43c04a6eb37ab0713152db18a27b05654d21;hb=e4025736c4d5e85ab7408f9d6932cc7b3e9c9fef;hp=d9314015954637dedacc4ac57e1ebc48c73c199c;hpb=549e79b19f4d24588121f55739f9fc53e00fcdaf;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 d931401..ea5f43c 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -158,6 +159,8 @@ DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "strikethrough", DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "inputStrikethrough", MAP, INPUT_STRIKETHROUGH ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "characterSpacing", FLOAT, CHARACTER_SPACING ) 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_SIGNAL_REGISTRATION(Toolkit, TextEditor, "textChanged", SIGNAL_TEXT_CHANGED ) DALI_SIGNAL_REGISTRATION(Toolkit, TextEditor, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED ) @@ -230,10 +233,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); @@ -361,6 +364,26 @@ Vector TextEditor::GetTextPosition(const uint32_t startIndex, const uin return mController->GetTextPosition(startIndex, endIndex); } +Rect TextEditor::GetLineBoundingRectangle(const uint32_t lineIndex) const +{ + return mController->GetLineBoundingRectangle(lineIndex); +} + +Rect TextEditor::GetCharacterBoundingRectangle(const uint32_t charIndex) const +{ + return mController->GetCharacterBoundingRectangle(charIndex); +} + +int TextEditor::GetCharacterIndexAtPosition(float visualX, float visualY) const +{ + return mController->GetCharacterIndexAtPosition(visualX, visualY); +} + +void TextEditor::SetSpannedText(const Text::Spanned& spannedText) +{ + mController->SetSpannedText(spannedText); +} + string TextEditor::GetSelectedText() const { string selectedText = ""; @@ -582,9 +605,6 @@ void TextEditor::OnInitialize() self.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT); self.OnSceneSignal().Connect(this, &TextEditor::OnSceneConnect); - //Enable highightability - self.SetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, true); - DevelControl::SetInputMethodContext(*this, mInputMethodContext); // Creates an extra control to be used as stencil buffer. @@ -602,14 +622,19 @@ void TextEditor::OnInitialize() self.Add(mStencil); - DevelControl::SetAccessibilityConstructor(self, [](Dali::Actor actor) { - return std::make_unique(actor, Dali::Accessibility::Role::ENTRY); - }); + // Accessibility + self.SetProperty(DevelControl::Property::ACCESSIBILITY_ROLE, Dali::Accessibility::Role::ENTRY); + self.SetProperty(DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, true); Accessibility::Bridge::EnabledSignal().Connect(this, &TextEditor::OnAccessibilityStatusChanged); Accessibility::Bridge::DisabledSignal().Connect(this, &TextEditor::OnAccessibilityStatusChanged); } +DevelControl::ControlAccessible* TextEditor::CreateAccessibleObject() +{ + return new TextEditorAccessible(Self()); +} + void TextEditor::OnStyleChange(Toolkit::StyleManager styleManager, StyleChange::Type change) { DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor::OnStyleChange\n"); @@ -670,6 +695,31 @@ void TextEditor::ResizeActor(Actor& actor, const Vector2& size) } } +void TextEditor::OnPropertySet(Property::Index index, const Property::Value& propertyValue) +{ + DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor::OnPropertySet index[%d]\n", index); + + switch(index) + { + case DevelActor::Property::USER_INTERACTION_ENABLED: + { + const bool enabled = propertyValue.Get(); + mController->SetUserInteractionEnabled(enabled); + if(mStencil) + { + float opacity = enabled ? 1.0f : mController->GetDisabledColorOpacity(); + mStencil.SetProperty(Actor::Property::OPACITY, opacity); + } + break; + } + default: + { + Control::OnPropertySet(index, propertyValue); // up call to control for non-handled properties + break; + } + } +} + void TextEditor::OnRelayout(const Vector2& size, RelayoutContainer& container) { DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor OnRelayout\n"); @@ -774,7 +824,7 @@ void TextEditor::OnRelayout(const Vector2& size, RelayoutContainer& container) void TextEditor::RenderText(Text::Controller::UpdateTextType updateTextType) { - CommonTextUtils::RenderText(Self(), mRenderer, mController, mDecorator, mAlignmentOffset, mRenderableActor, mBackgroundActor, mStencil, mClippingDecorationActors, mAnchorActors, updateTextType); + CommonTextUtils::RenderText(Self(), mRenderer, mController, mDecorator, mAlignmentOffset, mRenderableActor, mBackgroundActor, mCursorLayer, mStencil, mClippingDecorationActors, mAnchorActors, updateTextType); if(mRenderableActor) { ApplyScrollPosition(); @@ -808,7 +858,10 @@ void TextEditor::OnKeyInputFocusGained() notifier.ContentSelectedSignal().Connect(this, &TextEditor::OnClipboardTextSelected); } - mController->KeyboardFocusGainEvent(); // Called in the case of no virtual keyboard to trigger this event + if(IsEditable() && mController->IsUserInteractionEnabled()) + { + mController->KeyboardFocusGainEvent(); // Called in the case of no virtual keyboard to trigger this event + } EmitKeyInputFocusSignal(true); // Calls back into the Control hence done last. } @@ -860,12 +913,21 @@ void TextEditor::OnTap(const TapGesture& gesture) mController->TapEvent(gesture.GetNumberOfTaps(), localPoint.x - padding.start, localPoint.y - padding.top); mController->AnchorEvent(localPoint.x - padding.start, localPoint.y - padding.top); + Dali::Toolkit::KeyboardFocusManager keyboardFocusManager = Dali::Toolkit::KeyboardFocusManager::Get(); + if(keyboardFocusManager) + { + keyboardFocusManager.SetCurrentFocusActor(Self()); + } SetKeyInputFocus(); } void TextEditor::OnPan(const PanGesture& gesture) { mController->PanEvent(gesture.GetState(), gesture.GetDisplacement()); + if(gesture.GetState() == GestureState::STARTED && !mController->IsScrollable(gesture.GetDisplacement())) + { + Dali::DevelActor::SetNeedGesturePropagation(Self(), true); + } } void TextEditor::OnLongPress(const LongPressGesture& gesture) @@ -891,6 +953,11 @@ bool TextEditor::OnKeyEvent(const KeyEvent& event) // Make sure ClearKeyInputFocus when only key is up if(event.GetState() == KeyEvent::UP) { + Dali::Toolkit::KeyboardFocusManager keyboardFocusManager = Dali::Toolkit::KeyboardFocusManager::Get(); + if(keyboardFocusManager) + { + keyboardFocusManager.ClearFocus(); + } ClearKeyInputFocus(); } @@ -907,26 +974,17 @@ void TextEditor::RequestTextRelayout() void TextEditor::TextInserted(unsigned int position, unsigned int length, const std::string& content) { - if(Accessibility::IsUp()) - { - Control::Impl::GetAccessibilityObject(Self())->EmitTextInserted(position, length, content); - } + GetAccessibleObject()->EmitTextInserted(position, length, content); } void TextEditor::TextDeleted(unsigned int position, unsigned int length, const std::string& content) { - if(Accessibility::IsUp()) - { - Control::Impl::GetAccessibilityObject(Self())->EmitTextDeleted(position, length, content); - } + GetAccessibleObject()->EmitTextDeleted(position, length, content); } void TextEditor::CursorPositionChanged(unsigned int oldPosition, unsigned int newPosition) { - if(Accessibility::IsUp()) - { - Control::Impl::GetAccessibilityObject(Self())->EmitTextCursorMoved(newPosition); - } + GetAccessibleObject()->EmitTextCursorMoved(newPosition); if((oldPosition != newPosition) && !mCursorPositionChanged) { @@ -1313,8 +1371,8 @@ void TextEditor::OnLayoutDirectionChanged(Actor actor, LayoutDirection::Type typ mController->ChangedLayoutDirection(); } -TextEditor::TextEditor() -: Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT)), +TextEditor::TextEditor(ControlBehaviour additionalBehaviour) +: Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT | additionalBehaviour)), mAnimationPeriod(0.0f, 0.0f), mIdleCallback(NULL), mAlignmentOffset(0.f),