Merge remote-tracking branch 'origin/tizen' into new_text
[platform/core/uifw/dali-adaptor.git] / adaptors / common / application-impl.cpp
index 6b288b5..590297c 100644 (file)
@@ -31,9 +31,9 @@
 namespace Dali
 {
 
-namespace SlpPlatform
+namespace TizenPlatform
 {
-class SlpPlatformAbstraction;
+class TizenPlatformAbstraction;
 }
 
 namespace Integration
@@ -47,15 +47,6 @@ namespace Internal
 namespace Adaptor
 {
 
-namespace
-{
-// Defaults taken from H2 device
-const unsigned int DEFAULT_WINDOW_WIDTH   = 480;
-const unsigned int DEFAULT_WINDOW_HEIGHT  = 800;
-const float        DEFAULT_HORIZONTAL_DPI = 220;
-const float        DEFAULT_VERTICAL_DPI   = 217;
-}
-
 ApplicationPtr Application::New(
   int* argc,
   char **argv[],
@@ -74,7 +65,11 @@ Application::Application( int* argc, char** argv[], const std::string& name, con
   mResumeSignal(),
   mResetSignal(),
   mResizeSignal(),
+  mAppControlSignal(),
   mLanguageChangedSignal(),
+  mRegionChangedSignal(),
+  mBatteryLowSignal(),
+  mMemoryLowSignal(),
   mEventLoop( NULL ),
   mFramework( NULL ),
   mCommandLineOptions( NULL ),
@@ -104,15 +99,12 @@ Application::~Application()
 
 void Application::CreateWindow()
 {
-#ifndef __arm__
-   PositionSize windowPosition(0, 0, DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT);
-#else
-   PositionSize windowPosition(0, 0, 0, 0);  // this will use full screen
-#endif
-  if (mCommandLineOptions->stageWidth > 0 && mCommandLineOptions->stageHeight > 0)
+  PositionSize windowPosition(0, 0, 0, 0);  // this will use full screen
+
+  if( mCommandLineOptions->stageWidth > 0 && mCommandLineOptions->stageHeight > 0 )
   {
     // let the command line options over ride
-    windowPosition = PositionSize(0,0,mCommandLineOptions->stageWidth,mCommandLineOptions->stageHeight);
+    windowPosition = PositionSize( 0, 0, mCommandLineOptions->stageWidth, mCommandLineOptions->stageHeight );
   }
 
   mWindow = Dali::Window::New( windowPosition, mName, mWindowMode == Dali::Application::TRANSPARENT );
@@ -124,17 +116,6 @@ void Application::CreateAdaptor()
 
   mAdaptor = &Dali::Adaptor::New( mWindow, mBaseLayout, mContextLossConfiguration );
 
-  // Allow DPI to be overridden from command line.
-  unsigned int hDPI=DEFAULT_HORIZONTAL_DPI;
-  unsigned int vDPI=DEFAULT_VERTICAL_DPI;
-
-  std::string dpiStr = mCommandLineOptions->stageDPI;
-  if(!dpiStr.empty())
-  {
-    sscanf(dpiStr.c_str(), "%ux%u", &hDPI, &vDPI);
-  }
-  Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetDpi(hDPI, vDPI);
-
   mAdaptor->ResizedSignal().Connect( mSlotDelegate, &Application::OnResize );
 }
 
@@ -155,7 +136,7 @@ void Application::Lower()
 void Application::Quit()
 {
   // Actually quit the application.
-  AddIdle(boost::bind(&Application::QuitFromMainLoop, this));
+  AddIdle( MakeCallback( this, &Application::QuitFromMainLoop ) );
 }
 
 void Application::QuitFromMainLoop()
@@ -172,7 +153,7 @@ void Application::QuitFromMainLoop()
 
 void Application::OnInit()
 {
-  mFramework->AddAbortCallback(boost::bind(&Application::QuitFromMainLoop, this));
+  mFramework->AddAbortCallback( MakeCallback( this, &Application::QuitFromMainLoop ) );
 
   CreateWindow();
   CreateAdaptor();
@@ -251,20 +232,44 @@ void Application::OnReset()
   mWindow.Raise();
 }
 
+void Application::OnAppControl(void *data)
+{
+  Dali::Application application(this);
+  mAppControlSignal.Emit( application , data );
+}
+
 void Application::OnLanguageChanged()
 {
   mAdaptor->NotifyLanguageChanged();
 }
 
+void Application::OnRegionChanged()
+{
+  Dali::Application application(this);
+  mRegionChangedSignal.Emit( application );
+}
+
+void Application::OnBatteryLow()
+{
+  Dali::Application application(this);
+  mBatteryLowSignal.Emit( application );
+}
+
+void Application::OnMemoryLow()
+{
+  Dali::Application application(this);
+  mMemoryLowSignal.Emit( application );
+}
+
 void Application::OnResize(Dali::Adaptor& adaptor)
 {
   Dali::Application application(this);
   mResizeSignal.Emit( application );
 }
 
-bool Application::AddIdle(boost::function<void(void)> callBack)
+bool Application::AddIdle( CallbackBase* callback )
 {
-  return mAdaptor->AddIdle(callBack);
+  return mAdaptor->AddIdle( callback );
 }
 
 Dali::Adaptor& Application::GetAdaptor()
@@ -317,7 +322,9 @@ void Application::ReplaceWindow(PositionSize windowPosition, const std::string&
   windowImpl.SetAdaptor(*mAdaptor);
   newWindow.ShowIndicator(Dali::Window::INVISIBLE);
   Dali::RenderSurface* renderSurface = windowImpl.GetSurface();
-  Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).ReplaceSurface(*renderSurface);
+
+  Any nativeWindow = newWindow.GetNativeHandle();
+  Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).ReplaceSurface(nativeWindow, *renderSurface);
   mWindow = newWindow;
 }