2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali-toolkit/public-api/text/decorator/text-decorator.h>
22 #include <dali/public-api/common/constants.h>
23 #include <dali/public-api/images/image.h>
24 #include <dali/public-api/math/vector2.h>
25 #include <dali/public-api/math/vector4.h>
36 struct Decorator::Impl
44 color(Dali::Color::WHITE)
55 Impl(Dali::Toolkit::Internal::Control& parent, Observer& observer)
58 mActiveCursor(ACTIVE_CURSOR_NONE),
59 mCursorBlinkInterval(0.5f),
60 mCursorBlinkDuration(0.0f)
64 void Relayout( const Vector2& size )
69 Internal::Control& mParent;
72 unsigned int mActiveCursor;
74 CursorImpl mCursor[CURSOR_COUNT];
77 Image mGrabHandleImage;
79 float mCursorBlinkInterval;
80 float mCursorBlinkDuration;
83 DecoratorPtr Decorator::New( Internal::Control& parent, Observer& observer )
85 return DecoratorPtr( new Decorator(parent, observer) );
88 void Decorator::Relayout( const Vector2& size )
90 mImpl->Relayout( size );
93 void Decorator::SetActiveCursor( ActiveCursor activeCursor )
95 mImpl->mActiveCursor = activeCursor;
98 unsigned int Decorator::GetActiveCursor() const
100 return mImpl->mActiveCursor;
103 void Decorator::SetPosition( Cursor cursor, float x, float y, float height )
105 mImpl->mCursor[cursor].x = x;
106 mImpl->mCursor[cursor].y = y;
107 mImpl->mCursor[cursor].height = height;
110 void Decorator::GetPosition( Cursor cursor, float& x, float& y, float& height ) const
112 x = mImpl->mCursor[cursor].x;
113 y = mImpl->mCursor[cursor].y;
114 height = mImpl->mCursor[cursor].height;
117 void Decorator::SetCursorImage( Dali::Image image )
119 mImpl->mCursorImage = image;
122 Dali::Image Decorator::GetCursorImage() const
124 return mImpl->mCursorImage;
127 void Decorator::SetColor( Cursor cursor, const Dali::Vector4& color )
129 mImpl->mCursor[cursor].color = color;
132 const Dali::Vector4& Decorator::GetColor( Cursor cursor ) const
134 return mImpl->mCursor[cursor].color;
137 void Decorator::StartCursorBlink()
142 void Decorator::StopCursorBlink()
147 void Decorator::SetCursorBlinkInterval( float seconds )
149 mImpl->mCursorBlinkInterval = seconds;
152 float Decorator::GetCursorBlinkInterval() const
154 return mImpl->mCursorBlinkInterval;
157 void Decorator::SetCursorBlinkDuration( float seconds )
159 mImpl->mCursorBlinkDuration = seconds;
162 float Decorator::GetCursorBlinkDuration() const
164 return mImpl->mCursorBlinkDuration;
167 void Decorator::SetGrabHandleImage( Dali::Image image )
169 mImpl->mGrabHandleImage = image;
172 Dali::Image Decorator::GetGrabHandleImage() const
174 return mImpl->mGrabHandleImage;
177 Decorator::~Decorator()
182 Decorator::Decorator(Dali::Toolkit::Internal::Control& parent, Observer& observer)
185 mImpl = new Decorator::Impl(parent, observer);
190 } // namespace Toolkit