66 lines
1.5 KiB
C#
66 lines
1.5 KiB
C#
using Godot;
|
|
|
|
public sealed partial class MeetingControlDragData(MeetingControl meetingControl) : GodotObject
|
|
{
|
|
public MeetingControl MeetingControl { get; set; } = meetingControl;
|
|
}
|
|
|
|
[SceneTree]
|
|
public partial class MeetingControl : Control
|
|
{
|
|
[Export]
|
|
public Meeting Meeting;
|
|
|
|
public bool InSlot { get; set; }
|
|
|
|
public override Variant _GetDragData(Vector2 atPosition)
|
|
{
|
|
var preview = CreatePreview();
|
|
SetDragPreview(preview);
|
|
GD.Print("asdasdasdasd as dasd");
|
|
Visible = false;
|
|
|
|
InSlot = false;
|
|
|
|
return Variant.From(new MeetingControlDragData(this));
|
|
}
|
|
|
|
public void StartDrag()
|
|
{
|
|
var preview = CreatePreview();
|
|
var data = Variant.From(new MeetingControlDragData(this));
|
|
|
|
ForceDrag(data, preview);
|
|
}
|
|
|
|
public override void _Notification(int what)
|
|
{
|
|
if (what == NotificationDragEnd)
|
|
{
|
|
GD.Print("Drag End");
|
|
|
|
if (InSlot)
|
|
{
|
|
GD.Print("Dropped in Slot");
|
|
return;
|
|
}
|
|
|
|
GD.Print("Dropped somewhere");
|
|
|
|
FindParent("Main").AddChild(Meeting);
|
|
Meeting.Position = GetGlobalMousePosition();
|
|
QueueFree();
|
|
}
|
|
}
|
|
|
|
private Control CreatePreview()
|
|
{
|
|
var copy = Duplicate() as MeetingControl;
|
|
var preview = new Control();
|
|
preview.AddChild(copy);
|
|
copy.Position = new Vector2(-Size.X / 2, -Size.Y / 2);
|
|
|
|
return preview;
|
|
}
|
|
}
|