Control::UnregisterVisual does not remove renderers from actor
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / control.cpp
index 8652f1a..18eaeeb 100644 (file)
@@ -1,20 +1,24 @@
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
 
+// CLASS HEADER
 #include <dali-toolkit/public-api/controls/control.h>
+
+// INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/control-impl.h>
 
 namespace Dali
@@ -23,30 +27,17 @@ namespace Dali
 namespace Toolkit
 {
 
-const char* const Control::ACTION_CONTROL_ACTIVATED = "control-activated";
-const char* const Control::SIGNAL_KEY_EVENT = "key-event";
-
 Control Control::New()
 {
-  // Use TypeRegistry to create instance of control so that the type-info matches Control rather than ControlImpl
-  TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(Control) );
-  DALI_ASSERT_ALWAYS( typeInfo && "TypeRegistry returning Invalid TypeInfo" );
-
-  BaseHandle handle = typeInfo.CreateInstance();
-  DALI_ASSERT_ALWAYS( handle && "Unable to Create Control" );
-
-  Control control = DownCast( handle );
-  DALI_ASSERT_ALWAYS( handle && "TypeRegistry did not create a Control" );
-
-  return control;
+  return Internal::Control::New();
 }
 
 Control::Control()
 {
 }
 
-Control::Control(const Control& uiControl)
-: CustomActor( uiControl ? static_cast<const ControlImpl&>( uiControl.GetImplementation() ).GetOwner() : NULL)
+Control::Control( const Control& uiControl )
+: CustomActor( uiControl  )
 {
 }
 
@@ -65,155 +56,90 @@ Control& Control::operator=( const Control& handle )
 
 Control Control::DownCast( BaseHandle handle )
 {
-  return DownCast<Control, ControlImpl>(handle);
-}
-
-ControlImpl& Control::GetImplementation()
-{
-  return static_cast<ControlImpl&>(CustomActor::GetImplementation());
-}
-
-const ControlImpl& Control::GetImplementation() const
-{
-  return static_cast<const ControlImpl&>(CustomActor::GetImplementation());
-}
-
-void Control::SetSizePolicy( SizePolicy widthPolicy, SizePolicy heightPolicy )
-{
-  GetImplementation().SetSizePolicy( widthPolicy, heightPolicy );
-}
-
-void Control::GetSizePolicy( SizePolicy& widthPolicy, SizePolicy& heightPolicy ) const
-{
-  GetImplementation().GetSizePolicy( widthPolicy, heightPolicy );
-}
-
-void Control::SetMinimumSize( const Vector3& size )
-{
-  GetImplementation().SetMinimumSize( size );
-}
-
-const Vector3& Control::GetMinimumSize() const
-{
-  return GetImplementation().GetMinimumSize();
-}
-
-void Control::SetMaximumSize( const Vector3& size )
-{
-  GetImplementation().SetMaximumSize( size );
-}
-
-const Vector3& Control::GetMaximumSize() const
-{
-  return GetImplementation().GetMaximumSize();
-}
-
-Vector3 Control::GetNaturalSize()
-{
-  return GetImplementation().GetNaturalSize();
-}
-
-float Control::GetHeightForWidth( float width )
-{
-  return GetImplementation().GetHeightForWidth( width );
-}
-
-float Control::GetWidthForHeight( float height )
-{
-  return GetImplementation().GetWidthForHeight( height );
+  return DownCast< Control, Internal::Control >(handle);
 }
 
 void Control::SetKeyInputFocus()
 {
-  GetImplementation().SetKeyInputFocus();
+  Internal::GetImplementation(*this).SetKeyInputFocus();
 }
 
 bool Control::HasKeyInputFocus()
 {
-  return GetImplementation().HasKeyInputFocus();
+  return Internal::GetImplementation(*this).HasKeyInputFocus();
 }
 
 void Control::ClearKeyInputFocus()
 {
-  GetImplementation().ClearKeyInputFocus();
+  Internal::GetImplementation(*this).ClearKeyInputFocus();
 }
 
 PinchGestureDetector Control::GetPinchGestureDetector() const
 {
-  return GetImplementation().GetPinchGestureDetector();
+  return Internal::GetImplementation(*this).GetPinchGestureDetector();
 }
 
 PanGestureDetector Control::GetPanGestureDetector() const
 {
-  return GetImplementation().GetPanGestureDetector();
+  return Internal::GetImplementation(*this).GetPanGestureDetector();
 }
 
 TapGestureDetector Control::GetTapGestureDetector() const
 {
-  return GetImplementation().GetTapGestureDetector();
+  return Internal::GetImplementation(*this).GetTapGestureDetector();
 }
 
 LongPressGestureDetector Control::GetLongPressGestureDetector() const
 {
-  return GetImplementation().GetLongPressGestureDetector();
+  return Internal::GetImplementation(*this).GetLongPressGestureDetector();
 }
 
