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