/*
- * Copyright (c) 2015 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.
// EXTERNAL INCLUDES
#if defined(DEBUG_ENABLED)
#include <sstream>
-#include <dali/internal/event/common/system-overlay-impl.h>
#endif // defined(DEBUG_ENABLED)
// INTERNAL INCLUDES
#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
output << actor.GetTypeName();
- output << ", " << actor.GetName();
+ output << ", " << actor.GetProperty< std::string >( Dali::Actor::Property::NAME );
- output << " - Pos: " << actor.GetCurrentPosition() << " Size: " << actor.GetTargetSize();
+ output << " - Pos: " << actor.GetCurrentProperty< Vector3 >( Dali::Actor::Property::POSITION ) << " Size: " << actor.GetTargetSize();
output << ", Dirty: (" << ( GetImplementation( actor ).IsLayoutDirty( Dimension::WIDTH ) ? "TRUE" : "FALSE" ) << "," << ( GetImplementation( actor ).IsLayoutDirty( Dimension::HEIGHT ) ? "TRUE" : "FALSE" ) << ")";
output << ", Negotiated: (" << ( GetImplementation( actor ).IsLayoutNegotiated( Dimension::WIDTH ) ? "TRUE" : "FALSE" ) << "," << ( GetImplementation( actor ).IsLayoutNegotiated( Dimension::HEIGHT ) ? "TRUE" : "FALSE" ) << ")";
DALI_LOG_INFO( gLogFilter, Debug::Verbose, output.str().c_str() );
++level;
- unsigned int numChildren = actor.GetChildCount();
- for( unsigned int i=0; i<numChildren; ++i )
+ uint32_t numChildren = actor.GetChildCount();
+ for( uint32_t i=0; i<numChildren; ++i )
{
PrintChildren( actor.GetChildAt(i), level );
}
if ( gLogFilter->IsEnabledFor( Debug::Verbose ) )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "---------- ROOT LAYER ----------\n" );
+
PrintChildren( Stage::GetCurrent()->GetRootLayer(), 0 );
}
}
mRelayoutInfoAllocator(),
mSlotDelegate( this ),
mRelayoutStack( new MemoryPoolRelayoutContainer( mRelayoutInfoAllocator ) ),
- mStageSize(), // zero initialized
mRelayoutConnection( false ),
mRelayoutFlag( false ),
mEnabled( false ),
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 )
+void RelayoutController::QueueActor( Internal::Actor* actor, RelayoutContainer& actors, Vector2 size )
{
- if( GetImplementation( actor ).RelayoutRequired() )
+ if( actor && actor->RelayoutRequired() )
{
- actors.Add( actor, size );
+ Dali::Actor actorHandle = Dali::Actor( actor );
+ actors.Add( actorHandle, size );
}
}
topOfSubTreeStack.push_back( actor );
// Propagate on all dimensions
- for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i )
+ for( uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i )
{
if( dimension & ( 1 << i ) )
{
}
// Remove any redundant sub-tree heads
- for( std::vector< Dali::Actor >::iterator it = potentialRedundantSubRoots.begin(), itEnd = potentialRedundantSubRoots.end(); it != itEnd; ++it )
+ for( auto& subRoot : potentialRedundantSubRoots )
{
- Dali::Actor subRoot = *it;
-
RemoveRequest( subRoot );
}
if ( !mProcessingCoreEvents )
{
- mRenderController.RequestProcessEventsOnIdle();
+ mRenderController.RequestProcessEventsOnIdle( false );
}
}
// Open relayout controller to receive relayout requests
mEnabled = true;
- // Spread the dirty flag through whole tree - don't need to explicity
- // add request on rootLayer as it will automatically be added below.
- 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();
}
}
// Propagate down to children
- for( unsigned int i = 0; i < actor.GetChildCount(); ++i )
+ for( uint32_t i = 0; i < actor.GetChildCount(); ++i )
{
Dali::Actor child = actor.GetChildAt( i );
// Check for dimension dependecy: width for height/height for width etc
// Check each possible dimension and see if it is dependent on the input one
- for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i )
+ for( uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i )
{
Dimension::Type dimensionToCheck = static_cast< Dimension::Type >( 1 << i );
{
// Store the highest parent reached
bool found = false;
- for( unsigned int i = 0, count = topOfSubTreeStack.size(); i < count; ++i )
+ for( auto&& element : topOfSubTreeStack )
{
- if( topOfSubTreeStack[ i ] == parent )
+ if( element == parent )
{
found = true;
break;
// Check for dimension dependecy: width for height/height for width etc
// Check each possible dimension and see if it is dependent on the input one
- for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i )
+ for( uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i )
{
Dimension::Type dimensionToCheck = static_cast< Dimension::Type >( 1 << i );
}
// Propagate down to children
- for( unsigned int i = 0, childCount = actor.GetChildCount(); i < childCount; ++i )
+ for( uint32_t i = 0, childCount = actor.GetChildCount(); i < childCount; ++i )
{
Dali::Actor child = actor.GetChildAt( i );
Actor& childImpl = GetImplementation( child );
void RelayoutController::AddRequest( Dali::Actor& actor )
{
- BaseObject* actorPtr = &GetImplementation( actor );
+ Internal::Actor* actorPtr = &GetImplementation( actor );
// Only add the rootActor if it is not already recorded
- bool found = false;
- for( unsigned int i = 0, count = mDirtyLayoutSubTrees.Size(); i < count; ++i )
- {
- if( mDirtyLayoutSubTrees[ i ] == actorPtr )
- {
- found = true;
- break;
- }
- }
+ auto itr = std::find( mDirtyLayoutSubTrees.begin(), mDirtyLayoutSubTrees.end(), actorPtr );
- if( !found )
+ if( itr == mDirtyLayoutSubTrees.end() )
{
mDirtyLayoutSubTrees.PushBack( actorPtr );
}
void RelayoutController::RemoveRequest( Dali::Actor& actor )
{
- BaseObject* actorPtr = &GetImplementation( actor );
+ Internal::Actor* actorPtr = &GetImplementation( actor );
- // Remove actor from dirty sub trees
- for( RawActorList::Iterator it = mDirtyLayoutSubTrees.Begin(), itEnd = mDirtyLayoutSubTrees.End(); it != itEnd; ++it )
- {
- if( *it == actorPtr )
- {
- mDirtyLayoutSubTrees.Erase( it );
- break;
- }
- }
+ mDirtyLayoutSubTrees.Erase( std::remove( mDirtyLayoutSubTrees.begin(),
+ mDirtyLayoutSubTrees.end(),
+ actorPtr ),
+ mDirtyLayoutSubTrees.end() );
}
void RelayoutController::Request()
if( !mRelayoutConnection )
{
- Dali::Stage stage = Dali::Stage::GetCurrent();
- stage.GetObjectRegistry().ObjectDestroyedSignal().Connect( mSlotDelegate, &RelayoutController::OnObjectDestroyed );
+ ThreadLocalStorage::Get().GetObjectRegistry().ObjectDestroyedSignal().Connect( mSlotDelegate, &RelayoutController::OnObjectDestroyed );
mRelayoutConnection = true;
}
// Clear the flag as we're now doing the relayout
mRelayoutFlag = false;
- // 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.
- for( RawActorList::Iterator it = mDirtyLayoutSubTrees.Begin(), itEnd = mDirtyLayoutSubTrees.End(); it != itEnd; ++it )
+ // 1. Finds all top-level controls from the dirty list and allocate them the size of the scene
+ // These controls are paired with the parent/scene size and added to the stack.
+ for( auto& dirtyActor : mDirtyLayoutSubTrees )
{
- BaseObject* dirtyActor = *it;
-
// Need to test if actor is valid (could have been deleted and had the pointer cleared)
if( dirtyActor )
{
- // We know that BaseObject is a base class of Internal::Actor but need to instruct the compiler to do the cast
- Dali::Actor actor = Dali::Actor( reinterpret_cast<Dali::Internal::Actor*>( dirtyActor ) );
-
- // Only negotiate actors that are on stage
- if( actor.OnStage() )
+ // Only negotiate actors that are on the scene
+ if( dirtyActor->OnScene() )
{
- Dali::Actor parent = actor.GetParent();
- QueueActor( actor, *mRelayoutStack, ( parent ) ? Vector2( parent.GetTargetSize() ) : mStageSize );
+ Internal::Actor* parent = dirtyActor->GetParent();
+ QueueActor( dirtyActor, *mRelayoutStack, ( parent ) ? Vector2( parent->GetTargetSize() ) : dirtyActor->GetScene().GetSize() );
}
}
}
if( actorImpl.RelayoutRequired() )
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "[Internal::RelayoutController::Relayout] Negotiating %p %s %s (%.2f, %.2f)\n", &actorImpl, actor.GetTypeName().c_str(), actor.GetName().c_str(), size.width, size.height );
+ DALI_LOG_INFO( gLogFilter, Debug::General, "[Internal::RelayoutController::Relayout] Negotiating %p %s %s (%.2f, %.2f)\n", &actorImpl, actor.GetTypeName().c_str(), actor.GetProperty< std::string >( Dali::Actor::Property::NAME ).c_str(), size.width, size.height );
// 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 );
}
}
void RelayoutController::FindAndZero( const RawActorList& list, const Dali::RefObject* object )
{
// Object has been destroyed so clear it from this list
- for( RawActorList::Iterator it = list.Begin(), itEnd = list.End(); it != itEnd; ++it )
+ for( auto& actor : list )
{
- BaseObject* actor = *it;
-
if( actor && ( actor == object ) )
{
- *it = NULL; // Reset the pointer in the list. We don't want to remove it in case something is iterating over the list.
+ actor = nullptr; // Reset the pointer in the list. We don't want to remove it in case something is iterating over the list.
}
}
}