void setContainerPosition(float x, float y)
{
var stage = _targetElement.getStage();
if (stage == null)
{
return;
}
_container.pack();
float offsetX = _manager.offsetX, offsetY = _manager.offsetY, dist = _manager.edgeDistance;
var point = _targetElement.localToStageCoordinates(
new Vector2(x + offsetX - _container.getWidth() / 2, y - offsetY - _container.getHeight()));
if (point.Y < dist)
{
point = _targetElement.localToStageCoordinates(new Vector2(x + offsetX, y + offsetY));
}
if (point.X < dist)
{
point.X = dist;
}
if (point.X + _container.getWidth() > stage.getWidth() - dist)
{
point.X = stage.getWidth() - dist - _container.getWidth();
}
if (point.Y + _container.getHeight() > stage.getHeight() - dist)
{
point.Y = stage.getHeight() - dist - _container.getHeight();
}
_container.setPosition(point.X, point.Y);
point = _targetElement.localToStageCoordinates(
new Vector2(_targetElement.getWidth() / 2, _targetElement.getHeight() / 2));
point -= new Vector2(_container.getX(), _container.getY());
_container.setOrigin(point.X, point.Y);
}