Skip to content

Commit cc00127

Browse files
committed
Improve visuals of BasicSliderBar focus
1 parent df5fffc commit cc00127

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

osu.Framework.Tests/Visual/UserInterface/TestSceneSliderBar.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public TestSceneSliderBar()
5959
Size = new Vector2(200, 50),
6060
BackgroundColour = Color4.White,
6161
SelectionColour = Color4.Pink,
62-
FocusColour = Color4.Purple,
62+
FocusColour = Color4.OrangeRed,
6363
KeyboardStep = 1,
6464
Current = sliderBarValue
6565
},
@@ -73,7 +73,7 @@ public TestSceneSliderBar()
7373
RangePadding = 20,
7474
BackgroundColour = Color4.White,
7575
SelectionColour = Color4.Pink,
76-
FocusColour = Color4.Purple,
76+
FocusColour = Color4.OrangeRed,
7777
KeyboardStep = 1,
7878
Current = sliderBarValue
7979
},
@@ -87,7 +87,7 @@ public TestSceneSliderBar()
8787
Size = new Vector2(200, 10),
8888
BackgroundColour = Color4.White,
8989
SelectionColour = Color4.Pink,
90-
FocusColour = Color4.Purple,
90+
FocusColour = Color4.OrangeRed,
9191
KeyboardStep = 1,
9292
Current = sliderBarValue
9393
},
@@ -100,7 +100,7 @@ public TestSceneSliderBar()
100100
Size = new Vector2(200, 10),
101101
BackgroundColour = Color4.White,
102102
SelectionColour = Color4.Pink,
103-
FocusColour = Color4.Purple,
103+
FocusColour = Color4.OrangeRed,
104104
KeyboardStep = 1,
105105
Current = sliderBarValue
106106
},

osu.Framework/Graphics/UserInterface/BasicSliderBar.cs

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,10 @@ public Color4 BackgroundColour
1818
set => Box.Colour = value;
1919
}
2020

21-
private Color4 selectionColour = FrameworkColour.Yellow;
22-
2321
public Color4 SelectionColour
2422
{
25-
get => selectionColour;
26-
set
27-
{
28-
selectionColour = value;
29-
updateColour();
30-
}
23+
get => SelectionBox.Colour;
24+
set => SelectionBox.Colour = value;
3125
}
3226

3327
private Color4 focusColour = FrameworkColour.YellowGreen;
@@ -38,7 +32,7 @@ public Color4 FocusColour
3832
set
3933
{
4034
focusColour = value;
41-
updateColour();
35+
updateFocus();
4236
}
4337
}
4438

@@ -56,30 +50,39 @@ public BasicSliderBar()
5650
},
5751
SelectionBox = new Box
5852
{
53+
Colour = FrameworkColour.Yellow,
5954
RelativeSizeAxes = Axes.Both,
6055
}
6156
};
6257

63-
updateColour();
64-
}
65-
66-
private void updateColour()
67-
{
68-
SelectionBox.Colour = HasFocus ? FocusColour : SelectionColour;
58+
Masking = true;
6959
}
7060

7161
protected override void OnFocus(FocusEvent e)
7262
{
73-
updateColour();
63+
updateFocus();
7464
base.OnFocus(e);
7565
}
7666

7767
protected override void OnFocusLost(FocusLostEvent e)
7868
{
79-
updateColour();
69+
updateFocus();
8070
base.OnFocusLost(e);
8171
}
8272

73+
private void updateFocus()
74+
{
75+
if (HasFocus)
76+
{
77+
BorderThickness = 3;
78+
BorderColour = FocusColour;
79+
}
80+
else
81+
{
82+
BorderThickness = 0;
83+
}
84+
}
85+
8386
protected override void UpdateValue(float value)
8487
{
8588
SelectionBox.ScaleTo(new Vector2(value, 1), 300, Easing.OutQuint);

0 commit comments

Comments
 (0)