X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-controller.cpp;h=304276c640504e66d013e6aff6ed108ffc818cbe;hb=22fd3cd73ef12d4ef88f12eed11a2d6665a34c5a;hp=15db50b9cd08f78f8c34bcf9c4355061b87931f3;hpb=ee67cff961ec6b3003586c542dc473dd980c18c9;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 15db50b..304276c 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -19,12 +19,15 @@ #include // EXTERNAL INCLUDES +#include +#include #include #include #include #include // INTERNAL INCLUDES +#include #include #include #include @@ -124,6 +127,8 @@ void Controller::SetMarkupProcessorEnabled(bool enable) GetText(text); SetText(text); } + + mImpl->mModel->mVisualModel->SetMarkupProcessorEnabled(enable); } bool Controller::IsMarkupProcessorEnabled() const @@ -379,14 +384,19 @@ void Controller::SetIgnoreSpacesAfterText(bool ignore) mImpl->mModel->mIgnoreSpacesAfterText = ignore; } -bool Controller::IsMatchSystemLanguageDirection() const +void Controller::ChangedLayoutDirection() +{ + mImpl->mIsLayoutDirectionChanged = true; +} + +void Controller::SetMatchLayoutDirection(DevelText::MatchLayoutDirection type) { - return mImpl->mModel->mMatchSystemLanguageDirection; + mImpl->mModel->mMatchLayoutDirection = type; } -void Controller::SetMatchSystemLanguageDirection(bool match) +DevelText::MatchLayoutDirection Controller::GetMatchLayoutDirection() const { - mImpl->mModel->mMatchSystemLanguageDirection = match; + return mImpl->mModel->mMatchLayoutDirection; } void Controller::SetLayoutDirection(Dali::LayoutDirection::Type layoutDirection) @@ -394,6 +404,19 @@ void Controller::SetLayoutDirection(Dali::LayoutDirection::Type layoutDirection) mImpl->mLayoutDirection = layoutDirection; } +Dali::LayoutDirection::Type Controller::GetLayoutDirection(Dali::Actor& actor) const +{ + if(mImpl->mModel->mMatchLayoutDirection == DevelText::MatchLayoutDirection::LOCALE || + (mImpl->mModel->mMatchLayoutDirection == DevelText::MatchLayoutDirection::INHERIT && !mImpl->mIsLayoutDirectionChanged)) + { + return static_cast(DevelWindow::Get(actor).GetRootLayer().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get()); + } + else + { + return static_cast(actor.GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get()); + } +} + bool Controller::IsShowingRealText() const { return mImpl->IsShowingRealText(); @@ -403,15 +426,22 @@ void Controller::SetLineWrapMode(Text::LineWrap::Mode lineWrapMode) { if(lineWrapMode != mImpl->mModel->mLineWrapMode) { - // Set the text wrap mode. - mImpl->mModel->mLineWrapMode = lineWrapMode; - // Update Text layout for applying wrap mode - mImpl->mOperationsPending = static_cast(mImpl->mOperationsPending | + mImpl->mOperationsPending = static_cast(mImpl->mOperationsPending | ALIGN | LAYOUT | UPDATE_LAYOUT_SIZE | REORDER); + + if((mImpl->mModel->mLineWrapMode == (Text::LineWrap::Mode)DevelText::LineWrap::HYPHENATION) || (lineWrapMode == (Text::LineWrap::Mode)DevelText::LineWrap::HYPHENATION) || + (mImpl->mModel->mLineWrapMode == (Text::LineWrap::Mode)DevelText::LineWrap::MIXED) || (lineWrapMode == (Text::LineWrap::Mode)DevelText::LineWrap::MIXED)) // hyphen is treated as line break + { + mImpl->mOperationsPending = static_cast(mImpl->mOperationsPending | GET_LINE_BREAKS); + } + + // Set the text wrap mode. + mImpl->mModel->mLineWrapMode = lineWrapMode; + mImpl->mTextUpdateInfo.mCharacterIndex = 0u; mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters; mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count(); @@ -429,6 +459,7 @@ Text::LineWrap::Mode Controller::GetLineWrapMode() const void Controller::SetTextElideEnabled(bool enabled) { mImpl->mModel->mElideEnabled = enabled; + mImpl->mModel->mVisualModel->SetTextElideEnabled(enabled); } bool Controller::IsTextElideEnabled() const @@ -1224,28 +1255,37 @@ void Controller::SetInputColor(const Vector4& color) if(EventData::SELECTING == mImpl->mEventData->mState || EventData::EDITING == mImpl->mEventData->mState || EventData::INACTIVE == mImpl->mEventData->mState) { - const bool handlesCrossed = mImpl->mEventData->mLeftSelectionPosition > mImpl->mEventData->mRightSelectionPosition; + if(EventData::SELECTING == mImpl->mEventData->mState) + { + const bool handlesCrossed = mImpl->mEventData->mLeftSelectionPosition > mImpl->mEventData->mRightSelectionPosition; + + // Get start and end position of selection + const CharacterIndex startOfSelectedText = handlesCrossed ? mImpl->mEventData->mRightSelectionPosition : mImpl->mEventData->mLeftSelectionPosition; + const Length lengthOfSelectedText = (handlesCrossed ? mImpl->mEventData->mLeftSelectionPosition : mImpl->mEventData->mRightSelectionPosition) - startOfSelectedText; - // Get start and end position of selection - const CharacterIndex startOfSelectedText = handlesCrossed ? mImpl->mEventData->mRightSelectionPosition : mImpl->mEventData->mLeftSelectionPosition; - const Length lengthOfSelectedText = (handlesCrossed ? mImpl->mEventData->mLeftSelectionPosition : mImpl->mEventData->mRightSelectionPosition) - startOfSelectedText; + // Add the color run. + const VectorBase::SizeType numberOfRuns = mImpl->mModel->mLogicalModel->mColorRuns.Count(); + mImpl->mModel->mLogicalModel->mColorRuns.Resize(numberOfRuns + 1u); - // Add the color run. - const VectorBase::SizeType numberOfRuns = mImpl->mModel->mLogicalModel->mColorRuns.Count(); - mImpl->mModel->mLogicalModel->mColorRuns.Resize(numberOfRuns + 1u); + ColorRun& colorRun = *(mImpl->mModel->mLogicalModel->mColorRuns.Begin() + numberOfRuns); + colorRun.color = color; + colorRun.characterRun.characterIndex = startOfSelectedText; + colorRun.characterRun.numberOfCharacters = lengthOfSelectedText; - ColorRun& colorRun = *(mImpl->mModel->mLogicalModel->mColorRuns.Begin() + numberOfRuns); - colorRun.color = color; - colorRun.characterRun.characterIndex = startOfSelectedText; - colorRun.characterRun.numberOfCharacters = lengthOfSelectedText; + mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText; + mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText; + mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText; + } + else + { + mImpl->mTextUpdateInfo.mCharacterIndex = 0; + mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters; + mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count(); + } // Request to relayout. mImpl->mOperationsPending = static_cast(mImpl->mOperationsPending | COLOR); mImpl->RequestRelayout(); - - mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText; - mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText; - mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText; } } } @@ -1599,6 +1639,23 @@ void Controller::GetHiddenInputOption(Property::Map& options) } } +void Controller::SetInputFilterOption(const Property::Map& options) +{ + if(!mImpl->mInputFilter) + { + mImpl->mInputFilter = std::unique_ptr(new InputFilter()); + } + mImpl->mInputFilter->SetProperties(options); +} + +void Controller::GetInputFilterOption(Property::Map& options) +{ + if(NULL != mImpl->mInputFilter) + { + mImpl->mInputFilter->GetProperties(options); + } +} + void Controller::SetPlaceholderProperty(const Property::Map& map) { PlaceholderHandler::SetPlaceholderProperty(*this, map); @@ -1663,6 +1720,17 @@ void Controller::SetVerticalLineAlignment(Toolkit::DevelText::VerticalLineAlignm mImpl->mModel->mVerticalLineAlignment = alignment; } +Toolkit::DevelText::EllipsisPosition::Type Controller::GetEllipsisPosition() const +{ + return mImpl->mModel->GetEllipsisPosition(); +} + +void Controller::SetEllipsisPosition(Toolkit::DevelText::EllipsisPosition::Type ellipsisPosition) +{ + mImpl->mModel->mEllipsisPosition = ellipsisPosition; + mImpl->mModel->mVisualModel->SetEllipsisPosition(ellipsisPosition); +} + // public : Relayout. Controller::UpdateTextType Controller::Relayout(const Size& size, Dali::LayoutDirection::Type layoutDirection)