From: Paul Wisbey
Date: Mon, 2 Feb 2015 09:30:00 +0000 (+0000)
Subject: Text Renderer base class & TextLabel skeleton
X-Git-Tag: new_text_0.1~60
X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=fc043d6d5ed6561deb09ac1c0b92134f9807518d
Text Renderer base class & TextLabel skeleton
Change-Id: Ief7e9491bb3b3abb130710b195a30e94a550e5e0
---
diff --git a/base/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/base/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
new file mode 100644
index 0000000..ed63ba3
--- /dev/null
+++ b/base/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
@@ -0,0 +1,134 @@
+/*
+ * 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
+{
+
+} // namespace
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+const Property::Index TextLabel::PROPERTY_TEXT( Internal::TextLabel::TEXTLABEL_PROPERTY_START_INDEX );
+
+namespace Internal
+{
+
+namespace
+{
+
+// Type registration
+BaseHandle Create()
+{
+ return Toolkit::TextLabel::New();
+}
+
+TypeRegistration mType( typeid(Toolkit::TextLabel), typeid(Toolkit::Control), Create );
+
+PropertyRegistration property1( mType, "text", Toolkit::TextLabel::PROPERTY_TEXT, Property::STRING, &TextLabel::SetProperty, &TextLabel::GetProperty );
+
+} // namespace
+
+Toolkit::TextLabel TextLabel::New()
+{
+ // Create the implementation, temporarily owned by this handle on stack
+ IntrusivePtr< TextLabel > impl = new TextLabel();
+
+ // Pass ownership to CustomActor handle
+ Toolkit::TextLabel 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 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 ) );
+ switch( index )
+ {
+ case Toolkit::TextLabel::PROPERTY_TEXT:
+ {
+ labelImpl.mText = value.Get< std::string >();
+
+ // TODO - Update Model etc.
+ break;
+ }
+ }
+ }
+}
+
+Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index index )
+{
+ Property::Value value;
+
+ Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( Dali::BaseHandle( object ) );
+
+ if( label )
+ {
+ TextLabel& labelImpl( GetImpl( label ) );
+ switch( index )
+ {
+ case Toolkit::TextLabel::PROPERTY_TEXT:
+ {
+ value = labelImpl.mText;
+ break;
+ }
+ }
+ }
+
+ return value;
+}
+
+void TextLabel::OnInitialize()
+{
+}
+
+TextLabel::TextLabel()
+: Control( ControlBehaviour( CONTROL_BEHAVIOUR_NONE ) )
+{
+}
+
+TextLabel::~TextLabel()
+{
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/base/dali-toolkit/internal/controls/text-controls/text-label-impl.h b/base/dali-toolkit/internal/controls/text-controls/text-label-impl.h
new file mode 100644
index 0000000..53bddf2
--- /dev/null
+++ b/base/dali-toolkit/internal/controls/text-controls/text-label-impl.h
@@ -0,0 +1,134 @@
+#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
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+/**
+ * @brief A control which renders a short text string.
+ */
+class TextLabel : public Control
+{
+public:
+
+ // Properties
+ enum
+ {
+ TEXTLABEL_PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
+ TEXTLABEL_PROPERTY_END_INDEX = TEXTLABEL_PROPERTY_START_INDEX + 1000 ///< Reserving 1000 property indices
+ };
+
+ /**
+ * @copydoc Dali::Toollkit::TextLabel::New()
+ */
+ static Toolkit::TextLabel New();
+
+ /**
+ * @copydoc Dali::Toollkit::TextLabel::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();
+
+private: // Implementation
+
+ /**
+ * Construct a new TextLabel.
+ */
+ TextLabel();
+
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~TextLabel();
+
+private:
+
+ // Undefined copy constructor and assignment operators
+ TextLabel(const TextLabel&);
+ TextLabel& operator=(const TextLabel& rhs);
+
+private: // Data
+
+ // TODO - Use Controller/Model for storage
+ Text::RendererPtr mRenderer;
+ std::string mText;
+};
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+
+inline Toolkit::Internal::TextLabel& GetImpl( Toolkit::TextLabel& textLabel )
+{
+ DALI_ASSERT_ALWAYS(textLabel);
+
+ Dali::RefObject& handle = textLabel.GetImplementation();
+
+ return static_cast(handle);
+}
+
+inline const Toolkit::Internal::TextLabel& GetImpl( const Toolkit::TextLabel& 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/base/dali-toolkit/internal/file.list b/base/dali-toolkit/internal/file.list
index 9e3eafb..6371962 100644
--- a/base/dali-toolkit/internal/file.list
+++ b/base/dali-toolkit/internal/file.list
@@ -35,6 +35,7 @@ toolkit_base_src_files = \
$(toolkit_base_src_dir)/controls/scrollable/scroll-view/scroll-view-slide-effect-impl.cpp \
$(toolkit_base_src_dir)/controls/scrollable/scroll-view/scroll-view-wobble-effect-impl.cpp \
$(toolkit_base_src_dir)/controls/table-view/table-view-impl.cpp \
+ $(toolkit_base_src_dir)/controls/text-controls/text-label-impl.cpp \
$(toolkit_base_src_dir)/focus-manager/focus-manager-impl.cpp \
$(toolkit_base_src_dir)/focus-manager/keyboard-focus-manager-impl.cpp \
$(toolkit_base_src_dir)/focus-manager/keyinput-focus-manager-impl.cpp \
diff --git a/base/dali-toolkit/public-api/controls/text-controls/text-label.cpp b/base/dali-toolkit/public-api/controls/text-controls/text-label.cpp
new file mode 100644
index 0000000..946de46
--- /dev/null
+++ b/base/dali-toolkit/public-api/controls/text-controls/text-label.cpp
@@ -0,0 +1,80 @@
+/*
+ * 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
+{
+
+TextLabel TextLabel::New()
+{
+ return Internal::TextLabel::New();
+}
+
+TextLabel::TextLabel()
+{
+}
+
+TextLabel::TextLabel( const TextLabel& handle )
+: Control( handle )
+{
+}
+
+TextLabel& TextLabel::operator=( const TextLabel& handle )
+{
+ if( &handle != this )
+ {
+ Control::operator=( handle );
+ }
+ return *this;
+}
+
+TextLabel::~TextLabel()
+{
+}
+
+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)
+{
+}
+
+TextLabel::TextLabel( Dali::Internal::CustomActor* internal )
+: Control( internal )
+{
+ VerifyCustomActorPointer( internal );
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/base/dali-toolkit/public-api/controls/text-controls/text-label.h b/base/dali-toolkit/public-api/controls/text-controls/text-label.h
new file mode 100644
index 0000000..bf44949
--- /dev/null
+++ b/base/dali-toolkit/public-api/controls/text-controls/text-label.h
@@ -0,0 +1,121 @@
+#ifndef __DALI_TOOLKIT_TEXT_LABEL_H__
+#define __DALI_TOOLKIT_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
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal DALI_INTERNAL
+{
+class TextLabel;
+}
+
+/**
+ * @brief A control which renders a short text string.
+ */
+class DALI_IMPORT_API TextLabel : public Control
+{
+public:
+
+ // Property indices
+ static const Property::Index PROPERTY_TEXT; ///< name "text", type STRING
+
+ // Property names
+ static const std::string TEXT_PROPERTY_NAME; ///< Property, name "text", type STRING
+
+ /**
+ * Create the TextLabel control.
+ * @return A handle to the TextLabel control.
+ */
+ static TextLabel New();
+
+ /**
+ * @brief Creates an empty handle.
+ */
+ TextLabel();
+
+ /**
+ * @brief Copy constructor.
+ *
+ * @param[in] handle The handle to copy from.
+ */
+ TextLabel( const TextLabel& handle );
+
+ /**
+ * @brief Assignment operator.
+ *
+ * @param[in] handle The handle to copy from.
+ * @return A reference to this.
+ */
+ TextLabel& operator=( const TextLabel& handle );
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~TextLabel();
+
+ /**
+ * @brief Downcast a handle to TextLabel.
+ *
+ * If the BaseHandle points is a TextLabel 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 TextLabel or an empty handle
+ */
+ 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
+
+ /**
+ * @brief Creates a handle using the Toolkit::Internal implementation.
+ *
+ * @param[in] implementation The Control implementation.
+ */
+ DALI_INTERNAL TextLabel( Internal::TextLabel& 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 TextLabel( Dali::Internal::CustomActor* internal );
+};
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_TEXT_LABEL_H__
diff --git a/base/dali-toolkit/public-api/file.list b/base/dali-toolkit/public-api/file.list
index b371c9d..f7d3578 100755
--- a/base/dali-toolkit/public-api/file.list
+++ b/base/dali-toolkit/public-api/file.list
@@ -39,7 +39,9 @@ public_api_base_src_files = \
$(public_api_base_src_dir)/controls/scrollable/scroll-view/scroll-view-slide-effect.cpp \
$(public_api_base_src_dir)/controls/scrollable/scroll-view/scroll-view-wobble-effect.cpp \
$(public_api_base_src_dir)/controls/table-view/table-view.cpp \
+ $(public_api_base_src_dir)/controls/text-controls/text-label.cpp \
$(public_api_base_src_dir)/text/logical-model.cpp \
+ $(public_api_base_src_dir)/text/text-renderer.cpp \
$(public_api_base_src_dir)/text/text-view.cpp \
$(public_api_base_src_dir)/text/text-view-interface.cpp \
$(public_api_base_src_dir)/text/visual-model.cpp \
@@ -116,9 +118,13 @@ public_api_base_scroll_view_header_files = \
public_api_base_table_view_header_files = \
$(public_api_base_src_dir)/controls/table-view/table-view.h
+public_api_base_text_controls_header_files = \
+ $(public_api_base_src_dir)/controls/text-controls/text-label.h
+
public_api_base_text_header_files = \
$(public_api_base_src_dir)/text/logical-model.h \
$(public_api_base_src_dir)/text/text-definitions.h \
+ $(public_api_base_src_dir)/text/text-renderer.h \
$(public_api_base_src_dir)/text/text-view.h \
$(public_api_base_src_dir)/text/text-view-interface.h \
$(public_api_base_src_dir)/text/visual-model.h
diff --git a/base/dali-toolkit/public-api/text/text-renderer.cpp b/base/dali-toolkit/public-api/text/text-renderer.cpp
new file mode 100644
index 0000000..f10968d
--- /dev/null
+++ b/base/dali-toolkit/public-api/text/text-renderer.cpp
@@ -0,0 +1,42 @@
+/*
+ * 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
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+Renderer::Renderer()
+{
+}
+
+Renderer::~Renderer()
+{
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/base/dali-toolkit/public-api/text/text-renderer.h b/base/dali-toolkit/public-api/text/text-renderer.h
new file mode 100644
index 0000000..d5001c1
--- /dev/null
+++ b/base/dali-toolkit/public-api/text/text-renderer.h
@@ -0,0 +1,86 @@
+#ifndef __DALI_TOOLKIT_TEXT_RENDERER_H__
+#define __DALI_TOOLKIT_TEXT_RENDERER_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
+#include
+#include
+
+// INTERNAL INCLUDES
+#include
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+class Renderer;
+typedef IntrusivePtr RendererPtr;
+
+/**
+ * @brief Abstract base class for Text rendering back-ends.
+ *
+ * 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.
+ */
+class Renderer : public RefObject
+{
+public:
+
+ /**
+ * @brief Render the glyphs from a ViewInterface.
+ *
+ * @param[in] view The interface to a view.
+ * @return The Renderable actor used to position the text.
+ */
+ virtual RenderableActor Render( ViewInterface& view ) = 0;
+
+protected:
+
+ /**
+ * @brief Constructor.
+ */
+ Renderer();
+
+ /**
+ * @brief A reference counted object may only be deleted by calling Unreference().
+ */
+ virtual ~Renderer();
+
+private:
+
+ // Undefined
+ Renderer( const Renderer& handle );
+
+ // Undefined
+ Renderer& operator=( const Renderer& handle );
+};
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_TEXT_RENDERER_H__
diff --git a/build/tizen/dali-toolkit/Makefile.am b/build/tizen/dali-toolkit/Makefile.am
index 6f9a202..60e340f 100644
--- a/build/tizen/dali-toolkit/Makefile.am
+++ b/build/tizen/dali-toolkit/Makefile.am
@@ -114,6 +114,7 @@ publicapibasescrollcomponentdir = $(publicapibasedir)/controls/scroll-component
publicapibasescrollabledir = $(publicapibasedir)/controls/scrollable
publicapibasescrollviewdir = $(publicapibasedir)/controls/scrollable/scroll-view
publicapibasetableviewdir = $(publicapibasedir)/controls/table-view
+publicapibasetextcontrolsdir = $(publicapibasedir)/controls/text-controls
publicapibasetextdir = $(publicapibasedir)/text
publicapibasefactorydir = $(publicapibasedir)/factory
publicapibasefocusmanagerdir = $(publicapibasedir)/focus-manager
@@ -134,6 +135,7 @@ publicapibasescrollcomponent_HEADERS = $(public_api_base_scroll_component_header
publicapibasescrollable_HEADERS = $(public_api_base_scrollable_header_files)
publicapibasescrollview_HEADERS = $(public_api_base_scroll_view_header_files)
publicapibasetableview_HEADERS = $(public_api_base_table_view_header_files)
+publicapibasetextcontrols_HEADERS = $(public_api_base_text_controls_header_files)
publicapibasetext_HEADERS = $(public_api_base_text_header_files)
publicapibasefocusmanager_HEADERS = $(public_api_base_focus_manager_header_files)
publicapibasemarkupprocessor_HEADERS = $(public_api_base_markup_processor_header_files)
diff --git a/optional/dali-toolkit/dali-toolkit.h b/optional/dali-toolkit/dali-toolkit.h
index 63c2598..d7aefeb 100644
--- a/optional/dali-toolkit/dali-toolkit.h
+++ b/optional/dali-toolkit/dali-toolkit.h
@@ -46,6 +46,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -61,6 +62,7 @@
#include
#include
#include
+#include
#include
#include
#include