Files
tbd-station-14/Content.Client/UserInterface/Controls/FancyWindow.xaml.cs
eoineoineoin ff9cf108b6 UX improvements to Air Alarm UI (#12681)
Co-authored-by: Eoin Mcloughlin <helloworld@eoinrul.es>
2022-12-06 15:46:07 -08:00

56 lines
1.4 KiB
C#

using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.UserInterface.Controls
{
[GenerateTypedNameReferences]
[Virtual]
public partial class FancyWindow : BaseWindow
{
private const int DRAG_MARGIN_SIZE = 7;
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)
{
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;
}
}
}