Support Widget Application 20/164120/12
authorminho.sun <minho.sun@samsung.com>
Mon, 13 Nov 2017 08:01:45 +0000 (17:01 +0900)
committerminho.sun <minho.sun@samsung.com>
Thu, 21 Dec 2017 07:56:35 +0000 (16:56 +0900)
Support Widget Application on tizen devices.

WidgetApplication
 - Class for getting Application lifecycle callbacks.
 - Manage Widget instances and Widget Creator functions.

Widget
 - Class for getting Widget Instance lifecycle.
 - Support virtual function for lifecycles.

Widget Controller
 - Class for communicating with widget framework.

Change-Id: Id5a7af66b412bf9b88d1449b6f899c430718066c

27 files changed:
adaptors/common/framework.h
adaptors/devel-api/file.list
adaptors/public-api/adaptor-framework/widget-application.cpp [new file with mode: 0644]
adaptors/public-api/adaptor-framework/widget-application.h [new file with mode: 0644]
adaptors/public-api/adaptor-framework/widget-impl.cpp [new file with mode: 0644]
adaptors/public-api/adaptor-framework/widget-impl.h [new file with mode: 0644]
adaptors/public-api/adaptor-framework/widget.cpp [new file with mode: 0644]
adaptors/public-api/adaptor-framework/widget.h [new file with mode: 0644]
adaptors/public-api/dali.h
adaptors/public-api/file.list
adaptors/tizen/file-3.list
adaptors/tizen/file.list
adaptors/tizen/framework-tizen.cpp
adaptors/tizen/widget-application-impl-tizen-3.cpp [new file with mode: 0644]
adaptors/tizen/widget-application-impl-tizen.cpp [new file with mode: 0644]
adaptors/tizen/widget-application-impl.h [new file with mode: 0644]
adaptors/tizen/widget-controller-tizen-3.cpp [new file with mode: 0644]
adaptors/tizen/widget-controller-tizen.cpp [new file with mode: 0644]
adaptors/tizen/widget-controller.h [new file with mode: 0644]
adaptors/ubuntu/file.list
adaptors/ubuntu/widget-application-impl-ubuntu.cpp [new file with mode: 0644]
adaptors/ubuntu/widget-application-impl.h [new file with mode: 0644]
adaptors/ubuntu/widget-controller-ubuntu.cpp [new file with mode: 0644]
adaptors/ubuntu/widget-controller.h [new file with mode: 0644]
build/tizen/adaptor/Makefile.am
build/tizen/adaptor/configure.ac
packaging/dali-adaptor.spec

