mirror of
https://github.com/osukey/osukey.git
synced 2025-06-25 05:07:59 +09:00
Always prefer clicked section when present
This commit is contained in:
parent
cff7b1e98f
commit
c7266c74a0
@ -23,7 +23,7 @@ namespace osu.Game.Graphics.Containers
|
|||||||
{
|
{
|
||||||
public Bindable<T> SelectedSection { get; } = new Bindable<T>();
|
public Bindable<T> SelectedSection { get; } = new Bindable<T>();
|
||||||
|
|
||||||
private Drawable lastClickedSection;
|
private T lastClickedSection;
|
||||||
|
|
||||||
public Drawable ExpandableHeader
|
public Drawable ExpandableHeader
|
||||||
{
|
{
|
||||||
@ -145,10 +145,12 @@ namespace osu.Game.Graphics.Containers
|
|||||||
footerHeight = null;
|
footerHeight = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ScrollTo(Drawable section)
|
public void ScrollTo(Drawable target)
|
||||||
{
|
{
|
||||||
lastClickedSection = section;
|
if (target is T section)
|
||||||
scrollContainer.ScrollTo(scrollContainer.GetChildPosInContent(section) - scrollContainer.DisplayableContent * scroll_y_centre - (FixedHeader?.BoundingBox.Height ?? 0));
|
lastClickedSection = section;
|
||||||
|
|
||||||
|
scrollContainer.ScrollTo(scrollContainer.GetChildPosInContent(target) - scrollContainer.DisplayableContent * scroll_y_centre - (FixedHeader?.BoundingBox.Height ?? 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ScrollToTop() => scrollContainer.ScrollTo(0);
|
public void ScrollToTop() => scrollContainer.ScrollTo(0);
|
||||||
@ -236,10 +238,12 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
var presentChildren = Children.Where(c => c.IsPresent);
|
var presentChildren = Children.Where(c => c.IsPresent);
|
||||||
|
|
||||||
if (Precision.AlmostBigger(0, scrollContainer.Current))
|
if (lastClickedSection != null)
|
||||||
SelectedSection.Value = lastClickedSection as T ?? presentChildren.FirstOrDefault();
|
SelectedSection.Value = lastClickedSection;
|
||||||
|
else if (Precision.AlmostBigger(0, scrollContainer.Current))
|
||||||
|
SelectedSection.Value = presentChildren.FirstOrDefault();
|
||||||
else if (Precision.AlmostBigger(scrollContainer.Current, scrollContainer.ScrollableExtent))
|
else if (Precision.AlmostBigger(scrollContainer.Current, scrollContainer.ScrollableExtent))
|
||||||
SelectedSection.Value = lastClickedSection as T ?? presentChildren.LastOrDefault();
|
SelectedSection.Value = presentChildren.LastOrDefault();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SelectedSection.Value = presentChildren
|
SelectedSection.Value = presentChildren
|
||||||
|
Loading…
x
Reference in New Issue
Block a user