projects
/
platform
/
core
/
uifw
/
dali-toolkit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "[AT-SPI] remove isRoot param from Accessible::Get" into devel/master
[platform/core/uifw/dali-toolkit.git]
/
dali-toolkit
/
internal
/
text
/
text-controller-background-actor.cpp
diff --git
a/dali-toolkit/internal/text/text-controller-background-actor.cpp
b/dali-toolkit/internal/text/text-controller-background-actor.cpp
index
72bfcde
..
bc7c79b
100644
(file)
--- a/
dali-toolkit/internal/text/text-controller-background-actor.cpp
+++ b/
dali-toolkit/internal/text/text-controller-background-actor.cpp
@@
-25,6
+25,7
@@
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
#include <dali-toolkit/internal/text/cursor-helper-functions.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
#include <dali-toolkit/internal/text/cursor-helper-functions.h>
+#include <dali-toolkit/internal/text/rendering/styles/character-spacing-helper-functions.h>
#include <dali-toolkit/internal/text/text-view.h>
namespace Dali::Toolkit::Text
#include <dali-toolkit/internal/text/text-view.h>
namespace Dali::Toolkit::Text
@@
-44,6
+45,18
@@
struct BackgroundMesh
};
} // unnamed namespace
};
} // unnamed namespace
+Length CalculateBackgroundLineHeight(LineRun lineRun)
+{
+ Length height = lineRun.ascender + -(lineRun.descender);
+
+ if(lineRun.lineSpacing > 0)
+ {
+ height += lineRun.lineSpacing;
+ }
+
+ return height;
+}
+
Actor CreateControllerBackgroundActor(const View& textView, const VisualModelPtr& textVisualModel, const LogicalModelPtr& textLogicalModel, Shader& textShaderBackground)
{
// NOTE: Currently we only support background color for left-to-right text.
Actor CreateControllerBackgroundActor(const View& textView, const VisualModelPtr& textVisualModel, const LogicalModelPtr& textLogicalModel, Shader& textShaderBackground)
{
// NOTE: Currently we only support background color for left-to-right text.
@@
-86,17
+99,19
@@
Actor CreateControllerBackgroundActor(const View& textView, const VisualModelPtr
const Vector4* const backgroundColorsBuffer = textView.GetBackgroundColors();
const ColorIndex* const backgroundColorIndicesBuffer = textView.GetBackgroundColorIndices();
const Vector4& defaultBackgroundColor = textVisualModel->IsBackgroundEnabled() ? textVisualModel->GetBackgroundColor() : Color::TRANSPARENT;
const Vector4* const backgroundColorsBuffer = textView.GetBackgroundColors();
const ColorIndex* const backgroundColorIndicesBuffer = textView.GetBackgroundColorIndices();
const Vector4& defaultBackgroundColor = textVisualModel->IsBackgroundEnabled() ? textVisualModel->GetBackgroundColor() : Color::TRANSPARENT;
- const float
characterSpacing
= textVisualModel->GetCharacterSpacing();
+ const float
modelCharacterSpacing
= textVisualModel->GetCharacterSpacing();
Vector<CharacterIndex>& glyphToCharacterMap = textVisualModel->mGlyphsToCharacters;
const CharacterIndex* glyphToCharacterMapBuffer = glyphToCharacterMap.Begin();
float calculatedAdvance = 0.f;
Vector<CharacterIndex>& glyphToCharacterMap = textVisualModel->mGlyphsToCharacters;
const CharacterIndex* glyphToCharacterMapBuffer = glyphToCharacterMap.Begin();
float calculatedAdvance = 0.f;
+ // Get the character-spacing runs.
+ const Vector<CharacterSpacingGlyphRun>& characterSpacingGlyphRuns = textVisualModel->GetCharacterSpacingGlyphRuns();
+
Vector4 quad;
uint32_t numberOfQuads = 0u;
Length yLineOffset = 0;
Length prevLineIndex = 0;
LineIndex lineIndex;
Vector4 quad;
uint32_t numberOfQuads = 0u;
Length yLineOffset = 0;
Length prevLineIndex = 0;
LineIndex lineIndex;
- Length numberOfLines;
for(uint32_t i = 0, glyphSize = glyphs.Size(); i < glyphSize; ++i)
{
for(uint32_t i = 0, glyphSize = glyphs.Size(); i < glyphSize; ++i)
{
@@
-109,17
+124,24
@@
Actor CreateControllerBackgroundActor(const View& textView, const VisualModelPtr
const bool isDefaultBackgroundColor = (0u == backgroundColorIndex);
const Vector4& backgroundColor = isDefaultBackgroundColor ? defaultBackgroundColor : *(backgroundColorsBuffer + backgroundColorIndex - 1u);
const bool isDefaultBackgroundColor = (0u == backgroundColorIndex);
const Vector4& backgroundColor = isDefaultBackgroundColor ? defaultBackgroundColor : *(backgroundColorsBuffer + backgroundColorIndex - 1u);
-
textVisualModel->GetNumberOfLines(i, 1, lineIndex, numberOfLines
);
- Length lineHeight =
lineRun[lineIndex].ascender + -(lineRun[lineIndex].descender) + lineRun[lineIndex].lineSpacing
;
+
lineIndex = textVisualModel->GetLineOfGlyph(i
);
+ Length lineHeight =
CalculateBackgroundLineHeight(lineRun[lineIndex])
;
if(lineIndex != prevLineIndex)
{
if(lineIndex != prevLineIndex)
{
- yLineOffset += lineHeight;
+ yLineOffset += CalculateBackgroundLineHeight(lineRun[prevLineIndex]);
+
+ if(lineRun[prevLineIndex].lineSpacing < 0)
+ {
+ yLineOffset += lineRun[prevLineIndex].lineSpacing;
+ }
}
// Only create quads for glyphs with a background color
if(backgroundColor != Color::TRANSPARENT)
{
}
// Only create quads for glyphs with a background color
if(backgroundColor != Color::TRANSPARENT)
{
+ const float characterSpacing = GetGlyphCharacterSpacing(i, characterSpacingGlyphRuns, modelCharacterSpacing);
+
const Vector2 position = *(positionsBuffer + i);
calculatedAdvance = GetCalculatedAdvance(*(textLogicalModel->mText.Begin() + (*(glyphToCharacterMapBuffer + i))), characterSpacing, glyph.advance);
const Vector2 position = *(positionsBuffer + i);
calculatedAdvance = GetCalculatedAdvance(*(textLogicalModel->mText.Begin() + (*(glyphToCharacterMapBuffer + i))), characterSpacing, glyph.advance);