-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Close context menus when deselecting items in editor #29279
Changes from all commits
de6d8e7
83aeb27
1ff0c7c
5c5fcd7
27d6c4c
3cc5466
5d31171
7c83d6a
2145368
38dacfe
7cebf4c
b32d97b
2720bcf
1b25633
2098fb8
6d385c6
75c0c6a
3c8d0ce
59ff549
22ab6f5
cb877b7
b91461e
c574551
c26a664
41d84ea
aae49d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using JetBrains.Annotations; | ||
using osu.Framework; | ||
|
@@ -159,7 +160,7 @@ public bool ReadyForUse | |
|
||
private string lastSavedHash; | ||
|
||
private Container<EditorScreen> screenContainer; | ||
private ScreenContainer screenContainer; | ||
|
||
[CanBeNull] | ||
private readonly EditorLoader loader; | ||
|
@@ -329,7 +330,7 @@ private void load(OsuConfigManager config) | |
Name = "Screen container", | ||
RelativeSizeAxes = Axes.Both, | ||
Padding = new MarginPadding { Top = 40, Bottom = 50 }, | ||
Child = screenContainer = new Container<EditorScreen> | ||
Child = screenContainer = new ScreenContainer | ||
{ | ||
RelativeSizeAxes = Axes.Both, | ||
} | ||
|
@@ -422,6 +423,7 @@ private void load(OsuConfigManager config) | |
MutationTracker, | ||
} | ||
}); | ||
|
||
changeHandler?.CanUndo.BindValueChanged(v => undoMenuItem.Action.Disabled = !v.NewValue, true); | ||
changeHandler?.CanRedo.BindValueChanged(v => redoMenuItem.Action.Disabled = !v.NewValue, true); | ||
|
||
|
@@ -1007,7 +1009,7 @@ private void onModeChanged(ValueChangedEvent<EditorScreenMode> e) | |
throw new InvalidOperationException("Editor menu bar switched to an unsupported mode"); | ||
} | ||
|
||
LoadComponentAsync(currentScreen, newScreen => | ||
screenContainer.LoadComponentAsync(currentScreen, newScreen => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's this change doing? @smoogipoo looks like one of yours? I'm not sure it's a big deal but I'm weirded out by it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously, the context menu container was stored as a local and cached in this class. Now, the context menu container caches itself via But this moves the dependencies one level lower from |
||
{ | ||
if (newScreen == currentScreen) | ||
{ | ||
|
@@ -1385,5 +1387,12 @@ public BeatmapEditorToast(LocalisableString value, string beatmapDisplayName) | |
{ | ||
} | ||
} | ||
|
||
private partial class ScreenContainer : Container<EditorScreen> | ||
{ | ||
public new Task LoadComponentAsync<TLoadable>([NotNull] TLoadable component, Action<TLoadable> onLoaded = null, CancellationToken cancellation = default, Scheduler scheduler = null) | ||
where TLoadable : Drawable | ||
=> base.LoadComponentAsync(component, onLoaded, cancellation, scheduler); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One situation I'm not sure about is that pasting doesn't close the menu even though it selects the newly-pasted hitobjects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
close the menu whatever the selected object changed
internal virtual void HandleSelected(SelectionBlueprint<T> blueprint) { // there are potentially multiple SelectionHandlers active, but we only want to add items to the selected list once. if (!SelectedItems.Contains(blueprint.Item)) SelectedItems.Add(blueprint.Item); selectedBlueprints.Add(blueprint); + ContextMenuContainer?.CloseMenu(); }