Merge "Fix issue using broken image" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / spannable / spans / underline-span-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_TEXT_UNDERLINE_SPAN_IMPL_H
2 #define DALI_TOOLKIT_INTERNAL_TEXT_UNDERLINE_SPAN_IMPL_H
3
4 /*
5  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali-toolkit/devel-api/text/spans/underline-span.h>
23 #include <memory>
24
25 // INTERNAL INCLUDES
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>
29
30 namespace Dali
31 {
32 namespace Toolkit
33 {
34 namespace Text
35 {
36 namespace Internal
37 {
38 class UnderlineSpan;
39 using UnderlineSpanPtr = IntrusivePtr<UnderlineSpan>;
40
41 /**
42  * @copydoc Dali::Toolkit::Text::UnderlineSpan
43  */
44 class UnderlineSpan : public BaseSpan
45 {
46 public:
47   /**
48    * @brief Creates a new UnderlineSpan object.
49    *
50    * @return A new UnderlineSpan object.
51    */
52   static Dali::Toolkit::Text::UnderlineSpan New();
53
54   /**
55    * @brief Creates a new UnderlineSpan object.
56    *
57    * @param[in] color The color of line.
58    * @param[in] height The height of line.
59    *
60    * @return A new UnderlineSpan object.
61    */
62   static Dali::Toolkit::Text::UnderlineSpan NewSolid(Vector4 color, float height);
63
64   /**
65    *
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.
70    *
71    * @return A new UnderlineSpan object.
72    */
73   static Dali::Toolkit::Text::UnderlineSpan NewDashed(Vector4 color, float height, float dashGap, float dashWidth);
74
75   /**
76    * @brief Creates a new UnderlineSpan object.
77    *
78    * @param[in] color The color of line.
79    * @param[in] height The height of line.
80    *
81    * @return A new UnderlineSpan object.
82    */
83   static Dali::Toolkit::Text::UnderlineSpan NewDouble(Vector4 color, float height);
84
85   /**
86    * Default Constructor
87    */
88   UnderlineSpan();
89
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
94
95   /**
96    * @brief Destructor
97    *
98    * A reference counted object may only be deleted by calling Unreference()
99    */
100   ~UnderlineSpan() override;
101
102 public: //Methods
103   /**
104    * @copydoc Dali::Toolkit::Text::UnderlineSpan::GetType()
105    */
106   const Text::Underline::Type GetType() const;
107
108   /**
109    * @copydoc Dali::Toolkit::Text::UnderlineSpan::IsTypeDefined()
110    */
111   bool IsTypeDefined() const;
112
113   /**
114    * @copydoc Dali::Toolkit::Text::UnderlineSpan::GetColor()
115    */
116   const Vector4 GetColor() const;
117
118   /**
119    * @copydoc Dali::Toolkit::Text::UnderlineSpan::IsColorDefined()
120    */
121   bool IsColorDefined() const;
122
123   /**
124    * @copydoc Dali::Toolkit::Text::UnderlineSpan::GetHeight()
125    */
126   const float GetHeight() const;
127
128   /**
129    * @copydoc Dali::Toolkit::Text::UnderlineSpan::IsHeightDefined()
130    */
131   bool IsHeightDefined() const;
132
133   /**
134    * @copydoc Dali::Toolkit::Text::UnderlineSpan::GetDashGap()
135    */
136   const float GetDashGap() const;
137
138   /**
139    * @copydoc Dali::Toolkit::Text::UnderlineSpan::IsDashGapDefined()
140    */
141   bool IsDashGapDefined() const;
142
143   /**
144    * @copydoc Dali::Toolkit::Text::UnderlineSpan::GetDashWidth()
145    */
146   const float GetDashWidth() const;
147
148   /**
149    * @copydoc Dali::Toolkit::Text::UnderlineSpan::IsDashWidthDefined()
150    */
151   bool IsDashWidthDefined() const;
152
153 public: //Methods. Not intended for application developers
154   /**
155    * @brief Set the type of underline.
156    *
157    * @param[in] type The type of line.
158    */
159   void SetType(const Text::Underline::Type& type);
160
161   /**
162    * @brief Set the color of underline.
163    *
164    * @param[in] color The color of line.
165    */
166   void SetColor(const Vector4& color);
167
168   /**
169    * @brief Set the height of underline.
170    *
171    * @param[in] height The height of line.
172    */
173   void SetHeight(const float& height);
174
175   /**
176    * @brief Set the dash-gap of underline.
177    *
178    * @param[in] dashGap The dash-gap of line.
179    */
180   void SetDashGap(const float& dashGap);
181
182   /**
183     * @brief Set the dash-width of underline.
184     *
185     * @param[in] dashWidth The dash-width of line.
186     */
187   void SetDashWidth(const float& dashWidth);
188
189 public: //Methods for internal only
190         /**
191    * @copydoc Dali::Toolkit::Text::BaseSpan::CreateStyleCharacterRun
192    */
193   void CreateStyleCharacterRun(IntrusivePtr<LogicalModel>& logicalModel, const Dali::Toolkit::Text::Range& range) const override;
194
195 private:
196   struct Impl;
197   std::unique_ptr<Impl> mImpl{nullptr};
198
199 }; // class UnderlineSpan
200
201 } // namespace Internal
202
203 // Helpers for public-api forwarding methods
204
205 inline Internal::UnderlineSpan& GetImplementation(Dali::Toolkit::Text::UnderlineSpan& underlineSpan)
206 {
207   DALI_ASSERT_ALWAYS(underlineSpan && "underlineSpan handle is empty");
208
209   BaseObject& object = underlineSpan.GetBaseObject();
210
211   return static_cast<Internal::UnderlineSpan&>(object);
212 }
213
214 inline const Internal::UnderlineSpan& GetImplementation(const Dali::Toolkit::Text::UnderlineSpan& underlineSpan)
215 {
216   DALI_ASSERT_ALWAYS(underlineSpan && "underlineSpan handle is empty");
217
218   const BaseObject& object = underlineSpan.GetBaseObject();
219
220   return static_cast<const Internal::UnderlineSpan&>(object);
221 }
222
223 } // namespace Text
224
225 } // namespace Toolkit
226
227 } // namespace Dali
228
229 #endif // DALI_TOOLKIT_INTERNAL_TEXT_UNDERLINE_SPAN_IMPL_H