diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/BottomEditor/AdjustTimeTagBottomEditor.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/BottomEditor/AdjustTimeTagBottomEditor.cs index a930546c0..620123d7b 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/BottomEditor/AdjustTimeTagBottomEditor.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/BottomEditor/AdjustTimeTagBottomEditor.cs @@ -19,13 +19,6 @@ protected override Drawable CreateInfo() return new Container(); } - protected override Drawable CreateContent() - { - return new AdjustTimeTagScrollContainer - { - RelativeSizeAxes = Axes.X, - Height = 100, - }; - } + protected override Drawable CreateContent() => new AdjustTimeTagScrollContainer(); } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/BottomEditor/BaseBottomEditor.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/BottomEditor/BaseBottomEditor.cs index 43f0902cf..dc14540b6 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/BottomEditor/BaseBottomEditor.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/BottomEditor/BaseBottomEditor.cs @@ -32,25 +32,28 @@ private void load(ILyricEditorState state, LyricEditorColourProvider colourProvi }, new GridContainer { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.Both, ColumnDimensions = new[] { new Dimension(GridSizeMode.Absolute, info_part_spacing), new Dimension() }, - RowDimensions = new[] { new Dimension(GridSizeMode.Relative) }, Content = new[] { new[] { - CreateInfo(), + CreateInfo().With(x => + { + x.RelativeSizeAxes = Axes.Both; + }), new Container { Masking = true, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Child = CreateContent(), + RelativeSizeAxes = Axes.Both, + Child = CreateContent().With(x => + { + x.RelativeSizeAxes = Axes.Both; + }), } } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/BottomEditor/NoteBottomEditor.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/BottomEditor/NoteBottomEditor.cs index 63e49960a..3bebabf2c 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/BottomEditor/NoteBottomEditor.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/BottomEditor/NoteBottomEditor.cs @@ -19,13 +19,6 @@ protected override Drawable CreateInfo() return new Container(); } - protected override Drawable CreateContent() - { - return new NoteEditor - { - RelativeSizeAxes = Axes.X, - Height = 150, - }; - } + protected override Drawable CreateContent() => new NoteEditor(); } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/BottomEditor/RecordingTimeTagBottomEditor.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/BottomEditor/RecordingTimeTagBottomEditor.cs index f69c45d21..1a9a5e100 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/BottomEditor/RecordingTimeTagBottomEditor.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/BottomEditor/RecordingTimeTagBottomEditor.cs @@ -19,13 +19,6 @@ protected override Drawable CreateInfo() return new Container(); } - protected override Drawable CreateContent() - { - return new RecordingTimeTagScrollContainer - { - RelativeSizeAxes = Axes.X, - Height = 60, - }; - } + protected override Drawable CreateContent() => new RecordingTimeTagScrollContainer(); } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/LyricComposer.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/LyricComposer.cs index b902fc65f..f1a1179c0 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/LyricComposer.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/LyricComposer.cs @@ -8,6 +8,7 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions.EnumExtensions; +using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -39,10 +40,11 @@ public class LyricComposer : CompositeDrawable [Resolved, AllowNull] private LyricEditorColourProvider colourProvider { get; set; } + private readonly GridContainer gridContainer; + private readonly Container centerEditArea; private readonly Container mainEditorArea; - private readonly Container bottomEditArea; private readonly Container bottomEditorContainer; public LyricComposer() @@ -50,56 +52,63 @@ public LyricComposer() Box centerEditorBackground; Box bottomEditorBackground; - InternalChildren = new Drawable[] + InternalChild = gridContainer = new GridContainer { - centerEditArea = new Container + RelativeSizeAxes = Axes.Both, + Content = new[] { - Name = "Edit area and action buttons", - RelativeSizeAxes = Axes.Both, - Children = new Drawable[] + new Drawable[] { - centerEditorBackground = new Box - { - Name = "Background", - RelativeSizeAxes = Axes.Both, - }, - mainEditorArea = new Container + centerEditArea = new Container { + Name = "Edit area and action buttons", RelativeSizeAxes = Axes.Both, Children = new Drawable[] { - new LyricEditor(), - new SpecialActionToolbar + centerEditorBackground = new Box { - Name = "Toolbar", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, + Name = "Background", + RelativeSizeAxes = Axes.Both, }, + mainEditorArea = new Container + { + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] + { + new LyricEditor(), + new SpecialActionToolbar + { + Name = "Toolbar", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + }, + } + } } - } - } - }, - bottomEditArea = new Container - { - Name = "Edit area and action buttons", - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - Children = new Drawable[] + }, + }, + new Drawable[] { - bottomEditorBackground = new Box + new Container { - Name = "Background", + Name = "Edit area and action buttons", RelativeSizeAxes = Axes.Both, + Masking = true, + Children = new Drawable[] + { + bottomEditorBackground = new Box + { + Name = "Background", + RelativeSizeAxes = Axes.Both, + }, + bottomEditorContainer = new Container + { + RelativeSizeAxes = Axes.Both, + } + } }, - bottomEditorContainer = new Container - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - } } - }, + } }; bindableModeAndSubMode.BindValueChanged(e => @@ -112,7 +121,7 @@ public LyricComposer() return; centerEditorBackground.Colour = colourProvider.Background1(e.NewValue.Mode); - bottomEditorBackground.Colour = colourProvider.Background5(e.NewValue.Mode); + bottomEditorBackground.Colour = colourProvider.Background4(e.NewValue.Mode); }); }, true); @@ -126,7 +135,7 @@ public LyricComposer() bindableBottomEditorType.BindValueChanged(e => { assignBottomEditor(e.NewValue); - }); + }, true); foreach (var (type, bindable) in panelStatus) { @@ -292,13 +301,42 @@ private void toggleChangeBottomEditor() private void assignBottomEditor(BottomEditorType? bottomEditorType) { - bottomEditorContainer.Clear(); + const double remove_old_editor_time = 200; + const double new_animation_time = 200; - var bottomEditor = createBottomEditor(bottomEditorType); - if (bottomEditor != null) - bottomEditorContainer.Add(bottomEditor); + bool hasOldButtonEditor = bottomEditorContainer.Children.Any(); + var newButtonEditor = createBottomEditor(bottomEditorType).With(x => + { + if (x == null) + return; - calculateBottomEditAreaSize(bottomEditor); + x.RelativePositionAxes = Axes.Y; + x.Y = -1; + x.Alpha = 0; + }); + + if (hasOldButtonEditor) + { + bottomEditorContainer.Children.ForEach(editor => + { + editor.MoveToY(-1, remove_old_editor_time).FadeOut(remove_old_editor_time).Then().OnComplete(x => + { + x.Expire(); + + updateBottomEditAreaSize(newButtonEditor); + }); + }); + } + else + { + updateBottomEditAreaSize(newButtonEditor); + } + + if (newButtonEditor == null) + return; + + bottomEditorContainer.Add(newButtonEditor); + newButtonEditor.Delay(hasOldButtonEditor ? remove_old_editor_time : 0).FadeIn(0).MoveToY(0, new_animation_time); static BaseBottomEditor? createBottomEditor(BottomEditorType? bottomEditorType) => bottomEditorType switch @@ -308,11 +346,16 @@ private void assignBottomEditor(BottomEditorType? bottomEditorType) BottomEditorType.Note => new NoteBottomEditor(), _ => null }; - } - private void calculateBottomEditAreaSize(BaseBottomEditor? bottomEditor) - { - float bottomEditorHeight = bottomEditor?.ContentHeight ?? 0; + void updateBottomEditAreaSize(BaseBottomEditor? bottomEditor) + { + float bottomEditorHeight = bottomEditor?.ContentHeight ?? 0; + gridContainer.RowDimensions = new[] + { + new Dimension(), + new Dimension(GridSizeMode.Absolute, bottomEditorHeight) + }; + } } #endregion