mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 13:33:52 +08:00
Replace IsControlDragged
with an abstract ShouldBeExpanded
This commit is contained in:
parent
a34b8fc4d0
commit
2cc69d6b19
@ -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;
|
||||
|
||||
|
@ -118,6 +118,12 @@ namespace osu.Game.Overlays
|
||||
/// <summary>
|
||||
/// Whether the given control is currently active, by checking whether it's hovered or dragged.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
/// </summary>
|
||||
BindableBool Expanded { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether this drawable should be/stay expanded by a parenting <see cref="IExpandingContainer"/>.
|
||||
/// By default, this is <see langword="true"/> when this drawable is in a hovered or dragged state.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is defined for certain controls which may have a child handling dragging instead.
|
||||
/// (e.g. <see cref="ExpandableSlider{T,TSlider}"/> in which dragging is handled by their underlying <see cref="OsuSliderBar{T}"/> control).
|
||||
/// </remarks>
|
||||
bool ShouldBeExpanded => IsHovered || IsDragged;
|
||||
}
|
||||
}
|
||||
|
@ -8,9 +8,5 @@ namespace osu.Game.Overlays
|
||||
/// </summary>
|
||||
public interface IExpandableControl : IExpandable
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns whether the UI control is currently in a dragged state.
|
||||
/// </summary>
|
||||
bool IsControlDragged { get; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user