Merge "Block the changeness of PreMultiplied for some visuals" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / control.cpp
index bf3d9cc..245bdd5 100644 (file)
-//
-// 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) 2022 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>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/controls/control/control-data-impl.h>
 #include <dali-toolkit/public-api/controls/control-impl.h>
 
 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()
 {
-  return ControlImpl::New();
+  return Toolkit::Internal::Control::New();
 }
 
-Control::Control()
+Control Control::New(ControlBehaviour additionalBehaviour)
 {
+  return Toolkit::Internal::Control::New(static_cast<Toolkit::Internal::Control::ControlBehaviour>(additionalBehaviour));
 }
 
-Control::Control(const Control& uiControl)
-: CustomActor( uiControl ? static_cast<const ControlImpl&>( uiControl.GetImplementation() ).GetOwner() : NULL)
+Control::Control()
 {
 }
 
-Control::~Control()
-{
-}
+Control::Control(const Control& uiControl) = default;
 
-Control& Control::operator=( const Control& handle )
-{
-  if( &handle != this )
-  {
-    CustomActor::operator=( handle );
-  }
-  return *this;
-}
+Control::Control(Control&& rhs) = default;
 
-Control Control::DownCast( BaseHandle handle )
+Control::~Control()
 {
-  return DownCast<Control, ControlImpl>(handle);
 }
 
-ControlImpl& Control::GetImplementation()
-{
-  return static_cast<ControlImpl&>(CustomActor::GetImplementation());
-}
+Control& Control::operator=(const Control& handle) = default;
 
-const ControlImpl& Control::GetImplementation() const
-{
-  return static_cast<const ControlImpl&>(CustomActor::GetImplementation());
-}
+Control& Control::operator=(Control&& rhs) = default;
 
-void Control::SetSizePolicy( SizePolicy widthPolicy, SizePolicy heightPolicy )
+Control Control::DownCast(BaseHandle handle)
 {
-  GetImplementation().SetSizePolicy( widthPolicy, heightPolicy );
+  return DownCast<Control, Internal::Control>(handle);
 }
 
-void Control::GetSizePolicy( SizePolicy& widthPolicy, SizePolicy& heightPolicy ) const
+void Control::SetKeyInputFocus()
 {
-  GetImplementation().GetSizePolicy( widthPolicy, heightPolicy );
+  Internal::GetImplementation(*this).SetKeyInputFocus();
 }
 
-void Control::SetMinimumSize( const Vector3& size )
+bool Control::HasKeyInputFocus()
 {
-  GetImplementation().SetMinimumSize( size );
+  return Internal::GetImplementation(*this).HasKeyInputFocus();
 }
 
-const Vector3& Control::GetMinimumSize() const
+void Control::ClearKeyInputFocus()
 {
-  return GetImplementation().GetMinimumSize();
+  Internal::GetImplementation(*this).ClearKeyInputFocus();
 }
 
-void Control::SetMaximumSize( const Vector3& size )
+PinchGestureDetector Control::GetPinchGestureDetector() const
 {
-  GetImplementation().SetMaximumSize( size );
+  return Internal::GetImplementation(*this).GetPinchGestureDetector();
 }
 
-const Vector3& Control::GetMaximumSize() const
+PanGestureDetector Control::GetPanGestureDetector() const
 {
-  return GetImplementation().GetMaximumSize();
+  return Internal::GetImplementation(*this).GetPanGestureDetector();
 }
 
-Vector3 Control::GetNaturalSize()
+TapGestureDetector Control::GetTapGestureDetector() const
 {
-  return GetImplementation().GetNaturalSize();
+  return Internal::GetImplementation(*this).GetTapGestureDetector();
 }
 
-float Control::GetHeightForWidth( float width )
+LongPressGestureDetector Control::GetLongPressGestureDetector() const
 {
-  return GetImplementation().GetHeightForWidth( width );
+  return Internal::GetImplementation(*this).GetLongPressGestureDetector();
 }
 
