mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Remove bindable to promote one-way access
This commit is contained in:
@ -56,7 +56,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
AddStep("disable menu items", () =>
|
AddStep("disable menu items", () =>
|
||||||
{
|
{
|
||||||
foreach (var item in menu.Items)
|
foreach (var item in menu.Items)
|
||||||
((OsuMenuItem)item).Enabled.Value = false;
|
((OsuMenuItem)item).Action.Disabled = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("move to first menu item", () => InputManager.MoveMouseTo(menu.ChildrenOfType<DrawableOsuMenuItem>().First()));
|
AddStep("move to first menu item", () => InputManager.MoveMouseTo(menu.ChildrenOfType<DrawableOsuMenuItem>().First()));
|
||||||
@ -71,13 +71,13 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
AddStep("disable menu items", () =>
|
AddStep("disable menu items", () =>
|
||||||
{
|
{
|
||||||
foreach (var item in menu.Items)
|
foreach (var item in menu.Items)
|
||||||
((OsuMenuItem)item).Enabled.Value = false;
|
((OsuMenuItem)item).Action.Disabled = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("enable menu items", () =>
|
AddStep("enable menu items", () =>
|
||||||
{
|
{
|
||||||
foreach (var item in menu.Items)
|
foreach (var item in menu.Items)
|
||||||
((OsuMenuItem)item).Enabled.Value = true;
|
((OsuMenuItem)item).Action.Disabled = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("move to first menu item", () => InputManager.MoveMouseTo(menu.ChildrenOfType<DrawableOsuMenuItem>().First()));
|
AddStep("move to first menu item", () => InputManager.MoveMouseTo(menu.ChildrenOfType<DrawableOsuMenuItem>().First()));
|
||||||
|
@ -2,15 +2,12 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
{
|
{
|
||||||
public class OsuMenuItem : MenuItem
|
public class OsuMenuItem : MenuItem
|
||||||
{
|
{
|
||||||
public readonly Bindable<bool> Enabled = new Bindable<bool>(true);
|
|
||||||
|
|
||||||
public readonly MenuItemType Type;
|
public readonly MenuItemType Type;
|
||||||
|
|
||||||
public OsuMenuItem(string text, MenuItemType type = MenuItemType.Standard)
|
public OsuMenuItem(string text, MenuItemType type = MenuItemType.Standard)
|
||||||
@ -22,9 +19,6 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
: base(text, action)
|
: base(text, action)
|
||||||
{
|
{
|
||||||
Type = type;
|
Type = type;
|
||||||
|
|
||||||
Enabled.BindValueChanged(enabled => Action.Disabled = !enabled.NewValue);
|
|
||||||
Action.BindDisabledChanged(disabled => Enabled.Value = !disabled);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,8 @@ namespace osu.Game.Screens.Edit
|
|||||||
dependencies.CacheAs<IEditorChangeHandler>(changeHandler);
|
dependencies.CacheAs<IEditorChangeHandler>(changeHandler);
|
||||||
|
|
||||||
EditorMenuBar menuBar;
|
EditorMenuBar menuBar;
|
||||||
|
OsuMenuItem undoMenuItem;
|
||||||
|
OsuMenuItem redoMenuItem;
|
||||||
|
|
||||||
var fileMenuItems = new List<MenuItem>
|
var fileMenuItems = new List<MenuItem>
|
||||||
{
|
{
|
||||||
@ -155,8 +157,8 @@ namespace osu.Game.Screens.Edit
|
|||||||
{
|
{
|
||||||
Items = new[]
|
Items = new[]
|
||||||
{
|
{
|
||||||
new EditorMenuItem("Undo", MenuItemType.Standard, undo) { Enabled = { BindTarget = changeHandler.CanUndo } },
|
undoMenuItem = new EditorMenuItem("Undo", MenuItemType.Standard, undo),
|
||||||
new EditorMenuItem("Redo", MenuItemType.Standard, redo) { Enabled = { BindTarget = changeHandler.CanRedo } }
|
redoMenuItem = new EditorMenuItem("Redo", MenuItemType.Standard, redo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,6 +216,9 @@ namespace osu.Game.Screens.Edit
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
changeHandler.CanUndo.BindValueChanged(v => undoMenuItem.Action.Disabled = !v.NewValue, true);
|
||||||
|
changeHandler.CanRedo.BindValueChanged(v => redoMenuItem.Action.Disabled = !v.NewValue, true);
|
||||||
|
|
||||||
menuBar.Mode.ValueChanged += onModeChanged;
|
menuBar.Mode.ValueChanged += onModeChanged;
|
||||||
|
|
||||||
bottomBackground.Colour = colours.Gray2;
|
bottomBackground.Colour = colours.Gray2;
|
||||||
|
Reference in New Issue
Block a user