From 270ab5c9870c635d22edc3231f1e6fae02d09f28 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 21 Jul 2017 13:37:22 +0300 Subject: [PATCH] Allow ChatOverlay resize only if it dragged by the tabs area only --- osu.Game/Overlays/ChatOverlay.cs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 1f9f7e57ca..04988bf789 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -52,6 +52,7 @@ namespace osu.Game.Overlays private readonly ChatTabControl channelTabs; private readonly Container chatContainer; + private readonly Container tabsArea; private readonly Box chatBackground; private readonly Box tabBackground; @@ -144,7 +145,7 @@ namespace osu.Game.Overlays loading = new LoadingAnimation(), } }, - new Container + tabsArea = new Container { Name = @"tabs area", RelativeSizeAxes = Axes.X, @@ -191,9 +192,12 @@ namespace osu.Game.Overlays } private double startDragChatHeight; + private bool canBeDragged; protected override bool OnDragStart(InputState state) { + canBeDragged = tabsArea.IsHovered; + if (!channelTabs.IsHovered) return base.OnDragStart(state); @@ -203,10 +207,21 @@ namespace osu.Game.Overlays protected override bool OnDrag(InputState state) { - Trace.Assert(state.Mouse.PositionMouseDown != null); + if (canBeDragged) + { + Trace.Assert(state.Mouse.PositionMouseDown != null); - chatHeight.Value = startDragChatHeight - (state.Mouse.Position.Y - state.Mouse.PositionMouseDown.Value.Y) / Parent.DrawSize.Y; - return base.OnDrag(state); + chatHeight.Value = startDragChatHeight - (state.Mouse.Position.Y - state.Mouse.PositionMouseDown.Value.Y) / Parent.DrawSize.Y; + return base.OnDrag(state); + } + + return true; + } + + protected override bool OnDragEnd(InputState state) + { + canBeDragged = false; + return base.OnDragEnd(state); } public void APIStateChanged(APIAccess api, APIState state)