ae6476cf89e5a1b1b1de2b8386a6b8363e3c350b
[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/spannable/spans/base-span-impl.h>
27 #include <dali/public-api/math/vector4.h>
28
29 namespace Dali
30 {
31 namespace Toolkit
32 {
33 namespace Text
34 {
35 namespace Internal
36 {
37 class ForegroundColorSpan;
38 using ForegroundColorSpanPtr = IntrusivePtr<ForegroundColorSpan>;
39
40 /**
41  * @copydoc Dali::Toolkit::Text::ForegroundColorSpan
42  */
43 class ForegroundColorSpan : public BaseSpan
44 {
45 public:
46   /**
47    * @brief Creates a new ForegroundColorSpan object.
48    */
49   static Dali::Toolkit::Text::ForegroundColorSpan New(Vector4 color);
50
51   /**
52    * Default Constructor
53    */
54   ForegroundColorSpan();
55
56   ForegroundColorSpan(const ForegroundColorSpan&) = delete;            ///< Deleted copy constructor
57   ForegroundColorSpan(ForegroundColorSpan&&)      = delete;            ///< Deleted move constructor
58   ForegroundColorSpan& operator=(const ForegroundColorSpan&) = delete; ///< Deleted copy assignment operator
59   ForegroundColorSpan& operator=(ForegroundColorSpan&&) = delete;      ///< Deleted move assignment operator
60
61   /**
62    * @brief Destructor
63    *
64    * A reference counted object may only be deleted by calling Unreference()
65    */
66   ~ForegroundColorSpan() override;
67
68 public: //Methods
69   /**
70    * @copydoc Dali::Toolkit::Text::ForegroundColorSpan::GetForegroundColor()
71    */
72   const Vector4 GetForegroundColor() const;
73
74   /**
75    * @copydoc Dali::Toolkit::Text::ForegroundColorSpan::IsForegroundColorDefined()
76    */
77   bool IsForegroundColorDefined() const;
78
79 public: //Methods. Not intended for application developers
80   /**
81    * @brief Set the foreground-color.
82    *
83    * @param[in] color The foreground-color.
84    */
85   void SetForegroundColor(Vector4 color);
86
87 private:
88   struct Impl;
89   std::unique_ptr<Impl> mImpl{nullptr};
90
91 }; // class ForegroundColorSpan
92
93 } // namespace Internal
94
95 // Helpers for public-api forwarding methods
96
97 inline Internal::ForegroundColorSpan& GetImplementation(Dali::Toolkit::Text::ForegroundColorSpan& foregroundColorSpan)
98 {
99   DALI_ASSERT_ALWAYS(foregroundColorSpan && "foregroundColorSpan handle is empty");
100
101   BaseObject& object = foregroundColorSpan.GetBaseObject();
102
103   return static_cast<Internal::ForegroundColorSpan&>(object);
104 }
105
106 inline const Internal::ForegroundColorSpan& GetImplementation(const Dali::Toolkit::Text::ForegroundColorSpan& foregroundColorSpan)
107 {
108   DALI_ASSERT_ALWAYS(foregroundColorSpan && "foregroundColorSpan handle is empty");
109
110   const BaseObject& object = foregroundColorSpan.GetBaseObject();
111
112   return static_cast<const Internal::ForegroundColorSpan&>(object);
113 }
114
115 } // namespace Text
116
117 } // namespace Toolkit
118
119 } // namespace Dali
120
121 #endif // DALI_TOOLKIT_INTERNAL_TEXT_FOREGROUND_COLOR_SPAN_IMPL_H