From 2cc69d6b19b2682db3a7c6ec8dd79ccc1421a0d1 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 27 Jan 2022 15:57:56 +0300 Subject: [PATCH] Replace `IsControlDragged` with an abstract `ShouldBeExpanded` --- osu.Game/Overlays/ExpandableSlider.cs | 2 +- osu.Game/Overlays/ExpandingControlContainer.cs | 8 +++++++- osu.Game/Overlays/IExpandable.cs | 11 +++++++++++ osu.Game/Overlays/IExpandableControl.cs | 4 ---- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/ExpandableSlider.cs b/osu.Game/Overlays/ExpandableSlider.cs index 524485d806..d346b9b22c 100644 --- a/osu.Game/Overlays/ExpandableSlider.cs +++ b/osu.Game/Overlays/ExpandableSlider.cs @@ -72,7 +72,7 @@ namespace osu.Game.Overlays public BindableBool Expanded { get; } = new BindableBool(); - public bool IsControlDragged => slider.IsDragged; + bool IExpandable.ShouldBeExpanded => IsHovered || slider.IsDragged; public override bool HandlePositionalInput => true; diff --git a/osu.Game/Overlays/ExpandingControlContainer.cs b/osu.Game/Overlays/ExpandingControlContainer.cs index fb6a71ba97..859e4bcd25 100644 --- a/osu.Game/Overlays/ExpandingControlContainer.cs +++ b/osu.Game/Overlays/ExpandingControlContainer.cs @@ -118,6 +118,12 @@ namespace osu.Game.Overlays /// /// Whether the given control is currently active, by checking whether it's hovered or dragged. /// - private bool isControlActive(TControl control) => control.IsHovered || control.IsDragged || (control is IExpandableControl expandable && expandable.IsControlDragged); + private bool isControlActive(TControl control) + { + if (control is IExpandable expandable) + return expandable.ShouldBeExpanded; + + return control.IsHovered || control.IsDragged; + } } } diff --git a/osu.Game/Overlays/IExpandable.cs b/osu.Game/Overlays/IExpandable.cs index 770ac97847..f998fc7b9f 100644 --- a/osu.Game/Overlays/IExpandable.cs +++ b/osu.Game/Overlays/IExpandable.cs @@ -3,6 +3,7 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; +using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays { @@ -15,5 +16,15 @@ namespace osu.Game.Overlays /// Whether this drawable is in an expanded state. /// BindableBool Expanded { get; } + + /// + /// Whether this drawable should be/stay expanded by a parenting . + /// By default, this is when this drawable is in a hovered or dragged state. + /// + /// + /// This is defined for certain controls which may have a child handling dragging instead. + /// (e.g. in which dragging is handled by their underlying control). + /// + bool ShouldBeExpanded => IsHovered || IsDragged; } } diff --git a/osu.Game/Overlays/IExpandableControl.cs b/osu.Game/Overlays/IExpandableControl.cs index fae07ae23b..2cda6f467b 100644 --- a/osu.Game/Overlays/IExpandableControl.cs +++ b/osu.Game/Overlays/IExpandableControl.cs @@ -8,9 +8,5 @@ namespace osu.Game.Overlays /// public interface IExpandableControl : IExpandable { - /// - /// Returns whether the UI control is currently in a dragged state. - /// - bool IsControlDragged { get; } } }