X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Fvisual-model-impl.cpp;h=490bae3b82746f2c5bd9f08f32d7875464edb4a2;hp=eda56336d3473463a2b6d5f840cba1648cd8b9d9;hb=4bc73f2e78812b262f09830bb2b1d87034f34496;hpb=f2039d47f9bed8104575da80a2ecf0bb6e37ff8d diff --git a/dali-toolkit/internal/text/visual-model-impl.cpp b/dali-toolkit/internal/text/visual-model-impl.cpp index eda5633..490bae3 100644 --- a/dali-toolkit/internal/text/visual-model-impl.cpp +++ b/dali-toolkit/internal/text/visual-model-impl.cpp @@ -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. @@ -204,6 +204,11 @@ void VisualModel::GetGlyphPositions(Vector2* glyphPositions, memcpy(glyphPositions, mGlyphPositions.Begin() + glyphIndex, numberOfGlyphs * sizeof(Vector2)); } +Length VisualModel::GetTotalNumberOfLines() const +{ + return mLines.Size(); +} + void VisualModel::GetNumberOfLines(GlyphIndex glyphIndex, Length numberOfGlyphs, LineIndex& firstLine, @@ -230,6 +235,12 @@ void VisualModel::GetNumberOfLines(GlyphIndex glyphIndex, firstLineFound = true; ++numberOfLines; } + else if((line.glyphRunSecondHalf.glyphIndex + line.glyphRunSecondHalf.numberOfGlyphs > glyphIndex) && + (lastGlyphIndex > line.glyphRunSecondHalf.glyphIndex)) + { + firstLineFound = true; + ++numberOfLines; + } else if(lastGlyphIndex <= line.glyphRun.glyphIndex) { // nothing else to do. @@ -243,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 @@ -294,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) @@ -369,6 +386,21 @@ void VisualModel::SetUnderlineHeight(float height) mUnderlineHeight = height; } +void VisualModel::SetUnderlineType(Text::Underline::Type type) +{ + mUnderlineType = type; +} + +void VisualModel::SetDashedUnderlineWidth(float width) +{ + mDashedUnderlineWidth = width; +} + +void VisualModel::SetDashedUnderlineGap(float gap) +{ + mDashedUnderlineGap = gap; +} + void VisualModel::SetOutlineWidth(uint16_t width) { mOutlineWidth = width; @@ -384,6 +416,61 @@ void VisualModel::SetBackgroundEnabled(bool enabled) mBackgroundEnabled = enabled; } +void VisualModel::SetMarkupProcessorEnabled(bool enabled) +{ + mMarkupProcessorEnabled = enabled; +} + +void VisualModel::SetTextElideEnabled(bool enabled) +{ + mTextElideEnabled = enabled; +} + +void VisualModel::SetEllipsisPosition(Toolkit::DevelText::EllipsisPosition::Type ellipsisPosition) +{ + mEllipsisPosition = ellipsisPosition; +} + +void VisualModel::SetStartIndexOfElidedGlyphs(GlyphIndex startIndexOfElidedGlyphs) +{ + mStartIndexOfElidedGlyphs = startIndexOfElidedGlyphs; +} + +void VisualModel::SetEndIndexOfElidedGlyphs(GlyphIndex endIndexOfElidedGlyphs) +{ + mEndIndexOfElidedGlyphs = endIndexOfElidedGlyphs; +} + +void VisualModel::SetFirstMiddleIndexOfElidedGlyphs(GlyphIndex firstMiddleIndexOfElidedGlyphs) +{ + mFirstMiddleIndexOfElidedGlyphs = firstMiddleIndexOfElidedGlyphs; +} + +void VisualModel::SetSecondMiddleIndexOfElidedGlyphs(GlyphIndex secondMiddleIndexOfElidedGlyphs) +{ + mSecondMiddleIndexOfElidedGlyphs = secondMiddleIndexOfElidedGlyphs; +} + +void VisualModel::SetStrikethroughColor(const Vector4& color) +{ + mStrikethroughColor = color; +} + +void VisualModel::SetStrikethroughEnabled(bool enabled) +{ + mStrikethroughEnabled = enabled; +} + +void VisualModel::SetStrikethroughHeight(float height) +{ + mStrikethroughHeight = height; +} + +void VisualModel::SetCharacterSpacing(float characterSpacing) +{ + mCharacterSpacing = characterSpacing; +} + const Vector4& VisualModel::GetTextColor() const { return mTextColor; @@ -424,6 +511,21 @@ float VisualModel::GetUnderlineHeight() const return mUnderlineHeight; } +Text::Underline::Type VisualModel::GetUnderlineType() const +{ + return mUnderlineType; +} + +float VisualModel::GetDashedUnderlineWidth() const +{ + return mDashedUnderlineWidth; +} + +float VisualModel::GetDashedUnderlineGap() const +{ + return mDashedUnderlineGap; +} + uint16_t VisualModel::GetOutlineWidth() const { return mOutlineWidth; @@ -434,21 +536,105 @@ const Vector4& VisualModel::GetBackgroundColor() const return mBackgroundColor; } +const float VisualModel::GetCharacterSpacing() const +{ + return mCharacterSpacing; +} + bool VisualModel::IsBackgroundEnabled() const { return mBackgroundEnabled; } +bool VisualModel::IsMarkupProcessorEnabled() const +{ + return mMarkupProcessorEnabled; +} + +bool VisualModel::IsTextElideEnabled() const +{ + return mTextElideEnabled; +} + +Toolkit::DevelText::EllipsisPosition::Type VisualModel::GetEllipsisPosition() const +{ + return mEllipsisPosition; +} + +GlyphIndex VisualModel::GetStartIndexOfElidedGlyphs() const +{ + return mStartIndexOfElidedGlyphs; +} + +GlyphIndex VisualModel::GetEndIndexOfElidedGlyphs() const +{ + return mEndIndexOfElidedGlyphs; +} + +GlyphIndex VisualModel::GetFirstMiddleIndexOfElidedGlyphs() const +{ + return mFirstMiddleIndexOfElidedGlyphs; +} + +GlyphIndex VisualModel::GetSecondMiddleIndexOfElidedGlyphs() const +{ + return mSecondMiddleIndexOfElidedGlyphs; +} + Length VisualModel::GetNumberOfUnderlineRuns() const { return mUnderlineRuns.Count(); } +const Vector4& VisualModel::GetStrikethroughColor() const +{ + return mStrikethroughColor; +} + +bool VisualModel::IsStrikethroughEnabled() const +{ + return mStrikethroughEnabled; +} + +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& VisualModel::GetCharacterSpacingGlyphRuns() const +{ + return mCharacterSpacingRuns; +} + void VisualModel::ClearCaches() { mCachedLineIndex = 0u; } +const Vector& VisualModel::GetGlyphsToCharacters() const +{ + return mGlyphsToCharacters; +} + VisualModel::~VisualModel() { } @@ -466,17 +652,32 @@ VisualModel::VisualModel() mUnderlineColor(Color::BLACK), mOutlineColor(Color::WHITE), mBackgroundColor(Color::TRANSPARENT), + mStrikethroughColor(Color::BLACK), mControlSize(), mShadowOffset(), mUnderlineHeight(0.0f), + mStrikethroughHeight(0.0f), + mUnderlineType(Text::Underline::SOLID), + mDashedUnderlineWidth(2.0f), + mDashedUnderlineGap(1.0f), mShadowBlurRadius(0.0f), mOutlineWidth(0u), mNaturalSize(), mLayoutSize(), mCachedLineIndex(0u), + mEllipsisPosition(DevelText::EllipsisPosition::END), + mStartIndexOfElidedGlyphs(0u), + mEndIndexOfElidedGlyphs(0u), + mFirstMiddleIndexOfElidedGlyphs(0u), + mSecondMiddleIndexOfElidedGlyphs(0u), + mTextElideEnabled(false), mUnderlineEnabled(false), mUnderlineColorSet(false), - mBackgroundEnabled(false) + mBackgroundEnabled(false), + mMarkupProcessorEnabled(false), + mStrikethroughEnabled(false), + mCharacterSpacing(0.0f) + { }