-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the grid layer for the composer.
- Loading branch information
1 parent
b1da561
commit 0095970
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
...Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/GridLayer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using osu.Framework.Graphics; | ||
using osu.Game.Rulesets.Karaoke.Objects; | ||
using osu.Game.Screens.Edit.Compose.Components; | ||
using osuTK; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Content.Components.Lyrics; | ||
|
||
public partial class GridLayer : Layer | ||
{ | ||
private readonly RectangularPositionSnapGrid rectangularPositionSnapGrid; | ||
|
||
public GridLayer(Lyric lyric) | ||
: base(lyric) | ||
{ | ||
InternalChild = rectangularPositionSnapGrid = new RectangularPositionSnapGrid | ||
{ | ||
RelativeSizeAxes = Axes.Both, | ||
}; | ||
} | ||
|
||
public int Spacing | ||
{ | ||
get => rectangularPositionSnapGrid.Spacing; | ||
set => rectangularPositionSnapGrid.Spacing = value; | ||
} | ||
|
||
public override void UpdateDisableEditState(bool editable) | ||
{ | ||
this.FadeTo(editable ? 1 : 0.5f, 100); | ||
} | ||
|
||
private partial class RectangularPositionSnapGrid : LinedPositionSnapGrid | ||
{ | ||
protected override void CreateContent() | ||
{ | ||
GenerateGridLines(new Vector2(0, -Spacing), DrawSize); | ||
GenerateGridLines(new Vector2(0, Spacing), DrawSize); | ||
|
||
GenerateGridLines(new Vector2(-Spacing, 0), DrawSize); | ||
GenerateGridLines(new Vector2(Spacing, 0), DrawSize); | ||
|
||
GenerateOutline(DrawSize); | ||
} | ||
|
||
public override Vector2 GetSnappedPosition(Vector2 original) | ||
{ | ||
return StartPosition.Value + original; | ||
} | ||
|
||
private int spacing; | ||
|
||
public int Spacing | ||
{ | ||
get => spacing; | ||
set | ||
{ | ||
spacing = value; | ||
GridCache.Invalidate(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters