mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 17:03:02 +08:00
Merge remote-tracking branch 'refs/remotes/ppy/master' into comments_api
This commit is contained in:
commit
7ac87494e0
@ -16,7 +16,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
{
|
{
|
||||||
typeof(CommentsHeader),
|
typeof(CommentsHeader),
|
||||||
typeof(HeaderButton),
|
typeof(HeaderButton),
|
||||||
typeof(SortSelector),
|
typeof(SortTabControl),
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly Bindable<CommentsSortCriteria> sort = new Bindable<CommentsSortCriteria>();
|
private readonly Bindable<CommentsSortCriteria> sort = new Bindable<CommentsSortCriteria>();
|
||||||
|
@ -15,10 +15,7 @@ namespace osu.Game.Overlays.Comments
|
|||||||
{
|
{
|
||||||
public class CommentsHeader : CompositeDrawable
|
public class CommentsHeader : CompositeDrawable
|
||||||
{
|
{
|
||||||
private const int height = 40;
|
private const int font_size = 14;
|
||||||
private const int spacing = 10;
|
|
||||||
private const int padding = 50;
|
|
||||||
private const int text_size = 14;
|
|
||||||
|
|
||||||
public readonly Bindable<CommentsSortCriteria> Sort = new Bindable<CommentsSortCriteria>();
|
public readonly Bindable<CommentsSortCriteria> Sort = new Bindable<CommentsSortCriteria>();
|
||||||
public readonly BindableBool ShowDeleted = new BindableBool();
|
public readonly BindableBool ShowDeleted = new BindableBool();
|
||||||
@ -28,7 +25,8 @@ namespace osu.Game.Overlays.Comments
|
|||||||
public CommentsHeader()
|
public CommentsHeader()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
Height = height;
|
Height = 40;
|
||||||
|
|
||||||
AddRangeInternal(new Drawable[]
|
AddRangeInternal(new Drawable[]
|
||||||
{
|
{
|
||||||
background = new Box
|
background = new Box
|
||||||
@ -38,14 +36,14 @@ namespace osu.Game.Overlays.Comments
|
|||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Padding = new MarginPadding { Horizontal = padding },
|
Padding = new MarginPadding { Horizontal = 50 },
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new FillFlowContainer
|
new FillFlowContainer
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Direction = FillDirection.Horizontal,
|
Direction = FillDirection.Horizontal,
|
||||||
Spacing = new Vector2(spacing, 0),
|
Spacing = new Vector2(10, 0),
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
@ -54,10 +52,10 @@ namespace osu.Game.Overlays.Comments
|
|||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
Font = OsuFont.GetFont(size: text_size),
|
Font = OsuFont.GetFont(size: font_size),
|
||||||
Text = @"Sort by"
|
Text = @"Sort by"
|
||||||
},
|
},
|
||||||
new SortSelector
|
new SortTabControl
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
@ -107,7 +105,7 @@ namespace osu.Game.Overlays.Comments
|
|||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
Font = OsuFont.GetFont(size: text_size),
|
Font = OsuFont.GetFont(size: font_size),
|
||||||
Text = @"Show deleted"
|
Text = @"Show deleted"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -116,19 +114,14 @@ namespace osu.Game.Overlays.Comments
|
|||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
Checked.BindValueChanged(onCheckedChanged, true);
|
Checked.BindValueChanged(isChecked => checkboxIcon.Icon = isChecked.NewValue ? FontAwesome.Solid.CheckSquare : FontAwesome.Regular.Square, true);
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onCheckedChanged(ValueChangedEvent<bool> isChecked)
|
|
||||||
{
|
|
||||||
checkboxIcon.Icon = isChecked.NewValue ? FontAwesome.Solid.CheckSquare : FontAwesome.Regular.Square;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
{
|
{
|
||||||
Checked.Value = !Checked.Value;
|
Checked.Value = !Checked.Value;
|
||||||
return base.OnClick(e);
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,7 @@ namespace osu.Game.Overlays.Comments
|
|||||||
{
|
{
|
||||||
public class HeaderButton : Container
|
public class HeaderButton : Container
|
||||||
{
|
{
|
||||||
private const int height = 20;
|
private const int transition_duration = 200;
|
||||||
private const int corner_radius = 3;
|
|
||||||
private const int margin = 10;
|
|
||||||
private const int duration = 200;
|
|
||||||
|
|
||||||
protected override Container<Drawable> Content => content;
|
protected override Container<Drawable> Content => content;
|
||||||
|
|
||||||
@ -26,9 +23,9 @@ namespace osu.Game.Overlays.Comments
|
|||||||
public HeaderButton()
|
public HeaderButton()
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.X;
|
AutoSizeAxes = Axes.X;
|
||||||
Height = height;
|
Height = 20;
|
||||||
Masking = true;
|
Masking = true;
|
||||||
CornerRadius = corner_radius;
|
CornerRadius = 3;
|
||||||
AddRangeInternal(new Drawable[]
|
AddRangeInternal(new Drawable[]
|
||||||
{
|
{
|
||||||
background = new Box
|
background = new Box
|
||||||
@ -41,7 +38,7 @@ namespace osu.Game.Overlays.Comments
|
|||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Margin = new MarginPadding { Horizontal = margin }
|
Margin = new MarginPadding { Horizontal = 10 }
|
||||||
},
|
},
|
||||||
new HoverClickSounds(),
|
new HoverClickSounds(),
|
||||||
});
|
});
|
||||||
@ -55,18 +52,18 @@ namespace osu.Game.Overlays.Comments
|
|||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
FadeInBackground();
|
ShowBackground();
|
||||||
return base.OnHover(e);
|
return base.OnHover(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnHoverLost(HoverLostEvent e)
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
{
|
{
|
||||||
base.OnHoverLost(e);
|
base.OnHoverLost(e);
|
||||||
FadeOutBackground();
|
HideBackground();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void FadeInBackground() => background.FadeIn(duration, Easing.OutQuint);
|
protected void ShowBackground() => background.FadeIn(transition_duration, Easing.OutQuint);
|
||||||
|
|
||||||
protected void FadeOutBackground() => background.FadeOut(duration, Easing.OutQuint);
|
protected void HideBackground() => background.FadeOut(transition_duration, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,8 @@ using osuTK.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.Comments
|
namespace osu.Game.Overlays.Comments
|
||||||
{
|
{
|
||||||
public class SortSelector : OsuTabControl<CommentsSortCriteria>
|
public class SortTabControl : OsuTabControl<CommentsSortCriteria>
|
||||||
{
|
{
|
||||||
private const int spacing = 5;
|
|
||||||
|
|
||||||
protected override Dropdown<CommentsSortCriteria> CreateDropdown() => null;
|
protected override Dropdown<CommentsSortCriteria> CreateDropdown() => null;
|
||||||
|
|
||||||
protected override TabItem<CommentsSortCriteria> CreateTabItem(CommentsSortCriteria value) => new SortTabItem(value);
|
protected override TabItem<CommentsSortCriteria> CreateTabItem(CommentsSortCriteria value) => new SortTabItem(value);
|
||||||
@ -27,36 +25,33 @@ namespace osu.Game.Overlays.Comments
|
|||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Direction = FillDirection.Horizontal,
|
Direction = FillDirection.Horizontal,
|
||||||
Spacing = new Vector2(spacing, 0),
|
Spacing = new Vector2(5, 0),
|
||||||
};
|
};
|
||||||
|
|
||||||
public SortSelector()
|
public SortTabControl()
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SortTabItem : TabItem<CommentsSortCriteria>
|
private class SortTabItem : TabItem<CommentsSortCriteria>
|
||||||
{
|
{
|
||||||
private readonly TabContent content;
|
|
||||||
|
|
||||||
public SortTabItem(CommentsSortCriteria value)
|
public SortTabItem(CommentsSortCriteria value)
|
||||||
: base(value)
|
: base(value)
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
Child = content = new TabContent(value)
|
Child = new TabButton(value) { Active = { BindTarget = Active } };
|
||||||
{
|
|
||||||
Active = { BindTarget = Active }
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnActivated() => content.Activate();
|
protected override void OnActivated()
|
||||||
|
|
||||||
protected override void OnDeactivated() => content.Deactivate();
|
|
||||||
|
|
||||||
private class TabContent : HeaderButton
|
|
||||||
{
|
{
|
||||||
private const int text_size = 14;
|
}
|
||||||
|
|
||||||
|
protected override void OnDeactivated()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TabButton : HeaderButton
|
||||||
|
{
|
||||||
public readonly BindableBool Active = new BindableBool();
|
public readonly BindableBool Active = new BindableBool();
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
@ -64,34 +59,42 @@ namespace osu.Game.Overlays.Comments
|
|||||||
|
|
||||||
private readonly SpriteText text;
|
private readonly SpriteText text;
|
||||||
|
|
||||||
public TabContent(CommentsSortCriteria value)
|
public TabButton(CommentsSortCriteria value)
|
||||||
{
|
{
|
||||||
Add(text = new SpriteText
|
Add(text = new SpriteText
|
||||||
{
|
{
|
||||||
Font = OsuFont.GetFont(size: text_size),
|
Font = OsuFont.GetFont(size: 14),
|
||||||
Text = value.ToString()
|
Text = value.ToString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
FadeInBackground();
|
base.LoadComplete();
|
||||||
text.Font = text.Font.With(weight: FontWeight.Bold);
|
|
||||||
text.Colour = colours.BlueLighter;
|
Active.BindValueChanged(active =>
|
||||||
|
{
|
||||||
|
updateBackgroundState();
|
||||||
|
|
||||||
|
text.Font = text.Font.With(weight: active.NewValue ? FontWeight.Bold : FontWeight.Medium);
|
||||||
|
text.Colour = active.NewValue ? colours.BlueLighter : Color4.White;
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Deactivate()
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
if (!IsHovered)
|
updateBackgroundState();
|
||||||
FadeOutBackground();
|
return true;
|
||||||
|
|
||||||
text.Font = text.Font.With(weight: FontWeight.Medium);
|
|
||||||
text.Colour = Color4.White;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnHoverLost(HoverLostEvent e)
|
protected override void OnHoverLost(HoverLostEvent e) => updateBackgroundState();
|
||||||
|
|
||||||
|
private void updateBackgroundState()
|
||||||
{
|
{
|
||||||
if (!Active.Value) base.OnHoverLost(e);
|
if (Active.Value || IsHovered)
|
||||||
|
ShowBackground();
|
||||||
|
else
|
||||||
|
HideBackground();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user