Merge branch 'devel/master' into sandbox/dkdk/tizen
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / common / application-impl.h
index 239f373..4d3a4eb 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_INTERNAL_APPLICATION_H__
-#define __DALI_INTERNAL_APPLICATION_H__
+#ifndef DALI_INTERNAL_APPLICATION_H
+#define DALI_INTERNAL_APPLICATION_H
 
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
 
 // INTERNAL INCLUDES
 #include <dali/public-api/adaptor-framework/application.h>
-#include <dali/devel-api/adaptor-framework/singleton-service.h>
+#include <dali/devel-api/common/singleton-service.h>
 
 #include <dali/internal/adaptor/common/framework.h>
-#include <dali/internal/window-system/common/window-impl.h>
 #include <dali/internal/system/common/environment-options.h>
+#include <dali/internal/adaptor/common/adaptor-builder-impl.h>
 
 namespace Dali
 {
@@ -99,7 +99,7 @@ public:
   /**
    * @copydoc Dali::Application::MainLoop()
    */
-  void MainLoop(Dali::Configuration::ContextLoss configuration);
+  void MainLoop();
 
   /**
    * @copydoc Dali::Application::Lower()
@@ -114,7 +114,7 @@ public:
   /**
    * @copydoc Dali::Application::AddIdle()
    */
-  bool AddIdle( CallbackBase* callback );
+  bool AddIdle( CallbackBase* callback, bool hasReturnValue );
 
   /**
    * @copydoc Dali::Application::GetAdaptor();
@@ -137,9 +137,9 @@ public:
   std::string GetLanguage() const;
 
   /**
-   * @copydoc Dali::Application::ReplaceWindow();
+   * @copydoc Dali::Application::GetObjectRegistry();
    */
-  void ReplaceWindow( const PositionSize& positionSize, const std::string& name);
+  Dali::ObjectRegistry GetObjectRegistry() const;
 
   /**
    * @copydoc Dali::Application::GetResourcePath();
@@ -147,126 +147,81 @@ public:
   static std::string GetResourcePath();
 
   /**
+   * @copydoc Dali::DevelApplication::GetDataPath()
+   */
+  static std::string GetDataPath();
+
+  /**
    * Retrieves the pre-initialized application.
    *
    * @return A pointer to the pre-initialized application
    */
   static ApplicationPtr GetPreInitializedApplication();
 
-public: // Stereoscopy
-
-  /**
-   * @copydoc Dali::Application::SetViewMode()
-   */
-  void SetViewMode( ViewMode viewMode );
-
-  /**
-   * @copydoc Dali::Application::GetViewMode()
-   */
-  ViewMode GetViewMode() const;
-
-  /**
-   * @copydoc Dali::Application::SetStereoBase()
-   */
-  void SetStereoBase( float stereoBase );
-
-  /**
-   * @copydoc Dali::Application::GetStereoBase()
-   */
-  float GetStereoBase() const;
-
-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 OnPause is called or the framework is paused.
-   */
-  void DoPause();
-
-  /**
-   * Called when OnResume is called or the framework resumes from a paused state.
-   */
-  void DoResume();
-
-  /**
-   * 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();
+  void OnInit() override;
 
   /**
    * Called when the framework is terminated.
    */
-  virtual void OnTerminate();
+  void OnTerminate() override;
 
   /**
    * Called when the framework is paused.
    */
-  virtual void OnPause();
+  void OnPause() override;
 
   /**
    * Called when the framework resumes from a paused state.
    */
-  virtual void OnResume();
+  void OnResume() override;
 
   /**
   * Called when the framework received AppControlSignal.
   * @param[in] The bundle data of AppControl event.
   */
-  virtual void OnAppControl(void *data);
+  void OnAppControl(void *data) override;
 
   /**
    * Called when the framework informs the application that it should reset itself.
    */
-  virtual void OnReset();
+  void OnReset() override;
 
   /**
    * Called when the framework informs the application that the language of the device has changed.
    */
-  virtual void OnLanguageChanged();
+  void OnLanguageChanged() override;
 
   /**
   * Called when the framework informs the application that the region of the device has changed.
   */
-  virtual void OnRegionChanged();
+  void OnRegionChanged() override;
 
   /**
   * Called when the framework informs the application that the battery level of the device is low.
   */
-  virtual void OnBatteryLow( Dali::DeviceStatus::Battery::Status status );
+  void OnBatteryLow( Dali::DeviceStatus::Battery::Status status ) override;
 
   /**
   * Called when the framework informs the application that the memory level of the device is low.
   */
-  virtual void OnMemoryLow( Dali::DeviceStatus::Memory::Status status );
+  void OnMemoryLow( Dali::DeviceStatus::Memory::Status status ) override;
 
-public:
+  /**
+   * Called when the framework informs the application that the platform surface is created.
+   */
+  void OnSurfaceCreated( Any newSurface ) override;
 
   /**
-   * Signal handler when the adaptor's window resizes itself.
-   * @param[in]  adaptor  The adaptor
+   * Called when the framework informs the application that the platform surface is destroyed.
    */
-  void OnResize(Dali::Adaptor& adaptor);
+  void OnSurfaceDestroyed( Any newSurface ) override;
+
+public:
 
   /**
    * Sets a user defined theme file.
@@ -275,6 +230,14 @@ public:
    */
   void SetStyleSheet( const std::string& stylesheet );
 
+  /**
+   * Sets a command line options.
+   * This is used in case of the preinitialized application.
+   * @param[in] argc A pointer to the number of arguments
+   * @param[in] argv A pointer to the argument list
+   */
+  void SetCommandLineOptions( int* argc, char **argv[] );
+
 public:  // Signals
 
   /**
@@ -308,11 +271,6 @@ public:  // Signals
   Dali::Application::AppControlSignalType& AppControlSignal() { return mAppControlSignal; }
 
   /**
-   * @copydoc Dali::Application::ResizeSignal()
-   */
-  Dali::Application::AppSignalType& ResizeSignal() { return mResizeSignal; }
-
-  /**
    * @copydoc Dali::Application::LanguageChangedSignal()
    */
   Dali::Application::AppSignalType& LanguageChangedSignal() { return mLanguageChangedSignal; }
@@ -323,16 +281,6 @@ public:  // Signals
   Dali::Application::AppSignalType& RegionChangedSignal() { return mRegionChangedSignal; }
 
   /**
-  * @copydoc Dali::Application::BatteryLowSignal()
-  */
-  Dali::Application::AppSignalType& BatteryLowSignal() { return mBatteryLowSignal; }
-
-  /**
-  * @copydoc Dali::Application::MemoryLowSignal()
-  */
-  Dali::Application::AppSignalType& MemoryLowSignal() { return mMemoryLowSignal; }
-
-  /**
   * @copydoc Dali::Application::LowBatterySignal()
   */
   Dali::Application::LowBatterySignalType& LowBatterySignal() { return mLowBatterySignal; }
@@ -359,7 +307,7 @@ protected:
   /**
    * Destructor
    */
-  virtual ~Application();
+  ~Application() override;
 
   // Undefined
   Application(const Application&);
@@ -376,6 +324,11 @@ protected:
   void CreateAdaptor();
 
   /**
+   * Creates the adaptor builder
+   */
+  void CreateAdaptorBuilder();
+
+  /**
    * Quits from the main loop
    */
   void QuitFromMainLoop();
@@ -387,35 +340,35 @@ private:
   AppSignalType                         mPauseSignal;
   AppSignalType                         mResumeSignal;
   AppSignalType                         mResetSignal;
-  AppSignalType                         mResizeSignal;
   AppControlSignalType                  mAppControlSignal;
   AppSignalType                         mLanguageChangedSignal;
   AppSignalType                         mRegionChangedSignal;
-  AppSignalType                         mBatteryLowSignal;
-  AppSignalType                         mMemoryLowSignal;
   LowBatterySignalType                  mLowBatterySignal;
   LowMemorySignalType                   mLowMemorySignal;
 
   EventLoop*                            mEventLoop;
   Framework*                            mFramework;
 
-  Dali::Configuration::ContextLoss      mContextLossConfiguration;
   CommandLineOptions*                   mCommandLineOptions;
 
-  Dali::SingletonService                mSingletonService;
-  Dali::Adaptor*                        mAdaptor;
-  Dali::Window                          mWindow;
-  Dali::Application::WINDOW_MODE        mWindowMode;
-  std::string                           mName;
-  std::string                           mStylesheet;
-  EnvironmentOptions                    mEnvironmentOptions;
-  PositionSize                          mWindowPositionSize;
-  Launchpad::State                      mLaunchpadState;
-  bool                                  mUseRemoteSurface;
+  Dali::Internal::Adaptor::AdaptorBuilder* mAdaptorBuilder;   ///< The adaptor builder
+  Dali::Adaptor*                           mAdaptor;
 
-  SlotDelegate< Application >           mSlotDelegate;
+  // The Main Window is that window created by the Application during initial startup
+  // (previously this was the only window)
+  Dali::Window                             mMainWindow;       ///< Main Window instance
+  Dali::Application::WINDOW_MODE           mMainWindowMode;   ///< Window mode of the main window
+  std::string                              mMainWindowName;   ///< Name of the main window as obtained from environment options
 
-  static ApplicationPtr                 gPreInitializedApplication;
+  std::string                              mStylesheet;
+  EnvironmentOptions                       mEnvironmentOptions;
+  PositionSize                             mWindowPositionSize;
+  Launchpad::State                         mLaunchpadState;
+  bool                                     mUseRemoteSurface;
+
+  SlotDelegate< Application >              mSlotDelegate;
+
+  static ApplicationPtr                    gPreInitializedApplication;
 };
 
 inline Application& GetImplementation(Dali::Application& application)
@@ -429,7 +382,7 @@ inline Application& GetImplementation(Dali::Application& application)
 
 inline const Application& GetImplementation(const Dali::Application& application)
 {
-  DALI_ASSERT_ALWAYS(application && "Timre handle is empty");
+  DALI_ASSERT_ALWAYS(application && "application handle is empty");
 
   const BaseObject& handle = application.GetBaseObject();
 
@@ -443,4 +396,4 @@ inline const Application& GetImplementation(const Dali::Application& application
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_APPLICATION_H__
+#endif // DALI_INTERNAL_APPLICATION_H