[4.0] Create Widget Application
[platform/core/uifw/dali-adaptor.git] / adaptors / common / adaptor-impl.cpp
index 600a2a3..1f8d21a 100644 (file)
@@ -20,6 +20,9 @@
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/common/stage.h>
+#include <dali/public-api/actors/layer.h>
+#include <dali/devel-api/actors/actor-devel.h>
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/core.h>
 #include <dali/integration-api/context-notifier.h>
@@ -55,6 +58,8 @@
 #include <tizen-logging.h>
 #include <image-loading.h>
 
+#include <locale-utils.h>
+
 using Dali::TextAbstraction::FontClient;
 
 namespace Dali
@@ -68,7 +73,7 @@ namespace Adaptor
 
 namespace
 {
-__thread Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer to allow Adaptor::Get
+thread_local Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer to allow Adaptor::Get
 } // unnamed namespace
 
 Dali::Adaptor* Adaptor::New( Any nativeWindow, RenderSurface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
@@ -85,8 +90,11 @@ Dali::Adaptor* Adaptor::New( Any nativeWindow, RenderSurface *surface, Dali::Con
 Dali::Adaptor* Adaptor::New( Dali::Window window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
 {
   Any winId = window.GetNativeHandle();
+
   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;
 }
@@ -189,6 +197,8 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration )
   {
     Dali::SetMaxTextureSize( mEnvironmentOptions->GetMaxTextureSize() );
   }
+
+  SetupSystemInformation();
 }
 
 Adaptor::~Adaptor()
@@ -297,6 +307,9 @@ void Adaptor::Pause()
     mThreadController->Pause();
     mCore->Suspend();
     mState = PAUSED;
+
+    // Process remained events and rendering in the update thread
+    RequestUpdateOnce();
   }
 }
 
@@ -702,7 +715,7 @@ void Adaptor::OnDamaged( const DamageArea& area )
   RequestUpdate();
 }
 
-void Adaptor::SurfaceResizePrepare( Dali::Adaptor::SurfaceSize surfaceSize )
+void Adaptor::SurfaceResizePrepare( SurfaceSize surfaceSize )
 {
   // let the core know the surface size has changed
   mCore->SurfaceResized( surfaceSize.GetWidth(), surfaceSize.GetHeight() );
@@ -710,7 +723,7 @@ void Adaptor::SurfaceResizePrepare( Dali::Adaptor::SurfaceSize surfaceSize )
   mResizedSignal.Emit( mAdaptor );
 }
 
-void Adaptor::SurfaceResizeComplete( Dali::Adaptor::SurfaceSize surfaceSize )
+void Adaptor::SurfaceResizeComplete( SurfaceSize surfaceSize )
 {
   // flush the event queue to give the update-render thread chance
   // to start processing messages for new camera setup etc as soon as possible
@@ -736,6 +749,11 @@ void Adaptor::NotifyLanguageChanged()
   mLanguageChangedSignal.Emit( mAdaptor );
 }
 
+void Adaptor::RenderOnce()
+{
+  RequestUpdateOnce();
+}
+
 void Adaptor::RequestUpdateOnce()
 {
   if( PAUSED_WHILE_HIDDEN != mState )
@@ -793,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 )
 {
@@ -823,6 +842,24 @@ float Adaptor::GetStereoBase() const
   return mCore->GetStereoBase();
 }
 
+void Adaptor::SetRootLayoutDirection( std::string locale )
+{
+  Dali::Stage stage = Dali::Stage::GetCurrent();
+
+  stage.GetRootLayer().SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION,
+                                    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