[Tizen] Restore Uploaded signal for BufferImage and ResourceImage
[platform/core/uifw/dali-core.git] / dali / internal / event / size-negotiation / relayout-controller-impl.cpp
index 9c2120a..0b3ec2c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
@@ -15,8 +15,7 @@
  *
  */
 
-// FILE HEADER
-
+// CLASS HEADER
 #include "relayout-controller-impl.h"
 
 // EXTERNAL INCLUDES
 #endif // defined(DEBUG_ENABLED)
 
 // INTERNAL INCLUDES
-#include <dali/public-api/actors/layer.h>
-#include <dali/public-api/common/stage.h>
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/render-controller.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/object/object-registry.h>
 #include <dali/internal/event/actors/actor-impl.h>
+#include <dali/internal/event/common/stage-impl.h>
+#include <dali/internal/event/common/system-overlay-impl.h>
 #include <dali/internal/event/common/thread-local-storage.h>
 
 namespace Dali
@@ -93,7 +92,7 @@ void PrintHierarchy()
   if ( gLogFilter->IsEnabledFor( Debug::Verbose ) )
   {
     DALI_LOG_INFO( gLogFilter, Debug::Verbose, "---------- ROOT LAYER ----------\n" );
-    PrintChildren( Dali::Stage().GetCurrent().GetRootLayer(), 0 );
+    PrintChildren( Stage::GetCurrent()->GetRootLayer(), 0 );
   }
 }
 
@@ -107,16 +106,12 @@ void PrintHierarchy()
 
 } // unnamed namespace
 
-RelayoutController* RelayoutController::Get()
-{
-  return &ThreadLocalStorage::Get().GetRelayoutController();
-}
-
 RelayoutController::RelayoutController( Integration::RenderController& controller )
 : mRenderController( controller ),
   mRelayoutInfoAllocator(),
   mSlotDelegate( this ),
   mRelayoutStack( new MemoryPoolRelayoutContainer( mRelayoutInfoAllocator ) ),
+  mStageSize(), // zero initialized
   mRelayoutConnection( false ),
   mRelayoutFlag( false ),
   mEnabled( false ),
@@ -132,6 +127,17 @@ RelayoutController::~RelayoutController()
   delete mRelayoutStack;
 }
 
+RelayoutController* RelayoutController::Get()
+{
+  return &ThreadLocalStorage::Get().GetRelayoutController();
+}
+
+void RelayoutController::SetStageSize( unsigned int width, unsigned int height )
+{
+  mStageSize.width = width;
+  mStageSize.height = height;
+}
+
 void RelayoutController::QueueActor( Dali::Actor& actor, RelayoutContainer& actors, Vector2 size )
 {
   if( GetImplementation( actor ).RelayoutRequired() )
@@ -206,9 +212,19 @@ void RelayoutController::OnApplicationSceneCreated()
 
   // Spread the dirty flag through whole tree - don't need to explicity
   // add request on rootLayer as it will automatically be added below.
-  Dali::Actor rootLayer = Dali::Stage::GetCurrent().GetRootLayer();
+  Dali::Stage stage = Dali::Stage::GetCurrent();
+  Dali::Actor rootLayer = stage.GetRootLayer();
   RequestRelayoutTree( rootLayer );
 
+  // Also add request on the root of system overlay
+  Dali::Internal::SystemOverlay* systemOverlay = GetImplementation(stage).GetSystemOverlayInternal();
+  if( systemOverlay )
+  {
+    Dali::Internal::Actor& systemOverlayInternalRoot = systemOverlay->GetDefaultRootActor();
+    Dali::Actor systemOverlayRoot = Dali::Actor(&systemOverlayInternalRoot);
+    RequestRelayoutTree( systemOverlayRoot );
+  }
+
   // Flag request for end of frame
   Request();
 }
@@ -434,8 +450,6 @@ void RelayoutController::Relayout()
 
     // 1. Finds all top-level controls from the dirty list and allocate them the size of the stage
     //    These controls are paired with the parent/stage size and added to the stack.
-    const Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
-
     for( RawActorList::Iterator it = mDirtyLayoutSubTrees.Begin(), itEnd = mDirtyLayoutSubTrees.End(); it != itEnd; ++it )
     {
       BaseObject* dirtyActor = *it;
@@ -450,7 +464,7 @@ void RelayoutController::Relayout()
         if( actor.OnStage() )
         {
           Dali::Actor parent = actor.GetParent();
-          QueueActor( actor, *mRelayoutStack, ( parent ) ? Vector2( parent.GetTargetSize() ) : stageSize );
+          QueueActor( actor, *mRelayoutStack, ( parent ) ? Vector2( parent.GetTargetSize() ) : mStageSize );
         }
       }
     }
@@ -476,7 +490,11 @@ void RelayoutController::Relayout()
 
           // 3. Negotiate the size with the current actor. Pass it an empty container which the actor
           //    has to fill with all the actors it has not done any size negotiation for.
+
           actorImpl.NegotiateSize( size, *mRelayoutStack );
+
+          // Reset the flag so that size negotiation will respect the actor's original resize policy
+          actorImpl.SetUseAssignedSize( false );
         }
       }