/*
- * 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.
#include <dali-toolkit/internal/text/controller/text-controller-input-properties.h>
#include <dali-toolkit/internal/text/controller/text-controller-placeholder-handler.h>
#include <dali-toolkit/internal/text/controller/text-controller-relayouter.h>
+#include <dali-toolkit/internal/text/controller/text-controller-spannable-handler.h>
#include <dali-toolkit/internal/text/controller/text-controller-text-updater.h>
#include <dali-toolkit/internal/text/text-editable-control-interface.h>
#include <dali-toolkit/internal/text/text-geometry.h>
-
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<typename Type>
void EnsureCreated(Type*& object)
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);
{
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;
}
PlaceholderHandler::SetPlaceholderFontFamily(*this, placeholderTextFontFamily);
}
-const std::string& Controller::GetPlaceholderFontFamily() const
+std::string Controller::GetPlaceholderFontFamily() const
{
return PlaceholderHandler::GetPlaceholderFontFamily(*this);
}
mImpl->mEmbossDefaults->properties = embossProperties;
}
-const std::string& Controller::GetDefaultEmbossProperties() const
+std::string Controller::GetDefaultEmbossProperties() const
{
return mImpl->mEmbossDefaults ? mImpl->mEmbossDefaults->properties : EMPTY_STRING;
}
mImpl->mOutlineDefaults->properties = outlineProperties;
}
-const std::string& Controller::GetDefaultOutlineProperties() const
+std::string Controller::GetDefaultOutlineProperties() const
{
return mImpl->mOutlineDefaults ? mImpl->mOutlineDefaults->properties : EMPTY_STRING;
}
InputFontHandler::SetInputFontFamily(*this, fontFamily);
}
-const std::string& Controller::GetInputFontFamily() const
+std::string Controller::GetInputFontFamily() const
{
return InputFontHandler::GetInputFontFamily(*this);
}
InputProperties::SetInputShadowProperties(*this, shadowProperties);
}
-const std::string& Controller::GetInputShadowProperties() const
+std::string Controller::GetInputShadowProperties() const
{
return InputProperties::GetInputShadowProperties(*this);
}
InputProperties::SetInputUnderlineProperties(*this, underlineProperties);
}
-const std::string& Controller::GetInputUnderlineProperties() const
+std::string Controller::GetInputUnderlineProperties() const
{
return InputProperties::GetInputUnderlineProperties(*this);
}
InputProperties::SetInputEmbossProperties(*this, embossProperties);
}
-const std::string& Controller::GetInputEmbossProperties() const
+std::string Controller::GetInputEmbossProperties() const
{
return InputProperties::GetInputEmbossProperties(*this);
}
InputProperties::SetInputOutlineProperties(*this, outlineProperties);
}
-const std::string& Controller::GetInputOutlineProperties() const
+std::string Controller::GetInputOutlineProperties() const
{
return InputProperties::GetInputOutlineProperties(*this);
}
}
}
-const std::string& Controller::GetInputStrikethroughProperties() const
+std::string Controller::GetInputStrikethroughProperties() const
{
return (NULL != mImpl->mEventData) ? mImpl->mEventData->mInputStyle.strikethroughProperties : EMPTY_STRING;
}
return mImpl->mModel->GetNumberOfLines();
}
-const ModelInterface* const Controller::GetTextModel() const
+const ModelInterface* Controller::GetTextModel() const
{
return mImpl->mModel.Get();
}
return positionsList;
}
+Rect<float> Controller::GetLineBoundingRectangle(const uint32_t lineIndex)
+{
+ return GetLineBoundingRect(mImpl->mModel, lineIndex);
+}
+
+Rect<float> 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<Vector2> sizeList;
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++)
{
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};
}
Controller::~Controller()
{
- delete mImpl;
}
} // namespace Dali::Toolkit::Text