index 6b5965a..c741734 100644 (file)
@@ -52,8 +52,9 @@ public:
 
   enum Type
   {
-    NORMAL,       ///<  normal appFramework
-    WATCH     ///< watch appFramework
+    NORMAL,       ///< normal appFramework
+    WATCH,        ///< watch appFramework
+    WIDGET        ///< widget appFramework
   };
 
   /**
index 4eca888..15c96f1 100644 (file)
@@ -66,4 +66,3 @@ devel_api_adaptor_framework_header_files = \
   $(adaptor_devel_api_dir)/adaptor-framework/key-extension-plugin.h \
   $(adaptor_devel_api_dir)/adaptor-framework/virtual-keyboard.h \
   $(adaptor_devel_api_dir)/adaptor-framework/physical-keyboard.h
-
diff --git a/adaptors/public-api/adaptor-framework/widget-application.cpp b/adaptors/public-api/adaptor-framework/widget-application.cpp
new file mode 100644 (file)
index 0000000..dce9aed
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2017 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 "widget-application.h"
+
+// INTERNAL INCLUDES
+#include <widget-application-impl.h>
+
+namespace Dali
+{
+
+WidgetApplication WidgetApplication::New( int* argc, char **argv[], const std::string& stylesheet )
+{
+  Internal::Adaptor::WidgetApplicationPtr internal = Internal::Adaptor::WidgetApplication::New( argc, argv, stylesheet);
+  return WidgetApplication(internal.Get());
+}
+
+WidgetApplication::~WidgetApplication()
+{
+}
+
+WidgetApplication::WidgetApplication()
+{
+}
+
+WidgetApplication::WidgetApplication(const WidgetApplication& widgetApplication)
+: Application(widgetApplication)
+{
+}
+
+WidgetApplication& WidgetApplication::operator=(const WidgetApplication& widgetApplication)
+{
+  if( *this != widgetApplication )
+  {
+    BaseHandle::operator=( widgetApplication );
+  }
+  return *this;
+}
+
+void WidgetApplication::RegisterWidgetCreatingFunction( const std::string& widgetName, CreateWidgetFunction createFunction )
+{
+  Internal::Adaptor::GetImplementation(*this).RegisterWidgetCreatingFunction( widgetName, createFunction );
+}
+
+WidgetApplication::WidgetApplication(Internal::Adaptor::WidgetApplication* widgetApplication)
+: Application(widgetApplication)
+{
+}
+
+} // namespace Dali
diff --git a/adaptors/public-api/adaptor-framework/widget-application.h b/adaptors/public-api/adaptor-framework/widget-application.h
new file mode 100644 (file)
index 0000000..10f2a6d
--- /dev/null
@@ -0,0 +1,175 @@
+#ifndef DALI_WIDGET_APPLICATION_H
+#define DALI_WIDGET_APPLICATION_H
+
+/*
+ * Copyright (c) 2017 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
+#ifdef DALI_ADAPTOR_COMPILATION  // full path doesn't exist until adaptor is installed so we have to use relative
+#include <application.h>
+#else
+#include <dali/public-api/adaptor-framework/application.h>
+#endif
+namespace Dali
+{
+
+namespace Internal DALI_INTERNAL
+{
+
+namespace Adaptor
+{
+class WidgetApplication;
+}
+
+}
+
+class Widget;
+
+/**
+ * @brief An WidgetApplication class object should be created by every widget application
+ * that wishes to use Dali.
+ *
+ * It provides a means for initializing the
+ * resources required by the Dali::Core.
+ *
+ * The WidgetApplication class emits several signals which the user can
+ * connect to.  The user should not create any Dali objects in the main
+ * function and instead should connect to the Init signal of the
+ * WidgetApplication and create the Dali Widget object in the connected callback.
+ *
+ * WidgetApplications should follow the example below:
+ *
+ * @code
+ *
+ * //Widget header which
+ * #include <my-widget.h>
+ *
+ * class ExampleController: public ConnectionTracker
+ * {
+ * public:
+ *   ExampleController( Application& application )
+ *   : mWidgetApplication( application )
+ *   {
+ *     mApplication.InitSignal().Connect( this, &ExampleController::Create );
+ *   }
+ *
+ *   static Widget CreateWidgetFunction(const std::string& widgetName)
+ *   {
+ *     MyWidget widget = MyWidget::New();
+ *     return widget;
+ *   }
+ *
+ *   void Create( Application& application )
+ *   {
+ *     mApplication.RegisterWidgetCreatingFunction( "myWidget", &ExampleController::CreateWidgetFunction );
+ *   }
+ *
+ * private:
+ *   WidgetApplication& mWidgetApplication;
+ * };
+ *
+ * int main (int argc, char **argv)
+ * {
+ *   WidgetApplication app = WidgetApplication::New(&argc, &argv);
+ *   ExampleController example( app );
+ *   app.MainLoop();
+ * }
+ * @endcode
+ *
+ * If required, you can also connect class member functions to a signal:
+ *
+ * @code
+ * MyWidgetApplication app;
+ * app.ResumeSignal().Connect(&app, &MyWidgetApplication::Resume);
+ * @endcode
+ *
+ * @SINCE_1_3_5
+ */
+class DALI_IMPORT_API WidgetApplication : public Application
+{
+public:
+
+  /**
+   * @brief This is the typedef for Widget creator.
+   * @SINCE_1_3_5
+   */
+  typedef Widget(*CreateWidgetFunction)(const std::string&);
+
+public:
+
+  /**
+   * @brief This is the constructor for WidgetApplications with a name.
+   *
+   * @SINCE_1_3_5
+   * @param[in,out]  argc        A pointer to the number of arguments
+   * @param[in,out]  argv        A pointer to the argument list
+   * @param[in]      stylesheet  The path to user defined theme file
+   * @return A handle to the WidgetApplication
+   * @note If the stylesheet is not specified, then the library's default stylesheet will not be overridden.
+   */
+  static WidgetApplication New( int* argc, char **argv[], const std::string& stylesheet );
+
+  /**
+   * @brief The default constructor.
+   * @SINCE_1_3_5
+   */
+  WidgetApplication();
+
+  /**
+   * @brief Copy Constructor.
+   *
+   * @SINCE_1_3_5
+   * @param[in] widgetApplication Handle to an object
+   */
+  WidgetApplication( const WidgetApplication& widgetApplication );
+
+  /**
+   * @brief Assignment operator.
+   *
+   * @SINCE_1_3_5
+   * @param[in] widgetApplication Handle to an object
+   * @return A reference to this
+   */
+  WidgetApplication& operator=( const WidgetApplication& widgetApplication );
+
+ /**
+   * @brief Destructor
+   * @SINCE_1_3_5
+   */
+  ~WidgetApplication();
+
+  /**
+   * @brief Register create function for widget.
+   *
+   * @SINCE_1_3_5
+   * @param[in] widgetName  Name of widget
+   * @param[in] createFunction     Function pointer for widget creation.
+   */
+  void RegisterWidgetCreatingFunction( const std::string& widgetName, CreateWidgetFunction createFunction );
+
+public: // Not intended for application developers
+  /// @cond internal
+  /**
+   * @brief Internal constructor.
+   */
+  explicit DALI_INTERNAL WidgetApplication(Internal::Adaptor::WidgetApplication* widgetApplication);
+  /// @endcond
+};
+
+} // namespace Dali
+
+#endif // DALI_WIDGET_APPLICATION_H
diff --git a/adaptors/public-api/adaptor-framework/widget-impl.cpp b/adaptors/public-api/adaptor-framework/widget-impl.cpp
new file mode 100644 (file)
index 0000000..72e00d0
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2017 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 "widget-impl.h"
+
+// INTERNAL INCLUDES
+#include <window.h>
+#include <widget-controller.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+WidgetPtr Widget::New()
+{
+  return new Widget();
+}
+
+Widget::Widget()
+: mImpl( nullptr )
+{
+}
+
+Widget::~Widget()
+{
+  if( mImpl != nullptr )
+  {
+    delete mImpl;
+  }
+}
+
+void Widget::OnCreate( const std::string& contentInfo, Dali::Window window )
+{
+}
+
+void Widget::OnTerminate( const std::string& contentInfo, Dali::Widget::Termination type )
+{
+}
+
+void Widget::OnPause()
+{
+}
+
+void Widget::OnResume()
+{
+}
+
+void Widget::OnResize( Dali::Window window )
+{
+}
+
+void Widget::OnUpdate( const std::string& contentInfo, int force )
+{
+}
+
+void Widget::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
+{
+  mImpl->SignalConnected( slotObserver, callback );
+}
+
+void Widget::SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback )
+{
+  mImpl->SignalDisconnected( slotObserver, callback );
+}
+
+void Widget::SetContentInfo( const std::string& contentInfo )
+{
+  if( mImpl != nullptr )
+  {
+    mImpl->SetContentInfo( contentInfo );
+  }
+}
+
+void Widget::SetImpl( Impl* impl )
+{
+  mImpl = impl;
+}
+
+Internal::Adaptor::Widget& GetImplementation(Dali::Widget& widget)
+{
+  DALI_ASSERT_ALWAYS(widget && "widget handle is empty");
+
+  BaseObject& handle = widget.GetBaseObject();
+
+  return static_cast<Internal::Adaptor::Widget&>(handle);
+}
+
+const Internal::Adaptor::Widget& GetImplementation(const Dali::Widget& widget)
+{
+  const BaseObject& handle = widget.GetBaseObject();
+
+  return static_cast<const Internal::Adaptor::Widget&>(handle);
+}
+
+} // Adaptor
+
+} // Internal
+
+} // Dali
diff --git a/adaptors/public-api/adaptor-framework/widget-impl.h b/adaptors/public-api/adaptor-framework/widget-impl.h
new file mode 100644 (file)
index 0000000..b592c38
--- /dev/null
@@ -0,0 +1,199 @@
+#ifndef DALI_INTERNAL_WIDGET_H
+#define DALI_INTERNAL_WIDGET_H
+
+/*
+ * Copyright (c) 2017 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 <dali/public-api/object/base-object.h>
+#include <dali/public-api/signals/connection-tracker-interface.h>
+
+// INTERNAL INCLUDES
+#include "widget.h"
+
+namespace Dali
+{
+class Window;
+
+/**
+ * @addtogroup dali_adaptor_framework
+ * @{
+ */
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class Widget;
+typedef IntrusivePtr<Widget> WidgetPtr;
+
+/**
+ * @brief This is the internal base class of custom widget.
+ *
+ * It will provides several widget instance lifecycle virtual functions
+ * which the user can override.
+ *
+ * User should override OnCreate function and create scene for custom widget.
+ *
+ * Plus, Implements ConnectionTrackerInterface so that signals (typically connected to member functions) will
+ * be disconnected automatically when the control is destroyed.
+ *
+ * @SINCE_1_3_5
+ */
+class DALI_IMPORT_API Widget : public BaseObject, public ConnectionTrackerInterface
+{
+public:
+
+  /**
+   * @brief Creates a new WidgetImpl instance.
+   *
+   * @SINCE_1_3_5
+   * @return A handle to the WidgetImpl instance
+   */
+  static WidgetPtr New();
+
+  /**
+   * @brief The user should override this function to determine when they create widget.
+   *
+   * @SINCE_1_3_5
+   * @param[in] contentInfo Information from WidgetView for creating. It contains previous status of widget which is sent by SetContentInfo before.
+   * @param[in] window Window handle for widget
+   */
+  virtual void OnCreate( const std::string& contentInfo, Dali::Window window );
+
+  /**
+   * @brief The user should override this function to determine when they terminate widget.
+   *
+   * @SINCE_1_3_5
+   * @param[in] contentInfo Data from WidgetView for deleting
+   * @param[in] type Termination type. When user delete widget view, termination type is PERMANENT.
+   */
+  virtual void OnTerminate( const std::string& contentInfo, Dali::Widget::Termination type );
+
+  /**
+   * @brief The user should override this function to determine when they pause widget.
+   * @SINCE_1_3_5
+   */
+  virtual void OnPause();
+
+  /**
+   * @brief The user should override this function to determine when they resume widget.
+   * @SINCE_1_3_5
+   */
+  virtual void OnResume();
+
+  /**
+   * @brief The user should override this function to determine when they resize widget.
+   *
+   * @SINCE_1_3_5
+   * @param[in] window Window handle for widget
+   */
+  virtual void OnResize( Dali::Window window );
+
+  /**
+   * @brief The user should override this function to determine when they update widget.
+   *
+   * @SINCE_1_3_5
+   * @param[in] contentInfo Data from WidgetView for updating
+   * @param[in] force Although the widget is paused, if it is true, the widget can be updated
+   */
+  virtual void OnUpdate( const std::string& contentInfo, int force );
+
+  // From ConnectionTrackerInterface
+
+  /**
+   * @copydoc ConnectionTrackerInterface::SignalConnected
+   */
+  virtual void SignalConnected( SlotObserver* slotObserver, CallbackBase* callback );
+
+  /**
+   * @copydoc ConnectionTrackerInterface::SignalDisconnected
+   */
+  virtual void SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback );
+
+  /**
+   * @brief Set content info to WidgetView.
+   *
+   * @SINCE_1_3_5
+   * @param[in] contentInfo Content info is kind of context information which contains current status of widget.
+   */
+  void SetContentInfo( const std::string& contentInfo );
+
+protected:
+
+  /**
+   * @brief WidgetImpl constructor
+   */
+  Widget();
+
+  /**
+   * @brief Virtual destructor
+   */
+  virtual ~Widget();
+
+  /// @cond internal
+public:
+  class Impl; // Class declaration is public so we can internally add devel API's to the WidgetImpl
+
+  /*
+   * Set pointer of WidgetImpl Internal.
+   * @SINCE_1_3_5
+   */
+  void SetImpl( Widget::Impl* impl );
+
+private:
+  Impl* mImpl;
+
+  // Undefined
+  DALI_INTERNAL Widget(const Widget&);
+  DALI_INTERNAL Widget& operator=(Widget&);
+  /// @endcond
+
+};
+
+/**
+ * @brief Gets implementation from the handle.
+ *
+ * @SINCE_1_3_5
+ * @param handle
+ * @return Implementation
+ * @pre handle is initialized and points to a widget
+ */
+DALI_IMPORT_API Internal::Adaptor::Widget& GetImplementation( Dali::Widget& widget );
+
+/**
+ * @brief Gets implementation from the handle.
+ *
+ * @SINCE_1_3_5
+ * @param handle
+ * @return Implementation
+ * @pre Handle is initialized and points to a widget.
+ */
+DALI_IMPORT_API const Internal::Adaptor::Widget& GetImplementation( const Dali::Widget& widget );
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+/**
+ * @}
+ */
+
+} // namespace Dali
+#endif // DALI_INTERNAL_WIDGET_H
diff --git a/adaptors/public-api/adaptor-framework/widget.cpp b/adaptors/public-api/adaptor-framework/widget.cpp
new file mode 100644 (file)
index 0000000..2afa42c
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2017 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 "widget.h"
+
+// INTERNAL INCLUDES
+#include <widget-impl.h>
+
+namespace Dali
+{
+
+Widget Widget::New()
+{
+  Internal::Adaptor::WidgetPtr internal = Internal::Adaptor::Widget::New();
+  return Widget(internal.Get());
+}
+
+Widget::~Widget()
+{
+}
+
+Widget::Widget()
+{
+}
+
+Widget::Widget(const Widget& widget)
+: BaseHandle(widget)
+{
+}
+
+Widget& Widget::operator=(const Widget& widget)
+{
+  if( *this != widget )
+  {
+    BaseHandle::operator=( widget );
+  }
+  return *this;
+}
+
+Widget::Widget(Internal::Adaptor::Widget* widget)
+: BaseHandle(widget)
+{
+}
+
+} // namespace Dali
diff --git a/adaptors/public-api/adaptor-framework/widget.h b/adaptors/public-api/adaptor-framework/widget.h
new file mode 100644 (file)
index 0000000..c22245e
--- /dev/null
@@ -0,0 +1,110 @@
+#ifndef DALI_WIDGET_H
+#define DALI_WIDGET_H
+
+/*
+ * Copyright (c) 2017 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 <dali/public-api/object/base-handle.h>
+
+namespace Dali
+{
+
+  /**
+ * @addtogroup dali_adaptor_framework
+ * @{
+ */
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+class Widget;
+}
+
+}
+
+class Window;
+
+/**
+ * @brief Widget class is the base class for custom widget.
+ *
+ * To make own Widget, user should inherit this class and its impl class.
+ *
+ * @SINCE_1_3_5
+ */
+class DALI_IMPORT_API Widget : public BaseHandle
+{
+public:
+
+  /**
+   * @brief Enumeration class for termination type of widget instance.
+   * @SINCE_1_3_5
+   */
+  enum class Termination
+  {
+    PERMANENT, //< User deleted this widget from the viewer @SINCE_1_3_5
+    TEMPORARY, //< Widget is deleted because of other reasons (e.g. widget process is terminated temporarily by the system) @SINCE_1_3_5
+  };
+
+public:
+
+  /**
+   * @brief This is the constructor for Widget.
+   * @SINCE_1_3_5
+   * @return A handle to the Widget
+   */
+  static Widget New();
+
+  /**
+   * @brief The default constructor.
+   * @SINCE_1_3_5
+   */
+  Widget();
+
+  /**
+   * @brief Copy Constructor.
+   * @SINCE_1_3_5
+   * @param[in] widget Handle to an object
+   */
+  Widget( const Widget& widget );
+
+  /**
+   * @brief Assignment operator.
+   * @SINCE_1_3_5
+   * @param[in] widget Handle to an object
+   * @return A reference to this
+   */
+  Widget& operator=( const Widget& widget );
+
+  /**
+   * @brief Destructor
+   * @SINCE_1_3_5
+   */
+  ~Widget();
+
+public: // Not intended for application developers
+  explicit Widget(Internal::Adaptor::Widget* widget);
+};
+
+/**
+ * @}
+ */
+} // namespace Dali
+
+#endif // DALI_WIDGET_H
index 8a37838..0b7f78a 100644 (file)
@@ -28,6 +28,9 @@
 #include <dali/public-api/adaptor-framework/timer.h>
 #include <dali/public-api/adaptor-framework/tts-player.h>
 #include <dali/public-api/adaptor-framework/native-image-source.h>
