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.cpp;h=bf92f6ae0d218325c690954595c09ac08ccd07b6;hp=be985d11b88812f7cf54e905f6330098da906931;hb=a5167c61104580ae0ab724f904537a3a01ea3061;hpb=478e477e07fde916953748d2cd4befc0326bfc34 diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index be985d1..bf92f6a 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -667,6 +667,9 @@ void Controller::SetFontSizeScale(float scale) { mImpl->mFontSizeScale = scale; + // No relayout is required + if(!mImpl->mFontSizeScaleEnabled) return; + // Update the cursor position if it's in editing mode UpdateCursorPosition(mImpl->mEventData); @@ -681,6 +684,24 @@ float Controller::GetFontSizeScale() const return mImpl->mFontDefaults ? mImpl->mFontSizeScale : 1.0f; } +void Controller::SetFontSizeScaleEnabled(bool enabled) +{ + mImpl->mFontSizeScaleEnabled = enabled; + + // Update the cursor position if it's in editing mode + UpdateCursorPosition(mImpl->mEventData); + + // Clear the font-specific data + mImpl->ClearFontData(); + + mImpl->RequestRelayout(); +} + +bool Controller::IsFontSizeScaleEnabled() const +{ + return mImpl->mFontSizeScaleEnabled; +} + void Controller::SetDefaultFontSize(float fontSize, FontSizeType type) { EnsureCreated(mImpl->mFontDefaults); @@ -726,6 +747,26 @@ const Vector4& Controller::GetDefaultColor() const return mImpl->mTextColor; } +void Controller::SetDisabledColorOpacity(float opacity) +{ + mImpl->mDisabledColorOpacity = opacity; +} + +float Controller::GetDisabledColorOpacity() const +{ + return mImpl->mDisabledColorOpacity; +} + +void Controller::SetUserInteractionEnabled(bool enabled) +{ + mImpl->SetUserInteractionEnabled(enabled); +} + +bool Controller::IsUserInteractionEnabled() const +{ + return mImpl->mIsUserInteractionEnabled; +} + void Controller::SetPlaceholderTextColor(const Vector4& textColor) { PlaceholderHandler::SetPlaceholderTextColor(*this, textColor); @@ -805,6 +846,42 @@ float Controller::GetUnderlineHeight() const return mImpl->mModel->mVisualModel->GetUnderlineHeight(); } +void Controller::SetUnderlineType(Text::Underline::Type type) +{ + mImpl->mModel->mVisualModel->SetUnderlineType(type); + + mImpl->RequestRelayout(); +} + +Text::Underline::Type Controller::GetUnderlineType() const +{ + return mImpl->mModel->mVisualModel->GetUnderlineType(); +} + +void Controller::SetDashedUnderlineWidth(float width) +{ + mImpl->mModel->mVisualModel->SetDashedUnderlineWidth(width); + + mImpl->RequestRelayout(); +} + +float Controller::GetDashedUnderlineWidth() const +{ + return mImpl->mModel->mVisualModel->GetDashedUnderlineWidth(); +} + +void Controller::SetDashedUnderlineGap(float gap) +{ + mImpl->mModel->mVisualModel->SetDashedUnderlineGap(gap); + + mImpl->RequestRelayout(); +} + +float Controller::GetDashedUnderlineGap() const +{ + return mImpl->mModel->mVisualModel->GetDashedUnderlineGap(); +} + void Controller::SetOutlineColor(const Vector4& color) { mImpl->mModel->mVisualModel->SetOutlineColor(color); @@ -891,6 +968,16 @@ float Controller::GetDefaultLineSize() const return mImpl->mLayoutEngine.GetDefaultLineSize(); } +bool Controller::SetRelativeLineSize(float relativeLineSize) +{ + return mImpl->SetRelativeLineSize(relativeLineSize); +} + +float Controller::GetRelativeLineSize() const +{ + return mImpl->GetRelativeLineSize(); +} + void Controller::SetInputColor(const Vector4& color) { InputProperties::SetInputColor(*this, color); @@ -1092,6 +1179,65 @@ void Controller::FontStyleSetByString(bool setByString) mImpl->mFontStyleSetByString = setByString; } +void Controller::SetStrikethroughHeight(float height) +{ + mImpl->mModel->mVisualModel->SetStrikethroughHeight(height); + + mImpl->RequestRelayout(); +} + +float Controller::GetStrikethroughHeight() const +{ + return mImpl->mModel->mVisualModel->GetStrikethroughHeight(); +} + +void Controller::SetStrikethroughColor(const Vector4& color) +{ + mImpl->mModel->mVisualModel->SetStrikethroughColor(color); + + mImpl->RequestRelayout(); +} + +const Vector4& Controller::GetStrikethroughColor() const +{ + return mImpl->mModel->mVisualModel->GetStrikethroughColor(); +} + +void Controller::SetStrikethroughEnabled(bool enabled) +{ + mImpl->mModel->mVisualModel->SetStrikethroughEnabled(enabled); + + mImpl->RequestRelayout(); +} + +bool Controller::IsStrikethroughEnabled() const +{ + return mImpl->mModel->mVisualModel->IsStrikethroughEnabled(); +} + +void Controller::SetInputStrikethroughProperties(const std::string& strikethroughProperties) +{ + if(NULL != mImpl->mEventData) + { + mImpl->mEventData->mInputStyle.strikethroughProperties = strikethroughProperties; + } +} + +const std::string& Controller::GetInputStrikethroughProperties() const +{ + return (NULL != mImpl->mEventData) ? mImpl->mEventData->mInputStyle.strikethroughProperties : EMPTY_STRING; +} + +bool Controller::IsStrikethroughSetByString() +{ + return mImpl->mStrikethroughSetByString; +} + +void Controller::StrikethroughSetByString(bool setByString) +{ + mImpl->mStrikethroughSetByString = setByString; +} + Layout::Engine& Controller::GetLayoutEngine() { return mImpl->mLayoutEngine; @@ -1224,6 +1370,19 @@ void Controller::SetEllipsisPosition(Toolkit::DevelText::EllipsisPosition::Type mImpl->mModel->mVisualModel->SetEllipsisPosition(ellipsisPosition); } +void Controller::SetCharacterSpacing(float characterSpacing) +{ + mImpl->mModel->mVisualModel->SetCharacterSpacing(characterSpacing); + + mImpl->RelayoutAllCharacters(); + mImpl->RequestRelayout(); +} + +const float Controller::GetCharacterSpacing() const +{ + return mImpl->mModel->mVisualModel->GetCharacterSpacing(); +} + Controller::UpdateTextType Controller::Relayout(const Size& size, Dali::LayoutDirection::Type layoutDirection) { return Relayouter::Relayout(*this, size, layoutDirection); @@ -1252,6 +1411,34 @@ Vector Controller::GetTextPosition(CharacterIndex startIndex, Character return positionsList; } +Rect<> Controller::GetTextBoundingRectangle(CharacterIndex startIndex, CharacterIndex endIndex) +{ + Vector sizeList; + Vector positionList; + + GetTextGeometry(mImpl->mModel, startIndex, endIndex, sizeList, positionList); + + if(sizeList.Empty() || sizeList.Size() != positionList.Size()) + { + return {0, 0, 0, 0}; + } + + auto minX = positionList[0].x; + auto minY = positionList[0].y; + auto maxRight = positionList[0].x + sizeList[0].x; + auto maxBottom = positionList[0].y + sizeList[0].y; + + for(unsigned int i = 1; i < sizeList.Size(); i++) + { + minX = std::min(minX, positionList[i].x); + minY = std::min(minY, positionList[i].y); + maxRight = std::max(maxRight, positionList[i].x + sizeList[i].x); + maxBottom = std::max(maxBottom, positionList[i].y + sizeList[i].y); + } + + return {minX, minY, maxRight - minX, maxBottom - minY}; +} + bool Controller::IsInputStyleChangedSignalsQueueEmpty() { return mImpl->IsInputStyleChangedSignalsQueueEmpty(); @@ -1392,11 +1579,11 @@ void Controller::GetTargetSize(Vector2& targetSize) targetSize = mImpl->mModel->mVisualModel->mControlSize; } -void Controller::AddDecoration(Actor& actor, bool needsClipping) +void Controller::AddDecoration(Actor& actor, DecorationType type, bool needsClipping) { if(mImpl->mEditableControlInterface) { - mImpl->mEditableControlInterface->AddDecoration(actor, needsClipping); + mImpl->mEditableControlInterface->AddDecoration(actor, type, needsClipping); } } @@ -1481,7 +1668,7 @@ bool Controller::ShouldClearFocusOnEscape() const Actor Controller::CreateBackgroundActor() { - return CreateControllerBackgroundActor(mImpl->mView, mImpl->mModel->mVisualModel, mImpl->mShaderBackground); + return CreateControllerBackgroundActor(mImpl->mView, mImpl->mModel->mVisualModel, mImpl->mModel->mLogicalModel, mImpl->mShaderBackground); } void Controller::GetAnchorActors(std::vector& anchorActors)