From 6bcfc205331eae4902f6c4744eacb8ef4ec2e11b Mon Sep 17 00:00:00 2001 From: Ivaylo Draganov Date: Fri, 27 Sep 2024 17:30:49 +0300 Subject: [PATCH] Remove drag support from `BackgroundWidget` This was not used anywhere, was somewhat buggy and could be implemented in a better way when needed. --- .../Widgets/BackgroundWidget.cs | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/BackgroundWidget.cs b/OpenRA.Mods.Common/Widgets/BackgroundWidget.cs index e644e08e90..5d2614df67 100644 --- a/OpenRA.Mods.Common/Widgets/BackgroundWidget.cs +++ b/OpenRA.Mods.Common/Widgets/BackgroundWidget.cs @@ -16,7 +16,6 @@ namespace OpenRA.Mods.Common.Widgets public class BackgroundWidget : Widget { public readonly bool ClickThrough = false; - public readonly bool Draggable = false; public string Background = "dialog"; public override void Draw() @@ -26,37 +25,11 @@ namespace OpenRA.Mods.Common.Widgets public BackgroundWidget() { } - bool moving; - int2? prevMouseLocation; - public override bool HandleMouseInput(MouseInput mi) { if (ClickThrough || !RenderBounds.Contains(mi.Location)) return false; - if (!Draggable || (moving && (!TakeMouseFocus(mi) || mi.Button != MouseButton.Left))) - return true; - - if (prevMouseLocation == null) - prevMouseLocation = mi.Location; - var vec = mi.Location - (int2)prevMouseLocation; - prevMouseLocation = mi.Location; - switch (mi.Event) - { - case MouseInputEvent.Up: - moving = false; - YieldMouseFocus(mi); - break; - case MouseInputEvent.Down: - moving = true; - Bounds = new WidgetBounds(Bounds.X + vec.X, Bounds.Y + vec.Y, Bounds.Width, Bounds.Height); - break; - case MouseInputEvent.Move: - if (moving) - Bounds = new WidgetBounds(Bounds.X + vec.X, Bounds.Y + vec.Y, Bounds.Width, Bounds.Height); - break; - } - return true; } @@ -65,7 +38,6 @@ namespace OpenRA.Mods.Common.Widgets { Background = other.Background; ClickThrough = other.ClickThrough; - Draggable = other.Draggable; } public override Widget Clone() { return new BackgroundWidget(this); }