+#include <dali/public-api/adaptor-framework/widget-application.h>
+#include <dali/public-api/adaptor-framework/widget.h>
+#include <dali/public-api/adaptor-framework/widget-impl.h>
 #include <dali/public-api/dali-adaptor-version.h>
 
 #endif //__DALI_H__
index 4df586a..539cebb 100644 (file)
@@ -5,6 +5,9 @@ public_api_src_files = \
   $(adaptor_public_api_dir)/adaptor-framework/timer.cpp \
   $(adaptor_public_api_dir)/adaptor-framework/tts-player.cpp \
   $(adaptor_public_api_dir)/adaptor-framework/native-image-source.cpp \
+  $(adaptor_public_api_dir)/adaptor-framework/widget.cpp \
+  $(adaptor_public_api_dir)/adaptor-framework/widget-impl.cpp \
+  $(adaptor_public_api_dir)/adaptor-framework/widget-application.cpp \
   $(adaptor_public_api_dir)/dali-adaptor-version.cpp
 
 
@@ -22,7 +25,10 @@ public_api_adaptor_framework_header_files = \
   $(adaptor_public_api_dir)/adaptor-framework/timer.h \
   $(adaptor_public_api_dir)/adaptor-framework/tts-player.h \
   $(adaptor_public_api_dir)/adaptor-framework/native-image-source.h \
