@@ -155,32 +155,29 @@ fn test_widget_layout(name: &str, mut w: impl FnMut(&mut Ui) -> Response) -> Sna
155
155
TextWrapMode :: Truncate ,
156
156
TextWrapMode :: Wrap ,
157
157
] ;
158
- Grid :: new ( "wrapping" ) . show ( ui, |ui| {
159
- for mode in & modes {
160
- ui. label ( format ! ( "{mode:?}" ) ) ;
161
- }
162
- ui. end_row ( ) ;
163
-
164
- for mode in & modes {
165
- let rect = Rect :: from_min_size ( ui. cursor ( ) . min , wrap_test_size) ;
158
+ Grid :: new ( "wrapping" )
159
+ . spacing ( Vec2 :: new ( test_size. x / 2.0 , 4.0 ) )
160
+ . show ( ui, |ui| {
161
+ for mode in & modes {
162
+ ui. label ( format ! ( "{mode:?}" ) ) ;
163
+ }
164
+ ui. end_row ( ) ;
166
165
167
- ui . scope_builder ( UiBuilder :: new ( ) . max_rect ( rect ) , |ui| {
168
- ui . style_mut ( ) . wrap_mode = Some ( * mode ) ;
166
+ for mode in & modes {
167
+ let ( _ , rect ) = ui . allocate_space ( wrap_test_size ) ;
169
168
170
- w ( ui) ;
169
+ let mut child_ui = ui. new_child ( UiBuilder :: new ( ) . max_rect ( rect) ) ;
170
+ child_ui. style_mut ( ) . wrap_mode = Some ( * mode) ;
171
+ w ( & mut child_ui) ;
171
172
172
- // Ensure we always take the full height
173
- ui. allocate_rect ( rect, Sense :: hover ( ) ) ;
174
- } ) ;
175
-
176
- ui. painter ( ) . rect_stroke (
177
- rect,
178
- 0.0 ,
179
- Stroke :: new ( 1.0 , Color32 :: WHITE ) ,
180
- StrokeKind :: Outside ,
181
- ) ;
182
- }
183
- } ) ;
173
+ ui. painter ( ) . rect_stroke (
174
+ rect,
175
+ 0.0 ,
176
+ Stroke :: new ( 1.0 , Color32 :: WHITE ) ,
177
+ StrokeKind :: Outside ,
178
+ ) ;
179
+ }
180
+ } ) ;
184
181
}
185
182
186
183
ui. heading ( "Layout" ) ;
@@ -209,12 +206,11 @@ fn test_widget_layout(name: &str, mut w: impl FnMut(&mut Ui) -> Response) -> Sna
209
206
main_wrap : false ,
210
207
} ;
211
208
212
- let rect = Rect :: from_min_size ( ui. cursor ( ) . min , test_size) ;
213
- ui. scope_builder ( UiBuilder :: new ( ) . layout ( layout) . max_rect ( rect) , |ui| {
214
- w ( ui) ;
215
- // Ensure we always take the full height
216
- ui. allocate_rect ( rect, Sense :: hover ( ) ) ;
217
- } ) ;
209
+ let ( _, rect) = ui. allocate_space ( test_size) ;
210
+
211
+ let mut child_ui = ui. new_child ( UiBuilder :: new ( ) . layout ( layout) . max_rect ( rect) ) ;
212
+ w ( & mut child_ui) ;
213
+
218
214
ui. painter ( ) . rect_stroke (
219
215
rect,
220
216
0.0 ,
0 commit comments