2023-07-08 14:08:32 +10:00
|
|
|
|
using System.Numerics;
|
|
|
|
|
|
using Robust.Client.AutoGenerated;
|
2021-11-02 01:12:55 +01:00
|
|
|
|
using Robust.Client.UserInterface.CustomControls;
|
|
|
|
|
|
using Robust.Client.UserInterface.XAML;
|
|
|
|
|
|
|
2022-09-11 18:56:21 -07:00
|
|
|
|
namespace Content.Client.UserInterface.Controls
|
2021-11-02 01:12:55 +01:00
|
|
|
|
{
|
|
|
|
|
|
[GenerateTypedNameReferences]
|
2022-02-16 00:23:23 -07:00
|
|
|
|
[Virtual]
|
2021-11-02 01:12:55 +01:00
|
|
|
|
public partial class FancyWindow : BaseWindow
|
|
|
|
|
|
{
|
2022-12-06 23:46:07 +00:00
|
|
|
|
private const int DRAG_MARGIN_SIZE = 7;
|
|
|
|
|
|
|
2021-11-02 01:12:55 +01:00
|
|
|
|
public FancyWindow()
|
|
|
|
|
|
{
|
|
|
|
|
|
RobustXamlLoader.Load(this);
|
|
|
|
|
|
|
|
|
|
|
|
CloseButton.OnPressed += _ => Close();
|
|
|
|
|
|
XamlChildren = ContentsContainer.Children;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string? Title
|
|
|
|
|
|
{
|
|
|
|
|
|
get => WindowTitle.Text;
|
|
|
|
|
|
set => WindowTitle.Text = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override DragMode GetDragModeFor(Vector2 relativeMousePos)
|
|
|
|
|
|
{
|
2022-12-06 23:46:07 +00:00
|
|
|
|
var mode = DragMode.Move;
|
|
|
|
|
|
|
|
|
|
|
|
if (Resizable)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (relativeMousePos.Y < DRAG_MARGIN_SIZE)
|
|
|
|
|
|
{
|
|
|
|
|
|
mode = DragMode.Top;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (relativeMousePos.Y > Size.Y - DRAG_MARGIN_SIZE)
|
|
|
|
|
|
{
|
|
|
|
|
|
mode = DragMode.Bottom;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (relativeMousePos.X < DRAG_MARGIN_SIZE)
|
|
|
|
|
|
{
|
|
|
|
|
|
mode |= DragMode.Left;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (relativeMousePos.X > Size.X - DRAG_MARGIN_SIZE)
|
|
|
|
|
|
{
|
|
|
|
|
|
mode |= DragMode.Right;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return mode;
|
2021-11-02 01:12:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|