From: Adeel Kazmi Date: Mon, 2 Oct 2017 16:06:58 +0000 (+0100) Subject: (Control) Moved Resource Loading related APIs from Devel to Public X-Git-Tag: dali_1.2.60~12 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=8cd51ee7d23a0981aaacfae27cf39d4c80c898cf (Control) Moved Resource Loading related APIs from Devel to Public Change-Id: I47101c0bebf08c2071dada94fd1f364e5a002c89 --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp index 4d4a35e..9ba1bcf 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp @@ -836,7 +836,7 @@ int UtcDaliControlResourcesReady(void) actor.SetSize( 200.f, 200.f ); DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelControl::IsResourceReady( actor ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.IsResourceReady(), false, TEST_LOCATION ); Stage::GetCurrent().Add( actor ); application.SendNotification(); @@ -848,7 +848,7 @@ int UtcDaliControlResourcesReady(void) application.Render(); DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelControl::IsResourceReady( actor ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.IsResourceReady(), true, TEST_LOCATION ); Visual::Base largeVisual = factory.CreateVisual( propertyMapLarge ); largeVisual.SetName("largeVisual"); @@ -862,7 +862,7 @@ int UtcDaliControlResourcesReady(void) application.Render(); DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelControl::IsResourceReady( actor ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.IsResourceReady(), true, TEST_LOCATION ); END_TEST; } diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp index bac289e..894bad0 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp @@ -880,9 +880,9 @@ int UtcDaliImageViewCheckResourceReady(void) imageView.SetBackgroundImage( image ); - DALI_TEST_EQUALS( Toolkit::DevelControl::IsResourceReady( imageView ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION ); - Toolkit::DevelControl::ResourceReadySignal( imageView ).Connect( &ResourceReadySignal); + imageView.ResourceReadySignal().Connect( &ResourceReadySignal); Stage::GetCurrent().Add( imageView ); @@ -890,7 +890,7 @@ int UtcDaliImageViewCheckResourceReady(void) application.Render(16); - DALI_TEST_EQUALS( Toolkit::DevelControl::IsResourceReady( imageView ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION ); DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION ); @@ -1347,9 +1347,9 @@ int UtcDaliImageViewReplaceImage(void) // Check ImageView with background and main image, to ensure both visuals are marked as loaded ImageView imageView = ImageView::New( TEST_IMAGE_1 ); - DALI_TEST_EQUALS( Toolkit::DevelControl::IsResourceReady( imageView ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION ); - Toolkit::DevelControl::ResourceReadySignal( imageView ).Connect( &ResourceReadySignal); + imageView.ResourceReadySignal().Connect( &ResourceReadySignal); Stage::GetCurrent().Add( imageView ); @@ -1375,7 +1375,7 @@ int UtcDaliImageViewReplaceImage(void) DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( Toolkit::DevelControl::IsResourceReady( imageView ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION ); DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp index 2d846e7..a743793 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp @@ -1055,7 +1055,7 @@ int UtcDaliImageVisualAlphaMask(void) actor.SetSize( 200.f, 200.f ); DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelControl::IsResourceReady( actor ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.IsResourceReady(), false, TEST_LOCATION ); Stage::GetCurrent().Add( actor ); application.SendNotification(); @@ -1068,7 +1068,7 @@ int UtcDaliImageVisualAlphaMask(void) DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelControl::IsResourceReady( actor ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.IsResourceReady(), true, TEST_LOCATION ); END_TEST; } @@ -1105,7 +1105,7 @@ int UtcDaliImageVisualRemoteAlphaMask(void) DummyControl actor = DummyControl::New(); DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual ); - DALI_TEST_EQUALS( DevelControl::IsResourceReady( actor ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.IsResourceReady(), false, TEST_LOCATION ); actor.SetSize( 200.f, 200.f ); DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); @@ -1121,7 +1121,7 @@ int UtcDaliImageVisualRemoteAlphaMask(void) DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelControl::IsResourceReady( actor ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.IsResourceReady(), true, TEST_LOCATION ); END_TEST; } @@ -1164,7 +1164,7 @@ int UtcDaliImageVisualAlphaMaskCrop(void) actor.SetSize( 200.f, 200.f ); DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelControl::IsResourceReady( actor ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.IsResourceReady(), false, TEST_LOCATION ); Stage::GetCurrent().Add( actor ); application.SendNotification(); @@ -1181,7 +1181,7 @@ int UtcDaliImageVisualAlphaMaskCrop(void) DALI_TEST_EQUALS( size, Vector2( 100.0f, 100.0f ), 0.001f, TEST_LOCATION ); DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelControl::IsResourceReady( actor ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.IsResourceReady(), true, TEST_LOCATION ); END_TEST; } diff --git a/dali-toolkit/devel-api/controls/control-devel.cpp b/dali-toolkit/devel-api/controls/control-devel.cpp index 58b76f3..1276e1e 100644 --- a/dali-toolkit/devel-api/controls/control-devel.cpp +++ b/dali-toolkit/devel-api/controls/control-devel.cpp @@ -35,22 +35,6 @@ namespace Toolkit namespace DevelControl { -ResourceReadySignalType& ResourceReadySignal( Control& control ) -{ - Internal::Control& internalControl = Toolkit::Internal::GetImplementation(control); - Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( internalControl ); - - return controlImpl.mResourceReadySignal; -} - -bool IsResourceReady( const Control& control ) -{ - const Internal::Control& internalControl = Toolkit::Internal::GetImplementation(control); - const Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( internalControl ); - - return controlDataImpl.IsResourceReady(); -} - void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual ) { Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( control ); diff --git a/dali-toolkit/devel-api/controls/control-devel.h b/dali-toolkit/devel-api/controls/control-devel.h index eb58f91..2d20ee2 100644 --- a/dali-toolkit/devel-api/controls/control-devel.h +++ b/dali-toolkit/devel-api/controls/control-devel.h @@ -115,31 +115,6 @@ enum } // namespace Property -/// @brief ResourceReady signal type; -typedef Signal ResourceReadySignalType; - -/** - * @brief This signal is emitted after all resources required - * by a control are loaded and ready. - * Most resources are only loaded when the control is placed on stage. - * - * @note A RelayoutRequest is queued by Control before this signal is emitted - * - * A callback of the following type may be connected: - * @code - * void YourCallbackName( Control control ); - * @endcode - */ -DALI_IMPORT_API ResourceReadySignalType& ResourceReadySignal( Control& control ); - -/** - * @brief Query if all resources required by a control are loaded and ready. - * Most resources are only loaded when the control is placed on stage. - * @return true if the resources are loaded and ready, false otherwise - * - */ -DALI_IMPORT_API bool IsResourceReady( const Control& control ); - /** * @brief Register a visual by Property Index. * diff --git a/dali-toolkit/internal/controls/control/control-data-impl.h b/dali-toolkit/internal/controls/control/control-data-impl.h index 73c4626..dc00d60 100644 --- a/dali-toolkit/internal/controls/control/control-data-impl.h +++ b/dali-toolkit/internal/controls/control/control-data-impl.h @@ -322,8 +322,7 @@ public: Toolkit::Control::KeyEventSignalType mKeyEventSignal; Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusGainedSignal; Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusLostSignal; - - Toolkit::DevelControl::ResourceReadySignalType mResourceReadySignal; + Toolkit::Control::ResourceReadySignalType mResourceReadySignal; // Gesture Detection PinchGestureDetector mPinchGestureDetector; diff --git a/dali-toolkit/internal/controls/image-view/image-view-impl.cpp b/dali-toolkit/internal/controls/image-view/image-view-impl.cpp index 72faf14..fadd921 100644 --- a/dali-toolkit/internal/controls/image-view/image-view-impl.cpp +++ b/dali-toolkit/internal/controls/image-view/image-view-impl.cpp @@ -91,7 +91,7 @@ void ImageView::OnInitialize() { // ImageView can relayout in the OnImageReady, alternative to a signal would be to have a upcall from the Control to ImageView Dali::Toolkit::Control handle( GetOwner() ); - Toolkit::DevelControl::ResourceReadySignal( handle ).Connect( this, &ImageView::OnResourceReady ); + handle.ResourceReadySignal().Connect( this, &ImageView::OnResourceReady ); } void ImageView::SetImage( Image image ) diff --git a/dali-toolkit/public-api/controls/control.cpp b/dali-toolkit/public-api/controls/control.cpp index b882c1d..5d28b91 100644 --- a/dali-toolkit/public-api/controls/control.cpp +++ b/dali-toolkit/public-api/controls/control.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -23,6 +23,7 @@ // INTERNAL INCLUDES #include +#include namespace Dali { @@ -131,6 +132,14 @@ void Control::ClearBackground() Internal::GetImplementation(*this).ClearBackground(); } +bool Control::IsResourceReady() const +{ + const Internal::Control& internalControl = Toolkit::Internal::GetImplementation( *this ); + const Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( internalControl ); + + return controlDataImpl.IsResourceReady(); +} + Control::KeyEventSignalType& Control::KeyEventSignal() { return Internal::GetImplementation(*this).KeyEventSignal(); @@ -146,6 +155,14 @@ Control::KeyInputFocusSignalType& Control::KeyInputFocusLostSignal() return Internal::GetImplementation(*this).KeyInputFocusLostSignal(); } +Control::ResourceReadySignalType& Control::ResourceReadySignal() +{ + Internal::Control& internalControl = Toolkit::Internal::GetImplementation( *this ); + Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( internalControl ); + + return controlImpl.mResourceReadySignal; +} + Control::Control(Internal::Control& implementation) : CustomActor(implementation) { diff --git a/dali-toolkit/public-api/controls/control.h b/dali-toolkit/public-api/controls/control.h index cd72a0f..c68d41a 100644 --- a/dali-toolkit/public-api/controls/control.h +++ b/dali-toolkit/public-api/controls/control.h @@ -2,7 +2,7 @@ #define __DALI_TOOLKIT_CONTROL_H__ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -58,6 +58,7 @@ class Control; * | keyEvent | @ref KeyEventSignal() | * | keyInputFocusGained | @ref KeyInputFocusGainedSignal() | * | keyInputFocusLost | @ref KeyInputFocusLostSignal() | + * | resourceReady | @ref ResourceReadySignal() | * | tapped | @ref GetTapGestureDetector().DetectedSignal() | * | panned | @ref GetPanGestureDetector().DetectedSignal() | * | pinched | @ref GetPinchGestureDetector().DetectedSignal() | @@ -151,12 +152,15 @@ public: // Typedefs - /// @brief Key Event signal type; + /// @brief Key Event signal type. @SINCE_1_0.0 typedef Signal KeyEventSignalType; - /// @brief Key InputFocusType signal type; + /// @brief Key InputFocusType signal type. @SINCE_1_0.0 typedef Signal KeyInputFocusSignalType; + /// @brief ResourceReady signal type. @SINCE_1_2.60 + typedef Signal ResourceReadySignalType; + public: // Creation & Destruction /** @@ -350,6 +354,17 @@ public: */ void ClearBackground(); + // Resources + + /** + * @brief Query if all resources required by a control are loaded and ready. + * + * Most resources are only loaded when the control is placed on stage. + * @SINCE_1_2.60 + * @return true if the resources are loaded and ready, false otherwise + */ + bool IsResourceReady() const; + // Signals /** @@ -383,8 +398,9 @@ public: KeyInputFocusSignalType& KeyInputFocusGainedSignal(); /** - * @brief This signal is emitted when the control loses Key Input Focus - * which could be due to it being gained by another Control or Actor or just cleared from + * @brief This signal is emitted when the control loses Key Input Focus. + * + * This could be due to it being gained by another Control or Actor or just cleared from * this control as no longer required. * * A callback of the following type may be connected: @@ -399,6 +415,21 @@ public: */ KeyInputFocusSignalType& KeyInputFocusLostSignal(); + /** + * @brief This signal is emitted after all resources required by a control are loaded and ready. + * + * Most resources are only loaded when the control is placed on stage. + * + * A callback of the following type may be connected: + * @code + * void YourCallbackName( Control control ); + * @endcode + * + * @SINCE_1_2.60 + * @note A RelayoutRequest is queued by Control before this signal is emitted + */ + ResourceReadySignalType& ResourceReadySignal(); + public: // Intended for control developers /**