Makes the LTR/RTL alignment of text follow the system language by default.
[platform/core/uifw/dali-adaptor.git] / dali / internal / text / text-abstraction / bidirectional-support-impl.h
1 #ifndef DALI_INTERNAL_TEXT_ABSTRACTION_BIDIRECTIONAL_SUPPORT_IMPL_H
2 #define DALI_INTERNAL_TEXT_ABSTRACTION_BIDIRECTIONAL_SUPPORT_IMPL_H
3
4 /*
5  * Copyright (c) 2021 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/public-api/common/dali-vector.h>
23 #include <dali/public-api/object/base-object.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/devel-api/text-abstraction/bidirectional-support.h>
27
28 namespace Dali
29 {
30 namespace TextAbstraction
31 {
32 namespace Internal
33 {
34 /**
35  * Implementation of the BidirectionalSupport
36  */
37 class BidirectionalSupport : public BaseObject
38 {
39 public:
40   /**
41    * Constructor
42    */
43   BidirectionalSupport();
44
45   /**
46    * Destructor
47    */
48   ~BidirectionalSupport();
49
50   /**
51    * @copydoc Dali::BidirectionalSupport::Get()
52    */
53   static TextAbstraction::BidirectionalSupport Get();
54
55   /**
56    * @copydoc Dali::BidirectionalSupport::CreateInfo()
57    */
58   BidiInfoIndex CreateInfo(const Character* const paragraph,
59                            Length                 numberOfCharacters,
60                            bool                   matchLayoutDirection,
61                            LayoutDirection::Type  layoutDirection);
62
63   /**
64    * @copydoc Dali::BidirectionalSupport::DestroyInfo()
65    */
66   void DestroyInfo(BidiInfoIndex bidiInfoIndex);
67
68   /**
69    * @copydoc Dali::BidirectionalSupport::Reorder()
70    */
71   void Reorder(BidiInfoIndex   bidiInfoIndex,
72                CharacterIndex  firstCharacterIndex,
73                Length          numberOfCharacters,
74                CharacterIndex* visualToLogicalMap);
75
76   /**
77    * @copydoc Dali::BidirectionalSupport::GetMirroredText()
78    */
79   bool GetMirroredText(Character*          text,
80                        CharacterDirection* directions,
81                        Length              numberOfCharacters);
82
83   /**
84    * @copydoc Dali::BidirectionalSupport::GetParagraphDirection()
85    */
86   bool GetParagraphDirection(BidiInfoIndex bidiInfoIndex) const;
87
88   /**
89    * @copydoc Dali::BidirectionalSupport::GetCharactersDirection()
90    */
91   void GetCharactersDirection(BidiInfoIndex       bidiInfoIndex,
92                               CharacterDirection* directions,
93                               Length              numberOfCharacters);
94
95 private:
96   /**
97    * Helper for lazy initialization.
98    */
99   void CreatePlugin();
100
101 private:
102   // Undefined copy constructor.
103   BidirectionalSupport(const BidirectionalSupport&);
104
105   // Undefined assignment constructor.
106   BidirectionalSupport& operator=(const BidirectionalSupport&);
107
108 private:
109   struct Plugin;
110   Plugin* mPlugin;
111
112 }; // class BidirectionalSupport
113
114 } // namespace Internal
115
116 } // namespace TextAbstraction
117
118 inline static TextAbstraction::Internal::BidirectionalSupport& GetImplementation(TextAbstraction::BidirectionalSupport& bidirectionalSupport)
119 {
120   DALI_ASSERT_ALWAYS(bidirectionalSupport && "bidirectional support handle is empty");
121   BaseObject& handle = bidirectionalSupport.GetBaseObject();
122   return static_cast<TextAbstraction::Internal::BidirectionalSupport&>(handle);
123 }
124
125 inline static const TextAbstraction::Internal::BidirectionalSupport& GetImplementation(const TextAbstraction::BidirectionalSupport& bidirectionalSupport)
126 {
127   DALI_ASSERT_ALWAYS(bidirectionalSupport && "bidirectional support handle is empty");
128   const BaseObject& handle = bidirectionalSupport.GetBaseObject();
129   return static_cast<const TextAbstraction::Internal::BidirectionalSupport&>(handle);
130 }
131
132 } // namespace Dali
133
134 #endif // DALI_INTERNAL_TEXT_ABSTRACTION_BIDIRECTIONAL_SUPPORT_IMPL_H