for disabled visuals, ResourceReady is not called.
Change-Id: I9864cde4bffeb1eab5c11812f6911c1772692a4a
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
namespace
{
static bool gOnRelayoutCallBackCalled = false;
-void OnRelayoutCallback(Actor actor)
+void OnRelayoutCallback(Actor actor)
{
gOnRelayoutCallBackCalled = true;
}
static bool gResourceReadyCalled = false;
-void OnResourceReady(Control control)
+void OnResourceReady(Control control)
{
gResourceReadyCalled = true;
}
-}
+} // namespace
int UtcDaliControlImplResourceReady(void)
{
ToolkitTestApplication application;
gOnRelayoutCallBackCalled = false;
- gResourceReadyCalled = false;
- Control control = Control::New();
+ gResourceReadyCalled = false;
+ Control control = Control::New();
control.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
control.OnRelayoutSignal().Connect(OnRelayoutCallback);
// ResourceReady is true when there is no visual in the default Toolkit::Internal::Control.
DALI_TEST_EQUALS(impl.IsResourceReady(), true, TEST_LOCATION);
DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
- impl.SetResourceReady(false);
+ impl.SetResourceReady();
DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
application.SendNotification();
DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION);
gResourceReadyCalled = false;
DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
- impl.SetResourceReady(true);
+ impl.SetResourceReady();
DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
+ DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION);
END_TEST;
}
END_TEST;
}
-int UtcDaliImageViewPlaceholderImage(void)
+int UtcDaliImageViewPlaceholderImage01(void)
{
tet_infoline("Test imageView use placeholder image");
END_TEST;
}
+int UtcDaliImageViewPlaceholderImage02(void)
+{
+ tet_infoline("Test imageView use placeholder image without resource ready");
+
+ ToolkitTestApplication application;
+
+ Property::Map map;
+ map[Toolkit::ImageVisual::Property::URL] = gImage_600_RGB;
+
+ ImageView imageView = ImageView::New();
+ imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
+ imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
+ DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
+ imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
+ application.GetScene().Add(imageView);
+
+ Property::Value value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
+ std::string url;
+ DALI_TEST_CHECK(value.Get(url));
+ DALI_TEST_CHECK(url.empty());
+
+ imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ value = imageView.GetProperty(ImageView::Property::PLACEHOLDER_IMAGE);
+ DALI_TEST_CHECK(value.Get(url));
+ DALI_TEST_CHECK(url == gImage_34_RGBA);
+
+ DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
+
+ gResourceReadySignalFired = false;
+ map[Toolkit::ImageVisual::Property::URL] = "";
+ imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(gResourceReadySignalFired, false, TEST_LOCATION);
+
+ END_TEST;
+}
+
int UtcDaliImageViewTransitionEffect01(void)
{
tet_infoline("Test imageView use transition effect");
// Ensure texture has been uploaded
DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
- DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
+ DALI_TEST_EQUALS(gResourceReadySignalFired, false, TEST_LOCATION);
END_TEST;
}
tet_infoline("Testing texture is loaded and resource ready signal fired");
DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
- DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
+ DALI_TEST_EQUALS(gResourceReadySignalFired, false, TEST_LOCATION);
tet_infoline("Original control correctly signalled, now testing for signal with new Control reusing the image");
Dali::Scene3D::Loader::ResourceBundle& resources, const Dali::Scene3D::Loader::SceneDefinition& scene, Actor root, std::vector<Dali::Scene3D::Loader::BlendshapeShaderConfigurationRequest>&& requests)
{
std::vector<std::string> errors;
- auto onError = [&errors](const std::string& msg)
- { errors.push_back(msg); };
+ auto onError = [&errors](const std::string& msg) { errors.push_back(msg); };
if(!scene.ConfigureBlendshapeShaders(resources, root, std::move(requests), onError))
{
Dali::Scene3D::Loader::ExceptionFlinger flinger(ASSERT_LOCATION);
{
return;
}
- Control::SetResourceReady(false);
+ Control::SetResourceReady();
}
void Model::CreateModel()
mAnimations.clear();
if(!mModelLoadTask->GetAnimations().empty())
{
- auto getActor = [&](const Scene3D::Loader::AnimatedProperty& property)
- {
+ auto getActor = [&](const Scene3D::Loader::AnimatedProperty& property) {
if(property.mNodeIndex == Scene3D::Loader::INVALID_INDEX)
{
return mModelRoot.FindChildByName(property.mNodeName);
// If diffuse and specular textures are already loaded, emits resource ready signal here.
if(IsResourceReady())
{
- Control::SetResourceReady(false);
+ Control::SetResourceReady();
}
}
if(IsResourceReady())
{
- Control::SetResourceReady(false);
+ Control::SetResourceReady();
}
}
mSkyboxResourceReady = true;
if(IsResourceReady())
{
- Control::SetResourceReady(false);
+ Control::SetResourceReady();
}
mSkyboxTexture = mSkyboxLoadTask->GetLoadedTexture();
NotifyImageBasedLightTextureChange();
if(IsResourceReady())
{
- Control::SetResourceReady(false);
+ Control::SetResourceReady();
}
}
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
/**
* Finds visual in given array, returning true if found along with the iterator for that visual as a out parameter
*/
-bool FindVisual(const Toolkit::Visual::Base findVisual , const RegisteredVisualContainer& visuals, RegisteredVisualContainer::Iterator& iter)
+bool FindVisual(const Toolkit::Visual::Base findVisual, const RegisteredVisualContainer& visuals, RegisteredVisualContainer::Iterator& iter)
{
for(iter = visuals.Begin(); iter != visuals.End(); iter++)
{
return false;
}
+/**
+ * Finds internal visual in given array, returning true if found along with the iterator for that visual as a out parameter
+ */
+bool FindVisual(const Visual::Base& findInternalVisual, const RegisteredVisualContainer& visuals, RegisteredVisualContainer::Iterator& iter)
+{
+ for(iter = visuals.Begin(); iter != visuals.End(); iter++)
+ {
+ Visual::Base& visual = Toolkit::GetImplementation((*iter)->visual);
+ if((&visual == &findInternalVisual))
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
void FindChangableVisuals(Dictionary<Property::Map>& stateVisualsToAdd,
Dictionary<Property::Map>& stateVisualsToChange,
DictionaryKeys& stateVisualsToRemove)
{
visualImpl.SetOnScene(self);
}
- else if(visualImpl.IsResourceReady()) // When not being staged, check if visual already 'ResourceReady' before it was Registered. ( Resource may have been loaded already )
+ else if(enabled && visualImpl.IsResourceReady()) // When not being staged, check if visual already 'ResourceReady' before it was Registered. ( Resource may have been loaded already )
{
ResourceReady(visualImpl);
}
return;
}
- (*iter)->overideReadyTransition = enable;
+ (*iter)->overideReadyTransition = enable;
}
}
visualImpl.AddEventObserver(*this);
}
-void Control::Impl::ResourceReady(bool relayoutRequest)
+void Control::Impl::ResourceReady()
{
- Actor self = mControlImpl.Self();
- // A visual is ready so control may need relayouting if staged
- if(relayoutRequest && self.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE))
- {
- mControlImpl.RelayoutRequest();
- }
-
// Emit signal if all enabled visuals registered by the control are ready or there are no visuals.
if(IsResourceReady())
{
Actor self = mControlImpl.Self();
+ RegisteredVisualContainer::Iterator registeredIter;
+
// A resource is ready, find resource in the registered visuals container and get its index
- for(auto registeredIter = mVisuals.Begin(), end = mVisuals.End(); registeredIter != end; ++registeredIter)
+ if(!FindVisual(object, mVisuals, registeredIter))
{
- Internal::Visual::Base& registeredVisualImpl = Toolkit::GetImplementation((*registeredIter)->visual);
+ return;
+ }
- if(&object == ®isteredVisualImpl)
+ RegisteredVisualContainer::Iterator visualToRemoveIter;
+ // Find visual with the same index in the removal container
+ // Set if off stage as it's replacement is now ready.
+ // Remove if from removal list as now removed from stage.
+ // Set Pending flag on the ready visual to false as now ready.
+ if(FindVisual((*registeredIter)->index, mRemoveVisuals, visualToRemoveIter))
+ {
+ (*registeredIter)->pending = false;
+ if(!((*visualToRemoveIter)->overideReadyTransition))
{
- RegisteredVisualContainer::Iterator visualToRemoveIter;
- // Find visual with the same index in the removal container
- // Set if off stage as it's replacement is now ready.
- // Remove if from removal list as now removed from stage.
- // Set Pending flag on the ready visual to false as now ready.
- if(FindVisual((*registeredIter)->index, mRemoveVisuals, visualToRemoveIter))
- {
- (*registeredIter)->pending = false;
- if(!((*visualToRemoveIter)->overideReadyTransition))
- {
- Toolkit::GetImplementation((*visualToRemoveIter)->visual).SetOffScene(self);
- }
- mRemoveVisuals.Erase(visualToRemoveIter);
- }
- break;
+ Toolkit::GetImplementation((*visualToRemoveIter)->visual).SetOffScene(self);
}
+ mRemoveVisuals.Erase(visualToRemoveIter);
}
+ // A visual is ready so control may need relayouting if staged
+ RelayoutRequest(object);
+
// Called by a Visual when it's resource is ready
- ResourceReady(true);
+ if(((*registeredIter)->enabled))
+ {
+ ResourceReady();
+ }
}
void Control::Impl::NotifyVisualEvent(Visual::Base& object, Property::Index signalId)
void Control::Impl::RelayoutRequest(Visual::Base& object)
{
- mControlImpl.RelayoutRequest();
+ if(mControlImpl.Self().GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE))
+ {
+ mControlImpl.RelayoutRequest();
+ }
}
bool Control::Impl::IsResourceReady() const
/**
* @brief Called when resources of control are ready.
- * @param[in] relayoutRequest True to request relayout
*/
- void ResourceReady(bool relayoutRequest);
+ void ResourceReady();
/**
* @brief Called when a resource is ready.
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
RelayoutRequest();
}
-void Control::SetResourceReady(bool relayoutRequest)
+void Control::SetResourceReady()
{
Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(*this);
- controlDataImpl.ResourceReady(relayoutRequest);
+ controlDataImpl.ResourceReady();
}
Toolkit::DevelControl::ControlAccessible* Control::GetAccessibleObject()
#define DALI_TOOLKIT_CONTROL_IMPL_H
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
namespace Internal
{
-
/**
* @brief This is the internal base class for all controls.
*
void ClearBackground();
/**
- * @brief Called when resources of control are ready.
- * @param[in] relayoutRequest True to request relayout
+ * @brief Called when resources of control are ready. this api does not request relayout.
*/
- void SetResourceReady(bool relayoutRequest);
+ void SetResourceReady();
// Accessibility
DALI_INTERNAL void KeyboardEnter();
/// @endcond
-
// Signals
/**
void OnLayoutNegotiated(float size, Dimension::Type dimension) override;
public: // Helpers for deriving classes
-
/**
* @brief Flags for the constructor.
* @SINCE_1_0.0
* @param[in] destination Destination control of the animation.
* @param[in] visualIndex Property::Index to make animation.
*/
- void MakeVisualTransition(Dali::Property::Map& sourcePropertyMap, Dali::Property::Map& destinationPropertyMap,
- Dali::Toolkit::Control source, Dali::Toolkit::Control destination, Dali::Property::Index visualIndex);
+ void MakeVisualTransition(Dali::Property::Map& sourcePropertyMap, Dali::Property::Map& destinationPropertyMap, Dali::Toolkit::Control source, Dali::Toolkit::Control destination, Dali::Property::Index visualIndex);
/**
* @brief Retrieves source and destination visual properties for the Transition of this Control.