DALI_TEST_NOT_EQUALS(animation1, animation2, 0.0f, TEST_LOCATION);
END_TEST;
-}
\ No newline at end of file
+}
+
+// For ResourceReady
+namespace
+{
+static bool gOnRelayoutCallBackCalled = false;
+void OnRelayoutCallback(Actor actor)
+{
+ gOnRelayoutCallBackCalled = true;
+}
+
+static bool gResourceReadyCalled = false;
+void OnResourceReady(Control control)
+{
+ gResourceReadyCalled = true;
+}
+}
+
+int UtcDaliModelViewResourceReady(void)
+{
+ ToolkitTestApplication application;
+
+ gOnRelayoutCallBackCalled = false;
+ gResourceReadyCalled = false;
+ Scene3D::ModelView model = Scene3D::ModelView::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME);
+ model.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
+ model.OnRelayoutSignal().Connect(OnRelayoutCallback);
+ model.ResourceReadySignal().Connect(OnResourceReady);
+ DALI_TEST_EQUALS(model.IsResourceReady(), false, TEST_LOCATION);
+
+ // Sanity check
+ DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
+ DALI_TEST_CHECK(!gResourceReadyCalled);
+
+ application.GetScene().Add(model);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION);
+ DALI_TEST_EQUALS(model.IsResourceReady(), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
+
+ END_TEST;
+}
END_TEST;
}
+
+// For ResourceReady
+namespace
+{
+static bool gOnRelayoutCallBackCalled = false;
+void OnRelayoutCallback(Actor actor)
+{
+ gOnRelayoutCallBackCalled = true;
+}
+
+static bool gResourceReadyCalled = false;
+void OnResourceReady(Control control)
+{
+ gResourceReadyCalled = true;
+}
+}
+
+int UtcDaliSceneViewResourceReady(void)
+{
+ ToolkitTestApplication application;
+
+ gOnRelayoutCallBackCalled = false;
+ gResourceReadyCalled = false;
+ Scene3D::SceneView view = Scene3D::SceneView::New();
+ view.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
+ view.OnRelayoutSignal().Connect(OnRelayoutCallback);
+ view.ResourceReadySignal().Connect(OnResourceReady);
+ // SceneView::IsResourceReady() returns true by default.
+ DALI_TEST_EQUALS(view.IsResourceReady(), true, TEST_LOCATION);
+
+ // Sanity check
+ DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
+ DALI_TEST_CHECK(!gResourceReadyCalled);
+
+ application.GetScene().Add(view);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
+ DALI_TEST_EQUALS(view.IsResourceReady(), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
+
+ gOnRelayoutCallBackCalled = false;
+ gResourceReadyCalled = false;
+
+ view.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION);
+ DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
+
+ END_TEST;
+}
END_TEST;
}
+
+// For ResourceReady
+namespace
+{
+static bool gOnRelayoutCallBackCalled = false;
+void OnRelayoutCallback(Actor actor)
+{
+ gOnRelayoutCallBackCalled = true;
+}
+
+static bool gResourceReadyCalled = false;
+void OnResourceReady(Control control)
+{
+ gResourceReadyCalled = true;
+}
+}
+
+int UtcDaliControlImplResourceReady(void)
+{
+ ToolkitTestApplication application;
+
+ gOnRelayoutCallBackCalled = false;
+ 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);
+ control.ResourceReadySignal().Connect(OnResourceReady);
+ application.GetScene().Add(control);
+
+ // Sanity check
+ DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
+ DALI_TEST_CHECK(!gResourceReadyCalled);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
+ gOnRelayoutCallBackCalled = false;
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION);
+ Toolkit::Internal::Control& impl = Toolkit::Internal::GetImplementation(control);
+ // 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);
+ DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION);
+ gResourceReadyCalled = false;
+ DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
+ impl.SetResourceReady(true);
+ DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
+
+ END_TEST;
+}
// EXTERNAL INCLUDES
#include <dali-toolkit/dali-toolkit.h>
-#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/internal/controls/control/control-data-impl.h>
#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
#include <dali/integration-api/debug.h>
#include <filesystem>
// INTERNAL INCLUDES
-#include <dali-scene3d/public-api/controls/model-view/model-view.h>
#include <dali-scene3d/internal/controls/scene-view/scene-view-impl.h>
+#include <dali-scene3d/public-api/controls/model-view/model-view.h>
#include <dali-scene3d/public-api/loader/animation-definition.h>
#include <dali-scene3d/public-api/loader/camera-parameters.h>
#include <dali-scene3d/public-api/loader/cube-map-loader.h>
} // anonymous namespace
ModelView::ModelView(const std::string& modelPath, const std::string& resourcePath)
-: Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT)),
+: Control(ControlBehaviour(DISABLE_SIZE_NEGOTIATION | DISABLE_STYLE_CHANGE_SIGNALS)),
mModelPath(modelPath),
mResourcePath(resourcePath),
mModelRoot(),
mModelPivot(AnchorPoint::CENTER),
mIblScaleFactor(1.0f),
mFitSize(true),
- mFitCenter(true)
+ mFitCenter(true),
+ mModelResourceReady(false),
+ mIBLResourceReady(true)
{
}
void ModelView::SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor)
{
+ mIBLResourceReady = false;
Texture diffuseTexture = Dali::Scene3D::Loader::LoadCubeMap(diffuse);
Texture specularTexture = Dali::Scene3D::Loader::LoadCubeMap(specular);
SetImageBasedLightTexture(diffuseTexture, specularTexture, scaleFactor);
+ mIBLResourceReady = true;
+
+ // If Model resource is already ready, then set resource ready.
+ // If Model resource is still not ready, wait for model resource ready.
+ if(IsResourceReady())
+ {
+ SetResourceReady(false);
+ }
}
void ModelView::SetImageBasedLightTexture(Dali::Texture diffuse, Dali::Texture specular, float scaleFactor)
ScaleModel();
}
+bool ModelView::IsResourceReady() const
+{
+ return mModelResourceReady && mIBLResourceReady;
+}
+
void ModelView::LoadModel()
{
std::filesystem::path modelPath(mModelPath);
Self().SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
Self().SetProperty(Dali::Actor::Property::ANCHOR_POINT, Vector3(mModelPivot.x, 1.0f - mModelPivot.y, mModelPivot.z));
+
+ mModelResourceReady = true;
+
+ Control::SetResourceReady(false);
}
void ModelView::ScaleModel()
void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
/**
+ * @copydoc Toolkit::Control::IsResourceReady()
+ */
+ bool IsResourceReady() const override;
+
+ /**
* @brief Loads a model from file
*/
void LoadModel();
float mIblScaleFactor;
bool mFitSize;
bool mFitCenter;
+ bool mModelResourceReady;
+ bool mIBLResourceReady;
};
} // namespace Internal
void SceneView::SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor)
{
+ mIBLResourceReady = false;
Texture diffuseTexture = Dali::Scene3D::Loader::LoadCubeMap(diffuse);
if(diffuseTexture)
{
}
}
}
+ mIBLResourceReady = true;
+ Control::SetResourceReady(false);
}
void SceneView::UseFramebuffer(bool useFramebuffer)
UpdateRenderTask();
}
+bool SceneView::IsResourceReady() const
+{
+ return mIBLResourceReady;
+}
+
void SceneView::UpdateCamera(CameraActor camera)
{
if(camera)
void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
/**
+ * @copydoc Toolkit::Control::IsResourceReady()
+ */
+ bool IsResourceReady() const override;
+
+ /**
* @brief Changes main camera as a input camera
*
* @param camera CameraActor that will be a main camera of the SceneView
Dali::Texture mDiffuseTexture;
float mIblScaleFactor{1.0f};
bool mUseFrameBuffer{false};
+ bool mIBLResourceReady{true};
// TODO : Light Source
};
visualImpl.AddEventObserver(*this);
}
+void Control::Impl::ResourceReady(bool relayoutRequest)
+{
+ 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())
+ {
+ // Reset the flag
+ mNeedToEmitResourceReady = false;
+ EmitResourceReadySignal();
+ }
+}
+
// Called by a Visual when it's resource is ready
void Control::Impl::ResourceReady(Visual::Base& object)
{
}
}
- // A visual is ready so control may need relayouting if staged
- if(self.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE))
- {
- mControlImpl.RelayoutRequest();
- }
-
- // Emit signal if all enabled visuals registered by the control are ready.
- if(IsResourceReady())
- {
- // Reset the flag
- mNeedToEmitResourceReady = false;
-
- EmitResourceReadySignal();
- }
+ // Called by a Visual when it's resource is ready
+ ResourceReady(true);
}
void Control::Impl::NotifyVisualEvent(Visual::Base& object, Property::Index signalId)
void LongPressDetected(Actor actor, const LongPressGesture& longPress);
/**
+ * @brief Called when resources of control are ready.
+ * @param[in] relayoutRequest True to request relayout
+ */
+ void ResourceReady(bool relayoutRequest);
+
+ /**
* @brief Called when a resource is ready.
* @param[in] object The visual whose resources are ready
* @note Overriding method in Visual::EventObserver.
RelayoutRequest();
}
+void Control::SetResourceReady(bool relayoutRequest)
+{
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(*this);
+ controlDataImpl.ResourceReady(relayoutRequest);
+}
+
Toolkit::DevelControl::ControlAccessible* Control::GetAccessibleObject()
{
return mImpl->GetAccessibleObject();
{
}
+bool Control::IsResourceReady() const
+{
+ const Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(*this);
+ return controlDataImpl.IsResourceReady();
+}
+
void Control::OnStyleChange(Toolkit::StyleManager styleManager, StyleChange::Type change)
{
// By default the control is only interested in theme (not font) changes
*/
void ClearBackground();
+ /**
+ * @brief Called when resources of control are ready.
+ * @param[in] relayoutRequest True to request relayout
+ */
+ void SetResourceReady(bool relayoutRequest);
+
// Accessibility
/**
*/
virtual void OnInitialize();
+ /**
+ * @copydoc Dali::Toolkit::Control::IsResourceReady
+ */
+ virtual bool IsResourceReady() const;
+
// Styling
/**
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();
+ return Internal::GetImplementation(*this).IsResourceReady();
}
Toolkit::Visual::ResourceStatus Control::GetVisualResourceStatus(Dali::Property::Index index)