Added switching between grid/list and little transitions for the panels

This commit is contained in:
DrabWeb 2017-05-19 17:52:34 -03:00
parent 1d61fc84c7
commit 05b8fc5126
4 changed files with 116 additions and 15 deletions

View File

@ -22,11 +22,14 @@ namespace osu.Game.Overlays.Direct
private readonly float horizontal_padding = 10;
private readonly float vertical_padding = 5;
private FillFlowContainer bottomPanel;
public DirectGridPanel(BeatmapSetInfo beatmap) : base(beatmap)
{
Height = 140 + vertical_padding; //full height of all the elements plus vertical padding (autosize uses the image)
CornerRadius = 4;
Masking = true;
EdgeEffect = new EdgeEffect
{
Type = EdgeEffectType.Shadow,
@ -36,6 +39,16 @@ namespace osu.Game.Overlays.Direct
};
}
protected override void LoadComplete()
{
base.LoadComplete();
FadeInFromZero(200, EasingTypes.Out);
bottomPanel.LayoutDuration = 200;
bottomPanel.LayoutEasing = EasingTypes.Out;
bottomPanel.Origin = Anchor.BottomLeft;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, LocalisationEngine localisation, TextureStore textures)
{
@ -52,10 +65,10 @@ namespace osu.Game.Overlays.Direct
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black.Opacity(0.5f),
},
new FillFlowContainer
bottomPanel = new FillFlowContainer
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Origin = Anchor.TopLeft,
Direction = FillDirection.Vertical,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,

View File

@ -39,6 +39,13 @@ namespace osu.Game.Overlays.Direct
};
}
protected override void LoadComplete()
{
base.LoadComplete();
FadeInFromZero(200, EasingTypes.Out);
}
[BackgroundDependencyLoader]
private void load(LocalisationEngine localisation, TextureStore textures)
{

View File

@ -31,15 +31,16 @@ namespace osu.Game.Overlays.Direct
private readonly Box tabStrip;
private readonly FillFlowContainer<RulesetToggleButton> modeButtons;
private FillFlowContainer resultCountsContainer;
private OsuSpriteText resultCountsText;
private readonly FillFlowContainer resultCountsContainer;
private readonly OsuSpriteText resultCountsText;
public readonly SearchTextBox Search;
public readonly SortTabControl SortTabs;
public readonly OsuEnumDropdown<RankStatus> RankStatusDropdown;
public readonly Bindable<PanelDisplayStyle> DisplayStyle = new Bindable<PanelDisplayStyle>();
private ResultCounts resultCounts;
public ResultCounts ResultCounts
public ResultCounts ResultCounts
{
get { return resultCounts; }
set { resultCounts = value; updateResultCounts(); }
@ -49,6 +50,7 @@ namespace osu.Game.Overlays.Direct
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
DisplayStyle.Value = PanelDisplayStyle.Grid;
Children = new Drawable[]
{
@ -90,13 +92,33 @@ namespace osu.Game.Overlays.Direct
},
},
},
RankStatusDropdown = new SlimEnumDropdown<RankStatus>
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
RelativeSizeAxes = Axes.None,
Spacing = new Vector2(10f, 0f),
Direction = FillDirection.Horizontal,
Margin = new MarginPadding { Bottom = 5, Right = DirectOverlay.WIDTH_PADDING },
Width = 160f,
Children = new Drawable[]
{
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Spacing = new Vector2(5f, 0f),
Direction = FillDirection.Horizontal,
Children = new[]
{
new DisplayModeToggleButton(FontAwesome.fa_th_large, PanelDisplayStyle.Grid, DisplayStyle),
new DisplayModeToggleButton(FontAwesome.fa_list_ul, PanelDisplayStyle.List, DisplayStyle),
},
},
RankStatusDropdown = new SlimEnumDropdown<RankStatus>
{
RelativeSizeAxes = Axes.None,
Width = 160f,
},
},
},
resultCountsContainer = new FillFlowContainer
{
@ -117,7 +139,7 @@ namespace osu.Game.Overlays.Direct
TextSize = 15,
Font = @"Exo2.0-Bold",
},
}
}
},
};
@ -221,6 +243,47 @@ namespace osu.Game.Overlays.Direct
}
}
private class DisplayModeToggleButton : ClickableContainer
{
private readonly TextAwesome icon;
private readonly PanelDisplayStyle mode;
private readonly Bindable<PanelDisplayStyle> bindable;
public DisplayModeToggleButton(FontAwesome icon, PanelDisplayStyle mode, Bindable<PanelDisplayStyle> bindable)
{
this.bindable = bindable;
this.mode = mode;
Size = new Vector2(25f);
Children = new Drawable[]
{
this.icon = new TextAwesome
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Icon = icon,
TextSize = 18,
UseFullGlyphHeight = false,
Alpha = 0.5f,
},
};
bindable.ValueChanged += Bindable_ValueChanged;
Bindable_ValueChanged(bindable.Value);
Action = () => bindable.Value = this.mode;
}
private void Bindable_ValueChanged(PanelDisplayStyle mode)
{
icon.FadeTo(mode == this.mode ? 1.0f : 0.5f, 100);
}
protected override void Dispose(bool isDisposing)
{
bindable.ValueChanged -= Bindable_ValueChanged;
}
}
private class SlimEnumDropdown<T> : OsuEnumDropdown<T>
{
protected override DropdownHeader CreateHeader() => new SlimDropdownHeader { AccentColour = AccentColour };
@ -257,7 +320,7 @@ namespace osu.Game.Overlays.Direct
public readonly int Artists;
public readonly int Songs;
public readonly int Tags;
public ResultCounts(int artists, int songs, int tags)
{
Artists = artists;
@ -281,4 +344,10 @@ namespace osu.Game.Overlays.Direct
[Description("My Maps")]
MyMaps,
}
public enum PanelDisplayStyle
{
Grid,
List,
}
}

View File

@ -22,16 +22,16 @@ namespace osu.Game.Overlays
private readonly FilterControl filter;
private readonly FillFlowContainer<DirectPanel> panels;
private IEnumerable<BeatmapSetInfo> beatmapSets;
public IEnumerable<BeatmapSetInfo> BeatmapSets
{
get { return beatmapSets; }
set
{
var p = new List<DirectPanel>();
if (beatmapSets == value) return;
beatmapSets = value;
foreach (BeatmapSetInfo b in value)
p.Add(new DirectListPanel(b)); //todo: proper switching between grid/list
panels.Children = p;
recreatePanels(filter.DisplayStyle.Value);
}
}
@ -110,6 +110,18 @@ namespace osu.Game.Overlays
};
filter.Search.Exit = Hide;
filter.DisplayStyle.ValueChanged += recreatePanels;
}
private void recreatePanels(PanelDisplayStyle displayStyle)
{
var p = new List<DirectPanel>();
foreach (BeatmapSetInfo b in BeatmapSets)
p.Add(displayStyle == PanelDisplayStyle.Grid ? (DirectPanel)(new DirectGridPanel(b) { Width = 400}) :
(DirectPanel)(new DirectListPanel(b)));
panels.Children = p;
}
protected override void PopIn()