Merge "Add GetTextBoundingRectangle API for Text Controllers" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / spannable / spans / character-spacing-span-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_TEXT_CHARACTER_SPACING_SPAN_IMPL_H
2 #define DALI_TOOLKIT_INTERNAL_TEXT_CHARACTER_SPACING_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/character-spacing-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 CharacterSpacingSpan;
39 using CharacterSpacingSpanPtr = IntrusivePtr<CharacterSpacingSpan>;
40
41 /**
42  * @copydoc Dali::Toolkit::Text::CharacterSpacingSpan
43  */
44 class CharacterSpacingSpan : public BaseSpan
45 {
46 public:
47   /**
48    * @brief Creates a new CharacterSpacingSpan object.
49    */
50   static Dali::Toolkit::Text::CharacterSpacingSpan New(const float& value);
51
52   /**
53    * Default Constructor
54    */
55   CharacterSpacingSpan();
56
57   CharacterSpacingSpan(const CharacterSpacingSpan&) = delete;            ///< Deleted copy constructor
58   CharacterSpacingSpan(CharacterSpacingSpan&&)      = delete;            ///< Deleted move constructor
59   CharacterSpacingSpan& operator=(const CharacterSpacingSpan&) = delete; ///< Deleted copy assignment operator
60   CharacterSpacingSpan& operator=(CharacterSpacingSpan&&) = 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   ~CharacterSpacingSpan() override;
68
69 public: //Methods
70   /**
71    * @copydoc Dali::Toolkit::Text::CharacterSpacingSpan::GetCharacterSpacing()
72    */
73   const float GetCharacterSpacing() const;
74
75   /**
76    * @copydoc Dali::Toolkit::Text::CharacterSpacingSpan::IsCharacterSpacingDefined()
77    */
78   bool IsCharacterSpacingDefined() const;
79
80 public: //Methods. Not intended for application developers
81   /**
82    * @brief Set the CharacterSpacing.
83    *
84    * @param[in] value The CharacterSpacing.
85    */
86   void SetCharacterSpacing(const float& value);
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 CharacterSpacingSpan
99
100 } // namespace Internal
101
102 // Helpers for public-api forwarding methods
103
104 inline Internal::CharacterSpacingSpan& GetImplementation(Dali::Toolkit::Text::CharacterSpacingSpan& characterSpacingSpan)
105 {
106   DALI_ASSERT_ALWAYS(characterSpacingSpan && "CharacterSpacingSpan handle is empty");
107
108   BaseObject& object = characterSpacingSpan.GetBaseObject();
109
110   return static_cast<Internal::CharacterSpacingSpan&>(object);
111 }
112
113 inline const Internal::CharacterSpacingSpan& GetImplementation(const Dali::Toolkit::Text::CharacterSpacingSpan& CharacterSpacingSpan)
114 {
115   DALI_ASSERT_ALWAYS(CharacterSpacingSpan && "CharacterSpacingSpan handle is empty");
116
117   const BaseObject& object = CharacterSpacingSpan.GetBaseObject();
118
119   return static_cast<const Internal::CharacterSpacingSpan&>(object);
120 }
121
122 } // namespace Text
123
124 } // namespace Toolkit
125
126 } // namespace Dali
127
128 #endif // DALI_TOOLKIT_INTERNAL_TEXT_CHARACTER_SPACING_SPAN_IMPL_H