2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/event/events/actor-observer.h>
20 #include <dali/integration-api/debug.h>
21 #include <dali/internal/event/actors/actor-impl.h>
31 #if defined(DEBUG_ENABLED)
32 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ACTOR_OBSERVER" );
33 #endif // defined(DEBUG_ENABLED)
36 ActorObserver::ActorObserver()
38 mActorDisconnected(false)
40 DALI_LOG_TRACE_METHOD( gLogFilter );
43 ActorObserver::~ActorObserver()
45 DALI_LOG_TRACE_METHOD( gLogFilter );
49 Actor* ActorObserver::GetActor()
51 return mActorDisconnected ? NULL : mActor;
54 void ActorObserver::SetActor( Actor* actor )
56 DALI_LOG_TRACE_METHOD( gLogFilter );
58 if ( mActor != actor )
66 mActor->AddObserver( *this );
67 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Start Observing: %p\n", mActor);
71 // Make sure this flag is unset (as we may have been disconnected if it's the same actor)
72 mActorDisconnected = false;
75 void ActorObserver::ResetActor()
79 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Stop Observing: %p\n", mActor);
80 mActor->RemoveObserver( *this );
82 mActorDisconnected = false;
86 void ActorObserver::SceneObjectRemoved( ProxyObject& proxy )
88 DALI_LOG_TRACE_METHOD( gLogFilter );
90 if ( mActor == &proxy )
92 // do not call proxy.RemoveObserver here, proxy is currently iterating through observers... you wouldnt want to upset proxy now would you?
93 mActorDisconnected = true;
97 void ActorObserver::ProxyDestroyed(ProxyObject& proxy)
99 DALI_LOG_TRACE_METHOD( gLogFilter );
101 if ( mActor == &proxy )
103 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Stop Observing: %p\n", mActor);
108 } // namespace Internal