mirror of
https://github.com/osukey/osukey.git
synced 2025-06-22 19:57:56 +09: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.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Layout;
|
using osu.Framework.Layout;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Compose.Components
|
namespace osu.Game.Screens.Edit.Compose.Components
|
||||||
@ -72,25 +73,29 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
float currentPosition = startPosition;
|
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
|
var gridLine = new Box
|
||||||
{
|
{
|
||||||
Colour = Colour4.White,
|
Colour = Colour4.White,
|
||||||
Alpha = index == 0 ? 0.3f : 0.1f,
|
Alpha = index == 0 ? 0.3f : 0.1f,
|
||||||
EdgeSmoothness = new Vector2(0.2f)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (direction == Direction.Horizontal)
|
if (direction == Direction.Horizontal)
|
||||||
{
|
{
|
||||||
|
gridLine.Origin = Anchor.CentreLeft;
|
||||||
gridLine.RelativeSizeAxes = Axes.X;
|
gridLine.RelativeSizeAxes = Axes.X;
|
||||||
gridLine.Height = 1;
|
gridLine.Height = lineWidth;
|
||||||
gridLine.Y = currentPosition;
|
gridLine.Y = currentPosition;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
gridLine.Origin = Anchor.TopCentre;
|
||||||
gridLine.RelativeSizeAxes = Axes.Y;
|
gridLine.RelativeSizeAxes = Axes.Y;
|
||||||
gridLine.Width = 1;
|
gridLine.Width = lineWidth;
|
||||||
gridLine.X = currentPosition;
|
gridLine.X = currentPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user