From 8363c13a95006c0cbfe3074e9b601bdaef9537f5 Mon Sep 17 00:00:00 2001 From: Paul Wisbey Date: Tue, 24 Feb 2015 18:08:24 +0000 Subject: [PATCH] Added some TextField boilerplate code Change-Id: I6d9d349a02f2243887f2e92af671c727be0ca04c --- .../controls/text-controls/text-field-impl.cpp | 301 +++++++++++++++++++++ .../controls/text-controls/text-field-impl.h | 147 ++++++++++ dali-toolkit/internal/file.list | 1 + .../controls/text-controls/text-field.cpp | 89 ++++++ .../public-api/controls/text-controls/text-field.h | 135 +++++++++ .../public-api/controls/text-controls/text-label.h | 2 + .../public-api/text/decorator/text-decorator.cpp | 19 +- .../public-api/text/decorator/text-decorator.h | 17 +- 8 files changed, 695 insertions(+), 16 deletions(-) create mode 100644 dali-toolkit/internal/controls/text-controls/text-field-impl.cpp create mode 100644 dali-toolkit/internal/controls/text-controls/text-field-impl.h create mode 100644 dali-toolkit/public-api/controls/text-controls/text-field.cpp create mode 100644 dali-toolkit/public-api/controls/text-controls/text-field.h diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp new file mode 100644 index 0000000..5799da0 --- /dev/null +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -0,0 +1,301 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include +#include +#include + +// INTERNAL INCLUDES +#include +#include // TODO - Get from RendererFactory + +using namespace Dali::Toolkit::Text; + +namespace +{ + +} // namespace + +namespace Dali +{ + +namespace Toolkit +{ + +const Property::Index TextField::PROPERTY_PLACEHOLDER_TEXT( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX ); +const Property::Index TextField::PROPERTY_TEXT( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 1 ); +const Property::Index TextField::PROPERTY_CURSOR_IMAGE( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 2 ); +const Property::Index TextField::PROPERTY_PRIMARY_CURSOR_COLOR( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 3 ); +const Property::Index TextField::PROPERTY_SECONDARY_CURSOR_COLOR( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 4 ); +const Property::Index TextField::PROPERTY_ENABLE_CURSOR_BLINK( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 5 ); +const Property::Index TextField::PROPERTY_CURSOR_BLINK_INTERVAL( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 6 ); +const Property::Index TextField::PROPERTY_CURSOR_BLINK_DURATION( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 7 ); + +namespace Internal +{ + +namespace +{ + +// Type registration +BaseHandle Create() +{ + return Toolkit::TextField::New(); +} + +TypeRegistration mType( typeid(Toolkit::TextField), typeid(Toolkit::Control), Create ); + +PropertyRegistration property1( mType, "placeholder-text", Toolkit::TextField::PROPERTY_PLACEHOLDER_TEXT, Property::STRING, &TextField::SetProperty, &TextField::GetProperty ); +PropertyRegistration property2( mType, "text", Toolkit::TextField::PROPERTY_TEXT, Property::STRING, &TextField::SetProperty, &TextField::GetProperty ); +PropertyRegistration property3( mType, "cursor-image", Toolkit::TextField::PROPERTY_CURSOR_IMAGE, Property::STRING, &TextField::SetProperty, &TextField::GetProperty ); +PropertyRegistration property4( mType, "primary-cursor-color", Toolkit::TextField::PROPERTY_PRIMARY_CURSOR_COLOR, Property::VECTOR4, &TextField::SetProperty, &TextField::GetProperty ); +PropertyRegistration property5( mType, "secondary-cursor-color", Toolkit::TextField::PROPERTY_SECONDARY_CURSOR_COLOR, Property::VECTOR4, &TextField::SetProperty, &TextField::GetProperty ); +PropertyRegistration property6( mType, "enable-cursor-blink", Toolkit::TextField::PROPERTY_ENABLE_CURSOR_BLINK, Property::BOOLEAN, &TextField::SetProperty, &TextField::GetProperty ); +PropertyRegistration property7( mType, "cursor-blink-interval", Toolkit::TextField::PROPERTY_CURSOR_BLINK_INTERVAL, Property::FLOAT, &TextField::SetProperty, &TextField::GetProperty ); +PropertyRegistration property8( mType, "cursor-blink-duration", Toolkit::TextField::PROPERTY_CURSOR_BLINK_DURATION, Property::FLOAT, &TextField::SetProperty, &TextField::GetProperty ); + +} // namespace + +Toolkit::TextField TextField::New() +{ + // Create the implementation, temporarily owned by this handle on stack + IntrusivePtr< TextField > impl = new TextField(); + + // Pass ownership to CustomActor handle + Toolkit::TextField handle( *impl ); + + // Second-phase init of the implementation + // This can only be done after the CustomActor connection has been made... + impl->Initialize(); + + return handle; +} + +void TextField::SetRenderer( Text::RendererPtr renderer ) +{ + mRenderer = renderer; +} + +void TextField::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value ) +{ + Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) ); + + if( textField ) + { + TextField& impl( GetImpl( textField ) ); + + switch( index ) + { + case Toolkit::TextField::PROPERTY_PLACEHOLDER_TEXT: + { + if( impl.mController ) + { + //impl.mController->SetPlaceholderText( value.Get< std::string >() ); TODO + } + break; + } + case Toolkit::TextField::PROPERTY_TEXT: + { + if( impl.mController ) + { + impl.mController->SetText( value.Get< std::string >() ); + } + break; + } + case Toolkit::TextField::PROPERTY_CURSOR_IMAGE: + { + Image image = Image::New( value.Get< std::string >() ); + //ResourceImage image = ResourceImage::New( value.Get< std::string >() ); + + if( impl.mDecorator ) + { + impl.mDecorator->SetCursorImage( image ); + } + break; + } + case Toolkit::TextField::PROPERTY_PRIMARY_CURSOR_COLOR: + { + if( impl.mDecorator ) + { + impl.mDecorator->SetColor( PRIMARY_CURSOR, value.Get< Vector4 >() ); + } + break; + } + case Toolkit::TextField::PROPERTY_SECONDARY_CURSOR_COLOR: + { + if( impl.mDecorator ) + { + impl.mDecorator->SetColor( SECONDARY_CURSOR, value.Get< Vector4 >() ); + } + break; + } + case Toolkit::TextField::PROPERTY_ENABLE_CURSOR_BLINK: + { + if( impl.mController ) + { + //impl.mController->SetEnableCursorBlink( value.Get< bool >() ); TODO + } + break; + } + case Toolkit::TextField::PROPERTY_CURSOR_BLINK_INTERVAL: + { + if( impl.mDecorator ) + { + impl.mDecorator->SetCursorBlinkInterval( value.Get< float >() ); + } + break; + } + case Toolkit::TextField::PROPERTY_CURSOR_BLINK_DURATION: + { + if( impl.mDecorator ) + { + impl.mDecorator->SetCursorBlinkDuration( value.Get< float >() ); + } + break; + } + } + } +} + +Property::Value TextField::GetProperty( BaseObject* object, Property::Index index ) +{ + Property::Value value; + + Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) ); + + if( textField ) + { + TextField& impl( GetImpl( textField ) ); + + switch( index ) + { + case Toolkit::TextField::PROPERTY_PLACEHOLDER_TEXT: + { + DALI_LOG_WARNING( "UTF-8 text representation was discarded\n" ); + break; + } + case Toolkit::TextField::PROPERTY_TEXT: + { + DALI_LOG_WARNING( "UTF-8 text representation was discarded\n" ); + break; + } + case Toolkit::TextField::PROPERTY_CURSOR_IMAGE: + { + if( impl.mDecorator ) + { + Image image = impl.mDecorator->GetCursorImage(); + //ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetCursorImage() ); + if( image ) + { + value = image.GetFilename(); + //value = image.GetUrl(); + } + } + break; + } + case Toolkit::TextField::PROPERTY_PRIMARY_CURSOR_COLOR: + { + if( impl.mDecorator ) + { + value = impl.mDecorator->GetColor( PRIMARY_CURSOR ); + } + break; + } + case Toolkit::TextField::PROPERTY_SECONDARY_CURSOR_COLOR: + { + if( impl.mDecorator ) + { + value = impl.mDecorator->GetColor( SECONDARY_CURSOR ); + } + break; + } + case Toolkit::TextField::PROPERTY_ENABLE_CURSOR_BLINK: + { + //value = impl.mController->GetEnableCursorBlink(); TODO + break; + } + case Toolkit::TextField::PROPERTY_CURSOR_BLINK_INTERVAL: + { + if( impl.mDecorator ) + { + value = impl.mDecorator->GetCursorBlinkInterval(); + } + break; + } + case Toolkit::TextField::PROPERTY_CURSOR_BLINK_DURATION: + { + if( impl.mDecorator ) + { + value = impl.mDecorator->GetCursorBlinkDuration(); + } + break; + } + } + } + + return value; +} + +void TextField::OnInitialize() +{ + mDecorator = Text::Decorator::New( *this ); + + mController = Text::Controller::New(); + mController->GetLayoutEngine().SetLayout( LayoutEngine::SINGLE_LINE_BOX ); + //mController->EnableTextInput( mDecorator ); TODO +} + +void TextField::OnRelayout( const Vector2& size, ActorSizeContainer& container ) +{ + if( mController->Relayout( size ) ) + { + if( !mRenderer ) + { + // TODO - Get from RendererFactory + mRenderer = Dali::Toolkit::Text::BasicRenderer::New(); + } + + if( mRenderer ) + { + Actor renderableActor = mRenderer->Render( mController->GetView() ); + + if( renderableActor ) + { + Self().Add( renderableActor ); + } + } + } +} + +TextField::TextField() +: Control( ControlBehaviour( CONTROL_BEHAVIOUR_NONE ) ) +{ +} + +TextField::~TextField() +{ +} + +} // namespace Internal + +} // namespace Toolkit + +} // namespace Dali diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.h b/dali-toolkit/internal/controls/text-controls/text-field-impl.h new file mode 100644 index 0000000..3dbec59 --- /dev/null +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.h @@ -0,0 +1,147 @@ +#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__ +#define __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__ + +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include +#include +#include + +namespace Dali +{ + +namespace Toolkit +{ + +namespace Internal +{ + +/** + * @brief A control which renders a short text string. + */ +class TextField : public Control +{ +public: + + // Properties + enum + { + TEXTFIELD_PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, + TEXTFIELD_PROPERTY_END_INDEX = TEXTFIELD_PROPERTY_START_INDEX + 1000 ///< Reserving 1000 property indices + }; + + /** + * @copydoc Dali::Toollkit::TextField::New() + */ + static Toolkit::TextField New(); + + /** + * @copydoc Dali::Toollkit::TextField::SetRenderer() + */ + void SetRenderer( Text::RendererPtr renderer ); + + // Properties + + /** + * Called when a property of an object of this type is set. + * @param[in] object The object whose property is set. + * @param[in] index The property index. + * @param[in] value The new property value. + */ + static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value ); + + /** + * Called to retrieve a property of an object of this type. + * @param[in] object The object whose property is to be retrieved. + * @param[in] index The property index. + * @return The current value of the property. + */ + static Property::Value GetProperty( BaseObject* object, Property::Index index ); + +private: // From Control + + /** + * @copydoc Control::OnInitialize() + */ + virtual void OnInitialize(); + + /** + * @copydoc Control::OnInitialize() + */ + virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container ); + +private: // Implementation + + /** + * Helper for SetProperty. + * @param[in] text The new "text" property value. + */ + void SetText( const std::string& text ); + + /** + * Construct a new TextField. + */ + TextField(); + + /** + * A reference counted object may only be deleted by calling Unreference() + */ + virtual ~TextField(); + +private: + + // Undefined copy constructor and assignment operators + TextField(const TextField&); + TextField& operator=(const TextField& rhs); + +private: // Data + + Text::ControllerPtr mController; + Text::RendererPtr mRenderer; + Text::DecoratorPtr mDecorator; +}; + +} // namespace Internal + +// Helpers for public-api forwarding methods + +inline Toolkit::Internal::TextField& GetImpl( Toolkit::TextField& textLabel ) +{ + DALI_ASSERT_ALWAYS(textLabel); + + Dali::RefObject& handle = textLabel.GetImplementation(); + + return static_cast(handle); +} + +inline const Toolkit::Internal::TextField& GetImpl( const Toolkit::TextField& textLabel ) +{ + DALI_ASSERT_ALWAYS(textLabel); + + const Dali::RefObject& handle = textLabel.GetImplementation(); + + return static_cast(handle); +} + +} // namespace Toolkit + +} // namespace Dali + +#endif // __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__ diff --git a/dali-toolkit/internal/file.list b/dali-toolkit/internal/file.list index a760e1a..5e98629 100644 --- a/dali-toolkit/internal/file.list +++ b/dali-toolkit/internal/file.list @@ -61,6 +61,7 @@ toolkit_src_files = \ $(toolkit_src_dir)/controls/slider/slider-impl.cpp \ $(toolkit_src_dir)/controls/super-blur-view/super-blur-view-impl.cpp \ $(toolkit_src_dir)/controls/table-view/table-view-impl.cpp \ + $(toolkit_src_dir)/controls/text-controls/text-field-impl.cpp \ $(toolkit_src_dir)/controls/text-controls/text-label-impl.cpp \ $(toolkit_src_dir)/controls/tool-bar/tool-bar-impl.cpp \ $(toolkit_src_dir)/controls/view/view-impl.cpp \ diff --git a/dali-toolkit/public-api/controls/text-controls/text-field.cpp b/dali-toolkit/public-api/controls/text-controls/text-field.cpp new file mode 100644 index 0000000..4d7a7ea --- /dev/null +++ b/dali-toolkit/public-api/controls/text-controls/text-field.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// INTERNAL INCLUDES +#include + +namespace Dali +{ + +namespace Toolkit +{ + +const std::string TextField::PLACEHOLDER_TEXT_PROPERTY_NAME("placeholder-text"); +const std::string TextField::TEXT_PROPERTY_NAME("text"); +const std::string TextField::CURSOR_IMAGE_PROPERTY_NAME("cursor-image"); +const std::string TextField::PRIMARY_CURSOR_COLOR_PROPERTY_NAME("primary-cursor-color"); +const std::string TextField::SECONDARY_CURSOR_COLOR_PROPERTY_NAME("secondary-cursor-color"); +const std::string TextField::ENABLE_CURSOR_BLINK_PROPERTY_NAME("enable-cursor-blink"); +const std::string TextField::CURSOR_BLINK_INTERVAL_PROPERTY_NAME("cursor-blink-interval"); +const std::string TextField::CURSOR_BLINK_DURATION_PROPERTY_NAME("cursor-blink-duration"); + +TextField TextField::New() +{ + return Internal::TextField::New(); +} + +TextField::TextField() +{ +} + +TextField::TextField( const TextField& handle ) +: Control( handle ) +{ +} + +TextField& TextField::operator=( const TextField& handle ) +{ + if( &handle != this ) + { + Control::operator=( handle ); + } + return *this; +} + +TextField::~TextField() +{ +} + +TextField TextField::DownCast( BaseHandle handle ) +{ + return Control::DownCast(handle); +} + +void TextField::SetRenderer( Text::RendererPtr renderer ) +{ + GetImpl(*this).SetRenderer( renderer ); +} + +TextField::TextField( Internal::TextField& implementation ) +: Control(implementation) +{ +} + +TextField::TextField( Dali::Internal::CustomActor* internal ) +: Control( internal ) +{ + VerifyCustomActorPointer( internal ); +} + +} // namespace Toolkit + +} // namespace Dali diff --git a/dali-toolkit/public-api/controls/text-controls/text-field.h b/dali-toolkit/public-api/controls/text-controls/text-field.h new file mode 100644 index 0000000..1ce8b7a --- /dev/null +++ b/dali-toolkit/public-api/controls/text-controls/text-field.h @@ -0,0 +1,135 @@ +#ifndef __DALI_TOOLKIT_TEXT_FIELD_H__ +#define __DALI_TOOLKIT_TEXT_FIELD_H__ + +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ + +namespace Toolkit +{ + +namespace Internal DALI_INTERNAL +{ +class TextField; +} + +/** + * @brief A control which provides a single-line editable text field. + */ +class DALI_IMPORT_API TextField : public Control +{ +public: + + // Property indices + static const Property::Index PROPERTY_PLACEHOLDER_TEXT; ///< name "placeholder-text", type STRING + static const Property::Index PROPERTY_TEXT; ///< name "text", type STRING + static const Property::Index PROPERTY_CURSOR_IMAGE; ///< name "cursor-image", type STRING + static const Property::Index PROPERTY_PRIMARY_CURSOR_COLOR; ///< name "primary-cursor-color", type VECTOR4 + static const Property::Index PROPERTY_SECONDARY_CURSOR_COLOR; ///< name "secondary-cursor-color", type VECTOR4 + static const Property::Index PROPERTY_ENABLE_CURSOR_BLINK; ///< name "enable-cursor-blink", type BOOLEAN + static const Property::Index PROPERTY_CURSOR_BLINK_INTERVAL; ///< name "cursor-blink-interval", type FLOAT + static const Property::Index PROPERTY_CURSOR_BLINK_DURATION; ///< name "cursor-blink-duration", type FLOAT + + // Property names + static const std::string PLACEHOLDER_TEXT_PROPERTY_NAME; ///< Property, name "placeholder-text", type STRING + static const std::string TEXT_PROPERTY_NAME; ///< Property, name "text", type STRING + static const std::string CURSOR_IMAGE_PROPERTY_NAME; ///< Property, name "cursor-image", type STRING + static const std::string PRIMARY_CURSOR_COLOR_PROPERTY_NAME; ///< Property, name "primary-cursor-color", type VECTOR4 + static const std::string SECONDARY_CURSOR_COLOR_PROPERTY_NAME; ///< Property, name "secondary-cursor-color", type VECTOR4 + static const std::string ENABLE_CURSOR_BLINK_PROPERTY_NAME; ///< Property, name "enable-cursor-blink", type BOOLEAN + static const std::string CURSOR_BLINK_INTERVAL_PROPERTY_NAME; ///< Property, name "cursor-blink-interval", type FLOAT + static const std::string CURSOR_BLINK_DURATION_PROPERTY_NAME; ///< Property, name "cursor-blink-duration", type FLOAT + + /** + * Create the TextField control. + * @return A handle to the TextField control. + */ + static TextField New(); + + /** + * @brief Creates an empty handle. + */ + TextField(); + + /** + * @brief Copy constructor. + * + * @param[in] handle The handle to copy from. + */ + TextField( const TextField& handle ); + + /** + * @brief Assignment operator. + * + * @param[in] handle The handle to copy from. + * @return A reference to this. + */ + TextField& operator=( const TextField& handle ); + + /** + * @brief Destructor + * + * This is non-virtual since derived Handle types must not contain data or virtual methods. + */ + ~TextField(); + + /** + * @brief Downcast a handle to TextField. + * + * If the BaseHandle points is a TextField the downcast returns a valid handle. + * If not the returned handle is left empty. + * + * @param[in] handle Handle to an object + * @return handle to a TextField or an empty handle + */ + static TextField DownCast( BaseHandle handle ); + + /** + * @brief Set the rendering back-end used by the TextField. + * + * @param[in] renderer The text renderer to use. + */ + void SetRenderer( Text::RendererPtr renderer ); + +public: // Not intended for application developers + + /** + * @brief Creates a handle using the Toolkit::Internal implementation. + * + * @param[in] implementation The Control implementation. + */ + DALI_INTERNAL TextField( Internal::TextField& implementation ); + + /** + * @brief Allows the creation of this Control from an Internal::CustomActor pointer. + * + * @param[in] internal A pointer to the internal CustomActor. + */ + explicit DALI_INTERNAL TextField( Dali::Internal::CustomActor* internal ); +}; + +} // namespace Toolkit + +} // namespace Dali + +#endif // __DALI_TOOLKIT_TEXT_FIELD_H__ diff --git a/dali-toolkit/public-api/controls/text-controls/text-label.h b/dali-toolkit/public-api/controls/text-controls/text-label.h index 449d23b..1c83e62 100644 --- a/dali-toolkit/public-api/controls/text-controls/text-label.h +++ b/dali-toolkit/public-api/controls/text-controls/text-label.h @@ -35,6 +35,8 @@ class TextLabel; /** * @brief A control which renders a short text string. + * + * Text labels are lightweight, non-editable and do not respond to user input. */ class DALI_IMPORT_API TextLabel : public Control { diff --git a/dali-toolkit/public-api/text/decorator/text-decorator.cpp b/dali-toolkit/public-api/text/decorator/text-decorator.cpp index 49d26ec..23a2da8 100644 --- a/dali-toolkit/public-api/text/decorator/text-decorator.cpp +++ b/dali-toolkit/public-api/text/decorator/text-decorator.cpp @@ -49,11 +49,10 @@ struct Decorator::Impl float y; float height; - Image image; Vector4 color; }; - Impl(ControlImpl& parent) + Impl(Internal::Control& parent) : mParent(parent), mActiveCursor(ACTIVE_CURSOR_NONE), mCursorBlinkInterval(0.5f), @@ -66,17 +65,19 @@ struct Decorator::Impl // TODO } - ControlImpl& mParent; + Internal::Control& mParent; unsigned int mActiveCursor; CursorImpl mCursor[CURSOR_COUNT]; + Image mCursorImage; + float mCursorBlinkInterval; float mCursorBlinkDuration; }; -DecoratorPtr Decorator::New(ControlImpl& parent) +DecoratorPtr Decorator::New(Internal::Control& parent) { return DecoratorPtr( new Decorator(parent) ); } @@ -110,14 +111,14 @@ void Decorator::GetPosition( Cursor cursor, float& x, float& y, float& height ) height = mImpl->mCursor[cursor].height; } -void Decorator::SetImage( Cursor cursor, Dali::Image image ) +void Decorator::SetCursorImage( Dali::Image image ) { - mImpl->mCursor[cursor].image = image; + mImpl->mCursorImage = image; } -Dali::Image Decorator::GetImage( Cursor cursor ) const +Dali::Image Decorator::GetCursorImage() const { - return mImpl->mCursor[cursor].image; + return mImpl->mCursorImage; } void Decorator::SetColor( Cursor cursor, const Dali::Vector4& color ) @@ -165,7 +166,7 @@ Decorator::~Decorator() delete mImpl; } -Decorator::Decorator(ControlImpl& parent) +Decorator::Decorator(Internal::Control& parent) : mImpl( NULL ) { mImpl = new Decorator::Impl(parent); diff --git a/dali-toolkit/public-api/text/decorator/text-decorator.h b/dali-toolkit/public-api/text/decorator/text-decorator.h index b9adf17..e3501b1 100644 --- a/dali-toolkit/public-api/text/decorator/text-decorator.h +++ b/dali-toolkit/public-api/text/decorator/text-decorator.h @@ -32,7 +32,10 @@ class Vector4; namespace Toolkit { -class ControlImpl; +namespace Internal +{ +class Control; +} namespace Text { @@ -72,7 +75,7 @@ public: * @param[in] parent Decorations will be added to this parent control. * @return A pointer to a new Decorator. */ - static DecoratorPtr New( ControlImpl& parent ); + static DecoratorPtr New( Internal::Control& parent ); /** * @brief The decorator waits until a relayout before creating actors etc. @@ -119,22 +122,21 @@ public: /** * @brief Sets the image for a cursor. * - * @param[in] cursor The cursor to set. * @param[in] image The image to use. */ - void SetImage( Cursor cursor, Dali::Image image ); + void SetCursorImage( Dali::Image image ); /** * @brief Retrieves the image for a cursor. * * @return The cursor image. */ - Dali::Image GetImage( Cursor cursor ) const; + Dali::Image GetCursorImage() const; /** * @brief Sets the color for a cursor. * - * @param[in] cursor The cursor to set. + * @param[in] cursor Whether this color is for the primary or secondary cursor. * @param[in] color The color to use. */ void SetColor( Cursor cursor, const Dali::Vector4& color ); @@ -142,6 +144,7 @@ public: /** * @brief Retrieves the color for a cursor. * + * @param[in] cursor Whether this color is for the primary or secondary cursor. * @return The cursor color. */ const Dali::Vector4& GetColor( Cursor cursor ) const; @@ -197,7 +200,7 @@ private: * @brief Private constructor. * @param[in] parent Decorations will be added to this parent control. */ - Decorator(ControlImpl& parent); + Decorator(Internal::Control& parent); // Undefined Decorator( const Decorator& handle ); -- 2.7.4