[dali_2.3.22] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / visual-model-impl.cpp
index 6ac00cd..1d10383 100644 (file)
@@ -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.
@@ -254,6 +254,12 @@ void VisualModel::GetNumberOfLines(GlyphIndex glyphIndex,
   }
 }
 
+LineIndex VisualModel::GetLineOfGlyph( GlyphIndex glyphIndex )
+{
+  const CharacterIndex characterIndex = *(mGlyphsToCharacters.Begin() + glyphIndex);
+  return GetLineOfCharacter(characterIndex);
+}
+
 void VisualModel::GetLinesOfGlyphRange(LineRun*   lines,
                                        GlyphIndex glyphIndex,
                                        Length     numberOfGlyphs) const
@@ -305,13 +311,13 @@ LineIndex VisualModel::GetLineOfCharacter(CharacterIndex characterIndex)
   return index;
 }
 
-void VisualModel::GetUnderlineRuns(GlyphRun*         underlineRuns,
-                                   UnderlineRunIndex index,
-                                   Length            numberOfRuns) const
+void VisualModel::GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns,
+                                   UnderlineRunIndex   index,
+                                   Length              numberOfRuns) const
 {
   memcpy(underlineRuns,
          mUnderlineRuns.Begin() + index,
-         numberOfRuns * sizeof(GlyphRun));
+         numberOfRuns * sizeof(UnderlinedGlyphRun));
 }
 
 void VisualModel::SetNaturalSize(const Vector2& size)
@@ -334,6 +340,16 @@ const Vector2& VisualModel::GetLayoutSize() const
   return mLayoutSize;
 }
 
+void VisualModel::SetHeightForWidth(const Vector2& size)
+{
+  mHeightForWidth = size;
+}
+
+const Vector2& VisualModel::GetHeightForWidth() const
+{
+  return mHeightForWidth;
+}
+
 void VisualModel::SetTextColor(const Vector4& textColor)
 {
   mTextColor = textColor;
@@ -365,6 +381,11 @@ void VisualModel::SetUnderlineColor(const Vector4& color)
   mUnderlineColorSet = true;
 }
 
+void VisualModel::SetOutlineOffset(const Vector2& outlineOffset)
+{
+  mOutlineOffset = outlineOffset;
+}
+
 void VisualModel::SetOutlineColor(const Vector4& color)
 {
   mOutlineColor = color;
@@ -460,6 +481,11 @@ void VisualModel::SetStrikethroughHeight(float height)
   mStrikethroughHeight = height;
 }
 
+void VisualModel::SetCharacterSpacing(float characterSpacing)
+{
+  mCharacterSpacing = characterSpacing;
+}
+
 const Vector4& VisualModel::GetTextColor() const
 {
   return mTextColor;
@@ -485,6 +511,11 @@ const Vector4& VisualModel::GetUnderlineColor() const
   return mUnderlineColor;
 }
 
+const Vector2& VisualModel::GetOutlineOffset() const
+{
+  return mOutlineOffset;
+}
+
 const Vector4& VisualModel::GetOutlineColor() const
 {
   return mOutlineColor;
@@ -525,6 +556,11 @@ const Vector4& VisualModel::GetBackgroundColor() const
   return mBackgroundColor;
 }
 
+const float VisualModel::GetCharacterSpacing() const
+{
+  return mCharacterSpacing;
+}
+
 bool VisualModel::IsBackgroundEnabled() const
 {
   return mBackgroundEnabled;
@@ -585,11 +621,40 @@ float VisualModel::GetStrikethroughHeight() const
   return mStrikethroughHeight;
 }
 
+void VisualModel::GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns,
+                                       StrikethroughRunIndex  index,
+                                       Length                 numberOfRuns) const
+{
+  memcpy(strikethroughRuns,
+         mStrikethroughRuns.Begin() + index,
+         numberOfRuns * sizeof(StrikethroughGlyphRun));
+}
+
+Length VisualModel::GetNumberOfStrikethroughRuns() const
+{
+  return mStrikethroughRuns.Count();
+}
+
+Length VisualModel::GetNumberOfCharacterSpacingGlyphRuns() const
+{
+  return mCharacterSpacingRuns.Count();
+}
+
+const Vector<CharacterSpacingGlyphRun>& VisualModel::GetCharacterSpacingGlyphRuns() const
+{
+  return mCharacterSpacingRuns;
+}
+
 void VisualModel::ClearCaches()
 {
   mCachedLineIndex = 0u;
 }
 
+const Vector<CharacterIndex>& VisualModel::GetGlyphsToCharacters() const
+{
+  return mGlyphsToCharacters;
+}
+
 VisualModel::~VisualModel()
 {
 }
@@ -610,6 +675,7 @@ VisualModel::VisualModel()
   mStrikethroughColor(Color::BLACK),
   mControlSize(),
   mShadowOffset(),
+  mOutlineOffset(),
   mUnderlineHeight(0.0f),
   mStrikethroughHeight(0.0f),
   mUnderlineType(Text::Underline::SOLID),
@@ -619,6 +685,7 @@ VisualModel::VisualModel()
   mOutlineWidth(0u),
   mNaturalSize(),
   mLayoutSize(),
+  mHeightForWidth(0.0f, 0.0f),
   mCachedLineIndex(0u),
   mEllipsisPosition(DevelText::EllipsisPosition::END),
   mStartIndexOfElidedGlyphs(0u),
@@ -630,7 +697,8 @@ VisualModel::VisualModel()
   mUnderlineColorSet(false),
   mBackgroundEnabled(false),
   mMarkupProcessorEnabled(false),
-  mStrikethroughEnabled(false)
+  mStrikethroughEnabled(false),
+  mCharacterSpacing(0.0f)
 
 {
 }