X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-controller-impl-event-handler.cpp;h=f8aa7a59ed7e55e971c665b497a4ffd431494c76;hp=29f6ba358de9d75fabb98abe133c63e64ab16620;hb=094ca4278df850c7870382c3896476a1bd1c9b7b;hpb=ec503e92aa01bc67f8ea118cf14aa3b1ed9d390e diff --git a/dali-toolkit/internal/text/text-controller-impl-event-handler.cpp b/dali-toolkit/internal/text/text-controller-impl-event-handler.cpp index 29f6ba3..f8aa7a5 100644 --- a/dali-toolkit/internal/text/text-controller-impl-event-handler.cpp +++ b/dali-toolkit/internal/text/text-controller-impl-event-handler.cpp @@ -104,6 +104,11 @@ bool ControllerImplEventHandler::ProcessInputEvents(Controller::Impl& impl) OnSelectNoneEvent(impl); break; } + case Event::SELECT_RANGE: + { + OnSelectRangeEvent(impl, *iter); + break; + } } } } @@ -124,7 +129,7 @@ bool ControllerImplEventHandler::ProcessInputEvents(Controller::Impl& impl) if(nullptr != impl.mEditableControlInterface) { - impl.mEditableControlInterface->CaretMoved(eventData->mPrimaryCursorPosition); + impl.mEditableControlInterface->CursorMoved(eventData->mPrimaryCursorPosition); } if(eventData->mUpdateCursorHookPosition) @@ -333,7 +338,7 @@ void ControllerImplEventHandler::OnCursorKeyEvent(Controller::Impl& impl, const const LineRun& line = *(visualModel->mLines.Begin() + previousLineIndex); // Get the next hit 'y' point. - const float hitPointY = cursorInfo.lineOffset - 0.5f * (line.ascender - line.descender); + const float hitPointY = cursorInfo.lineOffset - 0.5f * GetLineHeight(line); // Use the cursor hook position 'x' and the next hit 'y' position to calculate the new cursor index. bool matchedCharacter = false; @@ -369,7 +374,7 @@ void ControllerImplEventHandler::OnCursorKeyEvent(Controller::Impl& impl, const const LineRun& line = *(visualModel->mLines.Begin() + lineIndex + 1u); // Get the next hit 'y' point. - const float hitPointY = cursorInfo.lineOffset + cursorInfo.lineHeight + 0.5f * (line.ascender - line.descender); + const float hitPointY = cursorInfo.lineOffset + cursorInfo.lineHeight + 0.5f * GetLineHeight(line); // Use the cursor hook position 'x' and the next hit 'y' position to calculate the new cursor index. bool matchedCharacter = false; @@ -658,7 +663,7 @@ void ControllerImplEventHandler::OnSelectAllEvent(Controller::Impl& impl) if(impl.mEventData) { EventData& eventData = *impl.mEventData; - if(eventData.mSelectionEnabled) + if(eventData.mSelectionEnabled && eventData.mState != EventData::INACTIVE) { ModelPtr& model = impl.mModel; const Vector2& scrollPosition = model->mScrollPosition; @@ -693,6 +698,29 @@ void ControllerImplEventHandler::OnSelectNoneEvent(Controller::Impl& impl) } } +void ControllerImplEventHandler::OnSelectRangeEvent(Controller::Impl& impl, const Event& event) +{ + if(impl.mEventData && impl.mEventData->mSelectionEnabled && impl.mEventData->mState != EventData::INACTIVE) + { + ModelPtr& model = impl.mModel; + const Vector2& scrollPosition = model->mScrollPosition; + + // Calculate the selection index. + const uint32_t length = static_cast(model->mLogicalModel->mText.Count()); + const uint32_t start = std::min(event.p2.mUint, length); + const uint32_t end = std::min(event.p3.mUint, length); + + if(start != end) + { + // Calculates the logical position from the x,y coords. + impl.RepositionSelectionHandles(0.f - scrollPosition.x, 0.f - scrollPosition.y, Controller::NoTextTap::HIGHLIGHT); + + impl.mEventData->mLeftSelectionPosition = start; + impl.mEventData->mRightSelectionPosition = end; + } + } +} + void ControllerImplEventHandler::OnHandlePressed(Controller::Impl& impl, const Event& event, const bool isSmoothHandlePanEnabled) { ModelPtr& model = impl.mModel;