Merge "Add GetTextBoundingRectangle API for Text Controllers" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / spannable / spans / strikethrough-span-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_TEXT_STRIKETHROUGH_SPAN_IMPL_H
2 #define DALI_TOOLKIT_INTERNAL_TEXT_STRIKETHROUGH_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/strikethrough-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 StrikethroughSpan;
39
40 using StrikethroughSpanPtr = IntrusivePtr<StrikethroughSpan>;
41
42 /**
43  * @copydoc Dali::Toolkit::Text::StrikethroughSpan
44  */
45
46 class StrikethroughSpan : public BaseSpan
47 {
48 public:
49   /**
50    * @brief Creates a new StrikethroughSpan object.
51    *
52    * @return A new StrikethroughSpan object.
53    */
54   static Dali::Toolkit::Text::StrikethroughSpan New();
55
56   /**
57    * @brief Creates a new StrikethroughSpan object.
58    *
59    * @param[in] color The color of line.
60    * @param[in] height The height of line.
61    *
62    * @return A new StrikethroughSpan object.
63    */
64   static Dali::Toolkit::Text::StrikethroughSpan New(Vector4 color, float height);
65
66   /**
67    * Default Constructor
68    */
69   StrikethroughSpan();
70   StrikethroughSpan(const StrikethroughSpan&) = delete;            ///< Deleted copy constructor
71   StrikethroughSpan(StrikethroughSpan&&)      = delete;            ///< Deleted move constructor
72   StrikethroughSpan& operator=(const StrikethroughSpan&) = delete; ///< Deleted copy assignment operator
73   StrikethroughSpan& operator=(StrikethroughSpan&&) = delete;      ///< Deleted move assignment operator
74
75   /**
76    * @brief Destructor
77    *
78    * A reference counted object may only be deleted by calling Unreference()
79    */
80   ~StrikethroughSpan() override;
81
82 public: //Methods
83   /**
84    * @copydoc Dali::Toolkit::Text::StrikethroughSpan::GetColor()
85    */
86   const Vector4 GetColor() const;
87
88   /**
89    * @copydoc Dali::Toolkit::Text::StrikethroughSpan::IsColorDefined()
90    */
91   bool IsColorDefined() const;
92
93   /**
94    * @copydoc Dali::Toolkit::Text::StrikethroughSpan::GetHeight()
95    */
96   const float GetHeight() const;
97
98   /**
99    * @copydoc Dali::Toolkit::Text::StrikethroughSpan::IsHeightDefined()
100    */
101   bool IsHeightDefined() const;
102
103 public: //Methods. Not intended for application developers
104   /**
105    * @brief Set the color of underline.
106    *
107    * @param[in] color The color of line.
108    */
109   void SetColor(const Vector4& color);
110
111   /**
112    * @brief Set the height of underline.
113    *
114    * @param[in] height The height of line.
115    */
116   void SetHeight(const float& height);
117
118 public: //Methods for internal only
119   /**
120    * @copydoc Dali::Toolkit::Text::BaseSpan::CreateStyleCharacterRun
121    */
122   void CreateStyleCharacterRun(IntrusivePtr<LogicalModel>& logicalModel, const Dali::Toolkit::Text::Range& range) const override;
123
124 private:
125   struct Impl;
126
127   std::unique_ptr<Impl> mImpl{nullptr};
128
129 }; // class StrikethroughSpan
130
131 } // namespace Internal
132
133 // Helpers for public-api forwarding methods
134
135 inline Internal::StrikethroughSpan& GetImplementation(Dali::Toolkit::Text::StrikethroughSpan& foregroundColorSpan)
136 {
137   DALI_ASSERT_ALWAYS(foregroundColorSpan && "foregroundColorSpan handle is empty");
138   BaseObject& object = foregroundColorSpan.GetBaseObject();
139   return static_cast<Internal::StrikethroughSpan&>(object);
140 }
141
142 inline const Internal::StrikethroughSpan& GetImplementation(const Dali::Toolkit::Text::StrikethroughSpan& foregroundColorSpan)
143 {
144   DALI_ASSERT_ALWAYS(foregroundColorSpan && "foregroundColorSpan handle is empty");
145   const BaseObject& object = foregroundColorSpan.GetBaseObject();
146   return static_cast<const Internal::StrikethroughSpan&>(object);
147 }
148
149 } // namespace Text
150
151 } // namespace Toolkit
152
153 } // namespace Dali
154
155 #endif // DALI_TOOLKIT_INTERNAL_TEXT_STRIKETHROUGH_SPAN_IMPL_H