X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Fcontroller%2Ftext-controller.cpp;h=810cd1a9b2345097d86cfd9c1adcdf59ac3b3b17;hb=e4c8362431523550a745b190c67c0c8e3f25ac4d;hp=5f775f7d595276273f8e1b0e7a9e5eae40f8529b;hpb=309be8bafca890aea5baad5c46679cf207adb497;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/controller/text-controller.cpp b/dali-toolkit/internal/text/controller/text-controller.cpp index 5f775f7..810cd1a 100644 --- a/dali-toolkit/internal/text/controller/text-controller.cpp +++ b/dali-toolkit/internal/text/controller/text-controller.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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. @@ -35,17 +35,17 @@ #include #include #include +#include #include #include #include - namespace { #if defined(DEBUG_ENABLED) Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_CONTROLS"); #endif -const std::string EMPTY_STRING(""); +const char* EMPTY_STRING = ""; template void EnsureCreated(Type*& object) @@ -473,6 +473,11 @@ void Controller::GetText(std::string& text) const mImpl->GetText(text); } +void Controller::SetSpannedText(const Text::Spanned& spannedText) +{ + SpannableHandler::SetSpannedText(*this, spannedText); +} + void Controller::SetPlaceholderText(PlaceholderType type, const std::string& text) { PlaceholderHandler::SetPlaceholderText(*this, type, text); @@ -517,20 +522,23 @@ void Controller::SetDefaultFontFamily(const std::string& defaultFontFamily) { EnsureCreated(mImpl->mFontDefaults); - mImpl->mFontDefaults->mFontDescription.family = defaultFontFamily; - DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::SetDefaultFontFamily %s\n", defaultFontFamily.c_str()); - mImpl->mFontDefaults->familyDefined = !defaultFontFamily.empty(); + if(mImpl->mFontDefaults->mFontDescription.family != defaultFontFamily) + { + mImpl->mFontDefaults->mFontDescription.family = defaultFontFamily; + DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::SetDefaultFontFamily %s\n", defaultFontFamily.c_str()); + mImpl->mFontDefaults->familyDefined = !defaultFontFamily.empty(); - // Update the cursor position if it's in editing mode - UpdateCursorPosition(mImpl->mEventData); + // Update the cursor position if it's in editing mode + UpdateCursorPosition(mImpl->mEventData); - // Clear the font-specific data - mImpl->ClearFontData(); + // Clear the font-specific data + mImpl->ClearFontData(); - mImpl->RequestRelayout(); + mImpl->RequestRelayout(); + } } -const std::string& Controller::GetDefaultFontFamily() const +std::string Controller::GetDefaultFontFamily() const { return mImpl->mFontDefaults ? mImpl->mFontDefaults->mFontDescription.family : EMPTY_STRING; } @@ -540,7 +548,7 @@ void Controller::SetPlaceholderFontFamily(const std::string& placeholderTextFont PlaceholderHandler::SetPlaceholderFontFamily(*this, placeholderTextFontFamily); } -const std::string& Controller::GetPlaceholderFontFamily() const +std::string Controller::GetPlaceholderFontFamily() const { return PlaceholderHandler::GetPlaceholderFontFamily(*this); } @@ -937,7 +945,7 @@ void Controller::SetDefaultEmbossProperties(const std::string& embossProperties) mImpl->mEmbossDefaults->properties = embossProperties; } -const std::string& Controller::GetDefaultEmbossProperties() const +std::string Controller::GetDefaultEmbossProperties() const { return mImpl->mEmbossDefaults ? mImpl->mEmbossDefaults->properties : EMPTY_STRING; } @@ -948,7 +956,7 @@ void Controller::SetDefaultOutlineProperties(const std::string& outlinePropertie mImpl->mOutlineDefaults->properties = outlineProperties; } -const std::string& Controller::GetDefaultOutlineProperties() const +std::string Controller::GetDefaultOutlineProperties() const { return mImpl->mOutlineDefaults ? mImpl->mOutlineDefaults->properties : EMPTY_STRING; } @@ -998,7 +1006,7 @@ void Controller::SetInputFontFamily(const std::string& fontFamily) InputFontHandler::SetInputFontFamily(*this, fontFamily); } -const std::string& Controller::GetInputFontFamily() const +std::string Controller::GetInputFontFamily() const { return InputFontHandler::GetInputFontFamily(*this); } @@ -1073,7 +1081,7 @@ void Controller::SetInputShadowProperties(const std::string& shadowProperties) InputProperties::SetInputShadowProperties(*this, shadowProperties); } -const std::string& Controller::GetInputShadowProperties() const +std::string Controller::GetInputShadowProperties() const { return InputProperties::GetInputShadowProperties(*this); } @@ -1083,7 +1091,7 @@ void Controller::SetInputUnderlineProperties(const std::string& underlinePropert InputProperties::SetInputUnderlineProperties(*this, underlineProperties); } -const std::string& Controller::GetInputUnderlineProperties() const +std::string Controller::GetInputUnderlineProperties() const { return InputProperties::GetInputUnderlineProperties(*this); } @@ -1093,7 +1101,7 @@ void Controller::SetInputEmbossProperties(const std::string& embossProperties) InputProperties::SetInputEmbossProperties(*this, embossProperties); } -const std::string& Controller::GetInputEmbossProperties() const +std::string Controller::GetInputEmbossProperties() const { return InputProperties::GetInputEmbossProperties(*this); } @@ -1103,7 +1111,7 @@ void Controller::SetInputOutlineProperties(const std::string& outlineProperties) InputProperties::SetInputOutlineProperties(*this, outlineProperties); } -const std::string& Controller::GetInputOutlineProperties() const +std::string Controller::GetInputOutlineProperties() const { return InputProperties::GetInputOutlineProperties(*this); } @@ -1228,7 +1236,7 @@ void Controller::SetInputStrikethroughProperties(const std::string& strikethroug } } -const std::string& Controller::GetInputStrikethroughProperties() const +std::string Controller::GetInputStrikethroughProperties() const { return (NULL != mImpl->mEventData) ? mImpl->mEventData->mInputStyle.strikethroughProperties : EMPTY_STRING; } @@ -1279,7 +1287,7 @@ int Controller::GetLineCount(float width) return mImpl->mModel->GetNumberOfLines(); } -const ModelInterface* const Controller::GetTextModel() const +const ModelInterface* Controller::GetTextModel() const { return mImpl->mModel.Get(); } @@ -1416,6 +1424,21 @@ Vector Controller::GetTextPosition(CharacterIndex startIndex, Character return positionsList; } +Rect Controller::GetLineBoundingRectangle(const uint32_t lineIndex) +{ + return GetLineBoundingRect(mImpl->mModel, lineIndex); +} + +Rect Controller::GetCharacterBoundingRectangle(const uint32_t charIndex) +{ + return GetCharacterBoundingRect(mImpl->mModel, charIndex); +} + +int Controller::GetCharacterIndexAtPosition(float visualX, float visualY) +{ + return GetCharIndexAtPosition(mImpl->mModel, visualX, visualY); +} + Rect<> Controller::GetTextBoundingRectangle(CharacterIndex startIndex, CharacterIndex endIndex) { Vector sizeList; @@ -1428,10 +1451,11 @@ Rect<> Controller::GetTextBoundingRectangle(CharacterIndex startIndex, Character 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; + auto controlWidth = mImpl->mModel->mVisualModel->mControlSize.width; + 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++) { @@ -1441,6 +1465,16 @@ Rect<> Controller::GetTextBoundingRectangle(CharacterIndex startIndex, Character maxBottom = std::max(maxBottom, positionList[i].y + sizeList[i].y); } + if(minX < 0.0f) + { + minX = 0.0f; + } + + if(maxRight > controlWidth) + { + maxRight = controlWidth; + } + return {minX, minY, maxRight - minX, maxBottom - minY}; } @@ -1701,7 +1735,6 @@ Controller::Controller(ControlInterface* controlInterface, Controller::~Controller() { - delete mImpl; } } // namespace Dali::Toolkit::Text