mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-16 15:22:27 +02:00
51 lines
1.2 KiB
C#
51 lines
1.2 KiB
C#
using System;
|
|
using Robust.Shared.Maths;
|
|
|
|
namespace Robust.Client.UserInterface.Controls
|
|
{
|
|
public class Popup : Control
|
|
{
|
|
public Popup()
|
|
{
|
|
Visible = false;
|
|
}
|
|
|
|
public event Action? OnPopupHide;
|
|
|
|
private Vector2 _desiredSize;
|
|
|
|
public void Open(UIBox2? box = null, Vector2? altPos = null)
|
|
{
|
|
if (Visible)
|
|
{
|
|
UserInterfaceManagerInternal.RemoveModal(this);
|
|
}
|
|
|
|
if (box != null && _desiredSize != box.Value.Size)
|
|
{
|
|
PopupContainer.SetPopupOrigin(this, box.Value.TopLeft);
|
|
PopupContainer.SetAltOrigin(this, altPos);
|
|
|
|
_desiredSize = box.Value.Size;
|
|
MinimumSizeChanged();
|
|
}
|
|
|
|
Visible = true;
|
|
UserInterfaceManagerInternal.PushModal(this);
|
|
}
|
|
|
|
protected internal override void ModalRemoved()
|
|
{
|
|
base.ModalRemoved();
|
|
|
|
Visible = false;
|
|
OnPopupHide?.Invoke();
|
|
}
|
|
|
|
protected override Vector2 CalculateMinimumSize()
|
|
{
|
|
return Vector2.ComponentMax(_desiredSize, base.CalculateMinimumSize());
|
|
}
|
|
}
|
|
}
|