Skip to content

Commit 0d655d3

Browse files
committed
Knock some sense into sheared drawable stuff
1 parent 321fc45 commit 0d655d3

16 files changed

+60
-74
lines changed

osu.Game.Tests/Visual/SongSelectV2/TestSceneLeaderboardScore.cs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using osu.Framework.Graphics.Cursor;
1111
using osu.Framework.Testing;
1212
using osu.Framework.Utils;
13-
using osu.Game;
1413
using osu.Game.Configuration;
1514
using osu.Game.Graphics.Sprites;
1615
using osu.Game.Graphics.UserInterface;

osu.Game.Tests/Visual/UserInterface/TestSceneShearAlignedDrawable.cs renamed to osu.Game.Tests/Visual/UserInterface/TestSceneShearAligningWrapper.cs

+8-10
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717

1818
namespace osu.Game.Tests.Visual.UserInterface
1919
{
20-
public partial class TestSceneShearAlignedDrawable : OsuTestScene
20+
public partial class TestSceneShearAligningWrapper : OsuTestScene
2121
{
22-
private static readonly Vector2 shear = new Vector2(OsuGame.SHEAR, 0);
23-
2422
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Aquamarine);
2523

2624
private ShearedBox first = null!;
@@ -36,7 +34,7 @@ public void SetUp() => Schedule(() =>
3634
Origin = Anchor.Centre,
3735
Width = 200f,
3836
AutoSizeAxes = Axes.Y,
39-
Shear = shear,
37+
Shear = OsuGame.SHEAR,
4038
CornerRadius = 10f,
4139
Masking = true,
4240
Children = new Drawable[]
@@ -52,20 +50,20 @@ public void SetUp() => Schedule(() =>
5250
AutoSizeAxes = Axes.Y,
5351
Direction = FillDirection.Vertical,
5452
Spacing = new Vector2(0f, 10f),
55-
Shear = -shear,
53+
Shear = -OsuGame.SHEAR,
5654
Children = new Drawable[]
5755
{
58-
new ShearAlignedDrawable(shear, first = new ShearedBox("Text 1", OsuColour.Gray(0.4f))
56+
new ShearAligningWrapper(first = new ShearedBox("Text 1", OsuColour.Gray(0.4f))
5957
{
6058
RelativeSizeAxes = Axes.X,
6159
Height = 30,
6260
}),
63-
new ShearAlignedDrawable(shear, second = new ShearedBox("Text 2", OsuColour.Gray(0.3f))
61+
new ShearAligningWrapper(second = new ShearedBox("Text 2", OsuColour.Gray(0.3f))
6462
{
6563
RelativeSizeAxes = Axes.X,
6664
Height = 30,
6765
}),
68-
new ShearAlignedDrawable(shear, third = new ShearedBox("Text 3", OsuColour.Gray(0.2f))
66+
new ShearAligningWrapper(third = new ShearedBox("Text 3", OsuColour.Gray(0.2f))
6967
{
7068
RelativeSizeAxes = Axes.X,
7169
Height = 30,
@@ -110,7 +108,7 @@ public ShearedBox(string text, Color4 boxColour)
110108
[BackgroundDependencyLoader]
111109
private void load()
112110
{
113-
Shear = new Vector2(OsuGame.SHEAR, 0);
111+
Shear = OsuGame.SHEAR;
114112
CornerRadius = 10;
115113
Masking = true;
116114

@@ -125,7 +123,7 @@ private void load()
125123
{
126124
Text = text,
127125
Colour = Color4.White,
128-
Shear = -new Vector2(OsuGame.SHEAR, 0),
126+
Shear = -OsuGame.SHEAR,
129127
Font = OsuFont.Torus.With(size: 24),
130128
Margin = new MarginPadding { Left = 50 },
131129
}

osu.Game/Collections/ShearedCollectionDropdown.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ private void load()
194194
{
195195
Anchor = Anchor.CentreRight,
196196
Origin = Anchor.CentreRight,
197-
Shear = new Vector2(-OsuGame.SHEAR, 0),
197+
Shear = -OsuGame.SHEAR,
198198
X = -OsuScrollContainer.SCROLL_BAR_WIDTH,
199199
Scale = new Vector2(0.65f),
200200
Action = addOrRemove,

osu.Game/Graphics/Containers/ShearAlignedDrawable.cs renamed to osu.Game/Graphics/Containers/ShearAligningWrapper.cs

+7-6
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@
88

99
namespace osu.Game.Graphics.Containers
1010
{
11-
public partial class ShearAlignedDrawable : CompositeDrawable
11+
/// <summary>
12+
/// Adds padding based on direct parent to make sheared pieces "align properly".
13+
/// TODO: get rid of this class or explain what it does here in great detail. hopefully the former.
14+
/// </summary>
15+
public partial class ShearAligningWrapper : CompositeDrawable
1216
{
13-
private readonly Vector2 shear;
1417
private readonly LayoutValue layout = new LayoutValue(Invalidation.MiscGeometry);
1518

16-
public ShearAlignedDrawable(Vector2 shear, Drawable drawable)
19+
public ShearAligningWrapper(Drawable drawable)
1720
{
18-
this.shear = shear;
19-
2021
RelativeSizeAxes = drawable.RelativeSizeAxes;
2122
AutoSizeAxes = Axes.Both & ~drawable.RelativeSizeAxes;
2223

@@ -38,7 +39,7 @@ protected override void Update()
3839

3940
private void updateLayout()
4041
{
41-
float shearWidth = shear.X * Parent!.DrawHeight;
42+
float shearWidth = OsuGame.SHEAR.X * Parent!.DrawHeight;
4243
float relativeY = Parent!.DrawHeight == 0 ? 0 : InternalChild.ToSpaceOfOtherDrawable(Vector2.Zero, Parent).Y / Parent!.DrawHeight;
4344
Padding = new MarginPadding { Right = shearWidth * relativeY };
4445
}

osu.Game/Graphics/UserInterface/ShearedNub.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public ShearedNub()
4141
{
4242
shadow = new Container
4343
{
44-
Shear = SHEAR,
44+
Shear = OsuGame.SHEAR,
4545
Masking = true,
4646
CornerRadius = 5,
4747
RelativeSizeAxes = Axes.Both,
@@ -59,7 +59,7 @@ public ShearedNub()
5959
},
6060
main = new Container
6161
{
62-
Shear = SHEAR,
62+
Shear = OsuGame.SHEAR,
6363
BorderColour = Colour4.White,
6464
BorderThickness = 8f,
6565
Masking = true,

osu.Game/Graphics/UserInterface/ShearedRangeSlider.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private void load(OverlayColourProvider colourProvider)
103103
RelativeSizeAxes = Axes.Y,
104104
Masking = true,
105105
CornerRadius = 5f,
106-
Shear = new Vector2(OsuGame.SHEAR, 0),
106+
Shear = OsuGame.SHEAR,
107107
Children = new Drawable[]
108108
{
109109
new Box
@@ -116,7 +116,7 @@ private void load(OverlayColourProvider colourProvider)
116116
Anchor = Anchor.Centre,
117117
Origin = Anchor.Centre,
118118
Text = label,
119-
Shear = new Vector2(-OsuGame.SHEAR, 0),
119+
Shear = -OsuGame.SHEAR,
120120
Margin = new MarginPadding { Horizontal = 12, Vertical = 5 },
121121
Font = OsuFont.Style.Body.With(weight: FontWeight.SemiBold),
122122
},

osu.Game/Screens/SelectV2/BeatmapDetailsArea.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using osu.Framework.Graphics;
66
using osu.Framework.Graphics.Containers;
77
using osu.Game.Graphics.Containers;
8-
using osuTK;
98

109
namespace osu.Game.Screens.SelectV2
1110
{
@@ -15,8 +14,6 @@ namespace osu.Game.Screens.SelectV2
1514
/// </summary>
1615
public partial class BeatmapDetailsArea : VisibilityContainer
1716
{
18-
private static readonly Vector2 shear = new Vector2(OsuGame.SHEAR, 0);
19-
2017
private Header header = null!;
2118
private Container contentContainer = null!;
2219

@@ -32,7 +29,7 @@ private void load()
3229

3330
InternalChildren = new Drawable[]
3431
{
35-
new ShearAlignedDrawable(shear, header = new Header
32+
new ShearAligningWrapper(header = new Header
3633
{
3734
RelativeSizeAxes = Axes.X,
3835
Height = header_height,
@@ -42,7 +39,7 @@ private void load()
4239
Depth = 1f,
4340
Padding = new MarginPadding { Top = header_height },
4441
RelativeSizeAxes = Axes.Both,
45-
Child = new ShearAlignedDrawable(shear, contentContainer = new Container
42+
Child = new ShearAligningWrapper(contentContainer = new Container
4643
{
4744
RelativeSizeAxes = Axes.Both,
4845
}),

osu.Game/Screens/SelectV2/BeatmapLeaderboardScore.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,9 @@ private void updateModDisplay()
518518
Anchor = Anchor.TopRight,
519519
Origin = Anchor.TopRight,
520520
AutoSizeAxes = Axes.Both,
521+
Child = modsContainer = new FillFlowContainer
521522
{
522-
Shear = new Vector2(sheared ? -OsuGame.SHEAR : 0, 0),
523+
Shear = sheared ? -OsuGame.SHEAR : Vector2.Zero,
523524
AutoSizeAxes = Axes.Both,
524525
Direction = FillDirection.Horizontal,
525526
Spacing = new Vector2(2f, 0f),

osu.Game/Screens/SelectV2/BeatmapLeaderboardWedge.cs

+4-7
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,11 @@
2828
using osu.Game.Rulesets.Mods;
2929
using osu.Game.Scoring;
3030
using osu.Game.Screens.Select.Leaderboards;
31-
using osuTK;
3231

3332
namespace osu.Game.Screens.SelectV2
3433
{
3534
public partial class BeatmapLeaderboardWedge : VisibilityContainer
3635
{
37-
private static readonly Vector2 shear = new Vector2(OsuGame.SHEAR, 0);
38-
3936
private Container scoresContainer = null!;
4037

4138
private OsuScrollContainer scoresScroll = null!;
@@ -87,7 +84,7 @@ private void load()
8784
{
8885
RelativeSizeAxes = Axes.Both,
8986
ScrollbarVisible = false,
90-
Shear = shear,
87+
Shear = OsuGame.SHEAR,
9188
Child = scoresContainer = new Container
9289
{
9390
RelativeSizeAxes = Axes.X,
@@ -101,7 +98,7 @@ private void load()
10198
Origin = Anchor.BottomLeft,
10299
RelativeSizeAxes = Axes.X,
103100
AutoSizeAxes = Axes.Y,
104-
Shear = shear,
101+
Shear = OsuGame.SHEAR,
105102
Margin = new MarginPadding { Left = -60f },
106103
CornerRadius = 16f,
107104
Masking = true,
@@ -118,7 +115,7 @@ private void load()
118115
{
119116
RelativeSizeAxes = Axes.X,
120117
AutoSizeAxes = Axes.Y,
121-
Shear = -shear,
118+
Shear = -OsuGame.SHEAR,
122119
Padding = new MarginPadding { Top = 5f, Bottom = 30f, Left = 100f, Right = 30f },
123120
Children = new Drawable[]
124121
{
@@ -282,7 +279,7 @@ protected void SetScores(IEnumerable<ScoreInfo> scores, ScoreInfo? userScore)
282279

283280
scoresContainer.Add(scoreDrawableContainer = new Container
284281
{
285-
Shear = -shear,
282+
Shear = -OsuGame.SHEAR,
286283
Y = (BeatmapLeaderboardScore.HEIGHT + 4f) * i,
287284
RelativeSizeAxes = Axes.X,
288285
AutoSizeAxes = Axes.Y,

osu.Game/Screens/SelectV2/BeatmapMetadataWedge.cs

+9-11
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ namespace osu.Game.Screens.SelectV2
1919
{
2020
public partial class BeatmapMetadataWedge : VisibilityContainer
2121
{
22-
private static readonly Vector2 shear = new Vector2(OsuGame.SHEAR, 0);
23-
2422
private MetadataDisplay creator = null!;
2523
private MetadataDisplay source = null!;
2624
private MetadataDisplay genre = null!;
@@ -68,21 +66,21 @@ private void load()
6866
Spacing = new Vector2(0f, 4f),
6967
Children = new[]
7068
{
71-
new ShearAlignedDrawable(shear, new Container
69+
new ShearAligningWrapper(new Container
7270
{
7371
CornerRadius = 10,
7472
Masking = true,
7573
RelativeSizeAxes = Axes.X,
7674
AutoSizeAxes = Axes.Y,
77-
Shear = shear,
75+
Shear = OsuGame.SHEAR,
7876
Children = new Drawable[]
7977
{
8078
new WedgeBackground(),
8179
new Container
8280
{
8381
RelativeSizeAxes = Axes.X,
8482
AutoSizeAxes = Axes.Y,
85-
Shear = -shear,
83+
Shear = -OsuGame.SHEAR,
8684
Padding = new MarginPadding { Left = SongSelect.WEDGE_CONTENT_MARGIN, Right = 35, Vertical = 16 },
8785
Children = new Drawable[]
8886
{
@@ -155,22 +153,22 @@ private void load()
155153
},
156154
},
157155
}),
158-
new ShearAlignedDrawable(shear, ratingsWedge = new Container
156+
new ShearAligningWrapper(ratingsWedge = new Container
159157
{
160158
Alpha = 0f,
161159
CornerRadius = 10,
162160
Masking = true,
163161
RelativeSizeAxes = Axes.X,
164162
AutoSizeAxes = Axes.Y,
165-
Shear = shear,
163+
Shear = OsuGame.SHEAR,
166164
Children = new Drawable[]
167165
{
168166
new WedgeBackground(),
169167
new GridContainer
170168
{
171169
RelativeSizeAxes = Axes.X,
172170
AutoSizeAxes = Axes.Y,
173-
Shear = -shear,
171+
Shear = -OsuGame.SHEAR,
174172
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) },
175173
ColumnDimensions = new[]
176174
{
@@ -195,22 +193,22 @@ private void load()
195193
},
196194
}
197195
}),
198-
new ShearAlignedDrawable(shear, failRetryWedge = new Container
196+
new ShearAligningWrapper(failRetryWedge = new Container
199197
{
200198
Alpha = 0f,
201199
CornerRadius = 10,
202200
Masking = true,
203201
RelativeSizeAxes = Axes.X,
204202
AutoSizeAxes = Axes.Y,
205-
Shear = shear,
203+
Shear = OsuGame.SHEAR,
206204
Children = new Drawable[]
207205
{
208206
new WedgeBackground(),
209207
new Container
210208
{
211209
RelativeSizeAxes = Axes.X,
212210
AutoSizeAxes = Axes.Y,
213-
Shear = -shear,
211+
Shear = -OsuGame.SHEAR,
214212
Padding = new MarginPadding { Left = SongSelect.WEDGE_CONTENT_MARGIN, Right = 40f, Vertical = 16 },
215213
Child = failRetryDisplay = new FailRetryDisplay(),
216214
},

osu.Game/Screens/SelectV2/BeatmapTitleWedge.cs

+7-9
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ public partial class BeatmapTitleWedge : VisibilityContainer
3232
{
3333
private const float corner_radius = 10;
3434

35-
private static readonly Vector2 shear = new Vector2(OsuGame.SHEAR, 0);
36-
3735
[Resolved]
3836
private IBindable<WorkingBeatmap> beatmap { get; set; } = null!;
3937

@@ -79,7 +77,7 @@ public BeatmapTitleWedge()
7977
[BackgroundDependencyLoader]
8078
private void load()
8179
{
82-
Shear = shear;
80+
Shear = OsuGame.SHEAR;
8381
Masking = true;
8482
CornerRadius = corner_radius;
8583

@@ -97,16 +95,16 @@ private void load()
9795
Left = SongSelect.WEDGE_CONTENT_MARGIN
9896
},
9997
Spacing = new Vector2(0f, 4f),
100-
Shear = -shear,
98+
Shear = -OsuGame.SHEAR,
10199
Children = new Drawable[]
102100
{
103-
new ShearAlignedDrawable(shear, statusPill = new BeatmapSetOnlineStatusPill
101+
new ShearAligningWrapper(statusPill = new BeatmapSetOnlineStatusPill
104102
{
105103
ShowUnknownStatus = true,
106104
TextSize = OsuFont.Style.Caption1.Size,
107105
TextPadding = new MarginPadding { Horizontal = 6, Vertical = 1 },
108106
}),
109-
new ShearAlignedDrawable(shear, titleContainer = new Container
107+
new ShearAligningWrapper(titleContainer = new Container
110108
{
111109
RelativeSizeAxes = Axes.X,
112110
Height = OsuFont.Style.Title.Size,
@@ -121,7 +119,7 @@ private void load()
121119
},
122120
}
123121
}),
124-
new ShearAlignedDrawable(shear, artistContainer = new Container
122+
new ShearAligningWrapper(artistContainer = new Container
125123
{
126124
RelativeSizeAxes = Axes.X,
127125
Height = OsuFont.Style.Heading2.Size,
@@ -136,7 +134,7 @@ private void load()
136134
},
137135
}
138136
}),
139-
new ShearAlignedDrawable(shear, new FillFlowContainer
137+
new ShearAligningWrapper(new FillFlowContainer
140138
{
141139
AutoSizeAxes = Axes.Both,
142140
Direction = FillDirection.Horizontal,
@@ -161,7 +159,7 @@ private void load()
161159
},
162160
},
163161
}),
164-
new ShearAlignedDrawable(shear, new Container
162+
new ShearAligningWrapper(new Container
165163
{
166164
RelativeSizeAxes = Axes.X,
167165
AutoSizeAxes = Axes.Y,

0 commit comments

Comments
 (0)