mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 10:33:01 +08:00
Fix gridline centering and ensure lines are always rendered using a fixed screen-space width
This commit is contained in:
parent
bb086800b1
commit
0bb90c7b07
@ -6,6 +6,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Layout;
|
||||
using osu.Framework.Utils;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components
|
||||
@ -72,25 +73,29 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
int index = 0;
|
||||
float currentPosition = startPosition;
|
||||
|
||||
while ((endPosition - currentPosition) * Math.Sign(step) > 0)
|
||||
// Make lines the same width independent of display resolution.
|
||||
float lineWidth = DrawWidth / ScreenSpaceDrawQuad.Width;
|
||||
|
||||
while (Precision.AlmostBigger((endPosition - currentPosition) * Math.Sign(step), 0))
|
||||
{
|
||||
var gridLine = new Box
|
||||
{
|
||||
Colour = Colour4.White,
|
||||
Alpha = index == 0 ? 0.3f : 0.1f,
|
||||
EdgeSmoothness = new Vector2(0.2f)
|
||||
};
|
||||
|
||||
if (direction == Direction.Horizontal)
|
||||
{
|
||||
gridLine.Origin = Anchor.CentreLeft;
|
||||
gridLine.RelativeSizeAxes = Axes.X;
|
||||
gridLine.Height = 1;
|
||||
gridLine.Height = lineWidth;
|
||||
gridLine.Y = currentPosition;
|
||||
}
|
||||
else
|
||||
{
|
||||
gridLine.Origin = Anchor.TopCentre;
|
||||
gridLine.RelativeSizeAxes = Axes.Y;
|
||||
gridLine.Width = 1;
|
||||
gridLine.Width = lineWidth;
|
||||
gridLine.X = currentPosition;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user