outlineMapSet["color"] = Color::RED;
outlineMapSet["width"] = 2.0f;
+ outlineMapSet["offset"] = Vector2(0.0f, 0.0f);
editor.SetProperty(TextEditor::Property::OUTLINE, outlineMapSet);
outlineMapSet["color"] = Color::RED;
outlineMapSet["width"] = 2.0f;
+ outlineMapSet["offset"] = Vector2(0.0f, 0.0f);
field.SetProperty(TextField::Property::OUTLINE, outlineMapSet);
outlineMapSet["color"] = Color::RED;
outlineMapSet["width"] = 2.0f;
+ outlineMapSet["offset"] = Vector2(2.0f, 2.0f);
label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
outlineMapSet.Clear();
outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
+ outlineMapSet[Toolkit::DevelText::Outline::Property::OFFSET] = Vector2(3.0f, 3.0f);
+
label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
- std::vector<std::string> outlineIndicesConversionTable = {"color", "width"};
+ std::vector<std::string> outlineIndicesConversionTable = {"color", "width", "offset"};
DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet, outlineIndicesConversionTable), true, TEST_LOCATION);
// Check the background property
outlineMapSet["color"] = Color::BLUE;
outlineMapSet["width"] = 2.0f;
+ outlineMapSet["offset"] = "2 2";
label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
application.SendNotification();
propertyMap.Insert("underline", underlineMapSet.Add("enable", true).Add("color", Color::GREEN).Add("height", 1).Add("type", Text::Underline::Type::SOLID).Add("dashWidth", 2).Add("dashGap", 1));
Property::Map outlineMapSet;
- propertyMap.Insert("outline", outlineMapSet.Add("color", Color::YELLOW).Add("width", 1));
+ propertyMap.Insert("outline", outlineMapSet.Add("color", Color::YELLOW).Add("width", 1).Add("offset", Vector2(2.0f, 2.0f)));
Property::Map backgroundMapSet;
propertyMap.Insert("textBackground", backgroundMapSet.Add("enable", true).Add("color", Color::CYAN));
* @details Name "width", type Property::STRING or Property::FLOAT i.e. "1.0" or 1.f
* @note Optional. If not provided then the outline is not enabled.
*/
- WIDTH
+ WIDTH,
+
+ /**
+ * @brief The offset in pixels of the outline.
+ * @details Name "offset", type Property::STRING or Property::VECTOR2. i.e "3.0 3.0" or Vector2( 3.f, 3.f )
+ * @note Optional. If not provided then the outline is not enabled.
+ */
+ OFFSET
};
} // namespace Property
return mImpl->mModel->mVisualModel->GetDashedUnderlineGap();
}
+void Controller::SetOutlineOffset(const Vector2& outlineOffset)
+{
+ mImpl->mModel->mVisualModel->SetOutlineOffset(outlineOffset);
+ mImpl->RequestRelayout();
+}
+
+const Vector2& Controller::GetOutlineOffset() const
+{
+ return mImpl->mModel->mVisualModel->GetOutlineOffset();
+}
+
void Controller::SetOutlineColor(const Vector4& color)
{
mImpl->mModel->mVisualModel->SetOutlineColor(color);
*/
float GetDashedUnderlineGap() const;
+ /**
+ * @brief Set the outline offset.
+ *
+ * @param[in] outlineOffset The outline offset.
+ */
+ void SetOutlineOffset(const Vector2& outlineOffset);
+
+ /**
+ * @brief Retrieve the outline offset.
+ *
+ * @return The outline offset.
+ */
+ const Vector2& GetOutlineOffset() const;
+
/**
* @brief Set the outline color.
*
const bool underlineEnabled = view.IsUnderlineEnabled();
const uint16_t outlineWidth = view.GetOutlineWidth();
const Vector4& outlineColor(view.GetOutlineColor());
+ const Vector2& outlineOffset(view.GetOutlineOffset());
const bool isOutline = 0u != outlineWidth;
const GlyphInfo* hyphens = view.GetHyphens();
const Length* hyphenIndices = view.GetHyphenIndices();
if(0u != slot.mImageId) // invalid slot id, glyph has failed to be added to atlas
{
- Vector2 positionPlusOutlineOffset = position;
+ Vector2 positionPlusOutlineOffset = position + outlineOffset;
if(isOutline)
{
// Add an offset to the text.
if(style == Typesetter::STYLE_OUTLINE)
{
+ const Vector2& outlineOffset = mModel->GetOutlineOffset();
+
glyphData.horizontalOffset -= outlineWidth;
+ glyphData.horizontalOffset += outlineOffset.x;
if(lineIndex == 0u)
{
// Only need to add the vertical outline offset for the first line
glyphData.verticalOffset -= outlineWidth;
+ glyphData.verticalOffset += outlineOffset.y;
}
}
else if(style == Typesetter::STYLE_SHADOW)
mModel->GetUnderlineRuns(underlineRuns, index, numberOfRuns);
}
+const Vector2& ViewModel::GetOutlineOffset() const
+{
+ return mModel->GetOutlineOffset();
+}
+
const Vector4& ViewModel::GetOutlineColor() const
{
return mModel->GetOutlineColor();
*/
void GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const override;
+ /**
+ * @copydoc ModelInterface::GetOutlineOffset()
+ */
+ const Vector2& GetOutlineOffset() const override;
+
/**
* @copydoc ModelInterface::GetOutlineColor()
*/
bool& colorDefined,
Vector4& color,
bool& widthDefined,
- uint16_t& width)
+ uint16_t& width,
+ bool& offsetDefined,
+ Vector2& offset)
{
const unsigned int numberOfItems = underlinePropertiesMap.Count();
widthDefined = true;
width = static_cast<uint16_t>(valueGet.second.Get<float>());
}
+ else if((DevelText::Outline::Property::OFFSET == valueGet.first.indexKey) || (OFFSET_KEY == valueGet.first.stringKey))
+ {
+ /// Offset key.
+ offsetDefined = true;
+
+ if(valueGet.second.GetType() == Dali::Property::STRING)
+ {
+ const std::string offsetStr = valueGet.second.Get<std::string>();
+ StringToVector2(offsetStr.c_str(), offsetStr.size(), offset);
+ }
+ else
+ {
+ offset = valueGet.second.Get<Vector2>();
+ }
+ }
}
return 0u == numberOfItems;
{
const Property::Map& propertiesMap = value.Get<Property::Map>();
- bool colorDefined = false;
+ bool colorDefined = false;
Vector4 color;
- bool widthDefined = false;
- uint16_t width = 0u;
+ bool widthDefined = false;
+ uint16_t width = 0u;
+ bool offsetDefined = false;
+ Vector2 offset;
bool empty = true;
colorDefined,
color,
widthDefined,
- width);
+ width,
+ offsetDefined,
+ offset);
controller->OutlineSetByString(false);
}
controller->SetOutlineWidth(width);
update = true;
}
+
+ if(offsetDefined && (controller->GetOutlineOffset() != offset))
+ {
+ controller->SetOutlineOffset(offset);
+ update = true;
+ }
}
else
{
}
else
{
- const Vector4& color = controller->GetOutlineColor();
- const uint16_t width = controller->GetOutlineWidth();
+ const Vector4& color = controller->GetOutlineColor();
+ const uint16_t width = controller->GetOutlineWidth();
+ const Vector2& offset = controller->GetOutlineOffset();
+
Property::Map map;
map.Insert(COLOR_KEY, color);
map.Insert(WIDTH_KEY, static_cast<int>(width));
+ map.Insert(OFFSET_KEY, offset);
value = map;
*/
virtual void GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const = 0;
+ /**
+ * @brief Retrieves the outline offset.
+ *
+ * @return The outline offset.
+ */
+ virtual const Vector2& GetOutlineOffset() const = 0;
+
/**
* @brief Retrieve the outline color.
*
mVisualModel->GetUnderlineRuns(underlineRuns, index, numberOfRuns);
}
+const Vector2& Model::GetOutlineOffset() const
+{
+ return mVisualModel->GetOutlineOffset();
+}
+
const Vector4& Model::GetOutlineColor() const
{
return mVisualModel->GetOutlineColor();
*/
void GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const override;
+ /**
+ * @copydoc ModelInterface::GetOutlineOffset()
+ */
+ const Vector2& GetOutlineOffset() const override;
+
/**
* @copydoc ModelInterface::GetOutlineColor()
*/
UnderlineRunIndex index,
Length numberOfRuns) const = 0;
+ /**
+ * @brief Retrieves the outline offset.
+ *
+ * @return The outline offset.
+ */
+ virtual const Vector2& GetOutlineOffset() const = 0;
+
/**
* @brief Retrieve the outline color.
*
}
}
+const Vector2& View::GetOutlineOffset() const
+{
+// TODO : We should support outline offset to editable text.
+/*
+ if(mImpl->mVisualModel)
+ {
+ return mImpl->mVisualModel->GetOutlineOffset();
+ }
+*/
+ return Vector2::ZERO;
+}
+
const Vector4& View::GetOutlineColor() const
{
if(mImpl->mVisualModel)
UnderlineRunIndex index,
Length numberOfRuns) const;
+ /**
+ * @copydoc Dali::Toolkit::Text::ViewInterface::GetOutlineOffset()
+ */
+ const Vector2& GetOutlineOffset() const override;
+
/**
* @copydoc Dali::Toolkit::Text::ViewInterface::GetOutlineColor()
*/
mUnderlineColorSet = true;
}
+void VisualModel::SetOutlineOffset(const Vector2& outlineOffset)
+{
+ mOutlineOffset = outlineOffset;
+}
+
void VisualModel::SetOutlineColor(const Vector4& color)
{
mOutlineColor = color;
return mUnderlineColor;
}
+const Vector2& VisualModel::GetOutlineOffset() const
+{
+ return mOutlineOffset;
+}
+
const Vector4& VisualModel::GetOutlineColor() const
{
return mOutlineColor;
mStrikethroughColor(Color::BLACK),
mControlSize(),
mShadowOffset(),
+ mOutlineOffset(),
mUnderlineHeight(0.0f),
mStrikethroughHeight(0.0f),
mUnderlineType(Text::Underline::SOLID),
*/
Length GetNumberOfUnderlineRuns() const;
+ /**
+ * @brief Sets the text's outline offset.
+ *
+ * @param[in] outlineOffset The outline offset.
+ */
+ void SetOutlineOffset(const Vector2& outlineOffset);
+
/**
* @brief Set the outline color.
*
*/
void SetOutlineColor(const Vector4& color);
+ /**
+ * @brief Retrieves the text's outline offset.
+ *
+ * @return The text's outline offset.
+ */
+ const Vector2& GetOutlineOffset() const;
+
/**
* @brief Retrieve the outline color.
*
Vector4 mStrikethroughColor; ///< Color of text background
Size mControlSize; ///< The size of the UI control.
Vector2 mShadowOffset; ///< Offset for drop shadow, 0 indicates no shadow
+ Vector2 mOutlineOffset; ///< Offset for outline
float mUnderlineHeight; ///< Fixed height for underline to override font metrics.
float mStrikethroughHeight; ///< Fixed height for strikethrough to override font metrics.
Text::Underline::Type mUnderlineType; ///< The type of the underline.