mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 12:33:01 +08:00
Make selection happen on click only
This commit is contained in:
parent
cfdf710676
commit
8d50b155e8
@ -18,9 +18,10 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
{
|
{
|
||||||
public class PathControlPointPiece : BlueprintPiece<Slider>
|
public class PathControlPointPiece : BlueprintPiece<Slider>
|
||||||
{
|
{
|
||||||
|
public Action<int> RequestSelection;
|
||||||
public Action<Vector2[]> ControlPointsChanged;
|
public Action<Vector2[]> ControlPointsChanged;
|
||||||
public readonly Bindable<bool> IsSelected = new Bindable<bool>();
|
|
||||||
|
|
||||||
|
public readonly Bindable<bool> IsSelected = new Bindable<bool>();
|
||||||
public readonly int Index;
|
public readonly int Index;
|
||||||
|
|
||||||
private readonly Slider slider;
|
private readonly Slider slider;
|
||||||
@ -28,6 +29,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
private readonly Container marker;
|
private readonly Container marker;
|
||||||
private readonly Drawable markerRing;
|
private readonly Drawable markerRing;
|
||||||
|
|
||||||
|
private bool isClicked;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuColour colours { get; set; }
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
@ -98,7 +101,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
markerRing.Alpha = IsSelected.Value ? 1 : 0;
|
markerRing.Alpha = IsSelected.Value ? 1 : 0;
|
||||||
|
|
||||||
Color4 colour = isSegmentSeparator ? colours.Red : colours.Yellow;
|
Color4 colour = isSegmentSeparator ? colours.Red : colours.Yellow;
|
||||||
if (IsHovered || IsSelected.Value)
|
if (IsHovered || isClicked || IsSelected.Value)
|
||||||
colour = Color4.White;
|
colour = Color4.White;
|
||||||
marker.Colour = colour;
|
marker.Colour = colour;
|
||||||
}
|
}
|
||||||
@ -122,6 +125,24 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
// The connecting path is excluded from positional input
|
// The connecting path is excluded from positional input
|
||||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => marker.ReceivePositionalInputAt(screenSpacePos);
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => marker.ReceivePositionalInputAt(screenSpacePos);
|
||||||
|
|
||||||
|
protected override bool OnMouseDown(MouseDownEvent e)
|
||||||
|
{
|
||||||
|
isClicked = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnMouseUp(MouseUpEvent e)
|
||||||
|
{
|
||||||
|
isClicked = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnClick(ClickEvent e)
|
||||||
|
{
|
||||||
|
RequestSelection?.Invoke(Index);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool OnDragStart(DragStartEvent e) => true;
|
protected override bool OnDragStart(DragStartEvent e) => true;
|
||||||
|
|
||||||
protected override bool OnDrag(DragEvent e)
|
protected override bool OnDrag(DragEvent e)
|
||||||
|
@ -32,27 +32,29 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
while (slider.Path.ControlPoints.Length > Pieces.Count)
|
while (slider.Path.ControlPoints.Length > Pieces.Count)
|
||||||
Pieces.Add(new PathControlPointPiece(slider, Pieces.Count) { ControlPointsChanged = c => ControlPointsChanged?.Invoke(c) });
|
{
|
||||||
|
Pieces.Add(new PathControlPointPiece(slider, Pieces.Count)
|
||||||
|
{
|
||||||
|
ControlPointsChanged = c => ControlPointsChanged?.Invoke(c),
|
||||||
|
RequestSelection = selectPiece
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
while (slider.Path.ControlPoints.Length < Pieces.Count)
|
while (slider.Path.ControlPoints.Length < Pieces.Count)
|
||||||
Pieces.Remove(Pieces[Pieces.Count - 1]);
|
Pieces.Remove(Pieces[Pieces.Count - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseDown(MouseDownEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
{
|
{
|
||||||
bool anySelected = false;
|
|
||||||
|
|
||||||
foreach (var piece in Pieces)
|
foreach (var piece in Pieces)
|
||||||
{
|
piece.IsSelected.Value = false;
|
||||||
if (piece.IsHovered)
|
return false;
|
||||||
{
|
}
|
||||||
piece.IsSelected.Value = true;
|
|
||||||
anySelected = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
piece.IsSelected.Value = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return anySelected;
|
private void selectPiece(int index)
|
||||||
|
{
|
||||||
|
foreach (var piece in Pieces)
|
||||||
|
piece.IsSelected.Value = piece.Index == index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user