-void Control::SetBackgroundColor( const Vector4& color )
+void Control::SetStyleName( const std::string& styleName )
 {
-  GetImplementation().SetBackgroundColor( color );
+  Internal::GetImplementation(*this).SetStyleName( styleName );
 }
 
-Vector4 Control::GetBackgroundColor() const
+const std::string& Control::GetStyleName() const
 {
-  return GetImplementation().GetBackgroundColor();
+  return Internal::GetImplementation(*this).GetStyleName();
 }
 
-void Control::SetBackground( Image image )
+void Control::SetBackgroundColor( const Vector4& color )
 {
-  GetImplementation().SetBackground( image );
+  Internal::GetImplementation(*this).SetBackgroundColor( color );
 }
 
-void Control::ClearBackground()
+Vector4 Control::GetBackgroundColor() const
 {
-  GetImplementation().ClearBackground();
+  return Internal::GetImplementation(*this).GetBackgroundColor();
 }
 
-Actor Control::GetBackgroundActor() const
+void Control::SetBackgroundImage( Image image )
 {
-  return GetImplementation().GetBackgroundActor();
+  Internal::GetImplementation(*this).SetBackgroundImage( image );
 }
 
-Control::KeyEventSignalV2& Control::KeyEventSignal()
+void Control::ClearBackground()
 {
-  return GetImplementation().KeyEventSignal();
+  Internal::GetImplementation(*this).ClearBackground();
 }
 
-/**
- * @copydoc ConnectionTrackerInterface::SignalConnected
- */
-void Control::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
+Control::KeyEventSignalType& Control::KeyEventSignal()
 {
-  GetImplementation().SignalConnected(slotObserver, callback );
+  return Internal::GetImplementation(*this).KeyEventSignal();
 }
 
-/**
- * @copydoc ConnectionTrackerInterface::SignalDisconnected
- */
-void Control::SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback )
+Control::KeyInputFocusSignalType& Control::KeyInputFocusGainedSignal()
 {
-  GetImplementation().SignalDisconnected(slotObserver, callback );
+  return Internal::GetImplementation(*this).KeyInputFocusGainedSignal();
 }
 
-/**
- * @copydoc ConnectionTrackerInterface::GetConnectionCount
- */
-std::size_t Control::GetConnectionCount() const
+Control::KeyInputFocusSignalType& Control::KeyInputFocusLostSignal()
 {
-  return GetImplementation().GetConnectionCount( );
+  return Internal::GetImplementation(*this).KeyInputFocusLostSignal();
 }
 
-
-Control::Control(ControlImpl& implementation)
+Control::Control(Internal::Control& implementation)
 : CustomActor(implementation)
 {
 }
@@ -221,7 +147,7 @@ Control::Control(ControlImpl& implementation)
 Control::Control(Dali::Internal::CustomActor* internal)
 : CustomActor(internal)
 {
-  VerifyCustomActorPointer<ControlImpl>(internal);
+  VerifyCustomActorPointer<Internal::Control>(internal);
 }
 
 } // namespace Toolkit