#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>
+
using namespace Dali;
using namespace Toolkit;
return spannableString;
}
+Text::SpannableString CreateSpannableStringForCharacterSpacing()
+{
+ Text::SpannableString spannableString = Text::SpannableString::New("Hello World");
+ DALI_TEST_CHECK(spannableString);
+
+ auto isCharacterSpacingSpan = spannableString.AttachSpan(
+ Text::CharacterSpacingSpan::New(5.2f),
+ Text::Range::New(5u, 7u));
+ DALI_TEST_CHECK(isCharacterSpacingSpan);
+
+ return spannableString;
+}
+
void CheckColorIndices(const Text::ColorIndex* const colorIndicesBuffer,
uint32_t numberOfIndices,
std::vector<uint32_t> indicesToCheck,
DALI_TEST_CHECK(underlineRuns[0].properties == expectedProperties);
END_TEST;
+}
+
+int UtcDaliToolkitTextLabelSetSpannedText_CharacterSpacingSpan(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliToolkitTextLabelSetSpannedText_CharacterSpacingSpan");
+
+ TextLabel textLabel = TextLabel::New();
+ DALI_TEST_CHECK(textLabel);
+ application.GetScene().Add(textLabel);
+
+ Text::SpannableString spannableString = CreateSpannableStringForCharacterSpacing();
+ Text::SetSpannedText(textLabel, spannableString);
+
+ application.SendNotification();
+ application.Render();
+
+ 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;
}
\ No newline at end of file
utc-Dali-TableView.cpp
utc-Dali-Text-BaseSpan.cpp
utc-Dali-Text-ForegroundColorSpan.cpp
+ utc-Dali-Text-CharacterSpacingSpan.cpp
utc-Dali-Text-FontSpan.cpp
utc-Dali-Text-Range.cpp
utc-Dali-Text-SpannableString.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/character-spacing-span.h>
+
+using namespace Dali;
+using namespace Toolkit;
+
+int UtcDaliToolkitCharacterSpacingSpanNew(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliToolkitCharacterSpacingSpanNew");
+
+ auto charSpacingSpan = Text::CharacterSpacingSpan::New(5.6f);
+ DALI_TEST_CHECK(charSpacingSpan);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitGetCharacterSpacingSpan(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliToolkitCharacterSpacingSpanNew");
+
+ auto charSpacingSpan = Text::CharacterSpacingSpan::New(9.1f);
+ DALI_TEST_CHECK(charSpacingSpan);
+ DALI_TEST_EQUALS(9.1f, charSpacingSpan.GetCharacterSpacing(), TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitCharacterSpacingSpanDownCast(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliToolkitCharacterSpacingSpanDownCast");
+
+ Text::BaseSpan baseSpan = Text::CharacterSpacingSpan::New(3.6f);
+ DALI_TEST_CHECK(baseSpan);
+
+ Text::CharacterSpacingSpan charSpacingSpan = Text::CharacterSpacingSpan::DownCast(baseSpan);
+ DALI_TEST_CHECK(charSpacingSpan);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitIsCharacterSpacingDefined(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliToolkitIsCharacterSpacingDefined");
+
+ auto charSpacingSpan = Text::CharacterSpacingSpan::New(4.2f);
+ DALI_TEST_CHECK(charSpacingSpan);
+ DALI_TEST_EQUALS(true, charSpacingSpan.IsCharacterSpacingDefined(), TEST_LOCATION);
+
+ END_TEST;
+}
${devel_api_src_dir}/text/spannable-string.cpp
${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/font-span.cpp
${devel_api_src_dir}/text/spans/underline-span.cpp
${devel_api_src_dir}/transition-effects/cube-transition-cross-effect.cpp
${devel_api_src_dir}/text/spannable-string.h
${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/font-span.h
${devel_api_src_dir}/text/spans/underline-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/character-spacing-span.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/spannable/spans/character-spacing-span-impl.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+CharacterSpacingSpan CharacterSpacingSpan::New(const float value)
+{
+ return Internal::CharacterSpacingSpan::New(value);
+}
+
+CharacterSpacingSpan::CharacterSpacingSpan(Internal::CharacterSpacingSpan* internal)
+: BaseSpan(internal)
+{
+}
+
+CharacterSpacingSpan::CharacterSpacingSpan() = default;
+
+CharacterSpacingSpan::CharacterSpacingSpan(const CharacterSpacingSpan& rhs) = default;
+
+CharacterSpacingSpan::CharacterSpacingSpan(CharacterSpacingSpan&& rhs) = default;
+
+CharacterSpacingSpan& CharacterSpacingSpan::operator=(const CharacterSpacingSpan& rhs) = default;
+
+CharacterSpacingSpan& CharacterSpacingSpan::operator=(CharacterSpacingSpan&& rhs) = default;
+
+CharacterSpacingSpan::~CharacterSpacingSpan() = default;
+
+//Methods
+const float CharacterSpacingSpan::GetCharacterSpacing() const
+{
+ return GetImplementation(*this).GetCharacterSpacing();
+}
+
+bool CharacterSpacingSpan::IsCharacterSpacingDefined() const
+{
+ return GetImplementation(*this).IsCharacterSpacingDefined();
+}
+
+CharacterSpacingSpan CharacterSpacingSpan::DownCast(BaseHandle handle)
+{
+ return CharacterSpacingSpan(dynamic_cast<Dali::Toolkit::Text::Internal::CharacterSpacingSpan*>(handle.GetObjectPtr()));
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_TEXT_CHARACTER_SPACING_SPAN_H
+#define DALI_TOOLKIT_TEXT_CHARACTER_SPACING_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>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+namespace Internal DALI_INTERNAL
+{
+class CharacterSpacingSpan;
+}
+
+/**
+ * @brief CharacterSpacingSpan is a handle to an object that specifies the CharacterSpacing for range of characters.
+ */
+class DALI_TOOLKIT_API CharacterSpacingSpan : public BaseSpan
+{
+public:
+ /**
+ * @brief Create an initialized CharacterSpacingSpan.
+ *
+ * @param[in] value The CharacterSpacing value.
+ *
+ * @return A handle to a newly allocated Dali resource
+ */
+ static CharacterSpacingSpan New(const float value);
+
+ /**
+ * @brief Creates an uninitialized CharacterSpacingSpan handle.
+ *
+ * Calling member functions with an uninitialized CharacterSpacingSpan handle is not allowed.
+ */
+ CharacterSpacingSpan();
+
+ /**
+ * @brief Copy constructor.
+ * @param[in] rhs A reference to the copied handle
+ */
+ CharacterSpacingSpan(const CharacterSpacingSpan& rhs);
+
+ /**
+ * @brief Move constructor.
+ * @param[in] rhs A reference to the handle to move
+ */
+ CharacterSpacingSpan(CharacterSpacingSpan&& rhs);
+
+ /**
+ * @brief Assignment operator.
+ * @param[in] rhs A reference to the copied handle
+ * @return A reference to this
+ */
+ CharacterSpacingSpan& operator=(const CharacterSpacingSpan& rhs);
+
+ /**
+ * @brief Move assignment operator.
+ * @param[in] rhs A reference to the moved handle
+ * @return A reference to this
+ */
+ CharacterSpacingSpan& operator=(CharacterSpacingSpan&& rhs);
+
+ /**
+ * @brief Non virtual destructor.
+ */
+ ~CharacterSpacingSpan();
+
+ /**
+ * @brief Downcasts to a CharacterSpacingSpan handle.
+ * If handle is not a CharacterSpacingSpan, the returned handle is left uninitialized.
+ *
+ * @param[in] handle Handle to an object
+ * @return CharacterSpacingSpan handle or an uninitialized handle
+ */
+ static CharacterSpacingSpan DownCast(BaseHandle handle);
+
+public: //Methods
+ /**
+ * @brief Retrive the CharacterSpacing.
+ *
+ * @return A CharacterSpacing value.
+ */
+ const float GetCharacterSpacing() const;
+
+ /**
+ * @brief Retrieve whether the CharacterSpacing is defined.
+ *
+ * @return The return is true if CharacterSpacing is defined, otherwise false.
+ */
+ bool IsCharacterSpacingDefined() const;
+
+public: // Not intended for application developers
+ /// @cond internal
+ /**
+ * @brief This constructor is used internally to Create an initialized CharacterSpacingSpan handle.
+ *
+ * @param[in] charSpacingSpan Pointer to internal CharacterSpacingSpan
+ */
+ explicit DALI_INTERNAL CharacterSpacingSpan(Internal::CharacterSpacingSpan* charSpacingSpan);
+ /// @endcond
+};
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_CHARACTER_SPACING_SPAN_H
${toolkit_src_dir}/text/spannable/spannable-string-impl.cpp
${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/font-span-impl.cpp
${toolkit_src_dir}/text/spannable/spans/underline-span-impl.cpp
${toolkit_src_dir}/text/spannable/span-ranges-container-impl.cpp
{
//Mark-up processor case
if(impl.mModel->mVisualModel->IsMarkupProcessorEnabled() ||
- impl.mModel->mLogicalModel->mUnderlineRunsUpdated)
+ impl.mModel->mLogicalModel->mUnderlineRunsUpdated ||
+ impl.mModel->mLogicalModel->mCharacterSpacingRunsUpdated)
{
impl.CopyUnderlinedFromLogicalToVisualModels(true);
impl.CopyStrikethroughFromLogicalToVisualModels();
mModel->mVisualModel->mCharacterSpacingRuns.PushBack(characterSpacingGlyphRun);
}
+ mModel->mLogicalModel->mCharacterSpacingRunsUpdated = false;
}
void Controller::Impl::SetAutoScrollEnabled(bool enable)
LogicalModel::LogicalModel()
: mBidirectionalLineIndex(0u),
mSpannedTextPlaced(false),
- mUnderlineRunsUpdated(false)
+ mUnderlineRunsUpdated(false),
+ mCharacterSpacingRunsUpdated(false)
{
}
bool mSpannedTextPlaced : 1; ///< Whether the spanned-text is placed.
bool mUnderlineRunsUpdated : 1; /// Whether the UnderlinedCharacterRuns is updated. (Added for SpannedText)
+ bool mCharacterSpacingRunsUpdated : 1; // Flag for updating character-spacing.
};
} // 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/character-spacing-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 CharacterSpacingSpan::Impl
+{
+ float mCharacterSpacing; ///< The character-spacing-value.
+ bool mCharacterSpacingDefined : 1; ///< Whether the character-spacing-value is defined.
+};
+
+CharacterSpacingSpan::CharacterSpacingSpan()
+: BaseSpan()
+{
+ mImpl = std::make_unique<Impl>();
+}
+
+CharacterSpacingSpan ::~CharacterSpacingSpan()
+{
+}
+
+Dali::Toolkit::Text::CharacterSpacingSpan CharacterSpacingSpan::New(const float& value)
+{
+ CharacterSpacingSpanPtr object = new CharacterSpacingSpan();
+ object->SetCharacterSpacing(value);
+
+ Dali::Toolkit::Text::CharacterSpacingSpan handle = Dali::Toolkit::Text::CharacterSpacingSpan(object.Get());
+
+ return handle;
+}
+
+//Methods
+const float CharacterSpacingSpan::GetCharacterSpacing() const
+{
+ return mImpl->mCharacterSpacing;
+}
+
+bool CharacterSpacingSpan::IsCharacterSpacingDefined() const
+{
+ return mImpl->mCharacterSpacingDefined;
+}
+
+void CharacterSpacingSpan::SetCharacterSpacing(const float& value)
+{
+ mImpl->mCharacterSpacing = value;
+ mImpl->mCharacterSpacingDefined = true;
+}
+
+void CharacterSpacingSpan::CreateStyleCharacterRun(IntrusivePtr<LogicalModel>& logicalModel, const Dali::Toolkit::Text::Range& range) const
+{
+ CharacterSpacingCharacterRun characterSpacingCharacterRun;
+ characterSpacingCharacterRun.characterRun.characterIndex = range.GetStartIndex();
+ characterSpacingCharacterRun.characterRun.numberOfCharacters = range.GetNumberOfIndices();
+ characterSpacingCharacterRun.value = mImpl->mCharacterSpacing;
+ logicalModel->mCharacterSpacingCharacterRuns.PushBack(characterSpacingCharacterRun);
+ logicalModel->mCharacterSpacingRunsUpdated = true;
+}
+
+} // namespace Internal
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_INTERNAL_TEXT_CHARACTER_SPACING_SPAN_IMPL_H
+#define DALI_TOOLKIT_INTERNAL_TEXT_CHARACTER_SPACING_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/character-spacing-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 CharacterSpacingSpan;
+using CharacterSpacingSpanPtr = IntrusivePtr<CharacterSpacingSpan>;
+
+/**
+ * @copydoc Dali::Toolkit::Text::CharacterSpacingSpan
+ */
+class CharacterSpacingSpan : public BaseSpan
+{
+public:
+ /**
+ * @brief Creates a new CharacterSpacingSpan object.
+ */
+ static Dali::Toolkit::Text::CharacterSpacingSpan New(const float& value);
+
+ /**
+ * Default Constructor
+ */
+ CharacterSpacingSpan();
+
+ CharacterSpacingSpan(const CharacterSpacingSpan&) = delete; ///< Deleted copy constructor
+ CharacterSpacingSpan(CharacterSpacingSpan&&) = delete; ///< Deleted move constructor
+ CharacterSpacingSpan& operator=(const CharacterSpacingSpan&) = delete; ///< Deleted copy assignment operator
+ CharacterSpacingSpan& operator=(CharacterSpacingSpan&&) = delete; ///< Deleted move assignment operator
+
+ /**
+ * @brief Destructor
+ *
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ ~CharacterSpacingSpan() override;
+
+public: //Methods
+ /**
+ * @copydoc Dali::Toolkit::Text::CharacterSpacingSpan::GetCharacterSpacing()
+ */
+ const float GetCharacterSpacing() const;
+
+ /**
+ * @copydoc Dali::Toolkit::Text::CharacterSpacingSpan::IsCharacterSpacingDefined()
+ */
+ bool IsCharacterSpacingDefined() const;
+
+public: //Methods. Not intended for application developers
+ /**
+ * @brief Set the CharacterSpacing.
+ *
+ * @param[in] value The CharacterSpacing.
+ */
+ void SetCharacterSpacing(const float& value);
+
+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 CharacterSpacingSpan
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+
+inline Internal::CharacterSpacingSpan& GetImplementation(Dali::Toolkit::Text::CharacterSpacingSpan& characterSpacingSpan)
+{
+ DALI_ASSERT_ALWAYS(characterSpacingSpan && "CharacterSpacingSpan handle is empty");
+
+ BaseObject& object = characterSpacingSpan.GetBaseObject();
+
+ return static_cast<Internal::CharacterSpacingSpan&>(object);
+}
+
+inline const Internal::CharacterSpacingSpan& GetImplementation(const Dali::Toolkit::Text::CharacterSpacingSpan& CharacterSpacingSpan)
+{
+ DALI_ASSERT_ALWAYS(CharacterSpacingSpan && "CharacterSpacingSpan handle is empty");
+
+ const BaseObject& object = CharacterSpacingSpan.GetBaseObject();
+
+ return static_cast<const Internal::CharacterSpacingSpan&>(object);
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_INTERNAL_TEXT_CHARACTER_SPACING_SPAN_IMPL_H
\ No newline at end of file