StrikethroughSpan: Span to change the strikethrough properties (Color,Heighth) of characters
This patch should be preceded by the patch below:
https://review.tizen.org/gerrit/c/platform/core/uifw/dali-toolkit/+/285217
Change-Id: Id7823ea49b19fed3ae1a0a9a73e55538ccd2ad2e
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/controls/text-controls/text-spannable.h>
#include <dali-toolkit/devel-api/text/spannable-string.h>
+#include <dali-toolkit/devel-api/text/spans/background-color-span.h>
+#include <dali-toolkit/devel-api/text/spans/bold-span.h>
+#include <dali-toolkit/devel-api/text/spans/character-spacing-span.h>
#include <dali-toolkit/devel-api/text/spans/font-span.h>
#include <dali-toolkit/devel-api/text/spans/foreground-color-span.h>
+#include <dali-toolkit/devel-api/text/spans/italic-span.h>
+#include <dali-toolkit/devel-api/text/spans/strikethrough-span.h>
#include <dali-toolkit/devel-api/text/spans/underline-span.h>
#include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
#include <dali-toolkit/internal/controls/text-controls/text-editor-impl.h>
#include <dali-toolkit/internal/text/text-view.h>
#include <dali-toolkit/public-api/text/text-enumerations.h>
#include <toolkit-text-utils.h>
-#include <dali-toolkit/devel-api/text/spans/character-spacing-span.h>
-#include <dali-toolkit/devel-api/text/spans/bold-span.h>
-#include <dali-toolkit/devel-api/text/spans/italic-span.h>
-#include <dali-toolkit/devel-api/text/spans/background-color-span.h>
using namespace Dali;
using namespace Toolkit;
const float PIXEL_FORMAT_64_FACTOR = 64.f; ///< 64.f is used to convert from point size to 26.6 pixel format.
} // namespace
+Text::SpannableString CreateSpannableStringForStrikethroughSpan()
+{
+ Text::SpannableString spannableString = Text::SpannableString::New("Hello World");
+ DALI_TEST_CHECK(spannableString);
+
+ auto isAddedStrikethroughSpan = spannableString.AttachSpan(
+ Text::StrikethroughSpan::New(Color::GREEN, 5.0f),
+ Text::Range::New(5u, 7u));
+ DALI_TEST_CHECK(isAddedStrikethroughSpan);
+
+ return spannableString;
+}
+
Text::SpannableString CreateSpannableStringForForegroundColorSpan()
{
Text::SpannableString spannableString = Text::SpannableString::New("Hello مرحبا");
DALI_TEST_CHECK(spannableString);
auto isCharacterSpacingSpan = spannableString.AttachSpan(
- Text::CharacterSpacingSpan::New(5.2f),
- Text::Range::New(5u, 7u));
+ Text::CharacterSpacingSpan::New(5.2f),
+ Text::Range::New(5u, 7u));
DALI_TEST_CHECK(isCharacterSpacingSpan);
return spannableString;
Text::SpannableString spannableString = Text::SpannableString::New("Hello");
DALI_TEST_CHECK(spannableString);
- auto boldspan = Dali::Toolkit::Text::BoldSpan::New();
- auto isBoldSpan = spannableString.AttachSpan(boldspan,Dali::Toolkit::Text::Range::New(0u, 3u));
+ auto boldspan = Dali::Toolkit::Text::BoldSpan::New();
+ auto isBoldSpan = spannableString.AttachSpan(boldspan, Dali::Toolkit::Text::Range::New(0u, 3u));
DALI_TEST_CHECK(isBoldSpan);
return spannableString;
-
}
Text::SpannableString CreateSpannableStringForItalicSpan()
DALI_TEST_CHECK(spannableString);
auto isAddedItalic = spannableString.AttachSpan(
- Text::ItalicSpan::New(),
- Text::Range::New(0u, 3u));
+ Text::ItalicSpan::New(),
+ Text::Range::New(0u, 3u));
DALI_TEST_CHECK(isAddedItalic);
return spannableString;
Text::SpannableString CreateSpannableStringForBackgroundColorSpan()
{
-
Text::SpannableString spannableString = Text::SpannableString::New("Hello مرحبا");
DALI_TEST_CHECK(spannableString);
auto isAddedGreen = spannableString.AttachSpan(
- Text::BackgroundColorSpan::New(Color::GREEN),
- Text::Range::New(5u, 7u));
+ Text::BackgroundColorSpan::New(Color::GREEN),
+ Text::Range::New(5u, 7u));
DALI_TEST_CHECK(isAddedGreen);
return spannableString;
application.SendNotification();
application.Render();
- Toolkit::Internal::TextLabel& labelImpl = GetImpl(textLabel);
+ Toolkit::Internal::TextLabel& labelImpl = GetImpl(textLabel);
const Vector<Dali::Toolkit::Text::CharacterSpacingGlyphRun> characterSpacing = labelImpl.GetTextController()->GetTextModel()->GetCharacterSpacingGlyphRuns();
DALI_TEST_EQUALS(1, characterSpacing.Count(), TEST_LOCATION);
END_TEST;
application.SendNotification();
application.Render();
- Toolkit::Internal::TextLabel& labelImpl = GetImpl(textLabel);
+ Toolkit::Internal::TextLabel& labelImpl = GetImpl(textLabel);
const Vector<Text::FontRun>& validFonts = labelImpl.GetTextController()->GetTextModel()->GetFontRuns();
DALI_TEST_EQUALS(validFonts.Count(), 2, TEST_LOCATION);
- DALI_TEST_EQUALS(validFonts[0].characterRun.characterIndex,0, TEST_LOCATION);
- DALI_TEST_EQUALS(validFonts[0].characterRun.GetEndCharacterIndex(),3, TEST_LOCATION);
+ DALI_TEST_EQUALS(validFonts[0].characterRun.characterIndex, 0, TEST_LOCATION);
+ DALI_TEST_EQUALS(validFonts[0].characterRun.GetEndCharacterIndex(), 3, TEST_LOCATION);
DALI_TEST_EQUALS(validFonts[0].isBoldRequired, true, TEST_LOCATION);
END_TEST;
}
application.SendNotification();
application.Render();
- Toolkit::Internal::TextLabel& labelImpl = GetImpl(textLabel);
- const Vector<Text::FontRun>& validFontsItalic = labelImpl.GetTextController()->GetTextModel()->GetFontRuns();
+ Toolkit::Internal::TextLabel& labelImpl = GetImpl(textLabel);
+ const Vector<Text::FontRun>& validFontsItalic = labelImpl.GetTextController()->GetTextModel()->GetFontRuns();
DALI_TEST_EQUALS(validFontsItalic.Count(), 2, TEST_LOCATION);
DALI_TEST_EQUALS(validFontsItalic[0].characterRun.characterIndex, 0, TEST_LOCATION);
int UtcDaliToolkitTextLabelSetSpannedText_BackgroundColorSpan(void)
{
-
ToolkitTestApplication application;
tet_infoline("UtcDaliToolkitTextLabelSetSpannedText_BackgroundColorSpan");
application.SendNotification();
application.Render();
- Toolkit::Internal::TextLabel& labelImpl = GetImpl(textLabel);
- const Text::ColorIndex* const backgroundColorIndicesBuffer = labelImpl.GetTextController()->GetTextModel()->GetBackgroundColorIndices();
+ Toolkit::Internal::TextLabel& labelImpl = GetImpl(textLabel);
+ const Text::ColorIndex* const backgroundColorIndicesBuffer = labelImpl.GetTextController()->GetTextModel()->GetBackgroundColorIndices();
CheckColorIndices(backgroundColorIndicesBuffer, 4u, {0u, 5u, 7u, 10u}, {0u, 1u, 1u, 0u});
END_TEST;
}
+int UtcDaliToolkitTextLabelSetSpannedText_StrikethroughSpan(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliToolkitTextLabelSetSpannedText_StrikethroughSpan ");
+
+ Dali::Toolkit::Text::StrikethroughStyleProperties expectedProperties = {
+ Color::GREEN,
+ 5u,
+ true,
+ true};
+
+ TextLabel textLabel = TextLabel::New();
+
+ DALI_TEST_CHECK(textLabel);
+
+ application.GetScene().Add(textLabel);
+
+ Text::SpannableString spannableString = CreateSpannableStringForStrikethroughSpan();
+ Text::SetSpannedText(textLabel, spannableString);
+
+ application.SendNotification();
+ application.Render();
+
+ Toolkit::Internal::TextLabel& labelImpl = GetImpl(textLabel);
+
+ const Text::Length numberOfStrikethroughRuns = labelImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns();
+
+ DALI_TEST_EQUALS(numberOfStrikethroughRuns, 1u, TEST_LOCATION);
+
+ Vector<Dali::Toolkit::Text::StrikethroughGlyphRun> strikethroughRuns;
+ strikethroughRuns.Resize(numberOfStrikethroughRuns);
+
+ labelImpl.GetTextController()->GetTextModel()->GetStrikethroughRuns(strikethroughRuns.Begin(), 0u, numberOfStrikethroughRuns);
+
+ DALI_TEST_EQUALS(strikethroughRuns[0].glyphRun.glyphIndex, 5u, TEST_LOCATION);
+ DALI_TEST_EQUALS(strikethroughRuns[0].glyphRun.numberOfGlyphs, 3u, TEST_LOCATION);
+ DALI_TEST_CHECK(strikethroughRuns[0].properties == expectedProperties);
+
+ END_TEST;
+}
\ No newline at end of file
utc-Dali-Text-Range.cpp
utc-Dali-Text-SpannableString.cpp
utc-Dali-Text-UnderlineSpan.cpp
+ utc-Dali-Text-StrikethroughSpan.cpp
utc-Dali-TextEditor.cpp
utc-Dali-TextField.cpp
utc-Dali-TextGeometry.cpp
--- /dev/null
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/text/spans/strikethrough-span.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <iostream>
+
+using namespace Dali;
+using namespace Toolkit;
+
+int UtcDaliToolkitTextStrikethroughSpanNew(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliToolkitTextStrikethroughSpanNew");
+
+ auto strikethroughSpan = Text::StrikethroughSpan::New();
+ DALI_TEST_CHECK(strikethroughSpan);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitTextStrikethroughSpanNewColorHeight(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliToolkitTextStrikethroughSpanNewColorHeight");
+
+ auto strikethroughSpan = Text::StrikethroughSpan::New(Color::GREEN, 5.0f);
+ DALI_TEST_CHECK(strikethroughSpan);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitTextStrikethroughSpanGetColor(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliToolkitTextStrikethroughSpanGetColor");
+
+ auto strikethroughSpan = Text::StrikethroughSpan::New(Color::GREEN, 5.0f);
+
+ DALI_TEST_CHECK(strikethroughSpan);
+ DALI_TEST_EQUALS(Color::GREEN, strikethroughSpan.GetColor(), TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitTextStrikethroughSpanIsColorDefined(void)
+
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliToolkitTextStrikethroughSpanIsColorDefined");
+
+ auto strikethroughSpan = Text::StrikethroughSpan::New(Color::GREEN, 5.0f);
+
+ DALI_TEST_CHECK(strikethroughSpan);
+ DALI_TEST_EQUALS(true, strikethroughSpan.IsColorDefined(), TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitTextStrikethroughSpanGetHeight(void)
+
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliToolkitTextStrikethroughSpanGetHeight");
+
+ auto strikethroughSpan = Text::StrikethroughSpan::New(Color::GREEN, 5.0f);
+
+ DALI_TEST_CHECK(strikethroughSpan);
+ DALI_TEST_EQUALS(5.0f, strikethroughSpan.GetHeight(), TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitTextStrikethroughSpanIsHeightDefined(void)
+
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliToolkitTextStrikethroughSpanIsHeightDefined");
+
+ auto strikethroughSpan = Text::StrikethroughSpan::New(Color::GREEN, 5.0f);
+
+ DALI_TEST_CHECK(strikethroughSpan);
+ DALI_TEST_EQUALS(true, strikethroughSpan.IsHeightDefined(), TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitTextStrikethroughSpanStrikethroughSpanDownCast(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliToolkitTextStrikethroughSpanStrikethroughSpanDownCast");
+
+ Text::BaseSpan baseSpan = Text::StrikethroughSpan::New();
+ DALI_TEST_CHECK(baseSpan);
+
+ Text::StrikethroughSpan strikethroughSpan = Text::StrikethroughSpan::DownCast(baseSpan);
+ DALI_TEST_CHECK(strikethroughSpan);
+
+ END_TEST;
+}
\ No newline at end of file
${devel_api_src_dir}/text/spans/base-span.cpp
${devel_api_src_dir}/text/spans/foreground-color-span.cpp
${devel_api_src_dir}/text/spans/character-spacing-span.cpp
+ ${devel_api_src_dir}/text/spans/strikethrough-span.cpp
${devel_api_src_dir}/text/spans/font-span.cpp
${devel_api_src_dir}/text/spans/underline-span.cpp
${devel_api_src_dir}/text/spans/bold-span.cpp
${devel_api_src_dir}/text/spans/base-span.h
${devel_api_src_dir}/text/spans/foreground-color-span.h
${devel_api_src_dir}/text/spans/character-spacing-span.h
+ ${devel_api_src_dir}/text/spans/strikethrough-span.h
${devel_api_src_dir}/text/spans/font-span.h
${devel_api_src_dir}/text/spans/underline-span.h
${devel_api_src_dir}/text/spans/bold-span.h
--- /dev/null
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/text/spans/strikethrough-span.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/spannable/spans/strikethrough-span-impl.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+StrikethroughSpan StrikethroughSpan::New()
+{
+ return Internal::StrikethroughSpan::New();
+}
+
+StrikethroughSpan StrikethroughSpan::New(Vector4 color, float height)
+{
+ return Internal::StrikethroughSpan::New(color, height);
+}
+
+StrikethroughSpan::StrikethroughSpan(Internal::StrikethroughSpan* internal)
+: BaseSpan(internal)
+{
+}
+
+StrikethroughSpan::StrikethroughSpan() = default;
+StrikethroughSpan::StrikethroughSpan(const StrikethroughSpan& rhs) = default;
+StrikethroughSpan::StrikethroughSpan(StrikethroughSpan&& rhs) = default;
+StrikethroughSpan& StrikethroughSpan::operator=(const StrikethroughSpan& rhs) = default;
+StrikethroughSpan& StrikethroughSpan::operator=(StrikethroughSpan&& rhs) = default;
+StrikethroughSpan::~StrikethroughSpan() = default;
+
+//Methods
+const Vector4 StrikethroughSpan::GetColor() const
+{
+ return GetImplementation(*this).GetColor();
+}
+
+bool StrikethroughSpan::IsColorDefined() const
+{
+ return GetImplementation(*this).IsColorDefined();
+}
+
+const float StrikethroughSpan::GetHeight() const
+{
+ return GetImplementation(*this).GetHeight();
+}
+
+bool StrikethroughSpan::IsHeightDefined() const
+{
+ return GetImplementation(*this).IsHeightDefined();
+}
+
+StrikethroughSpan StrikethroughSpan::DownCast(BaseHandle handle)
+{
+ return StrikethroughSpan(dynamic_cast<Dali::Toolkit::Text::Internal::StrikethroughSpan*>(handle.GetObjectPtr()));
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
\ No newline at end of file
--- /dev/null
+#ifndef DALI_TOOLKIT_TEXT_STRIKETHROUGH_SPAN_H
+#define DALI_TOOLKIT_TEXT_STRIKETHROUGH_SPAN_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+
+#include <dali-toolkit/devel-api/text/spans/base-span.h>
+#include <dali-toolkit/public-api/text/text-enumerations.h>
+#include <dali/public-api/common/constants.h>
+#include <dali/public-api/math/vector4.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+namespace Internal DALI_INTERNAL
+{
+class StrikethroughSpan;
+}
+
+/**
+ * @brief StrikethroughSpan is a handle to an object that specifies the strikethrough properties for range of characters.
+ */
+
+class DALI_TOOLKIT_API StrikethroughSpan : public BaseSpan
+{
+public:
+ /**
+ * @brief Create an initialized StrikethroughSpan.
+ *
+ * @return A handle to a newly allocated Dali resource
+ */
+
+ static StrikethroughSpan New();
+ /**
+ * @brief Create an initialized StrikethroughSpan.
+ *
+ * @param[in] color The color of line.
+ * @param[in] height The height of line.
+ *
+ * @return A handle to a newly allocated Dali resource
+ */
+ static StrikethroughSpan New(Vector4 color, float height);
+
+ /**
+ * @brief Creates an uninitialized StrikethroughSpan handle.
+ *
+ * Calling member functions with an uninitialized StrikethroughSpan handle is not allowed.
+ */
+ StrikethroughSpan();
+
+ /**
+ * @brief Copy constructor.
+ * @param[in] rhs A reference to the copied handle
+ */
+ StrikethroughSpan(const StrikethroughSpan& rhs);
+
+ /**
+ * @brief Move constructor.
+ * @param[in] rhs A reference to the handle to move
+ */
+ StrikethroughSpan(StrikethroughSpan&& rhs);
+
+ /**
+ * @brief Assignment operator.
+ * @param[in] rhs A reference to the copied handle
+ * @return A reference to this
+ */
+ StrikethroughSpan& operator=(const StrikethroughSpan& rhs);
+
+ /**
+ * @brief Move assignment operator.
+ * @param[in] rhs A reference to the moved handle
+ * @return A reference to this
+ */
+ StrikethroughSpan& operator=(StrikethroughSpan&& rhs);
+
+ /**
+ * @brief Non virtual destructor.
+ */
+ ~StrikethroughSpan();
+
+ /**
+ * @brief Downcasts to a StrikethroughSpan handle.
+ * If handle is not a StrikethroughSpan, the returned handle is left uninitialized.
+ *
+ * @param[in] handle Handle to an object
+ * @return StrikethroughSpan handle or an uninitialized handle
+ */
+ static StrikethroughSpan DownCast(BaseHandle handle);
+
+public: //Methods
+ /**
+ * @brief Retrive the color of line.
+ *
+ * @return A color value.
+ */
+ const Vector4 GetColor() const;
+
+ /**
+ * @brief Retrieve whether the color is defined.
+ *
+ * @return The return is true if color is defined, otherwise false.
+ */
+ bool IsColorDefined() const;
+
+ /**
+ * @brief Retrive the height of line.
+ *
+ * @return A height value.
+ */
+ const float GetHeight() const;
+
+ /**
+ * @brief Retrieve whether the height is defined.
+ *
+ * @return The return is true if height is defined, otherwise false.
+ */
+ bool IsHeightDefined() const;
+
+public: // Not intended for application developers
+ /// @cond internal
+
+ /**
+ * @brief This constructor is used internally to Create an initialized StrikethroughSpan handle.
+ *
+ * @param[in] strikethroughSpan Pointer to internal StrikethroughSpan
+ */
+ explicit DALI_INTERNAL StrikethroughSpan(Internal::StrikethroughSpan* strikethroughSpan);
+
+ /// @endcond
+};
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_STRIKETHROUGH_SPAN_H
\ No newline at end of file
${toolkit_src_dir}/text/spannable/spans/base-span-impl.cpp
${toolkit_src_dir}/text/spannable/spans/foreground-color-span-impl.cpp
${toolkit_src_dir}/text/spannable/spans/character-spacing-span-impl.cpp
+ ${toolkit_src_dir}/text/spannable/spans/strikethrough-span-impl.cpp
${toolkit_src_dir}/text/spannable/spans/font-span-impl.cpp
${toolkit_src_dir}/text/spannable/spans/underline-span-impl.cpp
${toolkit_src_dir}/text/spannable/spans/bold-span-impl.cpp
//Mark-up processor case
if(impl.mModel->mVisualModel->IsMarkupProcessorEnabled() ||
impl.mModel->mLogicalModel->mUnderlineRunsUpdated ||
- impl.mModel->mLogicalModel->mCharacterSpacingRunsUpdated)
+ impl.mModel->mLogicalModel->mCharacterSpacingRunsUpdated ||
+ impl.mModel->mLogicalModel->mStrikethroughRunsUpdated)
{
impl.CopyUnderlinedFromLogicalToVisualModels(true);
impl.CopyStrikethroughFromLogicalToVisualModels();
mModel->mVisualModel->mStrikethroughRuns.PushBack(strikethroughGlyphRun);
}
+
+ // Reset flag. The updates have been applied from logical to visual.
+ mModel->mLogicalModel->mStrikethroughRunsUpdated = false;
}
void Controller::Impl::CopyCharacterSpacingFromLogicalToVisualModels()
: mBidirectionalLineIndex(0u),
mSpannedTextPlaced(false),
mUnderlineRunsUpdated(false),
- mCharacterSpacingRunsUpdated(false)
+ mCharacterSpacingRunsUpdated(false),
+ mStrikethroughRunsUpdated(false)
{
}
BidirectionalLineRunIndex mBidirectionalLineIndex; ///< The last fetched bidirectional line info.
bool mSpannedTextPlaced : 1; ///< Whether the spanned-text is placed.
- bool mUnderlineRunsUpdated : 1; /// Whether the UnderlinedCharacterRuns is updated. (Added for SpannedText)
+ bool mUnderlineRunsUpdated : 1; /// Whether the UnderlinedCharacterRuns is updated. (Added for SpannedText)
bool mCharacterSpacingRunsUpdated : 1; // Flag for updating character-spacing.
+ bool mStrikethroughRunsUpdated : 1; /// Whether the StrikethroughCharacterRuns is updated. (Added for SpannedText)
};
} // namespace Text
--- /dev/null
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/internal/text/spannable/spans/strikethrough-span-impl.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/color-run.h>
+#include <dali-toolkit/internal/text/markup-tags-and-attributes.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+namespace Internal
+{
+struct StrikethroughSpan::Impl
+{
+ StrikethroughStyleProperties mStrikethroughProperties; ///< The properties of strikethrough style.
+};
+
+StrikethroughSpan::StrikethroughSpan()
+: BaseSpan()
+{
+ mImpl = std::make_unique<Impl>();
+}
+
+StrikethroughSpan ::~StrikethroughSpan()
+{
+}
+
+Dali::Toolkit::Text::StrikethroughSpan StrikethroughSpan::New()
+{
+ StrikethroughSpanPtr object = new StrikethroughSpan();
+ Dali::Toolkit::Text::StrikethroughSpan handle = Dali::Toolkit::Text::StrikethroughSpan(object.Get());
+ return handle;
+}
+
+Dali::Toolkit::Text::StrikethroughSpan StrikethroughSpan::New(Vector4 color, float height)
+{
+ StrikethroughSpanPtr object = new StrikethroughSpan();
+ object->SetColor(color);
+ object->SetHeight(height);
+ Dali::Toolkit::Text::StrikethroughSpan handle = Dali::Toolkit::Text::StrikethroughSpan(object.Get());
+
+ return handle;
+}
+
+//Methods
+const Vector4 StrikethroughSpan::GetColor() const
+{
+ return mImpl->mStrikethroughProperties.color;
+}
+
+bool StrikethroughSpan::IsColorDefined() const
+{
+ return mImpl->mStrikethroughProperties.colorDefined;
+}
+
+void StrikethroughSpan::SetColor(const Vector4& color)
+{
+ mImpl->mStrikethroughProperties.color = color;
+ mImpl->mStrikethroughProperties.colorDefined = true;
+}
+
+const float StrikethroughSpan::GetHeight() const
+{
+ return mImpl->mStrikethroughProperties.height;
+}
+
+bool StrikethroughSpan::IsHeightDefined() const
+{
+ return mImpl->mStrikethroughProperties.heightDefined;
+}
+
+void StrikethroughSpan::SetHeight(const float& height)
+{
+ mImpl->mStrikethroughProperties.height = height;
+ mImpl->mStrikethroughProperties.heightDefined = true;
+}
+
+void StrikethroughSpan::CreateStyleCharacterRun(IntrusivePtr<LogicalModel>& logicalModel, const Dali::Toolkit::Text::Range& range) const
+
+{
+ StrikethroughCharacterRun strikethroughCharacterRun;
+ strikethroughCharacterRun.characterRun.characterIndex = range.GetStartIndex();
+ strikethroughCharacterRun.characterRun.numberOfCharacters = range.GetNumberOfIndices();
+ strikethroughCharacterRun.properties = mImpl->mStrikethroughProperties;
+ logicalModel->mStrikethroughCharacterRuns.PushBack(strikethroughCharacterRun);
+ logicalModel->mStrikethroughRunsUpdated = true;
+}
+
+} // namespace Internal
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
\ No newline at end of file
--- /dev/null
+#ifndef DALI_TOOLKIT_INTERNAL_TEXT_STRIKETHROUGH_SPAN_IMPL_H
+#define DALI_TOOLKIT_INTERNAL_TEXT_STRIKETHROUGH_SPAN_IMPL_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali-toolkit/devel-api/text/spans/strikethrough-span.h>
+#include <memory>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/logical-model-impl.h>
+#include <dali-toolkit/internal/text/spannable/spans/base-span-impl.h>
+#include <dali/public-api/math/vector4.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+namespace Internal
+{
+class StrikethroughSpan;
+
+using StrikethroughSpanPtr = IntrusivePtr<StrikethroughSpan>;
+
+/**
+ * @copydoc Dali::Toolkit::Text::StrikethroughSpan
+ */
+
+class StrikethroughSpan : public BaseSpan
+{
+public:
+ /**
+ * @brief Creates a new StrikethroughSpan object.
+ *
+ * @return A new StrikethroughSpan object.
+ */
+ static Dali::Toolkit::Text::StrikethroughSpan New();
+
+ /**
+ * @brief Creates a new StrikethroughSpan object.
+ *
+ * @param[in] color The color of line.
+ * @param[in] height The height of line.
+ *
+ * @return A new StrikethroughSpan object.
+ */
+ static Dali::Toolkit::Text::StrikethroughSpan New(Vector4 color, float height);
+
+ /**
+ * Default Constructor
+ */
+ StrikethroughSpan();
+ StrikethroughSpan(const StrikethroughSpan&) = delete; ///< Deleted copy constructor
+ StrikethroughSpan(StrikethroughSpan&&) = delete; ///< Deleted move constructor
+ StrikethroughSpan& operator=(const StrikethroughSpan&) = delete; ///< Deleted copy assignment operator
+ StrikethroughSpan& operator=(StrikethroughSpan&&) = delete; ///< Deleted move assignment operator
+
+ /**
+ * @brief Destructor
+ *
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ ~StrikethroughSpan() override;
+
+public: //Methods
+ /**
+ * @copydoc Dali::Toolkit::Text::StrikethroughSpan::GetColor()
+ */
+ const Vector4 GetColor() const;
+
+ /**
+ * @copydoc Dali::Toolkit::Text::StrikethroughSpan::IsColorDefined()
+ */
+ bool IsColorDefined() const;
+
+ /**
+ * @copydoc Dali::Toolkit::Text::StrikethroughSpan::GetHeight()
+ */
+ const float GetHeight() const;
+
+ /**
+ * @copydoc Dali::Toolkit::Text::StrikethroughSpan::IsHeightDefined()
+ */
+ bool IsHeightDefined() const;
+
+public: //Methods. Not intended for application developers
+ /**
+ * @brief Set the color of underline.
+ *
+ * @param[in] color The color of line.
+ */
+ void SetColor(const Vector4& color);
+
+ /**
+ * @brief Set the height of underline.
+ *
+ * @param[in] height The height of line.
+ */
+ void SetHeight(const float& height);
+
+public: //Methods for internal only
+ /**
+ * @copydoc Dali::Toolkit::Text::BaseSpan::CreateStyleCharacterRun
+ */
+ void CreateStyleCharacterRun(IntrusivePtr<LogicalModel>& logicalModel, const Dali::Toolkit::Text::Range& range) const override;
+
+private:
+ struct Impl;
+
+ std::unique_ptr<Impl> mImpl{nullptr};
+
+}; // class StrikethroughSpan
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+
+inline Internal::StrikethroughSpan& GetImplementation(Dali::Toolkit::Text::StrikethroughSpan& foregroundColorSpan)
+{
+ DALI_ASSERT_ALWAYS(foregroundColorSpan && "foregroundColorSpan handle is empty");
+ BaseObject& object = foregroundColorSpan.GetBaseObject();
+ return static_cast<Internal::StrikethroughSpan&>(object);
+}
+
+inline const Internal::StrikethroughSpan& GetImplementation(const Dali::Toolkit::Text::StrikethroughSpan& foregroundColorSpan)
+{
+ DALI_ASSERT_ALWAYS(foregroundColorSpan && "foregroundColorSpan handle is empty");
+ const BaseObject& object = foregroundColorSpan.GetBaseObject();
+ return static_cast<const Internal::StrikethroughSpan&>(object);
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_INTERNAL_TEXT_STRIKETHROUGH_SPAN_IMPL_H
\ No newline at end of file