-  $(adaptor_public_api_dir)/adaptor-framework/window.h
+  $(adaptor_public_api_dir)/adaptor-framework/window.h \
+  $(adaptor_public_api_dir)/adaptor-framework/widget.h \
+  $(adaptor_public_api_dir)/adaptor-framework/widget-impl.h \
+  $(adaptor_public_api_dir)/adaptor-framework/widget-application.h
 
 adaptor_dali_header_file = \
   $(adaptor_public_api_dir)/dali.h
index 116f439..e8d0224 100644 (file)
@@ -4,7 +4,9 @@ adaptor_tizen_internal_src_files = \
   $(adaptor_tizen_dir)/adaptor-impl-tizen.cpp \
   $(adaptor_tizen_dir)/vsync-monitor-tizen.cpp \
   $(adaptor_tizen_dir)/tilt-sensor-impl-tizen.cpp \
-  $(adaptor_tizen_dir)/tts-player-impl-tizen.cpp
+  $(adaptor_tizen_dir)/tts-player-impl-tizen.cpp \
+  $(adaptor_tizen_dir)/widget-application-impl-tizen-3.cpp \
+  $(adaptor_tizen_dir)/widget-controller-tizen-3.cpp
 
 # common to tizen platforms except not for mobile
 adaptor_tizen_internal_non_mobile_src_files = \
index a031515..1c4687a 100644 (file)
@@ -4,7 +4,9 @@ adaptor_tizen_internal_src_files = \
   $(adaptor_tizen_dir)/adaptor-impl-tizen.cpp \
   $(adaptor_tizen_dir)/vsync-monitor-tizen.cpp \
   $(adaptor_tizen_dir)/tilt-sensor-impl-tizen.cpp \
-  $(adaptor_tizen_dir)/tts-player-impl-tizen.cpp
+  $(adaptor_tizen_dir)/tts-player-impl-tizen.cpp \
+  $(adaptor_tizen_dir)/widget-application-impl-tizen.cpp \
+  $(adaptor_tizen_dir)/widget-controller-tizen.cpp
 
 # common to tizen platforms except not for mobile
 adaptor_tizen_internal_non_mobile_src_files = \
index d0e15bc..9628bdd 100644 (file)
@@ -28,7 +28,7 @@
 #include <system_info.h>
 #include <system_settings.h>
 #include <bundle_internal.h>
-
+#include <widget_base.h>
 // CONDITIONAL INCLUDES
 #ifdef APPCORE_WATCH_AVAILABLE
 #include <appcore-watch/watch_app.h>
