File tree 4 files changed +310
-145
lines changed
osu.Framework/Graphics/Containers
osu.Framework.Tests/Visual/Containers
4 files changed +310
-145
lines changed Original file line number Diff line number Diff line change 10
10
using osu . Framework . Graphics . Shapes ;
11
11
using osu . Framework . Graphics . Sprites ;
12
12
using osu . Framework . Testing ;
13
+ using osu . Framework . Threading ;
13
14
using osuTK ;
14
15
using osuTK . Graphics ;
15
16
@@ -142,6 +143,26 @@ public void TestSizing()
142
143
topLevelContainer . RelativeSizeAxes = textContainer . RelativeSizeAxes = Axes . None ;
143
144
topLevelContainer . AutoSizeAxes = textContainer . AutoSizeAxes = Axes . Both ;
144
145
} ) ;
146
+ AddStep ( "set autosize width with right anchored text" , ( ) =>
147
+ {
148
+ topLevelContainer . RelativeSizeAxes = textContainer . RelativeSizeAxes = Axes . None ;
149
+ topLevelContainer . AutoSizeAxes = textContainer . AutoSizeAxes = Axes . Both ;
150
+ textContainer . TextAnchor = Anchor . TopRight ;
151
+ } ) ;
152
+ }
153
+
154
+ [ Test ]
155
+ public void TestSetTextRepeatedly ( )
156
+ {
157
+ ScheduledDelegate repeat = null ! ;
158
+ AddStep ( "set text repeatedly" , ( ) => repeat = Scheduler . AddDelayed ( ( ) =>
159
+ {
160
+ textContainer . Clear ( ) ;
161
+ textContainer . AddParagraph ( "first paragraph lorem ipsum dolor sit amet and whatever else is needed to break a line" ) ;
162
+ textContainer . AddParagraph ( string . Empty ) ;
163
+ textContainer . AddParagraph ( "second paragraph lorem ipsum dolor sit amet and whatever else is needed to break a line" ) ;
164
+ } , 50 , true ) ) ;
165
+ AddStep ( "cancel" , ( ) => repeat . Cancel ( ) ) ;
145
166
}
146
167
147
168
private void assertSpriteTextCount ( int count )
Original file line number Diff line number Diff line change @@ -183,7 +183,7 @@ static Axes toAxes(FillDirection direction)
183
183
float rowWidth = rowBeginOffset + current . X + ( 1 - spacingFactor ( c ) . X ) * size . X ;
184
184
185
185
//We've exceeded our allowed width, move to a new row
186
- if ( direction != FillDirection . Horizontal && ( Precision . DefinitelyBigger ( rowWidth , max . X ) || direction == FillDirection . Vertical || ForceNewRow ( c ) ) )
186
+ if ( direction != FillDirection . Horizontal && ( Precision . DefinitelyBigger ( rowWidth , max . X ) || direction == FillDirection . Vertical ) )
187
187
{
188
188
current . X = 0 ;
189
189
current . Y += rowHeight ;
@@ -293,13 +293,6 @@ static Axes toAxes(FillDirection direction)
293
293
ArrayPool < int > . Shared . Return ( rowIndices ) ;
294
294
}
295
295
}
296
-
297
- /// <summary>
298
- /// Returns true if the given child should be placed on a new row, false otherwise. This will be called automatically for each child in this FillFlowContainers FlowingChildren-List.
299
- /// </summary>
300
- /// <param name="child">The child to check.</param>
301
- /// <returns>True if the given child should be placed on a new row, false otherwise.</returns>
302
- protected virtual bool ForceNewRow ( Drawable child ) => false ;
303
296
}
304
297
305
298
/// <summary>
Original file line number Diff line number Diff line change @@ -69,16 +69,10 @@ public Vector2 MaximumSize
69
69
70
70
protected override bool RequiresChildrenUpdate => base . RequiresChildrenUpdate || ! layout . IsValid ;
71
71
72
- internal event Action OnLayoutInvalidated ;
73
-
74
72
/// <summary>
75
73
/// Invoked when layout should be invalidated.
76
74
/// </summary>
77
- protected virtual void InvalidateLayout ( )
78
- {
79
- layout . Invalidate ( ) ;
80
- OnLayoutInvalidated ? . Invoke ( ) ;
81
- }
75
+ protected internal void InvalidateLayout ( ) => layout . Invalidate ( ) ;
82
76
83
77
private readonly Dictionary < Drawable , float > layoutChildren = new Dictionary < Drawable , float > ( ) ;
84
78
You can’t perform that action at this time.
0 commit comments