DALI_TYPE_REGISTRATION_END()
static constexpr Vector3 Y_DIRECTION(1.0f, -1.0f, 1.0f);
+static constexpr float SIZE_STEP_CONDITION = 0.1f;
static constexpr bool DEFAULT_MODEL_CHILDREN_SENSITIVE = false;
static constexpr bool DEFAULT_MODEL_CHILDREN_FOCUSABLE = false;
}
NotifyResourceReady();
+
+ mSizeNotification = Self().AddPropertyNotification(Actor::Property::SIZE, StepCondition(SIZE_STEP_CONDITION));
+ mSizeNotification.NotifySignal().Connect(this, &Model::OnSizeNotification);
Control::OnSceneConnection(depth);
}
GetImpl(sceneView).UnregisterSceneItem(this);
mParentSceneView.Reset();
}
+
+ mSizeNotification.NotifySignal().Disconnect(this, &Model::OnSizeNotification);
+ Self().RemovePropertyNotification(mSizeNotification);
+ mSizeNotification.Reset();
+
Control::OnSceneDisconnection();
}
+void Model::OnSizeSet(const Vector3& size)
+{
+ ScaleModel(false);
+}
+
Vector3 Model::GetNaturalSize()
{
if(!mModelRoot)
void Model::OnRelayout(const Vector2& size, RelayoutContainer& container)
{
Control::OnRelayout(size, container);
- ScaleModel();
+ ScaleModel(false);
}
bool Model::IsResourceReady() const
Self().Add(mModelRoot);
}
-void Model::ScaleModel()
+void Model::ScaleModel(bool useCurrentSize)
{
if(!mModelRoot)
{
}
float scale = 1.0f;
- Vector3 size = Self().GetProperty<Vector3>(Dali::Actor::Property::SIZE);
+ Vector3 size = (useCurrentSize) ? Self().GetCurrentProperty<Vector3>(Dali::Actor::Property::SIZE) : Self().GetProperty<Vector3>(Dali::Actor::Property::SIZE);
if(size.x > 0.0f && size.y > 0.0f)
{
scale = MAXFLOAT;
NotifyResourceReady();
}
+void Model::OnSizeNotification(Dali::PropertyNotification& source)
+{
+ ScaleModel(true);
+}
+
void Model::ResetResourceTasks()
{
if(!Dali::Adaptor::IsAvailable())
Self().SetProperty(Dali::Actor::Property::SIZE, mNaturalSize);
}
FitModelPosition();
- ScaleModel();
+ ScaleModel(false);
}
void Model::CreateAnimations(Dali::Scene3D::Loader::SceneDefinition& scene)