1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-30 23:03:20 +08:00
osu-lazer/osu.Game/Rulesets/Edit/ExpandingToolboxContainer.cs
Dean Herbert cca63b599e
Always block scroll input above editor toolbox areas
Originally this was an intentional choice (see
https://github.com/ppy/osu/pull/18088) when these controls were more
transparent and didn't for a solid toolbox area.

But this is no longer the case, so for now let's always block scroll to
match user expectations.

Closes #31262.
2025-01-02 14:31:27 +09:00

63 lines
1.8 KiB
C#

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Game.Configuration;
using osu.Game.Graphics.Containers;
using osu.Game.Screens.Edit;
using osuTK;
namespace osu.Game.Rulesets.Edit
{
public partial class ExpandingToolboxContainer : ExpandingContainer
{
protected override double HoverExpansionDelay => 250;
protected override bool ExpandOnHover => expandOnHover;
private readonly Bindable<bool> contractSidebars = new Bindable<bool>();
private bool expandOnHover;
[Resolved]
private Editor? editor { get; set; }
public ExpandingToolboxContainer(float contractedWidth, float expandedWidth)
: base(contractedWidth, expandedWidth)
{
RelativeSizeAxes = Axes.Y;
FillFlow.Spacing = new Vector2(5);
FillFlow.Padding = new MarginPadding { Vertical = 5 };
Expanded.Value = true;
}
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
config.BindWith(OsuSetting.EditorContractSidebars, contractSidebars);
}
protected override void Update()
{
base.Update();
bool requireContracting = contractSidebars.Value || editor?.DrawSize.X / editor?.DrawSize.Y < 1.7f;
if (expandOnHover != requireContracting)
{
expandOnHover = requireContracting;
Expanded.Value = !expandOnHover;
}
}
protected override bool OnMouseDown(MouseDownEvent e) => true;
protected override bool OnClick(ClickEvent e) => true;
}
}