3373ab7fc62315eb5ca6e84811bde04f1e046a41
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / text-view / text-view-character-processor.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // INTERNAL INCLUDES
19 #include <dali-toolkit/internal/controls/text-view/text-view-processor-types.h>
20
21 namespace Dali
22 {
23
24 namespace Toolkit
25 {
26
27 namespace Internal
28 {
29
30 namespace TextViewProcessor
31 {
32
33 /////////////////////
34 // Layout info.
35 /////////////////////
36
37 GradientInfo::GradientInfo()
38 : mGradientColor(),
39   mStartPoint(),
40   mEndPoint()
41 {
42 }
43
44 GradientInfo::~GradientInfo()
45 {
46 }
47
48 GradientInfo::GradientInfo( const GradientInfo& info )
49 : mGradientColor( info.mGradientColor ),
50   mStartPoint( info.mStartPoint ),
51   mEndPoint( info.mEndPoint )
52 {
53 }
54
55 GradientInfo& GradientInfo::operator=( const GradientInfo& info )
56 {
57   if( this != &info )
58   {
59     mGradientColor = info.mGradientColor;
60     mStartPoint = info.mStartPoint;
61     mEndPoint = info.mEndPoint;
62   }
63
64   return *this;
65 }
66
67 CharacterLayoutInfo::CharacterLayoutInfo()
68 : mSize(),
69   mBearing( 0.f ),
70   mAscender( 0.f ),
71   mUnderlineThickness( 0.f ),
72   mUnderlinePosition( 0.f ),
73   mPosition(),
74   mOffset(),
75   mGlyphActor(),
76   mStyledText(),
77   mColorAlpha( 1.f ),
78   mGradientInfo( NULL ),
79   mIsVisible( true ),
80   mSetText( true ),
81   mSetStyle( true ),
82   mIsColorGlyph( false )
83 {
84 }
85
86 CharacterLayoutInfo::~CharacterLayoutInfo()
87 {
88   // Deletes the gradient info.
89   delete mGradientInfo;
90 }
91
92 CharacterLayoutInfo::CharacterLayoutInfo( const CharacterLayoutInfo& character )
93 : mSize( character.mSize ),
94   mBearing( character.mBearing ),
95   mAscender( character.mAscender ),
96   mUnderlineThickness( character.mUnderlineThickness ),
97   mUnderlinePosition( character.mUnderlinePosition ),
98   mPosition( character.mPosition ),
99   mOffset( character.mOffset ),
100   mGlyphActor( character.mGlyphActor ),
101   mStyledText( character.mStyledText ),
102   mColorAlpha( character.mColorAlpha ),
103   mGradientInfo( ( NULL == character.mGradientInfo ) ? NULL : new GradientInfo( *character.mGradientInfo ) ), // Copies the gradient info.
104   mIsVisible( character.mIsVisible ),
105   mSetText( character.mSetText ),
106   mSetStyle( character.mSetStyle ),
107   mIsColorGlyph( character.mIsColorGlyph )
108 {
109 }
110
111 CharacterLayoutInfo& CharacterLayoutInfo::operator=( const CharacterLayoutInfo& character )
112 {
113   mSize = character.mSize;
114   mAscender = character.mAscender;
115   mBearing = character.mBearing;
116   mUnderlineThickness = character.mUnderlineThickness;
117   mUnderlinePosition = character.mUnderlinePosition;
118
119   mPosition = character.mPosition;
120   mOffset = character.mOffset;
121
122   mGlyphActor = character.mGlyphActor;
123   mStyledText = character.mStyledText;
124
125   mColorAlpha = character.mColorAlpha;
126
127   // Copies the gradient info.
128   if( NULL == character.mGradientInfo )
129   {
130     // The source doesn't have. Deletes the current one.
131     delete mGradientInfo;
132     mGradientInfo = NULL;
133   }
134   else
135   {
136     // The source has gradient info.
137     if( NULL != mGradientInfo )
138     {
139       // It it has, copy to it.
140       *mGradientInfo = *character.mGradientInfo;
141     }
142     else
143     {
144       // If it doesn't have, create a new one.
145       mGradientInfo = new GradientInfo( *character.mGradientInfo );
146     }
147   }
148
149   mIsVisible = character.mIsVisible;
150   mSetText = character.mSetText;
151   mSetStyle = character.mSetStyle;
152   mIsColorGlyph = character.mIsColorGlyph;
153
154   return *this;
155 }
156
157 } //namespace TextViewProcessor
158
159 } //namespace Internal
160
161 } //namespace Toolkit
162
163 } //namespace Dali