1 #ifndef DALI_TOOLKIT_INTERNAL_TEXT_UNDERLINE_SPAN_IMPL_H
2 #define DALI_TOOLKIT_INTERNAL_TEXT_UNDERLINE_SPAN_IMPL_H
5 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali-toolkit/devel-api/text/spans/underline-span.h>
26 #include <dali-toolkit/internal/text/logical-model-impl.h>
27 #include <dali-toolkit/internal/text/spannable/spans/base-span-impl.h>
28 #include <dali/public-api/math/vector4.h>
39 using UnderlineSpanPtr = IntrusivePtr<UnderlineSpan>;
42 * @copydoc Dali::Toolkit::Text::UnderlineSpan
44 class UnderlineSpan : public BaseSpan
48 * @brief Creates a new UnderlineSpan object.
50 * @return A new UnderlineSpan object.
52 static Dali::Toolkit::Text::UnderlineSpan New();
55 * @brief Creates a new UnderlineSpan object.
57 * @param[in] color The color of line.
58 * @param[in] height The height of line.
60 * @return A new UnderlineSpan object.
62 static Dali::Toolkit::Text::UnderlineSpan NewSolid(Vector4 color, float height);
66 * @param[in] color The color of line.
67 * @param[in] height The height of line.
68 * @param[in] dashGap The dash-gap of line.
69 * @param[in] dashWidth The dash-width of line.
71 * @return A new UnderlineSpan object.
73 static Dali::Toolkit::Text::UnderlineSpan NewDashed(Vector4 color, float height, float dashGap, float dashWidth);
76 * @brief Creates a new UnderlineSpan object.
78 * @param[in] color The color of line.
79 * @param[in] height The height of line.
81 * @return A new UnderlineSpan object.
83 static Dali::Toolkit::Text::UnderlineSpan NewDouble(Vector4 color, float height);
90 UnderlineSpan(const UnderlineSpan&) = delete; ///< Deleted copy constructor
91 UnderlineSpan(UnderlineSpan&&) = delete; ///< Deleted move constructor
92 UnderlineSpan& operator=(const UnderlineSpan&) = delete; ///< Deleted copy assignment operator
93 UnderlineSpan& operator=(UnderlineSpan&&) = delete; ///< Deleted move assignment operator
98 * A reference counted object may only be deleted by calling Unreference()
100 ~UnderlineSpan() override;
104 * @copydoc Dali::Toolkit::Text::UnderlineSpan::GetType()
106 const Text::Underline::Type GetType() const;
109 * @copydoc Dali::Toolkit::Text::UnderlineSpan::IsTypeDefined()
111 bool IsTypeDefined() const;
114 * @copydoc Dali::Toolkit::Text::UnderlineSpan::GetColor()
116 const Vector4 GetColor() const;
119 * @copydoc Dali::Toolkit::Text::UnderlineSpan::IsColorDefined()
121 bool IsColorDefined() const;
124 * @copydoc Dali::Toolkit::Text::UnderlineSpan::GetHeight()
126 const float GetHeight() const;
129 * @copydoc Dali::Toolkit::Text::UnderlineSpan::IsHeightDefined()
131 bool IsHeightDefined() const;
134 * @copydoc Dali::Toolkit::Text::UnderlineSpan::GetDashGap()
136 const float GetDashGap() const;
139 * @copydoc Dali::Toolkit::Text::UnderlineSpan::IsDashGapDefined()
141 bool IsDashGapDefined() const;
144 * @copydoc Dali::Toolkit::Text::UnderlineSpan::GetDashWidth()
146 const float GetDashWidth() const;
149 * @copydoc Dali::Toolkit::Text::UnderlineSpan::IsDashWidthDefined()
151 bool IsDashWidthDefined() const;
153 public: //Methods. Not intended for application developers
155 * @brief Set the type of underline.
157 * @param[in] type The type of line.
159 void SetType(const Text::Underline::Type& type);
162 * @brief Set the color of underline.
164 * @param[in] color The color of line.
166 void SetColor(const Vector4& color);
169 * @brief Set the height of underline.
171 * @param[in] height The height of line.
173 void SetHeight(const float& height);
176 * @brief Set the dash-gap of underline.
178 * @param[in] dashGap The dash-gap of line.
180 void SetDashGap(const float& dashGap);
183 * @brief Set the dash-width of underline.
185 * @param[in] dashWidth The dash-width of line.
187 void SetDashWidth(const float& dashWidth);
189 public: //Methods for internal only
191 * @copydoc Dali::Toolkit::Text::BaseSpan::CreateStyleCharacterRun
193 void CreateStyleCharacterRun(IntrusivePtr<LogicalModel>& logicalModel, const Dali::Toolkit::Text::Range& range) const override;
197 std::unique_ptr<Impl> mImpl{nullptr};
199 }; // class UnderlineSpan
201 } // namespace Internal
203 // Helpers for public-api forwarding methods
205 inline Internal::UnderlineSpan& GetImplementation(Dali::Toolkit::Text::UnderlineSpan& underlineSpan)
207 DALI_ASSERT_ALWAYS(underlineSpan && "underlineSpan handle is empty");
209 BaseObject& object = underlineSpan.GetBaseObject();
211 return static_cast<Internal::UnderlineSpan&>(object);
214 inline const Internal::UnderlineSpan& GetImplementation(const Dali::Toolkit::Text::UnderlineSpan& underlineSpan)
216 DALI_ASSERT_ALWAYS(underlineSpan && "underlineSpan handle is empty");
218 const BaseObject& object = underlineSpan.GetBaseObject();
220 return static_cast<const Internal::UnderlineSpan&>(object);
225 } // namespace Toolkit
229 #endif // DALI_TOOLKIT_INTERNAL_TEXT_UNDERLINE_SPAN_IMPL_H