@@ -55,13 +55,36 @@ namespace Internal
 namespace Adaptor
 {
 
-#if defined(DEBUG_ENABLED)
 namespace
 {
+#if defined(DEBUG_ENABLED)
 Integration::Log::Filter* gDBusLogging = Integration::Log::Filter::New( Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_DBUS" );
-} // anonymous namespace
 #endif
 
+bool IsWidgetFeatureEnabled()
+{
+  static bool feature = false;
+  static bool retrieved = false;
+  int ret;
+
+  if(retrieved == true)
+  {
+    return feature;
+  }
+
+  ret = system_info_get_platform_bool("http://tizen.org/feature/shell.appwidget", &feature);
+  if(ret != SYSTEM_INFO_ERROR_NONE)
+  {
+    DALI_LOG_ERROR("failed to get system info");
+    return false;
+  }
+
+  retrieved = true;
+  return feature;
+}
+
+} // anonymous namespace
+
 namespace AppCore
 {
 
@@ -196,6 +219,10 @@ struct Framework::Impl
     {
       ret = AppNormalMain();
     }
+    else if(mApplicationType == WIDGET)
+    {
+      ret = AppWidgetMain();
+    }
     else
     {
       ret = AppWatchMain();
@@ -209,6 +236,10 @@ struct Framework::Impl
     {
       AppNormalExit();
     }
+    else if(mApplicationType == WIDGET)
+    {
+      AppWidgetExit();
+    }
     else
     {
       AppWatchExit();
@@ -511,6 +542,57 @@ struct Framework::Impl
     appcore_ui_base_exit();
   }
 
+  void AppWidgetExit()
+  {
+    widget_base_exit();
+  }
+
+  static int WidgetAppCreate( void *data )
+  {
+    widget_base_on_create();
+    return static_cast<int>( static_cast<Framework*>(data)->Create() );
+  }
+
+  static int WidgetAppTerminate( void *data )
+  {
+    Observer *observer = &static_cast<Framework*>(data)->mObserver;
+    observer->OnTerminate();
+
+    widget_base_on_terminate();
+    return 0;
+  }
+
+  int AppWidgetMain()
+  {
+    if( !IsWidgetFeatureEnabled() )
+    {
+      DALI_LOG_ERROR("widget feature is not supported");
+      return 0;
+    }
+
+    AppCore::AppAddEventHandler(&handlers[AppCore::LOW_BATTERY], AppCore::LOW_BATTERY, AppBatteryLow, mFramework);
+    AppCore::AppAddEventHandler(&handlers[AppCore::LOW_MEMORY], AppCore::LOW_MEMORY, AppMemoryLow, mFramework);
+    AppCore::AppAddEventHandler(&handlers[AppCore::DEVICE_ORIENTATION_CHANGED], AppCore::DEVICE_ORIENTATION_CHANGED, AppDeviceRotated, mFramework);
+    AppCore::AppAddEventHandler(&handlers[AppCore::LANGUAGE_CHANGED], AppCore::LANGUAGE_CHANGED, AppLanguageChanged, mFramework);
+    AppCore::AppAddEventHandler(&handlers[AppCore::REGION_FORMAT_CHANGED], AppCore::REGION_FORMAT_CHANGED, AppRegionChanged, mFramework);
+
+    widget_base_ops ops = widget_base_get_default_ops();
+
+    /* override methods */
+    ops.create = WidgetAppCreate;
+    ops.terminate = WidgetAppTerminate;
+    ops.init = AppInit;
+    ops.finish = AppFinish;
+    ops.run = AppRun;
+    ops.exit = AppExit;
+
+    int result = widget_base_init(ops, *mFramework->mArgc, *mFramework->mArgv, mFramework);
+
+    widget_base_fini();
+
+    return result;
+  }
+
 #ifdef APPCORE_WATCH_AVAILABLE
   static bool WatchAppCreate(int width, int height, void *data)
   {
diff --git a/adaptors/tizen/widget-application-impl-tizen-3.cpp b/adaptors/tizen/widget-application-impl-tizen-3.cpp
new file mode 100644 (file)
index 0000000..7248442
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2017 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 "widget-application-impl.h"
+
+// INTERNAL INCLUDE
+#include <widget.h>
+#include <widget-impl.h>
+#include <widget-controller.h>
+#include <dali/integration-api/debug.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+WidgetApplicationPtr WidgetApplication::New(
+  int* argc,
+  char **argv[],
+  const std::string& stylesheet)
+{
+  WidgetApplicationPtr widgetApplication( new WidgetApplication (argc, argv, stylesheet ) );
+  return widgetApplication;
+}
+
+WidgetApplication::WidgetApplication( int* argc, char** argv[], const std::string& stylesheet )
+:Application(argc, argv, stylesheet, Dali::WidgetApplication::OPAQUE, PositionSize(), Framework::WIDGET)
+{
+  DALI_LOG_ERROR("WidgetApplication is not implemented in 3.0 tizen profile.\n");
+}
+
+WidgetApplication::~WidgetApplication()
+{
+}
+
+
+void WidgetApplication::RegisterWidgetCreatingFunction( const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction )
+{
+}
+
+void WidgetApplication::AddWidgetCreatingFunctionPair( CreateWidgetFunctionPair pair )
+{
+  mCreateWidgetFunctionContainer.push_back( pair );
+}
+
+WidgetApplication::CreateWidgetFunctionPair WidgetApplication::GetWidgetCreatingFunctionPair( const std::string& widgetName )
+{
+  for( CreateWidgetFunctionContainer::const_iterator iter = mCreateWidgetFunctionContainer.begin(); iter != mCreateWidgetFunctionContainer.end(); ++iter )
+  {
+    if( widgetName.find((*iter).first) != std::string::npos  )
+    {
+      return *iter;
+    }
+  }
+
+  return CreateWidgetFunctionPair( "", NULL );
+}
+
+void WidgetApplication::AddWidget( widget_base_instance_h widgetBaseInstance, Dali::Widget widget )
+{
+  mWidgetInstanceContainer.push_back( WidgetInstancePair(widgetBaseInstance, widget) );
+}
+
+Dali::Widget WidgetApplication::GetWidget( widget_base_instance_h widgetBaseInstance )
+{
+  for( WidgetInstanceContainer::const_iterator iter = mWidgetInstanceContainer.begin(); iter != mWidgetInstanceContainer.end(); ++iter )
+  {
+    if( (*iter).first == widgetBaseInstance  )
+    {
+      return (*iter).second;
+    }
+  }
+  return Dali::Widget();
+}
+
+void WidgetApplication::DeleteWidget( widget_base_instance_h widgetBaseInstance )
+{
+  for( WidgetInstanceContainer::const_iterator iter = mWidgetInstanceContainer.begin(); iter != mWidgetInstanceContainer.end(); ++iter )
+  {
+    if( (*iter).first == widgetBaseInstance  )
+    {
+      mWidgetInstanceContainer.erase(iter);
+      break;
+    }
+  }
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
diff --git a/adaptors/tizen/widget-application-impl-tizen.cpp b/adaptors/tizen/widget-application-impl-tizen.cpp
new file mode 100644 (file)
index 0000000..db403e3
--- /dev/null
@@ -0,0 +1,274 @@
+/*
+ * Copyright (c) 2017 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 "widget-application-impl.h"
+
+// INTERNAL INCLUDE
+#include <widget.h>
+#include <widget-impl.h>
+#include <widget-controller.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace
+{
+
+int OnInstanceInit(widget_base_instance_h instanceHandle, bundle *content, int w, int h, void *classData)
+{
+  char *id;
+  widget_base_context_get_id(instanceHandle, &id);
+
+  widget_base_class_on_create(instanceHandle, content, w, h);
+
+  Dali::Internal::Adaptor::WidgetApplication* application = static_cast<Dali::Internal::Adaptor::WidgetApplication*>(classData);
+
+  // After DALi can support multi window, this part should be changed.
+  Dali::Window window = application->GetWindow();
+  window.ShowIndicator(Dali::Window::INVISIBLE);
+  Any nativeHandle = window.GetNativeHandle();
+  Ecore_Wl_Window * wlWindow = AnyCast<Ecore_Wl_Window*>( nativeHandle );
+  widget_base_context_window_bind( instanceHandle, id, wlWindow );
+  window.SetSize( Dali::Window::WindowSize( w, h ) );
+
+  Dali::Internal::Adaptor::WidgetApplication::CreateWidgetFunctionPair pair = application->GetWidgetCreatingFunctionPair(std::string(id));
+  Dali::WidgetApplication::CreateWidgetFunction createFunction = pair.second;
+
+  Dali::Widget widgetInstance = createFunction( pair.first );
+  application->AddWidget( instanceHandle, widgetInstance );
+
+  Dali::Internal::Adaptor::Widget::Impl *widgetImpl = new Dali::Internal::Adaptor::Widget::Impl(instanceHandle);
+  Internal::Adaptor::GetImplementation(widgetInstance).SetImpl( widgetImpl );
+
+  std::string encodedContentString = "";
+
+  if( bundle_get_count( content ) )
+  {
+    bundle_raw *bundleRaw;
+    int len;
+    bundle_encode(content, &bundleRaw, &len);
+    char* encodedContent = reinterpret_cast< char* >( bundleRaw );
+    encodedContentString = std::string( encodedContent );
+    free(bundleRaw);
+  }
+
+  Internal::Adaptor::GetImplementation(widgetInstance).OnCreate( encodedContentString, window );
+
+  return 0;
+}
+
+int OnInstanceDestroy(widget_base_instance_h instanceHandle, widget_base_destroy_type_e reason, bundle *content, void *classData)
+{
+  Dali::Internal::Adaptor::WidgetApplication* application = static_cast<Dali::Internal::Adaptor::WidgetApplication*>(classData);
+
+  // Get Dali::Widget instance.
+  Dali::Widget widgetInstance = application->GetWidget( instanceHandle );
+
+  Dali::Widget::Termination destroyReason = Dali::Widget::Termination::TEMPORARY;
+
+  if(reason == WIDGET_BASE_DESTROY_TYPE_PERMANENT)
+  {
+    destroyReason = Dali::Widget::Termination::PERMANENT;
+  }
+
+  std::string encodedContentString = "";
+
+  if( bundle_get_count( content ) )
+  {
+    bundle_raw *bundleRaw;
+    int len;
+    bundle_encode(content, &bundleRaw, &len);
+    char* encodedContent = reinterpret_cast< char* >( bundleRaw );
+    encodedContentString = std::string(encodedContent);
+    free(bundleRaw);
+  }
+
+  Internal::Adaptor::GetImplementation(widgetInstance).OnTerminate( encodedContentString, destroyReason );
+
+  widget_base_class_on_destroy(instanceHandle, reason, content);
+
+  application->DeleteWidget( instanceHandle );
+
+  return 0;
+}
+
+int OnInstancePause(widget_base_instance_h instanceHandle, void *classData)
+{
+  widget_base_class_on_pause(instanceHandle);
+
+  Dali::Internal::Adaptor::WidgetApplication* application = static_cast<Dali::Internal::Adaptor::WidgetApplication*>(classData);
+
+  // Get Dali::Widget instance.
+  Dali::Widget widgetInstance = application->GetWidget( instanceHandle );
+
+  Internal::Adaptor::GetImplementation(widgetInstance).OnPause();
+
+  return 0;
+}
+
+int OnInstanceResume(widget_base_instance_h instanceHandle, void *classData)
+{
+  widget_base_class_on_resume(instanceHandle);
+
+  Dali::Internal::Adaptor::WidgetApplication* application = static_cast<Dali::Internal::Adaptor::WidgetApplication*>(classData);
+
+  // Get Dali::Widget instance.
+  Dali::Widget widgetInstance = application->GetWidget( instanceHandle );
+
+  Internal::Adaptor::GetImplementation(widgetInstance).OnResume();
+
+  return 0;
+}
+
+int OnInstanceResize(widget_base_instance_h instanceHandle, int w, int h, void *classData)
+{
+  widget_base_class_on_resize(instanceHandle, w, h);
+
+  Dali::Internal::Adaptor::WidgetApplication* application = static_cast<Dali::Internal::Adaptor::WidgetApplication*>(classData);
+
+  // Get Dali::Widget instance.
+  Dali::Widget widgetInstance = application->GetWidget( instanceHandle );
+
+  Dali::Window window = application->GetWindow();
+  window.SetSize( Dali::Window::WindowSize(w, h) );
+  Internal::Adaptor::GetImplementation(widgetInstance).OnResize(window);
+
+  return 0;
+}
+
+int OnInstanceUpdate(widget_base_instance_h instanceHandle, bundle *content, int force, void *classData)
+{
+  widget_base_class_on_update(instanceHandle, content, force);
+
+  Dali::Internal::Adaptor::WidgetApplication* application = static_cast<Dali::Internal::Adaptor::WidgetApplication*>(classData);
+
+  // Get Dali::Widget instance.
+  Dali::Widget widgetInstance = application->GetWidget( instanceHandle );
+
+  std::string encodedContentString = "";
+
+  if( bundle_get_count( content ) )
+  {
+    bundle_raw *bundleRaw;
+    int len;
+    bundle_encode(content, &bundleRaw, &len);
+    char* encodedContent = reinterpret_cast< char* >( bundleRaw );
+    encodedContentString = std::string(encodedContent);
+    free(bundleRaw);
+  }
+
+  Internal::Adaptor::GetImplementation(widgetInstance).OnUpdate( encodedContentString, force );
+
+  return 0;
+}
+
+} // anonymous namespace
+
+namespace Adaptor
+{
+
+WidgetApplicationPtr WidgetApplication::New(
+  int* argc,
+  char **argv[],
+  const std::string& stylesheet)
+{
+  WidgetApplicationPtr widgetApplication( new WidgetApplication (argc, argv, stylesheet ) );
+  return widgetApplication;
+}
+
+WidgetApplication::WidgetApplication( int* argc, char** argv[], const std::string& stylesheet )
+:Application(argc, argv, stylesheet, Dali::WidgetApplication::OPAQUE, PositionSize(), Framework::WIDGET)
+{
+}
+
+WidgetApplication::~WidgetApplication()
+{
+}
+
+
+void WidgetApplication::RegisterWidgetCreatingFunction( const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction )
+{
+  AddWidgetCreatingFunctionPair( CreateWidgetFunctionPair(widgetName, createFunction) );
+
+  // Register widget class to widget framework
+  widget_base_class cls = widget_base_class_get_default();
+  cls.ops.create = OnInstanceInit;
+  cls.ops.destroy = OnInstanceDestroy;
+  cls.ops.pause = OnInstancePause;
+  cls.ops.resume = OnInstanceResume;
+  cls.ops.resize = OnInstanceResize;
+  cls.ops.update = OnInstanceUpdate;
+
+  widget_base_class_add(cls, widgetName.c_str(), this);
+}
+
+void WidgetApplication::AddWidgetCreatingFunctionPair( CreateWidgetFunctionPair pair )
+{
+  mCreateWidgetFunctionContainer.push_back( pair );
+}
+
+WidgetApplication::CreateWidgetFunctionPair WidgetApplication::GetWidgetCreatingFunctionPair( const std::string& widgetName )
+{
+  for( CreateWidgetFunctionContainer::const_iterator iter = mCreateWidgetFunctionContainer.begin(); iter != mCreateWidgetFunctionContainer.end(); ++iter )
+  {
+    if( widgetName.find((*iter).first) != std::string::npos  )
+    {
+      return *iter;
+    }
+  }
+
+  return CreateWidgetFunctionPair( "", NULL );
+}
+
+void WidgetApplication::AddWidget( widget_base_instance_h widgetBaseInstance, Dali::Widget widget )
+{
+  mWidgetInstanceContainer.push_back( WidgetInstancePair(widgetBaseInstance, widget) );
+}
+
+Dali::Widget WidgetApplication::GetWidget( widget_base_instance_h widgetBaseInstance )
+{
+  for( WidgetInstanceContainer::const_iterator iter = mWidgetInstanceContainer.begin(); iter != mWidgetInstanceContainer.end(); ++iter )
+  {
+    if( (*iter).first == widgetBaseInstance  )
+    {
+      return (*iter).second;
+    }
+  }
+  return Dali::Widget();
+}
+
+void WidgetApplication::DeleteWidget( widget_base_instance_h widgetBaseInstance )
+{
+  for( WidgetInstanceContainer::const_iterator iter = mWidgetInstanceContainer.begin(); iter != mWidgetInstanceContainer.end(); ++iter )
+  {
+    if( (*iter).first == widgetBaseInstance  )
+    {
+      mWidgetInstanceContainer.erase(iter);
+      break;
+    }
+  }
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
diff --git a/adaptors/tizen/widget-application-impl.h b/adaptors/tizen/widget-application-impl.h
new file mode 100644 (file)
index 0000000..d6d1043
--- /dev/null
@@ -0,0 +1,149 @@
+#ifndef DALI_INTERNAL_WIDGET_APPLICATION_H
+#define DALI_INTERNAL_WIDGET_APPLICATION_H
+
+/*
+ * Copyright (c) 2017 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
+#ifdef WIDGET_SUPPOERTED
+#include <widget_base.h>
+#endif
+
+// INTERNAL INCLUDES
+#include <application-impl.h>
+#include <widget-application.h>
+
+namespace Dali
+{
+class Widget;
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class WidgetApplication;
+typedef IntrusivePtr<WidgetApplication> WidgetApplicationPtr;
+
+/**
+ * Implementation of the WidgetApplication class.
+ */
+class WidgetApplication : public Application
+{
+public:
+
+#ifndef WIDGET_SUPPOERTED
+  typedef void* widget_base_instance_h;
+#endif
+  typedef std::pair<const std::string, Dali::WidgetApplication::CreateWidgetFunction >  CreateWidgetFunctionPair;
+  typedef std::vector< CreateWidgetFunctionPair >   CreateWidgetFunctionContainer;
+
+  /**
+   * Create a new widget application
+   * @param[in]  argc         A pointer to the number of arguments
+   * @param[in]  argv         A pointer to the argument list
+   * @param[in]  stylesheet   The path to user defined theme file
+   */
+  static WidgetApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet );
+
+public:
+
+  /**
+   * @copydoc Dali::WidgetApplication::RegisterWidgetCreator()
+   */
+  void RegisterWidgetCreatingFunction( const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction );
+
+  /**
+   * Add widget name - CreateWidgetFunction pair to container.
+   */
+  void AddWidgetCreatingFunctionPair( CreateWidgetFunctionPair pair );
+
+  /**
+   * Find and get CreateWidgetFunctionPair in container by widget name.
+   */
+  CreateWidgetFunctionPair GetWidgetCreatingFunctionPair( const std::string& widgetName );
+
+  /**
+   * Add widget_base_instance_h - Widget instance pair to container.
+   */
+  void AddWidget( widget_base_instance_h widgetBaseInstance, Dali::Widget widget );
+
+  /**
+   * Find and get Widget instance in container by widget_base_instance_h.
+   */
+  Dali::Widget GetWidget( widget_base_instance_h widgetBaseInstance );
+
+  /**
+   * Delete widget_base_instance_h - Widget instance pair in container.
+   */
+  void DeleteWidget( widget_base_instance_h widgetBaseInstance );
+
+protected:
+
+  /**
+   * Private Constructor
+   * @param[in]  argc         A pointer to the number of arguments
+   * @param[in]  argv         A pointer to the argument list
+   * @param[in]  stylesheet   The path to user defined theme file
+   */
+  WidgetApplication( int* argc, char **argv[], const std::string& stylesheet );
+
+  /**
+   * Destructor
+   */
+  virtual ~WidgetApplication();
+
+  // Undefined
+  WidgetApplication(const Application&);
+  WidgetApplication& operator=(Application&);
+
+private:
+
+  typedef std::pair< widget_base_instance_h, Dali::Widget > WidgetInstancePair;
+  typedef std::vector< WidgetInstancePair >                 WidgetInstanceContainer;
+
+  CreateWidgetFunctionContainer  mCreateWidgetFunctionContainer;
+  WidgetInstanceContainer        mWidgetInstanceContainer;
+
+};
+
+inline WidgetApplication& GetImplementation(Dali::WidgetApplication& widgetApplication)
+{
+  DALI_ASSERT_ALWAYS(widgetApplication && "widget application handle is empty");
+
+  BaseObject& handle = widgetApplication.GetBaseObject();
+
+  return static_cast<Internal::Adaptor::WidgetApplication&>(handle);
+}
+
+inline const WidgetApplication& GetImplementation(const Dali::WidgetApplication& widgetApplication)
+{
+  DALI_ASSERT_ALWAYS(widgetApplication && "widget application handle is empty");
+
+  const BaseObject& handle = widgetApplication.GetBaseObject();
+
+  return static_cast<const Internal::Adaptor::WidgetApplication&>(handle);
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_WIDGET_APPLICATION_H
diff --git a/adaptors/tizen/widget-controller-tizen-3.cpp b/adaptors/tizen/widget-controller-tizen-3.cpp
new file mode 100644 (file)
index 0000000..aa87134
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2017 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 "widget-controller.h"
+
+// EXTERNAL INCLUDES
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+Widget::Impl::Impl( widget_base_instance_h instanceHandle )
+: mInstanceHandle( instanceHandle )
+{
+}
+
+Widget::Impl::~Impl()
+{
+}
+
+void Widget::Impl::SetContentInfo( const std::string& contentInfo )
+{
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
diff --git a/adaptors/tizen/widget-controller-tizen.cpp b/adaptors/tizen/widget-controller-tizen.cpp
new file mode 100644 (file)
index 0000000..dce7f64
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2017 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 "widget-controller.h"
+
+// EXTERNAL INCLUDES
+#include <bundle.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+Widget::Impl::Impl( widget_base_instance_h instanceHandle )
+: mInstanceHandle( instanceHandle )
+{
+}
+
+Widget::Impl::~Impl()
+{
+}
+
+void Widget::Impl::SetContentInfo( const std::string& contentInfo )
+{
+  bundle *contentBundle;
+  bundle_raw *contentBundleRaw = reinterpret_cast< bundle_raw* >( const_cast<char*>(contentInfo.c_str()) );
+  int len = contentInfo.length();
+  contentBundle = bundle_decode(contentBundleRaw, len);
+
+  widget_base_context_set_content_info( mInstanceHandle, contentBundle );
+
+  bundle_free( contentBundle );
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
diff --git a/adaptors/tizen/widget-controller.h b/adaptors/tizen/widget-controller.h
new file mode 100644 (file)
index 0000000..a1c0949
--- /dev/null
@@ -0,0 +1,78 @@
+#ifndef DALI_WIDGET_CONTROLLER_H
+#define DALI_WIDGET_CONTROLLER_H
+
+/*
+ * Copyright (c) 2017 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 <dali/public-api/signals/connection-tracker.h>
+
+// INTERNAL INCLUDES
+#ifdef WIDGET_SUPPOERTED
+#include <widget_base.h>
+#endif
+#include <widget-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * @brief Holds the Implementation for the internal WidgetImpl class
+ */
+class Widget::Impl : public ConnectionTracker
+{
+public:
+
+#ifndef WIDGET_SUPPOERTED
+  typedef void* widget_base_instance_h;
+#endif
+
+  /**
+   * Constructor
+   */
+  Impl( widget_base_instance_h instanceHandle );
+
+  /**
+   * Destructor
+   */
+  ~Impl();
+
+public:
+
+  /**
+   * Set content information to widget framework
+   */
+  void SetContentInfo( const std::string& contentInfo );
+
+private:
+
+  widget_base_instance_h mInstanceHandle;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_WIDGET_CONTROLLER_H
index feee7e9..0f06341 100644 (file)
@@ -7,4 +7,6 @@ adaptor_ubuntu_internal_src_files = \
   $(adaptor_ubuntu_dir)/vsync-monitor-ubuntu.cpp \
   $(adaptor_ubuntu_dir)/tilt-sensor-impl-ubuntu.cpp \
   $(adaptor_ubuntu_dir)/tts-player-impl-ubuntu.cpp \
-  $(adaptor_ubuntu_dir)/key-mapping-ubuntu.cpp
+  $(adaptor_ubuntu_dir)/key-mapping-ubuntu.cpp \
+  $(adaptor_ubuntu_dir)/widget-application-impl-ubuntu.cpp \
+  $(adaptor_ubuntu_dir)/widget-controller-ubuntu.cpp
diff --git a/adaptors/ubuntu/widget-application-impl-ubuntu.cpp b/adaptors/ubuntu/widget-application-impl-ubuntu.cpp
new file mode 100644 (file)
index 0000000..321a6e7
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2017 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 "widget-application-impl.h"
+#include <dali/integration-api/debug.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+WidgetApplicationPtr WidgetApplication::New(
+  int* argc,
+  char **argv[],
+  const std::string& stylesheet)
+{
+  WidgetApplicationPtr widgetApplication( new WidgetApplication (argc, argv, stylesheet ) );
+  return widgetApplication;
+}
+
+WidgetApplication::WidgetApplication( int* argc, char** argv[], const std::string& stylesheet )
+:Application(argc, argv, stylesheet, Dali::WidgetApplication::OPAQUE, PositionSize(), Framework::NORMAL)
+{
+  DALI_LOG_ERROR("WidgetApplication is not implemented in UBUNTU profile.\n");
+}
+
+WidgetApplication::~WidgetApplication()
+{
+}
+
+
+void WidgetApplication::RegisterWidgetCreatingFunction( const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction )
+{
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
diff --git a/adaptors/ubuntu/widget-application-impl.h b/adaptors/ubuntu/widget-application-impl.h
new file mode 100644 (file)
index 0000000..a15ef4b
--- /dev/null
@@ -0,0 +1,109 @@
+#ifndef DALI_INTERNAL_WIDGET_APPLICATION_H
+#define DALI_INTERNAL_WIDGET_APPLICATION_H
+
+/*
+ * Copyright (c) 2017 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 <application-impl.h>
+#include <widget-application.h>
+
+namespace Dali
+{
+class Widget;
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class WidgetApplication;
+typedef IntrusivePtr<WidgetApplication> WidgetApplicationPtr;
+
+/**
+ * Implementation of the WidgetApplication class.
+ */
+class WidgetApplication : public Application
+{
+public:
+
+  typedef std::pair<const std::string, Dali::WidgetApplication::CreateWidgetFunction >  CreateWidgetFunctionPair;
+  typedef std::vector< CreateWidgetFunctionPair >   CreateWidgetFunctionContainer;
+
+  /**
+   * Create a new widget application
+   * @param[in]  argc         A pointer to the number of arguments
+   * @param[in]  argv         A pointer to the argument list
+   * @param[in]  stylesheet   The path to user defined theme file
+   */
+  static WidgetApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet );
+
+public:
+
+  /**
+   * @copydoc Dali::WidgetApplication::RegisterWidgetCreator()
+   */
+  void RegisterWidgetCreatingFunction( const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction );
+
+protected:
+
+  /**
+   * Private Constructor
+   * @param[in]  argc         A pointer to the number of arguments
+   * @param[in]  argv         A pointer to the argument list
+   * @param[in]  stylesheet   The path to user defined theme file
+   */
+  WidgetApplication( int* argc, char **argv[], const std::string& stylesheet );
+
+  /**
+   * Destructor
+   */
+  virtual ~WidgetApplication();
+
+  // Undefined
+  WidgetApplication(const Application&);
+  WidgetApplication& operator=(Application&);
+
+
+};
+
+inline WidgetApplication& GetImplementation(Dali::WidgetApplication& widgetApplication)
+{
+  DALI_ASSERT_ALWAYS(widgetApplication && "widget application handle is empty");
+
+  BaseObject& handle = widgetApplication.GetBaseObject();
+
+  return static_cast<Internal::Adaptor::WidgetApplication&>(handle);
+}
+
+inline const WidgetApplication& GetImplementation(const Dali::WidgetApplication& widgetApplication)
+{
+  DALI_ASSERT_ALWAYS(widgetApplication && "widget application handle is empty");
+
+  const BaseObject& handle = widgetApplication.GetBaseObject();
+
+  return static_cast<const Internal::Adaptor::WidgetApplication&>(handle);
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_WIDGET_APPLICATION_H
diff --git a/adaptors/ubuntu/widget-controller-ubuntu.cpp b/adaptors/ubuntu/widget-controller-ubuntu.cpp
new file mode 100644 (file)
index 0000000..ac247df
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017 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 "widget-controller.h"
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+Widget::Impl::Impl()
+{
+}
+
+Widget::Impl::~Impl()
+{
+}
+
+void Widget::Impl::SetContentInfo( const std::string& contentInfo )
+{
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
diff --git a/adaptors/ubuntu/widget-controller.h b/adaptors/ubuntu/widget-controller.h
new file mode 100644 (file)
index 0000000..e537530
--- /dev/null
@@ -0,0 +1,67 @@
+#ifndef DALI_WIDGET_CONTROLLER_H
+#define DALI_WIDGET_CONTROLLER_H
+
+/*
+ * Copyright (c) 2017 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 <dali/public-api/signals/connection-tracker.h>
+
+// INTERNAL INCLUDES
+#include <widget-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * @brief Holds the Implementation for the internal WidgetImpl class
+ */
+class Widget::Impl : public ConnectionTracker
+{
+public:
+
+  /**
+   * Constructor
+   */
+  Impl();
+
+  /**
+   * Destructor
+   */
+  ~Impl();
+
+public:
+
+  /**
+   * Set content information to widget framework
+   */
+  void SetContentInfo( const std::string& contentInfo );
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_WIDGET_CONTROLLER_H
index de15107..4043ee9 100644 (file)
@@ -445,13 +445,18 @@ LIBDALI_ADAPTOR_LA_CXXFLAGS += $(ELEMENTARY_CFLAGS)
 LIBDALI_ADAPTOR_LA_LIBADD += $(ELEMENTARY_LIBS)
 
 else
-LIBDALI_ADAPTOR_LA_CXXFLAGS += $(CAPI_APPFW_COMMON_CFLAGS) \
+LIBDALI_ADAPTOR_LA_CXXFLAGS += $(BUNDLE_CFLAGS) \
+                               $(CAPI_APPFW_COMMON_CFLAGS) \
                                $(CAPI_APPFW_CONTROL_CFLAGS) \
+                               $(CAPI_APPFW_WIDGET_BASE_CFLAGS) \
                                $(ECORE_IMF_CFLAGS) \
-                               $(FRIBIDI_CFLAGS)
+                               $(FRIBIDI_CFLAGS) \
+                               -DWIDGET_SUPPOERTED
 
-LIBDALI_ADAPTOR_LA_LIBADD += $(CAPI_APPFW_COMMON_LIBS) \
+LIBDALI_ADAPTOR_LA_LIBADD += $(BUNDLE_LIBS) \
+                             $(CAPI_APPFW_COMMON_LIBS) \
                              $(CAPI_APPFW_CONTROL_LIBS) \
+                             $(CAPI_APPFW_WIDGET_BASE_LIBS) \
                              $(ECORE_IMF_LIBS) \
                              $(FRIBIDI_LIBS)
 endif
@@ -570,13 +575,6 @@ tizenwatchpublicapi_HEADERS = $(public_dali_watch_header_files)
 tizencapturepublicapidir = $(tizenadaptorpublicapidir)/capture
 tizencapturepublicapi_HEADERS = $(public_dali_capture_header_files)
 
-if USE_APPFW
-if USE_APPFW_EFL_BASE
-else
-tizenadaptorframeworkdevelapi_HEADERS += $(adaptor_widget_header_files)
-endif
-endif
-
 install-data-local:
        $(MKDIR_P) ${DESTDIR}/${daliUserFontCacheDir} ${DESTDIR}/${daliShaderbinCacheDir}
 
index 2bd1a7c..4a7f614 100644 (file)
@@ -277,7 +277,10 @@ if test "x$enable_tizen_major_version" = "x3"; then
 PKG_CHECK_MODULES(CAPI_APPFW_APPLICATION, capi-appfw-application)
 PKG_CHECK_MODULES(ELEMENTARY, elementary)
 else
+DALI_ADAPTOR_CFLAGS="$DALI_ADAPTOR_CFLAGS -DWIDGET_AVAILABLE"
+PKG_CHECK_MODULES(BUNDLE, bundle)
 PKG_CHECK_MODULES(CAPI_APPFW_APPLICATION, appcore-ui)
+PKG_CHECK_MODULES(CAPI_APPFW_WIDGET_BASE, appcore-widget-base)
 PKG_CHECK_MODULES(CAPI_APPFW_COMMON, capi-appfw-app-common)
 PKG_CHECK_MODULES(CAPI_APPFW_CONTROL, capi-appfw-app-control)
 fi
index d939921..0c20e82 100644 (file)
@@ -121,6 +121,8 @@ BuildRequires:  pkgconfig(capi-appfw-application)
 BuildRequires:  pkgconfig(elementary)
 %else
 BuildRequires:  pkgconfig(appcore-ui)
+BuildRequires:  pkgconfig(appcore-widget-base)
+BuildRequires:  pkgconfig(bundle)
 BuildRequires:  pkgconfig(capi-appfw-app-common)
 BuildRequires:  pkgconfig(capi-appfw-app-control)
 BuildRequires:  pkgconfig(ecore-imf)