-float Control::GetWidthForHeight( float height )
+void Control::SetStyleName(const std::string& styleName)
 {
-  return GetImplementation().GetWidthForHeight( height );
+  Internal::GetImplementation(*this).SetStyleName(styleName);
 }
 
-void Control::SetKeyInputFocus()
+const std::string& Control::GetStyleName() const
 {
-  GetImplementation().SetKeyInputFocus();
+  return Internal::GetImplementation(*this).GetStyleName();
 }
 
-bool Control::HasKeyInputFocus()
+void Control::SetBackgroundColor(const Vector4& color)
 {
-  return GetImplementation().HasKeyInputFocus();
+  Internal::GetImplementation(*this).SetBackgroundColor(color);
 }
 
-void Control::ClearKeyInputFocus()
+void Control::ClearBackground()
 {
-  GetImplementation().ClearKeyInputFocus();
+  Internal::GetImplementation(*this).ClearBackground();
 }
 
-PinchGestureDetector Control::GetPinchGestureDetector() const
+bool Control::IsResourceReady() const
 {
-  return GetImplementation().GetPinchGestureDetector();
-}
+  const Internal::Control&       internalControl = Toolkit::Internal::GetImplementation(*this);
+  const Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(internalControl);
 
-PanGestureDetector Control::GetPanGestureDetector() const
-{
-  return GetImplementation().GetPanGestureDetector();
+  return controlDataImpl.IsResourceReady();
 }
 
-TapGestureDetector Control::GetTapGestureDetector() const
+Toolkit::Visual::ResourceStatus Control::GetVisualResourceStatus(Dali::Property::Index index)
 {
-  return GetImplementation().GetTapGestureDetector();
+  const Internal::Control&       internalControl = Toolkit::Internal::GetImplementation(*this);
+  const Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(internalControl);
+  return controlDataImpl.GetVisualResourceStatus(index);
 }
 
-LongPressGestureDetector Control::GetLongPressGestureDetector() const
+Control::KeyEventSignalType& Control::KeyEventSignal()
 {
-  return GetImplementation().GetLongPressGestureDetector();
+  return Internal::GetImplementation(*this).KeyEventSignal();
 }
 
-Control::KeyEventSignalV2& Control::KeyEventSignal()
+Control::KeyInputFocusSignalType& Control::KeyInputFocusGainedSignal()
 {
-  return GetImplementation().KeyEventSignal();
+  return Internal::GetImplementation(*this).KeyInputFocusGainedSignal();
 }
 
-/**
- * @copydoc ConnectionTrackerInterface::SignalConnected
- */
-void Control::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
+Control::KeyInputFocusSignalType& Control::KeyInputFocusLostSignal()
 {
-  GetImplementation().SignalConnected(slotObserver, callback );
+  return Internal::GetImplementation(*this).KeyInputFocusLostSignal();
 }
 
-/**
- * @copydoc ConnectionTrackerInterface::SignalDisconnected
- */
-void Control::SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback )
+Control::ResourceReadySignalType& Control::ResourceReadySignal()
 {
-  GetImplementation().SignalDisconnected(slotObserver, callback );
-}
+  Internal::Control&       internalControl = Toolkit::Internal::GetImplementation(*this);
+  Internal::Control::Impl& controlImpl     = Internal::Control::Impl::Get(internalControl);
 
-/**
- * @copydoc ConnectionTrackerInterface::GetConnectionCount
- */
-std::size_t Control::GetConnectionCount() const
-{
-  return GetImplementation().GetConnectionCount( );
+  return controlImpl.mResourceReadySignal;
 }
 
-
-Control::Control(ControlImpl& implementation)
+Control::Control(Internal::Control& implementation)
 : CustomActor(implementation)
 {
 }
@@ -186,7 +161,7 @@ Control::Control(ControlImpl& implementation)
 Control::Control(Dali::Internal::CustomActor* internal)
 : CustomActor(internal)
 {
-  VerifyCustomActorPointer<ControlImpl>(internal);
+  VerifyCustomActorPointer<Internal::Control>(internal);
 }
 
 } // namespace Toolkit