-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scroll to toolbox group when clicked
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Bindables; | ||
using osu.Framework.Caching; | ||
|
@@ -28,6 +29,8 @@ public partial class SettingsToolboxGroup : Container, IExpandable | |
private const int header_height = 30; | ||
private const int corner_radius = 5; | ||
|
||
public event EventHandler? Clicked; | ||
|
||
private readonly Cached headerTextVisibilityCache = new Cached(); | ||
|
||
protected override Container<Drawable> Content => content; | ||
|
@@ -145,6 +148,12 @@ protected override void OnHoverLost(HoverLostEvent e) | |
base.OnHoverLost(e); | ||
} | ||
|
||
protected override bool OnClick(ClickEvent e) | ||
{ | ||
Clicked?.Invoke(this, EventArgs.Empty); | ||
return base.OnClick(e); | ||
} | ||
|
||
protected override void Update() | ||
{ | ||
base.Update(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
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.Overlays; | ||
using osu.Game.Screens.Edit; | ||
using osuTK; | ||
|
||
|
@@ -42,6 +44,32 @@ private void load(OsuConfigManager config) | |
config.BindWith(OsuSetting.EditorContractSidebars, contractSidebars); | ||
} | ||
|
||
protected override void LoadComplete() | ||
{ | ||
foreach (EditorToolboxGroup group in Children) | ||
{ | ||
group.Clicked += onToolboxGroupClicked; | ||
} | ||
base.LoadComplete(); | ||
} | ||
|
||
private void onToolboxGroupClicked(object? sender, EventArgs args) | ||
{ | ||
if (sender is not SettingsToolboxGroup toolboxGroup) | ||
return; | ||
|
||
scrollToToolboxGroup(toolboxGroup); | ||
} | ||
|
||
private void scrollToToolboxGroup(SettingsToolboxGroup toolboxGroup) | ||
{ | ||
if (InternalChild is OsuScrollContainer scrollContainer) | ||
{ | ||
float pos = scrollContainer.GetChildPosInContent(toolboxGroup); | ||
scrollContainer.ScrollTo(pos); | ||
} | ||
} | ||
|
||
protected override void Update() | ||
{ | ||
base.Update(); | ||
|