Fix incorrect margin/spacing handling

This commit is contained in:
Dean Herbert 2018-11-29 14:15:23 +09:00
parent 3d46ac7d35
commit d1c976880c
3 changed files with 12 additions and 12 deletions

View File

@ -44,17 +44,13 @@ protected override bool OnMouseMove(MouseMoveEvent e)
{
Column column = ColumnAt(e.ScreenSpaceMousePosition);
if (column == null)
SnappedMousePosition = e.MousePosition;
else
{
SnappedWidth = column.DrawWidth;
if (column == null) return false;
// Snap to the column
var parentPos = Parent.ToLocalSpace(column.ToScreenSpace(new Vector2(column.DrawWidth / 2, 0)));
SnappedMousePosition = new Vector2(parentPos.X, e.MousePosition.Y);
}
SnappedWidth = column.DrawWidth;
// Snap to the column
var parentPos = Parent.ToLocalSpace(column.ToScreenSpace(new Vector2(column.DrawWidth / 2, 0)));
SnappedMousePosition = new Vector2(parentPos.X, e.MousePosition.Y);
return true;
}

View File

@ -183,6 +183,6 @@ public bool OnPressed(ManiaAction action)
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos)
// This probably shouldn't exist as is, but the columns in the stage are separated by a 1px border
=> DrawRectangle.Inflate(new Vector2(1, 0)).Contains(ToLocalSpace(screenSpacePos));
=> DrawRectangle.Inflate(new Vector2(ManiaStage.COLUMN_SPACING / 2, 0)).Contains(ToLocalSpace(screenSpacePos));
}
}

View File

@ -25,6 +25,8 @@ namespace osu.Game.Rulesets.Mania.UI
/// </summary>
public class ManiaStage : ScrollingPlayfield
{
public const float COLUMN_SPACING = 1;
public const float HIT_TARGET_POSITION = 50;
public IReadOnlyList<Column> Columns => columnFlow.Children;
@ -40,6 +42,8 @@ public class ManiaStage : ScrollingPlayfield
private List<Color4> normalColumnColours = new List<Color4>();
private Color4 specialColumnColour;
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Columns.Any(c => c.ReceivePositionalInputAt(screenSpacePos));
private readonly int firstColumnIndex;
public ManiaStage(int firstColumnIndex, StageDefinition definition, ref ManiaAction normalColumnStartAction, ref ManiaAction specialColumnStartAction)
@ -84,8 +88,8 @@ public ManiaStage(int firstColumnIndex, StageDefinition definition, ref ManiaAct
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,
Direction = FillDirection.Horizontal,
Padding = new MarginPadding { Left = 1, Right = 1 },
Spacing = new Vector2(1, 0)
Padding = new MarginPadding { Left = COLUMN_SPACING, Right = COLUMN_SPACING },
Spacing = new Vector2(COLUMN_SPACING, 0)
},
}
},