[4.0] Create Widget Application 64/155664/3 accepted/tizen/4.0/unified/20171017.212913 submit/tizen_4.0/20171017.144330 submit/tizen_4.0/20171017.145254 tizen_4.0.m2_release
authorminho.sun <minho.sun@samsung.com>
Fri, 29 Sep 2017 01:16:04 +0000 (10:16 +0900)
committerminho.sun <minho.sun@samsung.com>
Tue, 17 Oct 2017 06:31:53 +0000 (15:31 +0900)
Create Widget Application using appcore-widget-base.

WidgetApplication - Application class to support Widget app

Widget            - Manage widget instance lifecycle.
                    It defines how widget works according to lifecycle

WigetApplication can have many types of Widget. And one Widget can have
instance more than one.

But now, User should define just one widget for widget application because
Dali can support only one window per application.

Change-Id: Idee6eb095352d103cfc942a4eb0a9502bf09bc4b

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

index 47512c7..1f8d21a 100644 (file)
@@ -93,6 +93,8 @@ Dali::Adaptor* Adaptor::New( Dali::Window window, Dali::Configuration::ContextLo
 
   Window& windowImpl = Dali::GetImplementation(window);
   Dali::Adaptor* adaptor = New( winId, windowImpl.GetSurface(), configuration, environmentOptions );
+
+  Internal::Adaptor::Adaptor::GetImplementation( *adaptor ).SetWindow( window );
   windowImpl.SetAdaptor(*adaptor);
   return adaptor;
 }
@@ -809,6 +811,7 @@ Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surfac
   mTriggerEventFactory(),
   mObjectProfiler( NULL ),
   mSocketFactory(),
+  mWindow(),
   mEnvironmentOptionsOwned( environmentOptions ? false : true /* If not provided then we own the object */ ),
   mUseRemoteSurface( false )
 {
@@ -847,6 +850,16 @@ void Adaptor::SetRootLayoutDirection( std::string locale )
                                     static_cast< LayoutDirection::Type >( Internal::Adaptor::Locale::GetDirection( std::string( locale ) ) ) );
 }
 
+void Adaptor::SetWindow( Dali::Window window )
+{
+  mWindow = window;
+}
+
+Dali::Window Adaptor::GetWindow()
+{
+  return mWindow;
+}
+
 } // namespace Adaptor
 
 } // namespace Internal
index f42b85f..064eef0 100644 (file)
@@ -27,6 +27,7 @@
 #include <dali/integration-api/render-controller.h>
 
 // INTERNAL INCLUDES
+#include <window.h>
 #include <adaptor.h>
 #include <render-surface.h>
 #include <tts-player.h>
@@ -438,6 +439,16 @@ public: // Stereoscopy
    */
   float GetStereoBase() const;
 
