From e7673eb153679d438cb144e2b2bdc74b5d4294d9 Mon Sep 17 00:00:00 2001
From: Paul Wisbey
Date: Tue, 24 Feb 2015 10:21:16 +0000
Subject: [PATCH] Skeleton Decorator API
Change-Id: Ib30eca2376d5927f52e4c06cb93dd65c903a629e
---
build/tizen/dali-toolkit/Makefile.am | 2 +
dali-toolkit/dali-toolkit.h | 1 +
dali-toolkit/public-api/file.list | 4 +
.../public-api/text/decorator/text-decorator.cpp | 178 +++++++++++++++++
.../public-api/text/decorator/text-decorator.h | 219 +++++++++++++++++++++
5 files changed, 404 insertions(+)
create mode 100644 dali-toolkit/public-api/text/decorator/text-decorator.cpp
create mode 100644 dali-toolkit/public-api/text/decorator/text-decorator.h
diff --git a/build/tizen/dali-toolkit/Makefile.am b/build/tizen/dali-toolkit/Makefile.am
index 7f49efa..8564714 100644
--- a/build/tizen/dali-toolkit/Makefile.am
+++ b/build/tizen/dali-toolkit/Makefile.am
@@ -101,6 +101,7 @@ publicapisuperblurviewdir = $(publicapicontrolsdir)/super-blur-view
publicapitableviewdir = $(publicapicontrolsdir)/table-view
publicapitextcontrolsdir = $(publicapidir)/controls/text-controls
publicapitextdir = $(publicapidir)/text
+publicapitextdecoratordir = $(publicapidir)/text/decorator
publicapitextlayoutsdir = $(publicapidir)/text/layouts
publicapitextrenderingdir = $(publicapidir)/text/rendering
publicapitextrenderingbasicdir = $(publicapidir)/text/rendering/basic
@@ -141,6 +142,7 @@ publicapisuperblurview_HEADERS = $(public_api_super_blur_view_header_files)
publicapitableview_HEADERS = $(public_api_table_view_header_files)
publicapitextcontrols_HEADERS = $(public_api_text_controls_header_files)
publicapitext_HEADERS = $(public_api_text_header_files)
+publicapitextdecorator_HEADERS = $(public_api_text_decorator_header_files)
publicapitextlayouts_HEADERS = $(public_api_text_layouts_header_files)
publicapitextrendering_HEADERS = $(public_api_text_rendering_header_files)
publicapitextrenderingbasic_HEADERS = $(public_api_text_rendering_basic_header_files)
diff --git a/dali-toolkit/dali-toolkit.h b/dali-toolkit/dali-toolkit.h
index c04d98b..db0be9c 100644
--- a/dali-toolkit/dali-toolkit.h
+++ b/dali-toolkit/dali-toolkit.h
@@ -130,6 +130,7 @@
#include
#include
#include
+#include
#include
#include
#include
diff --git a/dali-toolkit/public-api/file.list b/dali-toolkit/public-api/file.list
index 97d37ec..fab975a 100755
--- a/dali-toolkit/public-api/file.list
+++ b/dali-toolkit/public-api/file.list
@@ -103,6 +103,7 @@ public_api_src_files = \
$(public_api_src_dir)/text/text-view.cpp \
$(public_api_src_dir)/text/text-view-interface.cpp \
$(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-renderer.cpp \
$(public_api_src_dir)/text/rendering/basic/text-basic-renderer.cpp \
@@ -241,6 +242,9 @@ public_api_text_header_files = \
$(public_api_src_dir)/text/text-view-interface.h \
$(public_api_src_dir)/text/visual-model.h
+public_api_text_decorator_header_files = \
+ $(public_api_src_dir)/text/decorator/text-decorator.h
+
public_api_text_layouts_header_files = \
$(public_api_src_dir)/text/layouts/layout-engine.h
diff --git a/dali-toolkit/public-api/text/decorator/text-decorator.cpp b/dali-toolkit/public-api/text/decorator/text-decorator.cpp
new file mode 100644
index 0000000..49d26ec
--- /dev/null
+++ b/dali-toolkit/public-api/text/decorator/text-decorator.cpp
@@ -0,0 +1,178 @@
+/*
+ * 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
+#include
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+struct Decorator::Impl
+{
+ struct CursorImpl
+ {
+ CursorImpl()
+ : x(0.0f),
+ y(0.0f),
+ height(0.0f),
+ color(Dali::Color::WHITE)
+ {
+ }
+
+ float x;
+ float y;
+ float height;
+
+ Image image;
+ Vector4 color;
+ };
+
+ Impl(ControlImpl& parent)
+ : mParent(parent),
+ mActiveCursor(ACTIVE_CURSOR_NONE),
+ mCursorBlinkInterval(0.5f),
+ mCursorBlinkDuration(0.0f)
+ {
+ }
+
+ void Relayout( const Vector2& size )
+ {
+ // TODO
+ }
+
+ ControlImpl& mParent;
+
+ unsigned int mActiveCursor;
+
+ CursorImpl mCursor[CURSOR_COUNT];
+
+ float mCursorBlinkInterval;
+ float mCursorBlinkDuration;
+};
+
+DecoratorPtr Decorator::New(ControlImpl& parent)
+{
+ return DecoratorPtr( new Decorator(parent) );
+}
+
+void Decorator::Relayout( const Vector2& size )
+{
+ mImpl->Relayout( size );
+}
+
+void Decorator::SetActiveCursor( ActiveCursor activeCursor )
+{
+ mImpl->mActiveCursor = activeCursor;
+}
+
+unsigned int Decorator::GetActiveCursor() const
+{
+ return mImpl->mActiveCursor;
+}
+
+void Decorator::SetPosition( Cursor cursor, float x, float y, float height )
+{
+ mImpl->mCursor[cursor].x = x;
+ mImpl->mCursor[cursor].y = y;
+ mImpl->mCursor[cursor].height = height;
+}
+
+void Decorator::GetPosition( Cursor cursor, float& x, float& y, float& height ) const
+{
+ x = mImpl->mCursor[cursor].x;
+ y = mImpl->mCursor[cursor].y;
+ height = mImpl->mCursor[cursor].height;
+}
+
+void Decorator::SetImage( Cursor cursor, Dali::Image image )
+{
+ mImpl->mCursor[cursor].image = image;
+}
+
+Dali::Image Decorator::GetImage( Cursor cursor ) const
+{
+ return mImpl->mCursor[cursor].image;
+}
+
+void Decorator::SetColor( Cursor cursor, const Dali::Vector4& color )
+{
+ mImpl->mCursor[cursor].color = color;
+}
+
+const Dali::Vector4& Decorator::GetColor( Cursor cursor ) const
+{
+ return mImpl->mCursor[cursor].color;
+}
+
+void Decorator::StartCursorBlink()
+{
+ // TODO
+}
+
+void Decorator::StopCursorBlink()
+{
+ // TODO
+}
+
+void Decorator::SetCursorBlinkInterval( float seconds )
+{
+ mImpl->mCursorBlinkInterval = seconds;
+}
+
+float Decorator::GetCursorBlinkInterval() const
+{
+ return mImpl->mCursorBlinkInterval;
+}
+
+void Decorator::SetCursorBlinkDuration( float seconds )
+{
+ mImpl->mCursorBlinkDuration = seconds;
+}
+
+float Decorator::GetCursorBlinkDuration() const
+{
+ return mImpl->mCursorBlinkDuration;
+}
+
+Decorator::~Decorator()
+{
+ delete mImpl;
+}
+
+Decorator::Decorator(ControlImpl& parent)
+: mImpl( NULL )
+{
+ mImpl = new Decorator::Impl(parent);
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/public-api/text/decorator/text-decorator.h b/dali-toolkit/public-api/text/decorator/text-decorator.h
new file mode 100644
index 0000000..b9adf17
--- /dev/null
+++ b/dali-toolkit/public-api/text/decorator/text-decorator.h
@@ -0,0 +1,219 @@
+#ifndef __DALI_TOOLKIT_TEXT_DECORATOR_H__
+#define __DALI_TOOLKIT_TEXT_DECORATOR_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
+
+namespace Dali
+{
+
+class Image;
+class Vector2;
+class Vector4;
+
+namespace Toolkit
+{
+
+class ControlImpl;
+
+namespace Text
+{
+
+class Decorator;
+typedef IntrusivePtr DecoratorPtr;
+
+// Used to set the cursor positions etc.
+enum Cursor
+{
+ PRIMARY_CURSOR, ///< The primary cursor for bidirectional text (or the regular cursor for single-direction text)
+ SECONDARY_CURSOR, ///< The secondary cursor for bidirectional text
+ CURSOR_COUNT
+};
+
+// Determines which of the cursors are active (if any).
+enum ActiveCursor
+{
+ ACTIVE_CURSOR_NONE, ///< Neither primary nor secondary cursor are active
+ ACTIVE_CURSOR_PRIMARY, ///< Primary cursor is active (only)
+ ACTIVE_CURSOR_BOTH ///< Both primary and secondary cursor are active
+};
+
+/**
+ * @brief A Text Decorator is used to display cursors, handles, selection highlights and pop-ups.
+ *
+ * The decorator is responsible for clipping decorations which are positioned outside of the parent area.
+ * In some cases the decorations will be moved or flipped around, to maintain visibility on-screen.
+ */
+class Decorator : public RefObject
+{
+public:
+
+ /**
+ * @brief Create a new instance of a Decorator.
+ *
+ * @param[in] parent Decorations will be added to this parent control.
+ * @return A pointer to a new Decorator.
+ */
+ static DecoratorPtr New( ControlImpl& parent );
+
+ /**
+ * @brief The decorator waits until a relayout before creating actors etc.
+ *
+ * @param[in] size The size of the parent control after size-negotiation.
+ */
+ void Relayout( const Dali::Vector2& size );
+
+ /**
+ * @brief Sets which of the cursors are active.
+ *
+ * @note Cursor will only be visible if within the parent area.
+ * @param[in] activeCursor Which of the cursors should be active (if any).
+ */
+ void SetActiveCursor( ActiveCursor activeCursor );
+
+ /**
+ * @brief Sets whether a cursor should be visible.
+ *
+ * @return Which of the cursors are active (if any).
+ */
+ unsigned int GetActiveCursor() const;
+
+ /**
+ * @brief Sets the position of a cursor.
+ *
+ * @param[in] cursor The cursor to set.
+ * @param[in] x The x position relative to the top-left of the parent control.
+ * @param[in] y The y position relative to the top-left of the parent control.
+ * @param[in] height The logical height of the cursor.
+ */
+ void SetPosition( Cursor cursor, float x, float y, float height );
+
+ /**
+ * @brief Retrieves the position of a cursor.
+ *
+ * @param[in] cursor The cursor to get.
+ * @param[out] x The x position relative to the top-left of the parent control.
+ * @param[out] y The y position relative to the top-left of the parent control.
+ * @param[out] height The logical height of the cursor.
+ */
+ void GetPosition( Cursor cursor, float& x, float& y, float& height ) const;
+
+ /**
+ * @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 );
+
+ /**
+ * @brief Retrieves the image for a cursor.
+ *
+ * @return The cursor image.
+ */
+ Dali::Image GetImage( Cursor cursor ) const;
+
+ /**
+ * @brief Sets the color for a cursor.
+ *
+ * @param[in] cursor The cursor to set.
+ * @param[in] color The color to use.
+ */
+ void SetColor( Cursor cursor, const Dali::Vector4& color );
+
+ /**
+ * @brief Retrieves the color for a cursor.
+ *
+ * @return The cursor color.
+ */
+ const Dali::Vector4& GetColor( Cursor cursor ) const;
+
+ /**
+ * @brief Start blinking the cursor; see also SetCursorBlinkDuration().
+ */
+ void StartCursorBlink();
+
+ /**
+ * @brief Stop blinking the cursor.
+ */
+ void StopCursorBlink();
+
+ /**
+ * @brief Set the interval between cursor blinks.
+ *
+ * @param[in] seconds The interval in seconds.
+ */
+ void SetCursorBlinkInterval( float seconds );
+
+ /**
+ * @brief Retrieves the blink-interval for a cursor.
+ *
+ * @return The cursor blink-interval.
+ */
+ float GetCursorBlinkInterval() const;
+
+ /**
+ * @brief The cursor will stop blinking after this duration.
+ *
+ * @param[in] seconds The duration in seconds.
+ */
+ void SetCursorBlinkDuration( float seconds );
+
+ /**
+ * @brief Retrieves the blink-duration for a cursor.
+ *
+ * @return The cursor blink-duration.
+ */
+ float GetCursorBlinkDuration() const;
+
+protected:
+
+ /**
+ * @brief A reference counted object may only be deleted by calling Unreference().
+ */
+ virtual ~Decorator();
+
+private:
+
+ /**
+ * @brief Private constructor.
+ * @param[in] parent Decorations will be added to this parent control.
+ */
+ Decorator(ControlImpl& parent);
+
+ // Undefined
+ Decorator( const Decorator& handle );
+
+ // Undefined
+ Decorator& operator=( const Decorator& handle );
+
+private:
+
+ struct Impl;
+ Impl* mImpl;
+};
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_TEXT_DECORATOR_H__
--
2.7.4