From: Paul Wisbey
Date: Sat, 28 Feb 2015 18:51:18 +0000 (+0000)
Subject: Added Property for the rendering back-end
X-Git-Tag: new_text_0.1~33
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F76%2F36076%2F7;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git
Added Property for the rendering back-end
Change-Id: I17562b649bb8be0fc7038a0a5e3fb9becd6fc94a
---
diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
index 3e23e2e..4ebda6f 100644
--- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
+++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
@@ -25,7 +25,7 @@
// INTERNAL INCLUDES
#include
-#include // TODO - Get from RendererFactory
+#include
using namespace Dali::Toolkit::Text;
@@ -40,15 +40,16 @@ 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 );
-const Property::Index TextField::PROPERTY_GRAB_HANDLE_IMAGE( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 8 );
+const Property::Index TextField::PROPERTY_RENDERING_BACKEND( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX );
+const Property::Index TextField::PROPERTY_PLACEHOLDER_TEXT( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 1 );
+const Property::Index TextField::PROPERTY_TEXT( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 2 );
+const Property::Index TextField::PROPERTY_CURSOR_IMAGE( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 3 );
+const Property::Index TextField::PROPERTY_PRIMARY_CURSOR_COLOR( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 4 );
+const Property::Index TextField::PROPERTY_SECONDARY_CURSOR_COLOR( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 5 );
+const Property::Index TextField::PROPERTY_ENABLE_CURSOR_BLINK( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 6 );
+const Property::Index TextField::PROPERTY_CURSOR_BLINK_INTERVAL( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 7 );
+const Property::Index TextField::PROPERTY_CURSOR_BLINK_DURATION( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 8 );
+const Property::Index TextField::PROPERTY_GRAB_HANDLE_IMAGE( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 9 );
namespace Internal
{
@@ -64,15 +65,16 @@ BaseHandle Create()
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 );
-PropertyRegistration property9( mType, "grab-handle-image", Toolkit::TextField::PROPERTY_GRAB_HANDLE_IMAGE, Property::STRING, &TextField::SetProperty, &TextField::GetProperty );
+PropertyRegistration property01( mType, "rendering-backend", Toolkit::TextField::PROPERTY_RENDERING_BACKEND, Property::UNSIGNED_INTEGER, &TextField::SetProperty, &TextField::GetProperty );
+PropertyRegistration property02( mType, "placeholder-text", Toolkit::TextField::PROPERTY_PLACEHOLDER_TEXT, Property::STRING, &TextField::SetProperty, &TextField::GetProperty );
+PropertyRegistration property03( mType, "text", Toolkit::TextField::PROPERTY_TEXT, Property::STRING, &TextField::SetProperty, &TextField::GetProperty );
+PropertyRegistration property04( mType, "cursor-image", Toolkit::TextField::PROPERTY_CURSOR_IMAGE, Property::STRING, &TextField::SetProperty, &TextField::GetProperty );
+PropertyRegistration property05( mType, "primary-cursor-color", Toolkit::TextField::PROPERTY_PRIMARY_CURSOR_COLOR, Property::VECTOR4, &TextField::SetProperty, &TextField::GetProperty );
+PropertyRegistration property06( mType, "secondary-cursor-color", Toolkit::TextField::PROPERTY_SECONDARY_CURSOR_COLOR, Property::VECTOR4, &TextField::SetProperty, &TextField::GetProperty );
+PropertyRegistration property07( mType, "enable-cursor-blink", Toolkit::TextField::PROPERTY_ENABLE_CURSOR_BLINK, Property::BOOLEAN, &TextField::SetProperty, &TextField::GetProperty );
+PropertyRegistration property08( mType, "cursor-blink-interval", Toolkit::TextField::PROPERTY_CURSOR_BLINK_INTERVAL, Property::FLOAT, &TextField::SetProperty, &TextField::GetProperty );
+PropertyRegistration property09( mType, "cursor-blink-duration", Toolkit::TextField::PROPERTY_CURSOR_BLINK_DURATION, Property::FLOAT, &TextField::SetProperty, &TextField::GetProperty );
+PropertyRegistration property10( mType, "grab-handle-image", Toolkit::TextField::PROPERTY_GRAB_HANDLE_IMAGE, Property::STRING, &TextField::SetProperty, &TextField::GetProperty );
} // namespace
@@ -91,11 +93,6 @@ Toolkit::TextField TextField::New()
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 ) );
@@ -106,6 +103,17 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
switch( index )
{
+ case Toolkit::TextField::PROPERTY_RENDERING_BACKEND:
+ {
+ unsigned int backend = value.Get< unsigned int >();
+
+ if( impl.mRenderingBackend != backend )
+ {
+ impl.mRenderingBackend = backend;
+ impl.mRenderer.Reset();
+ }
+ break;
+ }
case Toolkit::TextField::PROPERTY_PLACEHOLDER_TEXT:
{
if( impl.mController )
@@ -198,6 +206,11 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde
switch( index )
{
+ case Toolkit::TextField::PROPERTY_RENDERING_BACKEND:
+ {
+ value = impl.mRenderingBackend;
+ break;
+ }
case Toolkit::TextField::PROPERTY_PLACEHOLDER_TEXT:
{
DALI_LOG_WARNING( "UTF-8 text representation was discarded\n" );
@@ -295,8 +308,7 @@ void TextField::OnRelayout( const Vector2& size, ActorSizeContainer& container )
{
if( !mRenderer )
{
- // TODO - Get from RendererFactory
- mRenderer = Dali::Toolkit::Text::BasicRenderer::New();
+ mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
}
if( mRenderer )
diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.h b/dali-toolkit/internal/controls/text-controls/text-field-impl.h
index 4e18eb2..443e3e1 100644
--- a/dali-toolkit/internal/controls/text-controls/text-field-impl.h
+++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.h
@@ -1,5 +1,5 @@
-#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__
-#define __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__
+#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H__
+#define __DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H__
/*
* Copyright (c) 2015 Samsung Electronics Co., Ltd.
@@ -53,11 +53,6 @@ public:
*/
static Toolkit::TextField New();
- /**
- * @copydoc Dali::Toollkit::TextField::SetRenderer()
- */
- void SetRenderer( Text::RendererPtr renderer );
-
// Properties
/**
@@ -121,26 +116,28 @@ private: // Data
Text::ControllerPtr mController;
Text::RendererPtr mRenderer;
Text::DecoratorPtr mDecorator;
+
+ unsigned int mRenderingBackend;
};
} // namespace Internal
// Helpers for public-api forwarding methods
-inline Toolkit::Internal::TextField& GetImpl( Toolkit::TextField& textLabel )
+inline Toolkit::Internal::TextField& GetImpl( Toolkit::TextField& textField )
{
- DALI_ASSERT_ALWAYS(textLabel);
+ DALI_ASSERT_ALWAYS(textField);
- Dali::RefObject& handle = textLabel.GetImplementation();
+ Dali::RefObject& handle = textField.GetImplementation();
return static_cast(handle);
}
-inline const Toolkit::Internal::TextField& GetImpl( const Toolkit::TextField& textLabel )
+inline const Toolkit::Internal::TextField& GetImpl( const Toolkit::TextField& textField )
{
- DALI_ASSERT_ALWAYS(textLabel);
+ DALI_ASSERT_ALWAYS(textField);
- const Dali::RefObject& handle = textLabel.GetImplementation();
+ const Dali::RefObject& handle = textField.GetImplementation();
return static_cast(handle);
}
@@ -149,4 +146,4 @@ inline const Toolkit::Internal::TextField& GetImpl( const Toolkit::TextField& te
} // namespace Dali
-#endif // __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__
+#endif // __DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H__
diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
index 073b02b..5e5d9ba 100644
--- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
+++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
@@ -24,13 +24,16 @@
// INTERNAL INCLUDES
#include
-#include // TODO - Get from RendererFactory
+#include
using Dali::Toolkit::Text::LayoutEngine;
+using Dali::Toolkit::Text::Backend;
namespace
{
+const unsigned int DEFAULT_RENDERING_BACKEND = 0;
+
} // namespace
namespace Dali
@@ -39,8 +42,9 @@ namespace Dali
namespace Toolkit
{
-const Property::Index TextLabel::PROPERTY_TEXT( Internal::TextLabel::TEXTLABEL_PROPERTY_START_INDEX );
-const Property::Index TextLabel::PROPERTY_MULTI_LINE( Internal::TextLabel::TEXTLABEL_PROPERTY_START_INDEX + 1 );
+const Property::Index TextLabel::PROPERTY_RENDERING_BACKEND( Internal::TextLabel::TEXTLABEL_PROPERTY_START_INDEX );
+const Property::Index TextLabel::PROPERTY_TEXT( Internal::TextLabel::TEXTLABEL_PROPERTY_START_INDEX + 1 );
+const Property::Index TextLabel::PROPERTY_MULTI_LINE( Internal::TextLabel::TEXTLABEL_PROPERTY_START_INDEX + 2 );
namespace Internal
{
@@ -56,8 +60,9 @@ BaseHandle Create()
TypeRegistration mType( typeid(Toolkit::TextLabel), typeid(Toolkit::Control), Create );
-PropertyRegistration property1( mType, "text", Toolkit::TextLabel::PROPERTY_TEXT, Property::STRING, &TextLabel::SetProperty, &TextLabel::GetProperty );
-PropertyRegistration property2( mType, "multi-line", Toolkit::TextLabel::PROPERTY_MULTI_LINE, Property::STRING, &TextLabel::SetProperty, &TextLabel::GetProperty );
+PropertyRegistration property1( mType, "rendering-backend", Toolkit::TextLabel::PROPERTY_RENDERING_BACKEND, Property::UNSIGNED_INTEGER, &TextLabel::SetProperty, &TextLabel::GetProperty );
+PropertyRegistration property2( mType, "text", Toolkit::TextLabel::PROPERTY_TEXT, Property::STRING, &TextLabel::SetProperty, &TextLabel::GetProperty );
+PropertyRegistration property3( mType, "multi-line", Toolkit::TextLabel::PROPERTY_MULTI_LINE, Property::STRING, &TextLabel::SetProperty, &TextLabel::GetProperty );
} // namespace
@@ -76,28 +81,41 @@ Toolkit::TextLabel TextLabel::New()
return handle;
}
-void TextLabel::SetRenderer( Text::RendererPtr renderer )
-{
- mRenderer = renderer;
-}
-
void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
{
Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( Dali::BaseHandle( object ) );
if( label )
{
- TextLabel& labelImpl( GetImpl( label ) );
+ TextLabel& impl( GetImpl( label ) );
switch( index )
{
+ case Toolkit::TextLabel::PROPERTY_RENDERING_BACKEND:
+ {
+ unsigned int backend = value.Get< unsigned int >();
+
+ if( impl.mRenderingBackend != backend )
+ {
+ impl.mRenderingBackend = backend;
+ impl.mRenderer.Reset();
+ }
+ break;
+ }
case Toolkit::TextLabel::PROPERTY_TEXT:
{
- labelImpl.SetText( value.Get< std::string >() );
+ if( impl.mController )
+ {
+ impl.mController->SetText( value.Get< std::string >() );
+ }
break;
}
case Toolkit::TextLabel::PROPERTY_MULTI_LINE:
{
- labelImpl.SetMultiLine( value.Get< bool >() );
+ if( impl.mController )
+ {
+ LayoutEngine::Layout layout = value.Get< bool >() ? LayoutEngine::MULTI_LINE_BOX : LayoutEngine::SINGLE_LINE_BOX;
+ impl.mController->GetLayoutEngine().SetLayout( layout );
+ }
break;
}
}
@@ -112,13 +130,29 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde
if( label )
{
+ TextLabel& impl( GetImpl( label ) );
switch( index )
{
+ case Toolkit::TextLabel::PROPERTY_RENDERING_BACKEND:
+ {
+ value = impl.mRenderingBackend;
+ break;
+ }
+
case Toolkit::TextLabel::PROPERTY_TEXT:
{
DALI_LOG_WARNING( "UTF-8 text representation was discarded\n" );
break;
}
+
+ case Toolkit::TextLabel::PROPERTY_MULTI_LINE:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->GetLayoutEngine().GetLayout();
+ }
+ break;
+ }
}
}
@@ -146,8 +180,7 @@ void TextLabel::OnRelayout( const Vector2& size, ActorSizeContainer& container )
{
if( !mRenderer )
{
- // TODO - Get from RendererFactory
- mRenderer = Dali::Toolkit::Text::BasicRenderer::New();
+ mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
}
if( mRenderer )
@@ -162,37 +195,14 @@ void TextLabel::OnRelayout( const Vector2& size, ActorSizeContainer& container )
}
}
-void TextLabel::SetText( const std::string& text )
-{
- if( mController )
- {
- // The Controller updates the View for the renderer
- mController->SetText( text );
- }
-}
-
-void TextLabel::SetMultiLine( bool multiLine )
-{
- if( mController )
- {
- if( multiLine )
- {
- mController->GetLayoutEngine().SetLayout( LayoutEngine::MULTI_LINE_BOX );
- }
- else
- {
- mController->GetLayoutEngine().SetLayout( LayoutEngine::SINGLE_LINE_BOX );
- }
- }
-}
-
void TextLabel::RequestTextRelayout()
{
RelayoutRequest();
}
TextLabel::TextLabel()
-: Control( ControlBehaviour( CONTROL_BEHAVIOUR_NONE ) )
+: Control( ControlBehaviour( CONTROL_BEHAVIOUR_NONE ) ),
+ mRenderingBackend( DEFAULT_RENDERING_BACKEND )
{
}
diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.h b/dali-toolkit/internal/controls/text-controls/text-label-impl.h
index 913d820..073d1ac 100644
--- a/dali-toolkit/internal/controls/text-controls/text-label-impl.h
+++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.h
@@ -22,6 +22,7 @@
#include
#include
#include
+#include
namespace Dali
{
@@ -51,11 +52,6 @@ public:
*/
static Toolkit::TextLabel New();
- /**
- * @copydoc Dali::Toollkit::TextLabel::SetRenderer()
- */
- void SetRenderer( Text::RendererPtr renderer );
-
// Properties
/**
@@ -104,18 +100,6 @@ private: // From Control
private: // Implementation
/**
- * Helper for SetProperty.
- * @param[in] text The new "text" property value.
- */
- void SetText( const std::string& text );
-
- /**
- * Helper for SetProperty.
- * @param[in] multiLine The new "multi-line" property value.
- */
- void SetMultiLine( bool multiLine );
-
- /**
* Construct a new TextLabel.
*/
TextLabel();
@@ -135,6 +119,8 @@ private: // Data
Text::ControllerPtr mController;
Text::RendererPtr mRenderer;
+
+ unsigned int mRenderingBackend;
};
} // namespace Internal
diff --git a/dali-toolkit/internal/file.list b/dali-toolkit/internal/file.list
index 5e98629..1a6826c 100644
--- a/dali-toolkit/internal/file.list
+++ b/dali-toolkit/internal/file.list
@@ -75,6 +75,7 @@ toolkit_src_files = \
$(toolkit_src_dir)/shader-effects/page-turn-effect-impl.cpp \
$(toolkit_src_dir)/shader-effects/water-effect-impl.cpp \
$(toolkit_src_dir)/styling/style-manager-impl.cpp \
+ $(toolkit_src_dir)/text/rendering/text-backend-impl.cpp \
$(toolkit_src_dir)/text/multi-language-support-impl.cpp \
$(toolkit_src_dir)/transition-effects/cube-transition-effect-impl.cpp \
$(toolkit_src_dir)/transition-effects/cube-transition-cross-effect-impl.cpp \
diff --git a/dali-toolkit/internal/text/rendering/text-backend-impl.cpp b/dali-toolkit/internal/text/rendering/text-backend-impl.cpp
new file mode 100644
index 0000000..87b8e6a
--- /dev/null
+++ b/dali-toolkit/internal/text/rendering/text-backend-impl.cpp
@@ -0,0 +1,115 @@
+/*
+ * 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
+
+// INTERNAL INCLUDES
+#include
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+namespace Internal
+{
+
+struct Backend::Impl
+{
+ int temp; // placeholder for future backend implemenations
+};
+
+Backend::Backend()
+: mImpl( NULL )
+{
+ mImpl = new Impl();
+}
+
+Backend::~Backend()
+{
+ delete mImpl;
+}
+
+Dali::Toolkit::Text::Backend Backend::Get()
+{
+ Dali::Toolkit::Text::Backend backendHandle;
+
+ Dali::SingletonService service( SingletonService::Get() );
+ if ( service )
+ {
+ // Check whether the singleton is already created
+ Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::Toolkit::Text::Backend ) );
+ if(handle)
+ {
+ // If so, downcast the handle
+ Backend* impl = dynamic_cast< Dali::Toolkit::Text::Internal::Backend* >( handle.GetObjectPtr() );
+ backendHandle = Dali::Toolkit::Text::Backend( impl );
+ }
+ else // create and register the object
+ {
+ backendHandle = Dali::Toolkit::Text::Backend( new Backend );
+ service.Register( typeid( backendHandle ), backendHandle );
+ }
+ }
+
+ return backendHandle;
+}
+
+RendererPtr Backend::NewRenderer( unsigned int renderingType )
+{
+ RendererPtr renderer;
+
+ switch( renderingType )
+ {
+ case Dali::Toolkit::Text::RENDERING_BASIC:
+ {
+ renderer = Dali::Toolkit::Text::BasicRenderer::New();
+ }
+ break;
+
+ case Dali::Toolkit::Text::RENDERING_SHARED_ATLAS:
+ {
+ // TODO
+ }
+ break;
+
+ default:
+ {
+ DALI_LOG_WARNING( "Unknown renderer type: %d", renderingType );
+ break;
+ }
+ }
+
+ return renderer;
+}
+
+} // namespace Internal
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/internal/text/rendering/text-backend-impl.h b/dali-toolkit/internal/text/rendering/text-backend-impl.h
new file mode 100644
index 0000000..6e0390b
--- /dev/null
+++ b/dali-toolkit/internal/text/rendering/text-backend-impl.h
@@ -0,0 +1,103 @@
+#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_BACKEND_H__
+#define __DALI_TOOLKIT_INTERNAL_TEXT_BACKEND_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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include
+
+// INTERNAL INCLUDES
+#include
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+namespace Internal
+{
+
+/**
+ * Implementation of the text rendering backend
+ */
+class Backend : public BaseObject
+{
+public:
+
+ /**
+ * Constructor
+ */
+ Backend();
+
+ /**
+ * Destructor
+ */
+ ~Backend();
+
+ /**
+ * @copydoc Dali::Toolkit::Text::Backend::Get()
+ */
+ static Dali::Toolkit::Text::Backend Get();
+
+ /**
+ * @copydoc Dali::Toolkit::Text::Backend::NewRenderer()
+ */
+ RendererPtr NewRenderer( unsigned int renderingType );
+
+private:
+
+ // Undefined copy constructor.
+ Backend( const Backend& );
+
+ // Undefined assignment constructor.
+ Backend& operator=( Backend& );
+
+private:
+
+ struct Impl;
+ Impl* mImpl;
+
+}; // class Backend
+
+} // namespace Internal
+
+inline static Internal::Backend& GetImplementation(Backend& backend)
+{
+ DALI_ASSERT_ALWAYS( backend && "backend handle is empty" );
+ BaseObject& handle = backend.GetBaseObject();
+ return static_cast(handle);
+}
+
+inline static const Internal::Backend& GetImplementation(const Backend& backend)
+{
+ DALI_ASSERT_ALWAYS( backend && "backend handle is empty" );
+ const BaseObject& handle = backend.GetBaseObject();
+ return static_cast(handle);
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_INTERNAL_TEXT_BACKEND_H__
diff --git a/dali-toolkit/public-api/controls/text-controls/text-field.cpp b/dali-toolkit/public-api/controls/text-controls/text-field.cpp
index d891302..bbe9d1f 100644
--- a/dali-toolkit/public-api/controls/text-controls/text-field.cpp
+++ b/dali-toolkit/public-api/controls/text-controls/text-field.cpp
@@ -27,6 +27,7 @@ namespace Dali
namespace Toolkit
{
+const std::string TextField::RENDERING_BACKEND_PROPERTY_NAME("rendering-backend");
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");
@@ -69,11 +70,6 @@ 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)
{
diff --git a/dali-toolkit/public-api/controls/text-controls/text-field.h b/dali-toolkit/public-api/controls/text-controls/text-field.h
index 1f9b6f8..941f495 100644
--- a/dali-toolkit/public-api/controls/text-controls/text-field.h
+++ b/dali-toolkit/public-api/controls/text-controls/text-field.h
@@ -41,6 +41,7 @@ class DALI_IMPORT_API TextField : public Control
public:
// Property indices
+ static const Property::Index PROPERTY_RENDERING_BACKEND; ///< name "rendering-backend", type UNSIGNED INT
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
@@ -52,6 +53,7 @@ public:
static const Property::Index PROPERTY_GRAB_HANDLE_IMAGE; ///< name "grab-handle-image", type STRING
// Property names
+ static const std::string RENDERING_BACKEND_PROPERTY_NAME; ///< Property, name "rendering-backend", type UNSIGNED INT
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
@@ -106,13 +108,6 @@ public:
*/
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
/**
diff --git a/dali-toolkit/public-api/controls/text-controls/text-label.cpp b/dali-toolkit/public-api/controls/text-controls/text-label.cpp
index 15bb52c..e647d8a 100644
--- a/dali-toolkit/public-api/controls/text-controls/text-label.cpp
+++ b/dali-toolkit/public-api/controls/text-controls/text-label.cpp
@@ -27,6 +27,7 @@ namespace Dali
namespace Toolkit
{
+const std::string TextLabel::RENDERING_BACKEND_PROPERTY_NAME("rendering-backend");
const std::string TextLabel::TEXT_PROPERTY_NAME("text");
const std::string TextLabel::MULTI_LINE_PROPERTY_NAME("multi-line");
@@ -62,11 +63,6 @@ TextLabel TextLabel::DownCast( BaseHandle handle )
return Control::DownCast(handle);
}
-void TextLabel::SetRenderer( Text::RendererPtr renderer )
-{
- GetImpl(*this).SetRenderer( renderer );
-}
-
TextLabel::TextLabel( Internal::TextLabel& implementation )
: Control(implementation)
{
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 1c83e62..8391682 100644
--- a/dali-toolkit/public-api/controls/text-controls/text-label.h
+++ b/dali-toolkit/public-api/controls/text-controls/text-label.h
@@ -43,12 +43,14 @@ class DALI_IMPORT_API TextLabel : public Control
public:
// Property indices
- static const Property::Index PROPERTY_TEXT; ///< name "text", type STRING
- static const Property::Index PROPERTY_MULTI_LINE; ///< name "multi-line", type BOOLEAN
+ static const Property::Index PROPERTY_RENDERING_BACKEND; ///< name "rendering-backend", type UNSIGNED INT
+ static const Property::Index PROPERTY_TEXT; ///< name "text", type STRING
+ static const Property::Index PROPERTY_MULTI_LINE; ///< name "multi-line", type BOOLEAN
// Property names
- static const std::string TEXT_PROPERTY_NAME; ///< Property, name "text", type STRING
- static const std::string MULTI_LINE_PROPERTY_NAME; ///< Property, name "multi-line", type BOOLEAN
+ static const std::string RENDERING_BACKEND_PROPERTY_NAME; ///< Property, name "rendering-backend", type UNSIGNED INT
+ static const std::string TEXT_PROPERTY_NAME; ///< Property, name "text", type STRING
+ static const std::string MULTI_LINE_PROPERTY_NAME; ///< Property, name "multi-line", type BOOLEAN
/**
* Create the TextLabel control.
@@ -94,13 +96,6 @@ public:
*/
static TextLabel DownCast( BaseHandle handle );
- /**
- * @brief Set the rendering back-end used by the TextLabel.
- *
- * @param[in] renderer The text renderer to use.
- */
- void SetRenderer( Text::RendererPtr renderer );
-
public: // Not intended for application developers
/**
diff --git a/dali-toolkit/public-api/file.list b/dali-toolkit/public-api/file.list
index 5dd397e..a354b63 100755
--- a/dali-toolkit/public-api/file.list
+++ b/dali-toolkit/public-api/file.list
@@ -108,6 +108,7 @@ public_api_src_files = \
$(public_api_src_dir)/text/visual-model.cpp \
$(public_api_src_dir)/text/decorator/text-decorator.cpp \
$(public_api_src_dir)/text/layouts/layout-engine.cpp \
+ $(public_api_src_dir)/text/rendering/text-backend.cpp \
$(public_api_src_dir)/text/rendering/text-renderer.cpp \
$(public_api_src_dir)/text/rendering/basic/text-basic-renderer.cpp \
$(public_api_src_dir)/text/rendering/shaders/text-basic-shader.cpp \
@@ -254,6 +255,7 @@ public_api_text_layouts_header_files = \
$(public_api_src_dir)/text/layouts/layout-engine.h
public_api_text_rendering_header_files = \
+ $(public_api_src_dir)/text/rendering/text-backend.h \
$(public_api_src_dir)/text/rendering/text-renderer.h
public_api_text_rendering_basic_header_files = \
diff --git a/dali-toolkit/public-api/text/layouts/layout-engine.cpp b/dali-toolkit/public-api/text/layouts/layout-engine.cpp
index cfdd9d4..ae65e17 100644
--- a/dali-toolkit/public-api/text/layouts/layout-engine.cpp
+++ b/dali-toolkit/public-api/text/layouts/layout-engine.cpp
@@ -223,6 +223,11 @@ void LayoutEngine::SetLayout( Layout layout )
mImpl->mLayout = layout;
}
+unsigned int LayoutEngine::GetLayout() const
+{
+ return mImpl->mLayout;
+}
+
void LayoutEngine::UpdateVisualModel( const Vector2& boundingBox,
const Vector& glyphs,
const Vector& characterIndices,
diff --git a/dali-toolkit/public-api/text/layouts/layout-engine.h b/dali-toolkit/public-api/text/layouts/layout-engine.h
index 07de6a2..bc328c1 100644
--- a/dali-toolkit/public-api/text/layouts/layout-engine.h
+++ b/dali-toolkit/public-api/text/layouts/layout-engine.h
@@ -68,6 +68,13 @@ public:
void SetLayout( Layout layout );
/**
+ * @brief Query the required layout.
+ *
+ * @return The required layout.
+ */
+ unsigned int GetLayout() const;
+
+ /**
* @brief Store the visual position of glyphs in the VisualModel.
*
* @param[in] boundingBox The size of the box containing the text.
diff --git a/dali-toolkit/public-api/text/rendering/text-backend.cpp b/dali-toolkit/public-api/text/rendering/text-backend.cpp
new file mode 100644
index 0000000..ae80da6
--- /dev/null
+++ b/dali-toolkit/public-api/text/rendering/text-backend.cpp
@@ -0,0 +1,71 @@
+/*
+ * 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
+{
+
+namespace Text
+{
+
+Backend Backend::Get()
+{
+ return Internal::Backend::Get();
+}
+
+RendererPtr Backend::NewRenderer( unsigned int renderingType )
+{
+ return GetImplementation(*this).NewRenderer( renderingType );
+}
+
+Backend::Backend()
+{
+}
+
+Backend::~Backend()
+{
+}
+
+Backend::Backend( const Backend& handle )
+: BaseHandle( handle )
+{
+}
+
+Backend& Backend::operator=( const Backend& handle )
+{
+ BaseHandle::operator=( handle );
+ return *this;
+}
+
+Backend::Backend( Internal::Backend* internal )
+: BaseHandle( internal )
+{
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/public-api/text/rendering/text-backend.h b/dali-toolkit/public-api/text/rendering/text-backend.h
new file mode 100644
index 0000000..ca54fa1
--- /dev/null
+++ b/dali-toolkit/public-api/text/rendering/text-backend.h
@@ -0,0 +1,113 @@
+#ifndef __DALI_TOOLKIT_TEXT_BACKEND_H__
+#define __DALI_TOOLKIT_TEXT_BACKEND_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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include
+
+// INTERNAL INCLUDES
+#include
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+namespace Internal DALI_INTERNAL
+{
+class Backend;
+}
+
+// The type of text renderer required
+enum RenderingType
+{
+ RENDERING_BASIC, ///< A bitmap-based reference implementation
+ RENDERING_SHARED_ATLAS ///< A bitmap-based solution where renderers can share a texture atlas
+};
+
+/**
+ * @brief Provides access to different text rendering backends.
+ */
+class DALI_IMPORT_API Backend : public BaseHandle
+{
+public:
+
+ /**
+ * @brief Retrieve a handle to the Backend instance.
+ *
+ * @return A handle to the Backend
+ */
+ static Backend Get();
+
+ /**
+ * @brief Create a renderer from a particluar rendering type.
+ *
+ * @param[in] renderingType The type of rendering required.
+ * @return A handle to the newly created renderer.
+ */
+ RendererPtr NewRenderer( unsigned int renderingType );
+
+ /**
+ * @brief Create an uninitialized TextAbstraction handle.
+ */
+ Backend();
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~Backend();
+
+ /**
+ * @brief This copy constructor is required for (smart) pointer semantics.
+ *
+ * @param[in] handle A reference to the copied handle.
+ */
+ Backend( const Backend& handle );
+
+ /**
+ * @brief This assignment operator is required for (smart) pointer semantics.
+ *
+ * @param [in] handle A reference to the copied handle.
+ * @return A reference to this.
+ */
+ Backend& operator=( const Backend& handle );
+
+public: // Not intended for application developers
+
+ /**
+ * @brief This constructor is used by Backend::Get().
+ *
+ * @param[in] backend A pointer to the internal backend object.
+ */
+ explicit DALI_INTERNAL Backend( Internal::Backend* backend );
+};
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_TEXT_BACKEND_H__
diff --git a/dali-toolkit/public-api/text/rendering/text-renderer.h b/dali-toolkit/public-api/text/rendering/text-renderer.h
index d5001c1..283439a 100644
--- a/dali-toolkit/public-api/text/rendering/text-renderer.h
+++ b/dali-toolkit/public-api/text/rendering/text-renderer.h
@@ -39,7 +39,7 @@ class Renderer;
typedef IntrusivePtr RendererPtr;
/**
- * @brief Abstract base class for Text rendering back-ends.
+ * @brief Abstract base class for Text renderers.
*
* This is reponsible for rendering the glyphs from a ViewInterface in the specified positions.
* It is implemented by returning a RenderableActor intended as the child of a UI control.