+  /**
+   * Set Window handle.
+   */
+  void SetWindow( Dali::Window window );
+
+  /**
+   * Return Window handle.
+   */
+  Dali::Window GetWindow();
+
 public: // Signals
 
   /**
@@ -597,6 +608,7 @@ private: // Data
   TriggerEventFactory                   mTriggerEventFactory;         ///< Trigger event factory
   ObjectProfiler*                       mObjectProfiler;              ///< Tracks object lifetime for profiling
   SocketFactory                         mSocketFactory;               ///< Socket factory
+  Dali::Window                          mWindow;                      ///< Window handle
   const bool                            mEnvironmentOptionsOwned:1;   ///< Whether we own the EnvironmentOptions (and thus, need to delete it)
   bool                                  mUseRemoteSurface;            ///< whether the remoteSurface is used or not
 public:
index 78c33ab..c8785f9 100644 (file)
@@ -114,6 +114,11 @@ Any Adaptor::GetNativeWindowHandle()
   return mImpl->GetNativeWindowHandle();
 }
 
+Window Adaptor::GetWindow()
+{
+  return mImpl->GetWindow();
+}
+
 void Adaptor::ReleaseSurfaceLock()
 {
   mImpl->ReleaseSurfaceLock();
index 37faef3..944b7db 100644 (file)
@@ -59,3 +59,7 @@ adaptor_common_internal_default_profile_src_files = \
 
 adaptor_common_internal_egl_extension_src_files = \
   $(adaptor_common_dir)/gl/egl-image-extensions.cpp
+
+adaptor_internal_widget_src_files = \
+  $(adaptor_common_dir)/widget-impl.cpp \
+  $(adaptor_common_dir)/widget-application-impl.cpp
index 6b5965a..a8b01f2 100644 (file)
@@ -52,8 +52,9 @@ public:
 
   enum Type
   {
-    NORMAL,       ///<  normal appFramework
-    WATCH     ///< watch appFramework
+    NORMAL,       ///< normal appFramework
+    WATCH,        ///< watch appFramework
+    WIDGET,       ///< widget appFramework
   };
 
   /**
diff --git a/adaptors/common/widget-application-impl.cpp b/adaptors/common/widget-application-impl.cpp
new file mode 100644 (file)
index 0000000..86fa034
--- /dev/null
@@ -0,0 +1,244 @@
+/*
+ * 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"
+
+// EXTERNAL INCLUDES
+#include <widget_base.h>
+
+// INTERNAL INCLUDES
+#include <style-monitor.h>
+#include <command-line-options.h>
+#include <common/adaptor-impl.h>
+#include <common/framework.h>
+#include <singleton-service-impl.h>
+#include <window-impl.h>
+
+namespace Dali
+{
+
+namespace TizenPlatform
+{
+class TizenPlatformAbstraction;
+}
+
+namespace Integration
+{
+class Core;
+}
+
+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 )
+: mInitSignal(),
+  mTerminateSignal(),
+  mLanguageChangedSignal(),
+  mRegionChangedSignal(),
+  mLowBatterySignal(),
+  mLowMemorySignal(),
+  mFramework( NULL ),
+  mContextLossConfiguration( Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS ),
+  mCommandLineOptions( NULL ),
+  mSingletonService( SingletonService::New() ),
+  mAdaptor( NULL ),
+  mName(),
+  mStylesheet( stylesheet ),
+  mEnvironmentOptions(),
+  mSlotDelegate( this )
+{
+  // Get mName from environment options
+  mName = mEnvironmentOptions.GetWindowName();
+  if( mName.empty() && argc && ( *argc > 0 ) )
+  {
+    // Set mName from command-line args if environment option not set
+    mName = (*argv)[0];
+  }
+
+  mCommandLineOptions = new CommandLineOptions(argc, argv);
+  mFramework = new Framework( *this, argc, argv, Framework::WIDGET );
+}
+
+WidgetApplication::~WidgetApplication()
+{
+  mSingletonService.UnregisterAll();
+
+  delete mAdaptor;
+  delete mCommandLineOptions;
+  delete mFramework;
+}
+
+void WidgetApplication::CreateAdaptor()
+{
+  mAdaptor = Dali::Internal::Adaptor::Adaptor::New( mWindow, mContextLossConfiguration, &mEnvironmentOptions );
+
+  Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetUseRemoteSurface( true );
+}
+
+void WidgetApplication::MainLoop()
+{
+  // Run the application
+  mFramework->Run();
+}
+
+void WidgetApplication::Quit()
+{
+  // Actually quit the application.
+  AddIdle( MakeCallback( this, &WidgetApplication::QuitFromMainLoop ) );
+}
+
+void WidgetApplication::QuitFromMainLoop()
+{
+  mAdaptor->Stop();
+
+  mFramework->Quit();
+  // This will trigger OnTerminate(), below, after the main loop has completed.
+}
+
+void WidgetApplication::DoInit()
+{
+  mWindow = Dali::Window::New( PositionSize(), "", mEnvironmentOptions.GetWindowClassName(), 1 );
+  // Quit the application when the window is closed
+  mWindow.ShowIndicator(Dali::Window::IndicatorVisibleMode::INVISIBLE);
+  GetImplementation( mWindow ).DeleteRequestSignal().Connect( mSlotDelegate, &WidgetApplication::Quit );
+
+  CreateAdaptor();
+  // Run the adaptor
+  mAdaptor->Start();
+
+  // Check if user requires no vsyncing and set Adaptor
+  if (mCommandLineOptions->noVSyncOnRender)
+  {
+    mAdaptor->SetUseHardwareVSync(false);
+  }
+
+  Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetStereoBase( mCommandLineOptions->stereoBase );
+
+  if( ! mStylesheet.empty() )
+  {
+    Dali::StyleMonitor::Get().SetTheme( mStylesheet );
+  }
+}
+
+void WidgetApplication::DoStart()
+{
+  mAdaptor->NotifySceneCreated();
+}
+
+void WidgetApplication::DoTerminate()
+{
+  if( mAdaptor )
+  {
+    // Ensure that the render-thread is not using the surface(window) after we delete it
+    mAdaptor->Stop();
+  }
+
+  mWindow.Reset();
+}
+
+void WidgetApplication::DoLanguageChange()
+{
+  mAdaptor->NotifyLanguageChanged();
+}
+
+void WidgetApplication::OnInit()
+{
+  mFramework->AddAbortCallback( MakeCallback( this, &WidgetApplication::QuitFromMainLoop ) );
+  DoInit();
+
+  Dali::WidgetApplication widgetApplication(this);
+  mInitSignal.Emit( widgetApplication );
+
+  DoStart();
+}
+
+void WidgetApplication::OnTerminate()
+{
+  Dali::WidgetApplication widgetApplication(this);
+  mTerminateSignal.Emit( widgetApplication );
+
+  DoTerminate();
+}
+
+void WidgetApplication::OnLanguageChanged()
+{
+  DoLanguageChange();
+  Dali::WidgetApplication widgetApplication(this);
+  mLanguageChangedSignal.Emit( widgetApplication );
+}
+
+void WidgetApplication::OnRegionChanged()
+{
+  Dali::WidgetApplication widgetApplication(this);
+  mRegionChangedSignal.Emit( widgetApplication );
+}
+
+void WidgetApplication::OnBatteryLow( Dali::DeviceStatus::Battery::Status status )
+{
+  Dali::WidgetApplication widgetApplication(this);
+  mLowBatterySignal.Emit( status );
+}
+
+void WidgetApplication::OnMemoryLow( Dali::DeviceStatus::Memory::Status status )
+{
+  Dali::WidgetApplication widgetApplication(this);
+  mLowMemorySignal.Emit( status );
+}
+
+bool WidgetApplication::AddIdle( CallbackBase* callback )
+{
+  return mAdaptor->AddIdle( callback );
+}
+
+Dali::Adaptor& WidgetApplication::GetAdaptor()
+{
+  return *mAdaptor;
+}
+
+std::string WidgetApplication::GetResourcePath()
+{
+  return Internal::Adaptor::Framework::GetResourcePath();
+}
+
+std::string WidgetApplication::GetRegion()
+{
+  return mFramework->GetRegion();
+}
+
+std::string WidgetApplication::GetLanguage()
+{
+  return mFramework->GetLanguage();
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
diff --git a/adaptors/common/widget-application-impl.h b/adaptors/common/widget-application-impl.h
new file mode 100644 (file)
index 0000000..6f53534
--- /dev/null
@@ -0,0 +1,267 @@
+#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
+#include <dali/public-api/object/base-object.h>
+#include <widget_base.h>
+#include <bundle.h>
+
+// INTERNAL INCLUDES
+#include <widget-application.h>
+#include <singleton-service.h>
+
+#include <framework.h>
+#include <window.h>
+#include <base/environment-options.h>
+
+namespace Dali
+{
+class Adaptor;
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+class CommandLineOptions;
+class EventLoop;
+
+class WidgetApplication;
+typedef IntrusivePtr<WidgetApplication> WidgetApplicationPtr;
+
+/**
+ * Implementation of the WidgetApplication class.
+ */
+class WidgetApplication : public BaseObject, public Framework::Observer
+{
+public:
+  typedef Dali::WidgetApplication::AppSignalType AppSignalType;
+  typedef Dali::WidgetApplication::LowBatterySignalType LowBatterySignalType;
+  typedef Dali::WidgetApplication::LowMemorySignalType LowMemorySignalType;
+
+  /**
+   * 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::MainLoop()
+   */
+  void MainLoop();
+
+  /**
+   * @copydoc Dali::WidgetApplication::Quit()
+   */
+  void Quit();
+
+  /**
+   * @copydoc Dali::WidgetApplication::GetAdaptor();
+   */
+  Dali::Adaptor& GetAdaptor();
+
+  /**
+   * @copydoc Dali::WidgetApplication::GetResourcePath();
+   */
+  static std::string GetResourcePath();
+
+  /**
+   * @copydoc Dali::WidgetApplication::GetRegion();
+   */
+  std::string GetRegion();
+
+  /**
+   * @copydoc Dali::WidgetApplication::GetLanguage();
+   */
+  std::string GetLanguage();
+
+public: // Lifecycle functionality
+
+  /**
+   * Called when OnInit is called or the framework is initialised.
+   */
+  void DoInit();
+
+  /**
+   * Called after OnInit is called or the framework is started.
+   */
+  void DoStart();
+
+  /**
+   * Called when OnTerminate is called or the framework is terminated.
+   */
+  void DoTerminate();
+
+  /**
+   * Called when OnLanguageChanged is called or the framework informs the application that the language of the device has changed.
+   */
+  void DoLanguageChange();
+
+public: // From Framework::Observer
+
+  /**
+   * Called when the framework is initialised.
+   */
+  virtual void OnInit();
+
+  /**
+   * Called when the framework is terminated.
+   */
+  virtual void OnTerminate();
+
+  /**
+   * Called when the framework informs the application that the language of the device has changed.
+   */
+  virtual void OnLanguageChanged();
+
+  /**
+  * Called when the framework informs the application that the region of the device has changed.
+  */
+  virtual void OnRegionChanged();
+
+  /**
+  * Called when the framework informs the application that the battery level of the device is low.
+  */
+  virtual void OnBatteryLow( Dali::DeviceStatus::Battery::Status status );
+
+  /**
+  * Called when the framework informs the application that the memory level of the device is low.
+  */
+  virtual void OnMemoryLow( Dali::DeviceStatus::Memory::Status status );
+
+public:  // Signals
+
+  /**
+   * @copydoc Dali::WidgetApplication::InitSignal()
+   */
+   Dali::WidgetApplication::AppSignalType& InitSignal() { return mInitSignal; }
+
+  /**
+   * @copydoc Dali::WidgetApplication::TerminateSignal()
+   */
+  Dali::WidgetApplication::AppSignalType& TerminateSignal() { return mTerminateSignal; }
+
+  /**
+   * @copydoc Dali::WidgetApplication::LanguageChangedSignal()
+   */
+  Dali::WidgetApplication::AppSignalType& LanguageChangedSignal() { return mLanguageChangedSignal; }
+
+  /**
+  * @copydoc Dali::WidgetApplication::RegionChangedSignal()
+  */
+  Dali::WidgetApplication::AppSignalType& RegionChangedSignal() { return mRegionChangedSignal; }
+
+  /**
+  * @copydoc Dali::WidgetApplication::LowBatterySignal()
+  */
+  Dali::WidgetApplication::LowBatterySignalType& LowBatterySignal() { return mLowBatterySignal; }
+
+  /**
+  * @copydoc Dali::WidgetApplication::LowMemorySignal()
+  */
+  Dali::WidgetApplication::LowMemorySignalType& LowMemorySignal() { return mLowMemorySignal; }
+
+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&);
+
+  /**
+   * Creates the adaptor
+   */
+  void CreateAdaptor();
+
+  /**
+   * Quits from the main loop
+   */
+  void QuitFromMainLoop();
+
+  /**
+   * Add idle
+   */
+  bool AddIdle( CallbackBase* callback );
+
+private:
+
+  AppSignalType                         mInitSignal;
+  AppSignalType                         mTerminateSignal;
+  AppSignalType                         mLanguageChangedSignal;
+  AppSignalType                         mRegionChangedSignal;
+  LowBatterySignalType                  mLowBatterySignal;
+  LowMemorySignalType                   mLowMemorySignal;
+
+  Framework*                            mFramework;
+
+  Dali::Configuration::ContextLoss      mContextLossConfiguration;
+  CommandLineOptions*                   mCommandLineOptions;
+
+  Dali::SingletonService                mSingletonService;
+  Dali::Adaptor*                        mAdaptor;
+  Dali::Window                          mWindow;
+  std::string                           mName;
+  std::string                           mStylesheet;
+  EnvironmentOptions                    mEnvironmentOptions;
+
+  SlotDelegate< WidgetApplication >     mSlotDelegate;
+};
+
+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/common/widget-impl.cpp b/adaptors/common/widget-impl.cpp
new file mode 100644 (file)
index 0000000..239c4f1
--- /dev/null
@@ -0,0 +1,207 @@
+/*
+ * Copyright (c) 2014 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"
+
+// EXTERNAL INCLUDES
+#include <system_info.h>
+#include <string.h>
+
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/math/vector2.h>
+
+// INTERNAL INCLUDES
+#include <adaptor.h>
+
+namespace Dali
+{
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+
+static 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\n"); /* LCOV_EXCL_LINE */
+    return false; /* LCOV_EXCL_LINE */
+  }
+
+  retrieved = true;
+
+  return feature;
+}
+
+} // anonymous namespace
+
+Dali::Widget Widget::New( const std::string& id )
+{
+  if(!IsWidgetFeatureEnabled())
+  {
+    DALI_LOG_ERROR("not supported");
+    Dali::Widget handle(NULL);
+    return handle;
+  }
+
+  if( id.size() < 1 )
+  {
+    DALI_LOG_ERROR("class id is NULL");
+    Dali::Widget handle(NULL);
+    return handle;
+  }
+
+  WidgetPtr widget ( new Widget( id ) );
+  Dali::Widget handle( widget.Get() );
+  return handle;
+}
+
+static int OnInit(widget_base_instance_h instance_h, bundle *content, int w, int h, void *classData)
+{
+  char *id;
+  widget_base_context_get_id(instance_h, &id);
+  widget_base_class_on_create(instance_h, content, w, h);
+
+  Dali::Window window = Dali::Adaptor::Get().GetWindow();
+  Any nativeHandle = window.GetNativeHandle();
+  Ecore_Wl_Window * wlWindow = AnyCast<Ecore_Wl_Window*>( nativeHandle );
+  widget_base_context_window_bind( instance_h, id, wlWindow);
+  window.SetSize( Dali::Window::WindowSize( w, h ) );
+
+  Internal::Adaptor::Widget* widget = static_cast< Internal::Adaptor::Widget* >( classData );
+  widget->mCreateSignal.Emit( std::string(id), content, window );
+
+  return 0;
+}
+
+static int OnDestroy(widget_base_instance_h instance_h, widget_base_destroy_type_e reason, bundle *content, void *classData)
+{
+  char *id;
+  widget_base_context_get_id(instance_h, &id);
+
+  Dali::Widget::WidgetTerminateType destroyReason = Dali::Widget::WidgetTerminateType::TEMPORARY;
+
+  if(reason == WIDGET_BASE_DESTROY_TYPE_PERMANENT)
+  {
+    destroyReason = Dali::Widget::WidgetTerminateType::PERMANENT;
+  }
+
+  Internal::Adaptor::Widget* widget = static_cast< Internal::Adaptor::Widget* >( classData );
+  widget->mTerminateSignal.Emit(std::string(id), content, destroyReason );
+
+  widget_base_class_on_destroy(instance_h, reason, content);
+
+  return 0;
+}
+
+static int OnPause(widget_base_instance_h instance_h, void *classData)
+{
+  char *id;
+  widget_base_context_get_id(instance_h, &id);
+
+  widget_base_class_on_pause(instance_h);
+
+  Internal::Adaptor::Widget* widget = static_cast< Internal::Adaptor::Widget* >( classData );
+  widget->mPauseSignal.Emit(id);
+
+  return 0;
+}
+
+static int OnResume(widget_base_instance_h instance_h, void *classData)
+{
+  char *id;
+  widget_base_context_get_id(instance_h, &id);
+
+  widget_base_class_on_resume(instance_h);
+
+  Internal::Adaptor::Widget* widget = static_cast< Internal::Adaptor::Widget* >( classData );
+  widget->mResumeSignal.Emit(id);
+
+  return 0;
+}
+
+static int OnResize(widget_base_instance_h instance_h, int w, int h, void *classData)
+{
+  char *id;
+  widget_base_context_get_id(instance_h, &id);
+
+  widget_base_class_on_resize(instance_h, w, h);
+
+  Internal::Adaptor::Widget* widget = static_cast< Internal::Adaptor::Widget* >( classData );
+  Dali::Window window = Dali::Adaptor::Get().GetWindow();
+  window.SetSize( Dali::Window::WindowSize(w, h) );
+  widget->mResizeSignal.Emit(id, window);
+
+  return 0;
+}
+
+static int OnUpdate(widget_base_instance_h instance_h, bundle *content, int force, void *classData)
+{
+  char *id;
+  widget_base_context_get_id(instance_h, &id);
+
+  widget_base_class_on_update(instance_h, content, force);
+
+  Internal::Adaptor::Widget* widget = static_cast< Internal::Adaptor::Widget* >( classData );
+  widget->mUpdateSignal.Emit(id, content, force);
+
+  return 0;
+}
+
+Widget::Widget( const std::string& id )
+: mCreateSignal(),
+  mTerminateSignal(),
+  mPauseSignal(),
+  mResumeSignal(),
+  mResizeSignal(),
+  mUpdateSignal(),
+  mClassId(id),
+  mSlotDelegate(this)
+{
+  widget_base_class cls = widget_base_class_get_default();
+  cls.ops.create = OnInit;
+  cls.ops.destroy = OnDestroy;
+  cls.ops.pause = OnPause;
+  cls.ops.resume = OnResume;
+  cls.ops.resize = OnResize;
+  cls.ops.update = OnUpdate;
+
+  widget_base_class_add(cls, mClassId.c_str(), this);
+}
+
+Widget::~Widget()
+{
+}
+
+} // Adaptor
+
+} // Internal
+
+} // Dali
diff --git a/adaptors/common/widget-impl.h b/adaptors/common/widget-impl.h
new file mode 100644 (file)
index 0000000..05bc782
--- /dev/null
@@ -0,0 +1,150 @@
+#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 <utility>
+#include <dali/public-api/common/vector-wrapper.h>
+#include <widget_base.h>
+
+// INTERNAL INCLUDES
+#include <widget.h>
+#include <widget-application.h>
+#include <widget-application-impl.h>
+#include <window.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+class Widget;
+typedef IntrusivePtr<Widget> WidgetPtr;
+
+/**
+ * Implementation of the Application class.
+ */
+class Widget : public BaseObject
+{
+public:
+  typedef Dali::Widget::WidgetCreateSignalType    WidgetCreateSignalType;
+  typedef Dali::Widget::WidgetTerminateSignalType WidgetTerminateSignalType;
+  typedef Dali::Widget::WidgetPauseSignalType     WidgetPauseSignalType;
+  typedef Dali::Widget::WidgetResumeSignalType    WidgetResumeSignalType;
+  typedef Dali::Widget::WidgetResizeSignalType    WidgetResizeSignalType;
+  typedef Dali::Widget::WidgetUpdateSignalType    WidgetUpdateSignalType;
+
+  /**
+   * Create a new Widget
+   * @param[in]  application  WidgetApplication for managing widget instance
+   * @param[in]  id           Id for widget class
+   */
+  static Dali::Widget New( const std::string& id );
+
+public:  // Signals
+
+  /**
+   * @copydoc Dali::Widget::InitSignal()
+   */
+  WidgetCreateSignalType& CreateSignal(){ return mCreateSignal; }
+
+  /**
+   * @copydoc Dali::Widget::TerminateSignal()
+   */
+  WidgetTerminateSignalType& TerminateSignal(){ return mTerminateSignal; }
+
+  /**
+   * @copydoc Dali::Widget::PauseSignal()
+   */
+  WidgetPauseSignalType& PauseSignal(){ return mPauseSignal; }
+
+  /**
+   * @copydoc Dali::Widget::ResumeSignal()
+   */
+  WidgetResumeSignalType& ResumeSignal(){ return mResumeSignal; }
+
+  /**
+   * @copydoc Dali::Widget::ResizeSignal()
+   */
+  WidgetResizeSignalType& ResizeSignal(){ return mResizeSignal; }
+
+  /**
+   * @copydoc Dali::Widget::UpdateSignal()
+   */
+  WidgetUpdateSignalType& UpdateSignal(){ return mUpdateSignal; }
+
+protected:
+
+  /**
+   * Private Constructor
+   * @param[in]  id           Id for widget class
+   */
+  Widget( const std::string& id );
+
+  /**
+   * Destructor
+   */
+  virtual ~Widget();
+
+  // Undefined
+  Widget(const Widget&);
+  Widget& operator=(Widget&);
+
+public:
+
+  WidgetCreateSignalType        mCreateSignal;
+  WidgetTerminateSignalType     mTerminateSignal;
+  WidgetPauseSignalType         mPauseSignal;
+  WidgetResumeSignalType        mResumeSignal;
+  WidgetResizeSignalType        mResizeSignal;
+  WidgetUpdateSignalType        mUpdateSignal;
+  const std::string             mClassId;
+
+private:
+  SlotDelegate< Widget >                mSlotDelegate;
+};
+
+inline Widget& GetImplementation(Dali::Widget& widget)
+{
+  DALI_ASSERT_ALWAYS(widget && "widget handle is empty");
+
+  BaseObject& handle = widget.GetBaseObject();
+
+  return static_cast<Internal::Adaptor::Widget&>(handle);
+}
+
+inline const Widget& GetImplementation(const Dali::Widget& widget)
+{
+  DALI_ASSERT_ALWAYS(widget && "widget handle is empty");
+
+  const BaseObject& handle = widget.GetBaseObject();
+
+  return static_cast<const Internal::Adaptor::Widget&>(handle);
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+#endif // __DALI_INTERNAL_WIDGET_H__
diff --git a/adaptors/devel-api/adaptor-framework/widget-application.cpp b/adaptors/devel-api/adaptor-framework/widget-application.cpp
new file mode 100644 (file)
index 0000000..68cfced
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * 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"
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.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)
+: BaseHandle(widgetApplication)
+{
+}
+
+WidgetApplication& WidgetApplication::operator=(const WidgetApplication& widgetApplication)
+{
+  if( *this != widgetApplication )
+  {
+    BaseHandle::operator=( widgetApplication );
+  }
+  return *this;
+}
+
+void WidgetApplication::MainLoop()
+{
+  Internal::Adaptor::GetImplementation(*this).MainLoop();
+}
+
+void WidgetApplication::Quit()
+{
+  Internal::Adaptor::GetImplementation(*this).Quit();
+}
+
+std::string WidgetApplication::GetResourcePath()
+{
+  return Internal::Adaptor::WidgetApplication::GetResourcePath();
+}
+
+std::string WidgetApplication::GetRegion()
+{
+  return Internal::Adaptor::GetImplementation(*this).GetRegion();
+}
+
+std::string WidgetApplication::GetLanguage()
+{
+  return Internal::Adaptor::GetImplementation(*this).GetLanguage();
+}
+
+WidgetApplication::AppSignalType& WidgetApplication::InitSignal()
+{
+  return Internal::Adaptor::GetImplementation(*this).InitSignal();
+}
+
+WidgetApplication::AppSignalType& WidgetApplication::TerminateSignal()
+{
+  return Internal::Adaptor::GetImplementation(*this).TerminateSignal();
+}
+
+WidgetApplication::AppSignalType& WidgetApplication::LanguageChangedSignal()
+{
+  return Internal::Adaptor::GetImplementation(*this).LanguageChangedSignal();
+}
+
+WidgetApplication::AppSignalType& WidgetApplication::RegionChangedSignal()
+{
+  return Internal::Adaptor::GetImplementation(*this).RegionChangedSignal();
+}
+
+WidgetApplication::LowBatterySignalType& WidgetApplication::LowBatterySignal()
+{
+  return Internal::Adaptor::GetImplementation(*this).LowBatterySignal();
+}
+
+WidgetApplication::LowMemorySignalType& WidgetApplication::LowMemorySignal()
+{
+  return Internal::Adaptor::GetImplementation(*this).LowMemorySignal();
+}
+
+WidgetApplication::WidgetApplication(Internal::Adaptor::WidgetApplication* widgetApplication)
+: BaseHandle(widgetApplication)
+{
+}
+
+} // namespace Dali
diff --git a/adaptors/devel-api/adaptor-framework/widget-application.h b/adaptors/devel-api/adaptor-framework/widget-application.h
new file mode 100644 (file)
index 0000000..696deb6
--- /dev/null
@@ -0,0 +1,232 @@
+#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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/signals/dali-signal.h>
+#include <dali/public-api/signals/callback.h>
+#include <bundle.h>
+
+// INTERNAL INCLUDES
+#ifdef DALI_ADAPTOR_COMPILATION  // full path doesn't exist until adaptor is installed so we have to use relative
+#include <device-status.h>
+#else
+#include <dali/public-api/adaptor-framework/device-status.h>
+#endif
+
+// INTERNAL INCLUDES
+
+namespace Dali
+{
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class WidgetApplication;
+}
+}
+
+class Window;
+
+/**
+ * @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
+ * class ExampleController: public ConnectionTracker
+ * {
+ * public:
+ *   ExampleController( WidgetApplication& widgetApplication )
+ *   : mWidgetApplication( widgetApplication )
+ *   {
+ *     mWidgetApplication.InitSignal().Connect( this, &ExampleController::Create );
+ *   }
+ *
+ *   void Create( WidgetApplication& widgetApplication )
+ *   {
+ *     Widget widget = Widget::New( WIDGET_ID );
+ *     widget.CreateSignal( this, &ExampleController::WidgetCreate );
+ *   }
+ *
+ *   void WidgetCreate( const std::string& id, bundle* content, Window window )
+ *   {
+ *     // Do Dali components...
+ *   }
+ *  ...
+ * 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_2.62
+ */
+class DALI_IMPORT_API WidgetApplication : public BaseHandle
+{
+public:
+
+  typedef Signal< void (WidgetApplication&) > AppSignalType;                   ///< Widget application lifecycle signal and system signal callback type
+  typedef Signal< void (DeviceStatus::Battery::Status) > LowBatterySignalType; ///< Widget application device signal type
+  typedef Signal< void (DeviceStatus::Memory::Status) > LowMemorySignalType;   ///< Widget application device signal type
+
+public:
+
+  /**
+   * @brief This is the constructor for WidgetApplications with a name.
+   *
+   * @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.
+   *
+   */
+  WidgetApplication();
+
+  /**
+   * @brief Copy Constructor.
+   * @param[in] WidgetApplication Handle to an object
+   */
+  WidgetApplication( const WidgetApplication& widgetApplication );
+
+  /**
+   * @brief Assignment operator.
+   * @param[in] WidgetApplication Handle to an object
+   * @return A reference to this
+   */
+  WidgetApplication& operator=( const WidgetApplication& widgetApplication );
+
+ /**
+   * @brief Destructor
+   *
+   */
+  ~WidgetApplication();
+
+  /**
+   * @brief This starts the application.
+   */
+  void MainLoop();
+
+  /**
+   * @brief This quits the application.  Tizen applications should use Lower to improve re-start performance unless they need to Quit completely.
+   */
+  void Quit();
+
+  /**
+   * @brief Get path application resources are stored at
+   * @return the full path of the resources
+   */
+  static std::string GetResourcePath();
+
+  /**
+   * @brief this is used to get region information from device.
+   *
+   * @return region information
+   */
+  std::string GetRegion();
+
+  /**
+   * @brief this is used to get language information from device.
+   *
+   * @return language information
+   */
+  std::string GetLanguage();
+
+public:  // Signals
+
+  /**
+   * @brief The user should connect to this signal to determine when they should initialize
+   * their application.
+   * @return The signal to connect to
+   */
+  AppSignalType& InitSignal();
+
+  /**
+   * @brief The user should connect to this signal to determine when they should terminate
+   * their application.
+   * @return The signal to connect to
+   */
+  AppSignalType& TerminateSignal();
+
+  /**
+   * @brief This signal is emitted when the language is changed on the device.
+   * @return The signal to connect to
+   */
+  AppSignalType& LanguageChangedSignal();
+
+  /**
+  * @brief This signal is emitted when the region of the device is changed.
+  * @return The signal to connect to
+  */
+  AppSignalType& RegionChangedSignal();
+
+  /**
+  * @brief This signal is emitted when the battery level of the device is low.
+  * @return The signal to connect to
+  */
+  LowBatterySignalType& LowBatterySignal();
+
+  /**
+  * @brief This signal is emitted when the memory level of the device is low.
+  * @return The signal to connect to
+  */
+  LowMemorySignalType& LowMemorySignal();
+
+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/devel-api/adaptor-framework/widget.cpp b/adaptors/devel-api/adaptor-framework/widget.cpp
new file mode 100644 (file)
index 0000000..26f07a8
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * 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"
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <widget-impl.h>
+
+namespace Dali
+{
+
+Widget Widget::New( const std::string& id)
+{
+  return Internal::Adaptor::Widget::New( id );
+}
+
+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::WidgetCreateSignalType& Widget::CreateSignal()
+{
+  return Internal::Adaptor::GetImplementation(*this).CreateSignal();
+}
+
+Widget::WidgetTerminateSignalType& Widget::TerminateSignal()
+{
+  return Internal::Adaptor::GetImplementation(*this).TerminateSignal();
+}
+
+Widget::WidgetPauseSignalType& Widget::PauseSignal()
+{
+  return Internal::Adaptor::GetImplementation(*this).PauseSignal();
+}
+
+Widget::WidgetResumeSignalType& Widget::ResumeSignal()
+{
+  return Internal::Adaptor::GetImplementation(*this).ResumeSignal();
+}
+
+Widget::WidgetResizeSignalType& Widget::ResizeSignal()
+{
+  return Internal::Adaptor::GetImplementation(*this).ResizeSignal();
+}
+
+Widget::WidgetUpdateSignalType& Widget::UpdateSignal()
+{
+  return Internal::Adaptor::GetImplementation(*this).UpdateSignal();
+}
+
+Widget::Widget(Internal::Adaptor::Widget* widget)
+: BaseHandle(widget)
+{
+}
+
+} // namespace Dali
diff --git a/adaptors/devel-api/adaptor-framework/widget.h b/adaptors/devel-api/adaptor-framework/widget.h
new file mode 100644 (file)
index 0000000..be23dc3
--- /dev/null
@@ -0,0 +1,205 @@
+#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>
+#include <dali/public-api/signals/dali-signal.h>
+#include <bundle.h>
+
+namespace Dali
+{
+/**
+ * @addtogroup dali_adaptor_framework
+ * @{
+ */
+
+namespace Internal DALI_INTERNAL
+{
+
+namespace Adaptor
+{
+class Widget;
+}
+
+}
+
+class Window;
+
+/**
+ * @brief Widget object should be created by WidgetApplication.
+ *
+ * The WidgetApplication class emits several widget instance lifecycle signals
+ * which the user can connect to.
+ * The user should connect to the CreateSignal of the Widget and
+ * create the Dali Widget object in the connected callback.
+ *
+ * Widget should follow the example below:
+ *
+ * @code
+ * class ExampleController: public ConnectionTracker
+ * {
+ * public:
+ *   ExampleController( WidgetApplication& widgetApplication )
+ *   : mWidgetApplication( widgetApplication )
+ *   {
+ *     mWidgetApplication.InitSignal().Connect( this, &ExampleController::Create );
+ *   }
+ *
+ *   void Create( WidgetApplication& widgetApplication )
+ *   {
+ *     Widget widget = Widget::New( WIDGET_ID );
+ *     widget.CreateSignal( this, &ExampleController::WidgetCreate );
+ *   }
+ *
+ *   void WidgetCreate( const std::string& id, bundle* content, Window window )
+ *   {
+ *     // Do Dali components...
+ *   }
+ *  ...
+ * private:
+ *   WidgetApplication& mWidgetApplication;
+ * };
+ *
+ * int main (int argc, char **argv)
+ * {
+ *   WidgetApplication app = WidgetApplication::New(&argc, &argv);
+ *   ExampleController example( app );
+ *   app.MainLoop();
+ * }
+ *
+ * @SINCE_1_2.62
+ */
+class DALI_IMPORT_API Widget : public BaseHandle
+{
+public:
+
+  /**
+   * @brief Enumeration for terminate type of widget instance.
+   * @SINCE_1_2.62
+   */
+  typedef enum
+  {
+    PERMANENT, //< User deleted this widget from the viewer @SINCE_1_2.62
+    TEMPORARY, //< Widget is deleted because of other reasons (e.g. widget process is terminated temporarily by the system) @SINCE_1_2.62
+  } WidgetTerminateType;
+
+  typedef Signal< void (const std::string&, bundle*, Window) > WidgetCreateSignalType;                  ///< Widget lifecycle signal type @SINCE_1_2.62
+  typedef Signal< void (const std::string&, bundle*, WidgetTerminateType) > WidgetTerminateSignalType;  ///< Widget lifecycle signal type @SINCE_1_2.62
+  typedef Signal< void (const std::string&) > WidgetPauseSignalType;                                    ///< Widget lifecycle signal type @SINCE_1_2.62
+  typedef Signal< void (const std::string&) > WidgetResumeSignalType;                                   ///< Widget lifecycle signal type @SINCE_1_2.62
+  typedef Signal< void (const std::string&, Window) > WidgetResizeSignalType;                           ///< Widget lifecycle signal type @SINCE_1_2.62
+  typedef Signal< void (const std::string&, bundle*, int) > WidgetUpdateSignalType;                     ///< Widget lifecycle signal type @SINCE_1_2.62
+
+public:
+
+  /**
+   * @brief This is the constructor for Widget.
+   * @SINCE_1_2.62
+   * @param[in]  id  Id for widget class
+   * @return A handle to the Widget
+   */
+  static Widget New( const std::string& id );
+
+  /**
+   * @brief The default constructor.
+   *
+   */
+  Widget();
+
+  /**
+   * @brief Copy Constructor.
+   * @SINCE_1_2.62
+   * @param[in] Widget Handle to an object
+   */
+  Widget( const Widget& widget );
+
+  /**
+   * @brief Assignment operator.
+   * @SINCE_1_2.62
+   * @param[in] Widget Handle to an object
+   * @return A reference to this
+   */
+  Widget& operator=( const Widget& widget );
+
+  /**
+   * @brief Destructor
+   * @SINCE_1_2.62
+   */
+  ~Widget();
+
+public:  // Signals
+
+  /**
+   * @brief The user should connect to this signal to determine when they create widget.
+   * @SINCE_1_2.62
+   * @return The signal to connect to
+   */
+  WidgetCreateSignalType& CreateSignal();
+
+  /**
+   * @brief The user should connect to this signal to determine when they terminate widget.
+   * @SINCE_1_2.62
+   * @return The signal to connect to
+   */
+  WidgetTerminateSignalType& TerminateSignal();
+
+  /**
+   * @brief The user should connect to this signal to determine when they pause widget.
+   * @SINCE_1_2.62
+   * @return The signal to connect to
+   */
+  WidgetPauseSignalType& PauseSignal();
+
+  /**
+   * @brief The user should connect to this signal to determine when they resume widget.
+   * @SINCE_1_2.62
+   * @return The signal to connect to
+   */
+  WidgetResumeSignalType& ResumeSignal();
+
+  /**
+   * @brief The user should connect to this signal to determine when they resize widget.
+   * @SINCE_1_2.62
+   * @return The signal to connect to
+   */
+  WidgetResizeSignalType& ResizeSignal();
+
+  /**
+   * @brief The user should connect to this signal to determine when they update widget.
+   * @SINCE_1_2.62
+   * @return The signal to connect to
+   */
+  WidgetUpdateSignalType& UpdateSignal();
+
+public: // Not intended for application developers
+  /// @cond internal
+  /**
+   * @brief Internal constructor.
+   */
+  explicit DALI_INTERNAL Widget(Internal::Adaptor::Widget* widget);
+  /// @endcond
+};
+
+/**
+ * @}
+ */
+} // namespace Dali
+
+#endif // ___DALI_WIDGET_H__
index 160ba00..a2df499 100644 (file)
@@ -68,3 +68,10 @@ devel_api_adaptor_framework_header_files = \
   $(adaptor_devel_api_dir)/adaptor-framework/virtual-keyboard.h \
   $(adaptor_devel_api_dir)/adaptor-framework/physical-keyboard.h
 
+adaptor_widget_src_files = \
+  $(adaptor_devel_api_dir)/adaptor-framework/widget.cpp \
+  $(adaptor_devel_api_dir)/adaptor-framework/widget-application.cpp
+
+adaptor_widget_header_files = \
+  $(adaptor_devel_api_dir)/adaptor-framework/widget.h \
+  $(adaptor_devel_api_dir)/adaptor-framework/widget-application.h
index 9e87551..26d24e4 100644 (file)
@@ -229,6 +229,13 @@ public:
   Any GetNativeWindowHandle();
 
   /**
+   * @brief Gets Window handle
+   *
+   * @return Window handle
+   */
+  Window GetWindow();
+
+  /**
    * @brief Release any locks the surface may hold.
    *
    * For example, after compositing an offscreen surface, use this method to allow
index addc5a7..6cfe739 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>
@@ -46,6 +46,7 @@
 // INTERNAL INCLUDES
 #include <callback-manager.h>
 
+#include <dlog.h>
 namespace Dali
 {
 
@@ -55,13 +56,34 @@ 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"); /* LCOV_EXCL_LINE */
+    return false; /* LCOV_EXCL_LINE */
+  }
+
+  retrieved = true;
+  return feature;
+}
+
+} // anonymous namespace
+
 namespace AppCore
 {
 
@@ -196,6 +218,10 @@ struct Framework::Impl
     {
       ret = AppNormalMain();
     }
+    else if(mApplicationType == WIDGET)
+    {
+      ret = AppWidgetMain();
+    }
     else
     {
       ret = AppWatchMain();
@@ -209,6 +235,10 @@ struct Framework::Impl
     {
       AppNormalExit();
     }
+    else if(mApplicationType == WIDGET)
+    {
+      AppWidgetExit();
+    }
     else
     {
       AppWatchExit();
@@ -495,6 +525,58 @@ struct Framework::Impl
     appcore_ui_base_exit();
   }
 
+  void AppWidgetExit()
+  {
+    widget_base_exit();
+  }
+
+  static int WidgetAppCreate( void *data )
+  {
+    dlog_print(DLOG_ERROR,"DALI","WidgetAppCreate!\n");
+    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)
   {
index 39e0145..2d0ca89 100644 (file)
@@ -90,7 +90,6 @@ include ../../../adaptors/public-api/file.list
 adaptor_devel_api_dir = ../../../adaptors/devel-api
 include ../../../adaptors/devel-api/file.list
 
-
 # Static libraries
 static_libraries_libunibreak_src_dir = ../../../text/dali/internal/libunibreak
 include ../../../text/dali/internal/libunibreak/file.list
@@ -257,6 +256,13 @@ endif # WAYLAND
 
 endif # IVI_PROFILE
 
+if USE_APPFW
+if USE_APPFW_EFL_BASE
+else
+adaptor_internal_src_files += $(adaptor_internal_widget_src_files)
+endif
+endif
+
 main_loop_integration_src_files = $(adaptor_common_internal_ecore_src_files)
 input_event_handler_src_files = $(adaptor_ecore_x_event_handler_internal_src_files)
 
@@ -290,6 +296,14 @@ LIBDALI_ADAPTOR_LA_SOURCES += \
   $(base_adaptor_networking_src_files)
 endif
 
+if USE_APPFW
+if USE_APPFW_EFL_BASE
+else # over Tizen 3.0
+LIBDALI_ADAPTOR_LA_SOURCES += \
+                     $(adaptor_widget_src_files)
+endif
+endif
+
 libdali_adaptor_la_DEPENDENCIES =
 
 # List include directories with more platform-specific (tizen) before portable root:
@@ -438,13 +452,17 @@ 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)
 
-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
@@ -569,6 +587,13 @@ tizenadaptorpublicapi_HEADERS += $(adaptor_dali_wearable_header_file)
 tizenwatchpublicapidir = $(tizenadaptorpublicapidir)/watch
 tizenwatchpublicapi_HEADERS = $(public_dali_watch_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 878d278..18a3822 100644 (file)
@@ -121,7 +121,9 @@ BuildRequires:  pkgconfig(evas)
 BuildRequires:  pkgconfig(capi-appfw-application)
 BuildRequires:  pkgconfig(elementary)
 %else
+BuildRequires:  pkgconfig(bundle)
 BuildRequires:  pkgconfig(appcore-ui)
+BuildRequires:  pkgconfig(appcore-widget-base)
 BuildRequires:  pkgconfig(capi-appfw-app-common)
 BuildRequires:  pkgconfig(capi-appfw-app-control)
 BuildRequires:  pkgconfig(ecore-imf)