mirror of
https://github.com/osukey/osukey.git
synced 2025-05-29 09:27:18 +09:00
Merge pull request #2011 from peppy/new-restore-default-design
Update design of "revert to default" button
This commit is contained in:
commit
a9148d81d2
@ -7,7 +7,6 @@ using OpenTK.Graphics;
|
|||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Colour;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Cursor;
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
@ -16,6 +15,7 @@ using osu.Framework.Graphics.UserInterface;
|
|||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Settings
|
namespace osu.Game.Overlays.Settings
|
||||||
{
|
{
|
||||||
@ -33,22 +33,10 @@ namespace osu.Game.Overlays.Settings
|
|||||||
|
|
||||||
private SpriteText text;
|
private SpriteText text;
|
||||||
|
|
||||||
private readonly RestoreDefaultValueButton restoreDefaultValueButton = new RestoreDefaultValueButton();
|
private readonly RestoreDefaultValueButton restoreDefaultButton;
|
||||||
|
|
||||||
public bool ShowsDefaultIndicator = true;
|
public bool ShowsDefaultIndicator = true;
|
||||||
|
|
||||||
private Color4? restoreDefaultValueColour;
|
|
||||||
|
|
||||||
public Color4 RestoreDefaultValueColour
|
|
||||||
{
|
|
||||||
get { return restoreDefaultValueColour ?? Color4.White; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
restoreDefaultValueColour = value;
|
|
||||||
restoreDefaultValueButton?.SetButtonColour(RestoreDefaultValueColour);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual string LabelText
|
public virtual string LabelText
|
||||||
{
|
{
|
||||||
get { return text?.Text ?? string.Empty; }
|
get { return text?.Text ?? string.Empty; }
|
||||||
@ -69,10 +57,7 @@ namespace osu.Game.Overlays.Settings
|
|||||||
|
|
||||||
public virtual Bindable<T> Bindable
|
public virtual Bindable<T> Bindable
|
||||||
{
|
{
|
||||||
get
|
get { return bindable; }
|
||||||
{
|
|
||||||
return bindable;
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
@ -80,8 +65,8 @@ namespace osu.Game.Overlays.Settings
|
|||||||
controlWithCurrent?.Current.BindTo(bindable);
|
controlWithCurrent?.Current.BindTo(bindable);
|
||||||
if (ShowsDefaultIndicator)
|
if (ShowsDefaultIndicator)
|
||||||
{
|
{
|
||||||
restoreDefaultValueButton.Bindable = bindable.GetBoundCopy();
|
restoreDefaultButton.Bindable = bindable.GetBoundCopy();
|
||||||
restoreDefaultValueButton.Bindable.TriggerChange();
|
restoreDefaultButton.Bindable.TriggerChange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,38 +88,30 @@ namespace osu.Game.Overlays.Settings
|
|||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
Padding = new MarginPadding { Right = SettingsOverlay.CONTENT_MARGINS };
|
Padding = new MarginPadding { Right = SettingsOverlay.CONTENT_MARGINS };
|
||||||
|
|
||||||
FlowContent = new FillFlowContainer
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
restoreDefaultButton = new RestoreDefaultValueButton(),
|
||||||
AutoSizeAxes = Axes.Y,
|
FlowContent = new FillFlowContainer
|
||||||
Padding = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS, Right = 5 },
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Padding = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS },
|
||||||
|
Child = Control = CreateControl()
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if ((Control = CreateControl()) != null)
|
|
||||||
{
|
|
||||||
if (controlWithCurrent != null)
|
|
||||||
controlWithCurrent.Current.DisabledChanged += disabled => { Colour = disabled ? Color4.Gray : Color4.White; };
|
|
||||||
FlowContent.Add(Control);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load()
|
||||||
{
|
{
|
||||||
AddInternal(FlowContent);
|
if (controlWithCurrent != null)
|
||||||
|
controlWithCurrent.Current.DisabledChanged += disabled => { Colour = disabled ? Color4.Gray : Color4.White; };
|
||||||
if (restoreDefaultValueButton != null)
|
|
||||||
{
|
|
||||||
if (!restoreDefaultValueColour.HasValue)
|
|
||||||
restoreDefaultValueColour = colours.Yellow;
|
|
||||||
restoreDefaultValueButton.SetButtonColour(RestoreDefaultValueColour);
|
|
||||||
AddInternal(restoreDefaultValueButton);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RestoreDefaultValueButton : Box, IHasTooltip
|
private class RestoreDefaultValueButton : Container, IHasTooltip
|
||||||
{
|
{
|
||||||
private Bindable<T> bindable;
|
private Bindable<T> bindable;
|
||||||
|
|
||||||
public Bindable<T> Bindable
|
public Bindable<T> Bindable
|
||||||
{
|
{
|
||||||
get { return bindable; }
|
get { return bindable; }
|
||||||
@ -157,6 +134,36 @@ namespace osu.Game.Overlays.Settings
|
|||||||
Alpha = 0f;
|
Alpha = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colour)
|
||||||
|
{
|
||||||
|
buttonColour = colour.Yellow;
|
||||||
|
|
||||||
|
Child = new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
CornerRadius = 3,
|
||||||
|
Masking = true,
|
||||||
|
Colour = buttonColour,
|
||||||
|
EdgeEffect = new EdgeEffectParameters
|
||||||
|
{
|
||||||
|
Colour = buttonColour.Opacity(0.1f),
|
||||||
|
Type = EdgeEffectType.Glow,
|
||||||
|
Radius = 2,
|
||||||
|
},
|
||||||
|
Size = new Vector2(0.33f, 0.8f),
|
||||||
|
Child = new Box { RelativeSizeAxes = Axes.Both },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
UpdateState();
|
||||||
|
}
|
||||||
|
|
||||||
public string TooltipText => "Revert to default";
|
public string TooltipText => "Revert to default";
|
||||||
|
|
||||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;
|
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;
|
||||||
@ -193,9 +200,10 @@ namespace osu.Game.Overlays.Settings
|
|||||||
{
|
{
|
||||||
if (bindable == null)
|
if (bindable == null)
|
||||||
return;
|
return;
|
||||||
var colour = bindable.Disabled ? Color4.Gray : buttonColour;
|
|
||||||
this.FadeTo(bindable.IsDefault ? 0f : hovering && !bindable.Disabled ? 1f : 0.5f, 200, Easing.OutQuint);
|
this.FadeTo(bindable.IsDefault ? 0f :
|
||||||
this.FadeColour(ColourInfo.GradientHorizontal(colour.Opacity(0.8f), colour.Opacity(0)), 200, Easing.OutQuint);
|
hovering && !bindable.Disabled ? 1f : 0.65f, 200, Easing.OutQuint);
|
||||||
|
this.FadeColour(bindable.Disabled ? Color4.Gray : buttonColour, 200, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
public abstract class SettingsOverlay : OsuFocusedOverlayContainer
|
public abstract class SettingsOverlay : OsuFocusedOverlayContainer
|
||||||
{
|
{
|
||||||
public const float CONTENT_MARGINS = 10;
|
public const float CONTENT_MARGINS = 15;
|
||||||
|
|
||||||
public const float TRANSITION_LENGTH = 600;
|
public const float TRANSITION_LENGTH = 600;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user