Merge "Fix resource package install issue." into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / rendering / view-model.h
1 #ifndef DALI_TOOLKIT_TEXT_VIEW_MODEL_H
2 #define DALI_TOOLKIT_TEXT_VIEW_MODEL_H
3
4 /*
5  * Copyright (c) 2017 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
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/internal/text/text-model-interface.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 namespace Text
34 {
35
36 /**
37  * @brief Responsible of creating and store temporary modifications of the text model.
38  * i.e. The elide of text.
39  */
40 class ViewModel : public ModelInterface
41 {
42 public:
43   /**
44    * @brief Constructor.
45    *
46    * Keeps the pointer to the text's model. It initializes all the members of the class to their defaults.
47    *
48    * @param[in] model Pointer to the text's model interface.
49    */
50   ViewModel( const ModelInterface* const model );
51
52   /**
53    * @brief Virtual destructor.
54    *
55    * It's a default destructor.
56    */
57   virtual ~ViewModel();
58
59   /**
60    * @copydoc ModelInterface::GetControlSize()
61    */
62   virtual const Size& GetControlSize() const;
63
64   /**
65    * @copydoc ModelInterface::GetLayoutSize()
66    */
67   virtual const Size& GetLayoutSize() const;
68
69   /**
70    * @copydoc ModelInterface::GetScrollPosition()
71    */
72   virtual const Vector2& GetScrollPosition() const;
73
74   /**
75    * @copydoc ModelInterface::GetHorizontalAlignment()
76    */
77   virtual Layout::HorizontalAlignment GetHorizontalAlignment() const;
78
79   /**
80    * @copydoc ModelInterface::GetVerticalAlignment()
81    */
82   virtual Layout::VerticalAlignment GetVerticalAlignment() const;
83
84   /**
85    * @copydoc ModelInterface::IsTextElideEnabled()
86    */
87   virtual bool IsTextElideEnabled() const;
88
89   /**
90    * @copydoc ModelInterface::GetNumberOfLines()
91    */
92   virtual Length GetNumberOfLines() const;
93
94   /**
95    * @copydoc ModelInterface::GetLines()
96    */
97   virtual const LineRun* const GetLines() const;
98
99   /**
100    * @copydoc ModelInterface::GetNumberOfGlyphs()
101    */
102   virtual Length GetNumberOfGlyphs() const;
103
104   /**
105    * @copydoc ModelInterface::GetGlyphs()
106    */
107   virtual const GlyphInfo* const GetGlyphs() const;
108
109   /**
110    * @copydoc ModelInterface::GetLayout()
111    */
112   virtual const Vector2* const GetLayout() const;
113
114   /**
115    * @copydoc ModelInterface::GetColors()
116    */
117   virtual const Vector4* const GetColors() const;
118
119   /**
120    * @copydoc ModelInterface::GetColorIndices()
121    */
122   virtual const ColorIndex* const GetColorIndices() const;
123
124   /**
125    * @copydoc ModelInterface::GetDefaultColor()
126    */
127   virtual const Vector4& GetDefaultColor() const;
128
129   /**
130    * @brief Does the text elide.
131    *
132    * It stores a copy of the visible glyphs and removes as many glyphs as needed
133    * from the last visible line to add the ellipsis glyph.
134    *
135    * It stores as well a copy of the positions for each visible glyph.
136    */
137   void ElideGlyphs();
138
139 private:
140   const ModelInterface* const mModel;            ///< Pointer to the text's model.
141   Vector<GlyphInfo>           mElidedGlyphs;     ///< Stores the glyphs of the elided text.
142   Vector<Vector2>             mElidedLayout;     ///< Stores the positions of each glyph of the elided text.
143   bool                        mIsTextElided : 1; ///< Whether the text has been elided.
144 };
145
146 } // namespace Text
147
148 } // namespace Toolkit
149
150 } // namespace Dali
151
152 #endif // DALI_TOOLKIT_TEXT_VIEW_MODEL_H