Skip to content

Commit

Permalink
Merge pull request #2269 from andy840119/adjust-panel
Browse files Browse the repository at this point in the history
Make the overlay in the lyric composer better.
  • Loading branch information
andy840119 authored Aug 15, 2024
2 parents 55e7a30 + 194486e commit 4a5305a
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static TimeTag convertTimeTag(KeyValuePair<LrcParser.Model.TextIndex, int?> time
static TextIndex convertTextIndex(LrcParser.Model.TextIndex textIndex)
{
int index = textIndex.Index;
var state = textIndex.State == IndexState.Start ? Framework.Graphics.Sprites.TextIndex.IndexState.Start : Framework.Graphics.Sprites.TextIndex.IndexState.End;
var state = textIndex.State == IndexState.Start ? TextIndex.IndexState.Start : TextIndex.IndexState.End;

return new TextIndex(index, state);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected override Drawable CreateContent(Lyric lyric)
new LyricLayer(lyric),
new InteractLyricLayer(lyric),
new TimeTagLayer(lyric),
}
},
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public LyricComposer()
closeOtherPanelsInTheSameDirection(type);
}

togglePanel(type, show);
panelInstance[type].State.Value = show ? Visibility.Visible : Visibility.Hidden;
}, true);
}
}
Expand Down Expand Up @@ -191,13 +191,6 @@ static Panel getInstance(PanelType panelType) =>
};
}

private void togglePanel(PanelType panel, bool show)
{
panelInstance[panel].State.Value = show ? Visibility.Visible : Visibility.Hidden;

calculateLyricEditorSize();
}

private void calculatePanelPosition()
{
float radio = DrawWidth / DrawHeight;
Expand Down Expand Up @@ -234,7 +227,6 @@ private void assignPanelPosition(PanelLayout panelLayout)
}

closeOtherPanelsInTheSameDirection(PanelType.Property);
calculateLyricEditorSize();
}

private void closeOtherPanelsInTheSameDirection(PanelType exceptPanel)
Expand All @@ -248,36 +240,6 @@ private void closeOtherPanelsInTheSameDirection(PanelType exceptPanel)
}
}

private void calculateLyricEditorSize()
{
var padding = new MarginPadding();

foreach (var (position, panelTypes) in panelDirections)
{
var instances = panelTypes.Select(panelType => panelInstance[panelType]).ToArray();
float maxWidth = instances.Any() ? instances.Max(getWidth) : 0;

switch (position)
{
case PanelDirection.Left:
padding.Left = maxWidth;
break;

case PanelDirection.Right:
padding.Right = maxWidth;
break;

default:
throw new ArgumentOutOfRangeException(nameof(position), position, null);
}
}

mainEditorArea.Padding = padding;

static float getWidth(Panel panel)
=> panel.State.Value == Visibility.Visible ? panel.Width : 0;
}

#endregion

#region Bottom editor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ public LyricEditor()

InternalChild = skinProvidingContainer = new SkinProvidingContainer(skin = new LyricEditorSkin(null))
{
Margin = new MarginPadding { Left = 30 },
Padding = new MarginPadding
{
Vertical = 64,
Horizontal = 120,
},
RelativeSizeAxes = Axes.Both,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,38 @@ public abstract partial class Panel : FocusedOverlayContainer
protected virtual string PopOutSampleName => "UI/overlay-pop-out";

private readonly IBindable<LyricEditorMode> bindableMode = new Bindable<LyricEditorMode>();

private readonly Box background;
private readonly FillFlowContainer fillFlowContainer;

protected override bool BlockPositionalInput => false;

protected Panel()
{
RelativeSizeAxes = Axes.Y;
Padding = new MarginPadding(10);

InternalChildren = new Drawable[]
InternalChild = new Container
{
background = new Box
{
Name = "Background",
RelativeSizeAxes = Axes.Both,
},
new OsuScrollContainer
Masking = true,
CornerRadius = 10,
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
RelativeSizeAxes = Axes.Both,
Child = fillFlowContainer = new FillFlowContainer
background = new Box
{
Name = "Background",
RelativeSizeAxes = Axes.Both,
Alpha = 0.6f,
},
new OsuScrollContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(10),
RelativeSizeAxes = Axes.Both,
Child = fillFlowContainer = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(10),
},
},
},
};
Expand Down Expand Up @@ -85,32 +93,25 @@ public PanelDirection Direction
switch (direction)
{
case PanelDirection.Left:
Anchor = Anchor.CentreLeft;
Origin = Anchor.CentreLeft;
Anchor = Anchor.TopLeft;
Origin = Anchor.TopLeft;
break;

case PanelDirection.Right:
Anchor = Anchor.CentreRight;
Origin = Anchor.CentreRight;
Anchor = Anchor.TopRight;
Origin = Anchor.TopRight;
break;

default:
throw new ArgumentOutOfRangeException(nameof(direction));
}

if (State.Value == Visibility.Hidden)
{
X = getHideXPosition();
}
}
}

protected override void PopIn()
{
samplePopIn?.Play();

// todo: adjust the effect.
this.MoveToX(0, transition_length, Easing.OutQuint);
this.FadeTo(1, transition_length, Easing.OutQuint);

// should load the content after opened.
Expand All @@ -121,20 +122,10 @@ protected override void PopOut()
{
samplePopOut?.Play();

float width = getHideXPosition();
this.MoveToX(width, transition_length, Easing.OutQuint);
this.FadeTo(0, transition_length, Easing.OutQuint).OnComplete(_ =>
{
// should clear the content if close.
fillFlowContainer.Clear();
});
}

private float getHideXPosition() =>
direction switch
{
PanelDirection.Left => -DrawWidth,
PanelDirection.Right => DrawWidth,
_ => throw new ArgumentOutOfRangeException(),
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public partial class InvalidPanel : Panel
public InvalidPanel()
{
Width = 200;
Height = 300;
}

protected override IReadOnlyList<Drawable> CreateSections() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public partial class PropertyPanel : Panel
public PropertyPanel()
{
Width = 200;
RelativeSizeAxes = Axes.Y;
}

protected override IReadOnlyList<Drawable> CreateSections()
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Karaoke/Screens/Edit/EditorTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected EditorTable()
RelativeSizeAxes = Axes.Both,
Depth = 1f,
Padding = new MarginPadding { Horizontal = -horizontal_inset },
Margin = new MarginPadding { Top = ROW_HEIGHT }
Margin = new MarginPadding { Top = ROW_HEIGHT },
});
}

Expand Down

0 comments on commit 4a5305a

Please sign in to comment.