mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 17:47:29 +08:00
CheckBox -> Checkbox.
This commit is contained in:
parent
f42935eccf
commit
24d06fa92d
@ -12,7 +12,7 @@ using osu.Framework.Graphics.UserInterface;
|
|||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
{
|
{
|
||||||
public class Nub : CircularContainer, IStateful<CheckBoxState>
|
public class Nub : CircularContainer, IStateful<CheckboxState>
|
||||||
{
|
{
|
||||||
public const float COLLAPSED_SIZE = 20;
|
public const float COLLAPSED_SIZE = 20;
|
||||||
public const float EXPANDED_SIZE = 40;
|
public const float EXPANDED_SIZE = 40;
|
||||||
@ -84,9 +84,9 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private CheckBoxState state;
|
private CheckboxState state;
|
||||||
|
|
||||||
public CheckBoxState State
|
public CheckboxState State
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@ -98,10 +98,10 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case CheckBoxState.Checked:
|
case CheckboxState.Checked:
|
||||||
fill.FadeIn(200, EasingTypes.OutQuint);
|
fill.FadeIn(200, EasingTypes.OutQuint);
|
||||||
break;
|
break;
|
||||||
case CheckBoxState.Unchecked:
|
case CheckboxState.Unchecked:
|
||||||
fill.FadeTo(0.01f, 200, EasingTypes.OutQuint); //todo: remove once we figure why containers aren't drawing at all times
|
fill.FadeTo(0.01f, 200, EasingTypes.OutQuint); //todo: remove once we figure why containers aren't drawing at all times
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ using OpenTK.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
{
|
{
|
||||||
public class OsuCheckbox : CheckBox
|
public class OsuCheckbox : Checkbox
|
||||||
{
|
{
|
||||||
private Bindable<bool> bindable;
|
private Bindable<bool> bindable;
|
||||||
|
|
||||||
@ -29,9 +29,9 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
bindable = value;
|
bindable = value;
|
||||||
if (bindable != null)
|
if (bindable != null)
|
||||||
{
|
{
|
||||||
bool state = State == CheckBoxState.Checked;
|
bool state = State == CheckboxState.Checked;
|
||||||
if (state != bindable.Value)
|
if (state != bindable.Value)
|
||||||
State = bindable.Value ? CheckBoxState.Checked : CheckBoxState.Unchecked;
|
State = bindable.Value ? CheckboxState.Checked : CheckboxState.Unchecked;
|
||||||
bindable.ValueChanged += bindableValueChanged;
|
bindable.ValueChanged += bindableValueChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
private void bindableValueChanged(object sender, EventArgs e)
|
private void bindableValueChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
State = bindable.Value ? CheckBoxState.Checked : CheckBoxState.Unchecked;
|
State = bindable.Value ? CheckboxState.Checked : CheckboxState.Unchecked;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
@ -122,7 +122,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
protected override void OnChecked()
|
protected override void OnChecked()
|
||||||
{
|
{
|
||||||
sampleChecked?.Play();
|
sampleChecked?.Play();
|
||||||
nub.State = CheckBoxState.Checked;
|
nub.State = CheckboxState.Checked;
|
||||||
|
|
||||||
if (bindable != null)
|
if (bindable != null)
|
||||||
bindable.Value = true;
|
bindable.Value = true;
|
||||||
@ -131,7 +131,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
protected override void OnUnchecked()
|
protected override void OnUnchecked()
|
||||||
{
|
{
|
||||||
sampleUnchecked?.Play();
|
sampleUnchecked?.Play();
|
||||||
nub.State = CheckBoxState.Unchecked;
|
nub.State = CheckboxState.Unchecked;
|
||||||
|
|
||||||
if (bindable != null)
|
if (bindable != null)
|
||||||
bindable.Value = false;
|
bindable.Value = false;
|
||||||
|
@ -50,7 +50,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
nub = new Nub
|
nub = new Nub
|
||||||
{
|
{
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
State = CheckBoxState.Unchecked,
|
State = CheckboxState.Unchecked,
|
||||||
Expanded = true,
|
Expanded = true,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -94,13 +94,13 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||||
{
|
{
|
||||||
nub.State = CheckBoxState.Checked;
|
nub.State = CheckboxState.Checked;
|
||||||
return base.OnMouseDown(state, args);
|
return base.OnMouseDown(state, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
|
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
|
||||||
{
|
{
|
||||||
nub.State = CheckBoxState.Unchecked;
|
nub.State = CheckboxState.Unchecked;
|
||||||
return base.OnMouseUp(state, args);
|
return base.OnMouseUp(state, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,15 +16,15 @@ using osu.Game.Graphics.Sprites;
|
|||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A checkbox styled to be placed in line with an <see cref="OsuTabControl{T}"/>
|
/// A Checkbox styled to be placed in line with an <see cref="OsuTabControl{T}"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class OsuTabControlCheckBox : CheckBox
|
public class OsuTabControlCheckbox : Checkbox
|
||||||
{
|
{
|
||||||
private readonly Box box;
|
private readonly Box box;
|
||||||
private readonly SpriteText text;
|
private readonly SpriteText text;
|
||||||
private readonly TextAwesome icon;
|
private readonly TextAwesome icon;
|
||||||
|
|
||||||
public event EventHandler<CheckBoxState> Action;
|
public event EventHandler<CheckboxState> Action;
|
||||||
|
|
||||||
private Color4? accentColour;
|
private Color4? accentColour;
|
||||||
public Color4 AccentColour
|
public Color4 AccentColour
|
||||||
@ -34,7 +34,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
accentColour = value;
|
accentColour = value;
|
||||||
|
|
||||||
if (State != CheckBoxState.Checked)
|
if (State != CheckboxState.Checked)
|
||||||
{
|
{
|
||||||
text.Colour = AccentColour;
|
text.Colour = AccentColour;
|
||||||
icon.Colour = AccentColour;
|
icon.Colour = AccentColour;
|
||||||
@ -84,7 +84,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
protected override void OnHoverLost(InputState state)
|
protected override void OnHoverLost(InputState state)
|
||||||
{
|
{
|
||||||
if (State == CheckBoxState.Unchecked)
|
if (State == CheckboxState.Unchecked)
|
||||||
fadeOut();
|
fadeOut();
|
||||||
|
|
||||||
base.OnHoverLost(state);
|
base.OnHoverLost(state);
|
||||||
@ -97,7 +97,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
AccentColour = colours.Blue;
|
AccentColour = colours.Blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OsuTabControlCheckBox()
|
public OsuTabControlCheckbox()
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
@ -17,14 +17,14 @@ namespace osu.Game.Screens.Select
|
|||||||
public class BeatmapDetailAreaTabControl : Container
|
public class BeatmapDetailAreaTabControl : Container
|
||||||
{
|
{
|
||||||
public static readonly float HEIGHT = 24;
|
public static readonly float HEIGHT = 24;
|
||||||
private readonly OsuTabControlCheckBox modsCheckbox;
|
private readonly OsuTabControlCheckbox modsCheckbox;
|
||||||
private readonly OsuTabControl<BeatmapDetailTab> tabs;
|
private readonly OsuTabControl<BeatmapDetailTab> tabs;
|
||||||
|
|
||||||
public Action<BeatmapDetailTab, bool> OnFilter; //passed the selected tab and if mods is checked
|
public Action<BeatmapDetailTab, bool> OnFilter; //passed the selected tab and if mods is checked
|
||||||
|
|
||||||
private void invokeOnFilter()
|
private void invokeOnFilter()
|
||||||
{
|
{
|
||||||
OnFilter?.Invoke(tabs.SelectedItem, modsCheckbox.State == CheckBoxState.Checked);
|
OnFilter?.Invoke(tabs.SelectedItem, modsCheckbox.State == CheckboxState.Checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -53,7 +53,7 @@ namespace osu.Game.Screens.Select
|
|||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
},
|
},
|
||||||
modsCheckbox = new OsuTabControlCheckBox
|
modsCheckbox = new OsuTabControlCheckbox
|
||||||
{
|
{
|
||||||
Anchor = Anchor.BottomRight,
|
Anchor = Anchor.BottomRight,
|
||||||
Origin = Anchor.BottomRight,
|
Origin = Anchor.BottomRight,
|
||||||
|
Loading…
Reference in New Issue
Block a user