@@ -37,7 +37,7 @@ const SHAPES: &[(&str, fn(&mut Node, &mut BorderRadius))] = &[
37
37
node. height = Val :: Px ( 80. ) ;
38
38
* radius = BorderRadius :: all ( Val :: Px ( 32. ) ) ;
39
39
} ) ,
40
- ( "5" , |node, radius| {
40
+ ( "5" , |node, radius| {
41
41
node. width = Val :: Px ( 80. ) ;
42
42
node. height = Val :: Px ( 240. ) ;
43
43
* radius = BorderRadius :: all ( Val :: Px ( 32. ) ) ;
@@ -120,7 +120,7 @@ fn setup(
120
120
} ,
121
121
BackgroundColor ( GRAY . into ( ) ) ,
122
122
) )
123
- . with_children ( |parent| {
123
+ . insert ( children ! [ {
124
124
let mut node = Node {
125
125
width: Val :: Px ( 164. ) ,
126
126
height: Val :: Px ( 164. ) ,
@@ -132,7 +132,7 @@ fn setup(
132
132
let mut radius = BorderRadius :: ZERO ;
133
133
SHAPES [ shape. index % SHAPES . len( ) ] . 1 ( & mut node, & mut radius) ;
134
134
135
- parent . spawn ( (
135
+ (
136
136
node,
137
137
BorderColor ( WHITE . into( ) ) ,
138
138
radius,
@@ -145,8 +145,8 @@ fn setup(
145
145
blur_radius: Val :: Px ( shadow. blur) ,
146
146
} ] ) ,
147
147
ShadowNode ,
148
- ) ) ;
149
- } ) ;
148
+ )
149
+ } ] ) ;
150
150
151
151
// Settings Panel
152
152
commands
@@ -169,129 +169,123 @@ fn setup(
169
169
BorderRadius :: all ( Val :: Px ( 12.0 ) ) ,
170
170
ZIndex ( 10 ) ,
171
171
) )
172
- . with_children ( |parent| {
172
+ . insert ( children ! [
173
173
// Shape settings
174
- spawn_setting (
175
- parent,
174
+ spawn_setting_children(
176
175
"Shape:" ,
177
176
SettingsButton :: ShapePrev ,
178
177
SettingsButton :: ShapeNext ,
179
178
shape. index as f32 ,
180
179
& asset_server,
181
- ) ;
180
+ ) ,
182
181
// Shadow settings
183
- for ( label , dec , inc , value ) in [
184
- (
185
- "X Offset:" ,
186
- SettingsButton :: XOffsetDec ,
187
- SettingsButton :: XOffsetInc ,
188
- shadow . x_offset ,
189
- ) ,
190
- (
191
- "Y Offset:" ,
192
- SettingsButton :: YOffsetDec ,
193
- SettingsButton :: YOffsetInc ,
194
- shadow. y_offset ,
195
- ) ,
196
- (
197
- "Blur:" ,
198
- SettingsButton :: BlurDec ,
199
- SettingsButton :: BlurInc ,
200
- shadow . blur ,
201
- ) ,
202
- (
203
- "Spread:" ,
204
- SettingsButton :: SpreadDec ,
205
- SettingsButton :: SpreadInc ,
206
- shadow . spread ,
207
- ) ,
208
- (
209
- "Count:" ,
210
- SettingsButton :: CountDec ,
211
- SettingsButton :: CountInc ,
212
- shadow . count as f32 ,
213
- ) ,
214
- ] {
215
- spawn_setting ( parent , label , dec , inc , value , & asset_server ) ;
216
- }
217
-
182
+ spawn_setting_children (
183
+ "X Offset:" ,
184
+ SettingsButton :: XOffsetDec ,
185
+ SettingsButton :: XOffsetInc ,
186
+ shadow . x_offset ,
187
+ & asset_server ,
188
+ ) ,
189
+ spawn_setting_children (
190
+ "Y Offset:" ,
191
+ SettingsButton :: YOffsetDec ,
192
+ SettingsButton :: YOffsetInc ,
193
+ shadow. y_offset,
194
+ & asset_server ,
195
+ ) ,
196
+ spawn_setting_children (
197
+ "Blur:" ,
198
+ SettingsButton :: BlurDec ,
199
+ SettingsButton :: BlurInc ,
200
+ shadow . blur ,
201
+ & asset_server ,
202
+ ) ,
203
+ spawn_setting_children (
204
+ "Spread:" ,
205
+ SettingsButton :: SpreadDec ,
206
+ SettingsButton :: SpreadInc ,
207
+ shadow . spread ,
208
+ & asset_server ,
209
+ ) ,
210
+ spawn_setting_children (
211
+ "Count:" ,
212
+ SettingsButton :: CountDec ,
213
+ SettingsButton :: CountInc ,
214
+ shadow . count as f32 ,
215
+ & asset_server ,
216
+ ) ,
218
217
// Reset button
219
- parent
220
- . spawn ( Node {
218
+ (
219
+ Node {
221
220
flex_direction: FlexDirection :: Row ,
222
221
align_items: AlignItems :: Center ,
223
222
height: Val :: Px ( 36.0 ) ,
224
223
margin: UiRect :: top( Val :: Px ( 12.0 ) ) ,
225
224
justify_content: JustifyContent :: Center ,
226
225
..default ( )
227
- } )
228
- . with_children ( |row| {
229
- row. spawn ( (
230
- Button ,
231
- Node {
232
- width : Val :: Px ( 90. ) ,
233
- height : Val :: Px ( 32. ) ,
234
- justify_content : JustifyContent :: Center ,
235
- align_items : AlignItems :: Center ,
226
+ } ,
227
+ children![ (
228
+ Button ,
229
+ Node {
230
+ width: Val :: Px ( 90. ) ,
231
+ height: Val :: Px ( 32. ) ,
232
+ justify_content: JustifyContent :: Center ,
233
+ align_items: AlignItems :: Center ,
234
+ ..default ( )
235
+ } ,
236
+ BackgroundColor ( Color :: WHITE ) ,
237
+ BorderRadius :: all( Val :: Px ( 8. ) ) ,
238
+ SettingsButton :: Reset ,
239
+ children![ (
240
+ Text :: new( "Reset" ) ,
241
+ TextFont {
242
+ font: asset_server. load( "fonts/FiraSans-Bold.ttf" ) ,
243
+ font_size: 16.0 ,
236
244
..default ( )
237
245
} ,
238
- BackgroundColor ( Color :: WHITE ) ,
239
- BorderRadius :: all ( Val :: Px ( 8. ) ) ,
240
- SettingsButton :: Reset ,
241
- ) )
242
- . with_children ( |btn| {
243
- btn. spawn ( (
244
- Text :: new ( "Reset" ) ,
245
- TextFont {
246
- font : asset_server. load ( "fonts/FiraSans-Bold.ttf" ) ,
247
- font_size : 16.0 ,
248
- ..default ( )
249
- } ,
250
- TextColor ( Color :: WHITE ) ,
251
- ) ) ;
252
- } ) ;
253
- } ) ;
254
- } ) ;
246
+ TextColor ( Color :: WHITE ) ,
247
+ ) ] ,
248
+ ) ] ,
249
+ ) ,
250
+ ] ) ;
255
251
}
256
252
257
253
// --- UI Helper Functions ---
258
254
259
- // Shadow settings (now also used for shape selector)
260
- fn spawn_setting (
261
- parent : & mut ChildSpawnerCommands ,
255
+ // Helper to return children! macro output for a setting row
256
+ fn spawn_setting_children (
262
257
label : & str ,
263
258
dec : SettingsButton ,
264
259
inc : SettingsButton ,
265
260
value : f32 ,
266
261
asset_server : & Res < AssetServer > ,
267
- ) {
268
- parent
269
- . spawn ( Node {
262
+ ) -> impl Bundle {
263
+ (
264
+ Node {
270
265
flex_direction : FlexDirection :: Row ,
271
266
align_items : AlignItems :: Center ,
272
267
height : Val :: Px ( 32.0 ) ,
273
268
..default ( )
274
- } )
275
- . with_children ( |row| {
276
- row. spawn ( ( Node {
277
- width : Val :: Px ( 80.0 ) ,
278
- justify_content : JustifyContent :: FlexEnd ,
279
- align_items : AlignItems :: Center ,
280
- ..default ( )
281
- } , ) )
282
- . with_children ( |label_node| {
283
- label_node. spawn ( (
284
- Text :: new ( label) ,
285
- TextFont {
286
- font : asset_server. load ( "fonts/FiraSans-Bold.ttf" ) ,
287
- font_size : 16.0 ,
288
- ..default ( )
289
- } ,
290
- TextColor ( Color :: WHITE ) ,
291
- ) ) ;
292
- } ) ;
293
- // Decrement button
294
- row. spawn ( (
269
+ } ,
270
+ children ! [
271
+ (
272
+ Node {
273
+ width: Val :: Px ( 80.0 ) ,
274
+ justify_content: JustifyContent :: FlexEnd ,
275
+ align_items: AlignItems :: Center ,
276
+ ..default ( )
277
+ } ,
278
+ children![ (
279
+ Text :: new( label) ,
280
+ TextFont {
281
+ font: asset_server. load( "fonts/FiraSans-Bold.ttf" ) ,
282
+ font_size: 16.0 ,
283
+ ..default ( )
284
+ } ,
285
+ TextColor ( Color :: WHITE ) ,
286
+ ) ] ,
287
+ ) ,
288
+ (
295
289
Button ,
296
290
Node {
297
291
width: Val :: Px ( 28. ) ,
@@ -304,20 +298,17 @@ fn spawn_setting(
304
298
BackgroundColor ( Color :: WHITE ) ,
305
299
BorderRadius :: all( Val :: Px ( 6. ) ) ,
306
300
dec,
307
- ) )
308
- . with_children ( |btn| {
309
- btn. spawn ( (
301
+ children![ (
310
302
Text :: new( if label == "Shape:" { "<" } else { "-" } ) ,
311
303
TextFont {
312
304
font: asset_server. load( "fonts/FiraSans-Bold.ttf" ) ,
313
305
font_size: 18.0 ,
314
306
..default ( )
315
307
} ,
316
308
TextColor ( Color :: WHITE ) ,
317
- ) ) ;
318
- } ) ;
319
- // Value display
320
- row. spawn ( (
309
+ ) ] ,
310
+ ) ,
311
+ (
321
312
Node {
322
313
width: Val :: Px ( 48. ) ,
323
314
height: Val :: Px ( 28. ) ,
@@ -328,39 +319,37 @@ fn spawn_setting(
328
319
} ,
329
320
BackgroundColor ( Color :: WHITE . with_alpha( 0.08 ) ) ,
330
321
BorderRadius :: all( Val :: Px ( 6. ) ) ,
331
- ) )
332
- . with_children ( |val_node| {
333
- // For shape selector, show the shape label, else show the value
334
- if label == "Shape:" {
335
- val_node. spawn ( (
336
- Text :: new ( SHAPES [ value as usize % SHAPES . len ( ) ] . 0 ) ,
337
- TextFont {
338
- font : asset_server. load ( "fonts/FiraSans-Bold.ttf" ) ,
339
- font_size : 16.0 ,
340
- ..default ( )
341
- } ,
342
- TextColor ( Color :: WHITE ) ,
343
- ValueLabel ( label. to_string ( ) ) ,
344
- ) ) ;
345
- } else {
346
- val_node. spawn ( (
347
- Text :: new ( if label == "Count:" {
348
- format ! ( "{}" , value as usize )
349
- } else {
350
- format ! ( "{:.1}" , value)
351
- } ) ,
352
- TextFont {
353
- font : asset_server. load ( "fonts/FiraSans-Bold.ttf" ) ,
354
- font_size : 16.0 ,
355
- ..default ( )
356
- } ,
357
- TextColor ( Color :: WHITE ) ,
358
- ValueLabel ( label. to_string ( ) ) ,
359
- ) ) ;
360
- }
361
- } ) ;
362
- // Increment button
363
- row. spawn ( (
322
+ children![ {
323
+ if label == "Shape:" {
324
+ (
325
+ Text :: new( SHAPES [ value as usize % SHAPES . len( ) ] . 0 ) ,
326
+ TextFont {
327
+ font: asset_server. load( "fonts/FiraSans-Bold.ttf" ) ,
328
+ font_size: 16.0 ,
329
+ ..default ( )
330
+ } ,
331
+ TextColor ( Color :: WHITE ) ,
332
+ ValueLabel ( label. to_string( ) ) ,
333
+ )
334
+ } else {
335
+ (
336
+ Text :: new( if label == "Count:" {
337
+ format!( "{}" , value as usize )
338
+ } else {
339
+ format!( "{:.1}" , value)
340
+ } ) ,
341
+ TextFont {
342
+ font: asset_server. load( "fonts/FiraSans-Bold.ttf" ) ,
343
+ font_size: 16.0 ,
344
+ ..default ( )
345
+ } ,
346
+ TextColor ( Color :: WHITE ) ,
347
+ ValueLabel ( label. to_string( ) ) ,
348
+ )
349
+ }
350
+ } ] ,
351
+ ) ,
352
+ (
364
353
Button ,
365
354
Node {
366
355
width: Val :: Px ( 28. ) ,
@@ -372,19 +361,18 @@ fn spawn_setting(
372
361
BackgroundColor ( Color :: WHITE ) ,
373
362
BorderRadius :: all( Val :: Px ( 6. ) ) ,
374
363
inc,
375
- ) )
376
- . with_children ( |btn| {
377
- btn. spawn ( (
364
+ children![ (
378
365
Text :: new( if label == "Shape:" { ">" } else { "+" } ) ,
379
366
TextFont {
380
367
font: asset_server. load( "fonts/FiraSans-Bold.ttf" ) ,
381
368
font_size: 18.0 ,
382
369
..default ( )
383
370
} ,
384
371
TextColor ( Color :: WHITE ) ,
385
- ) ) ;
386
- } ) ;
387
- } ) ;
372
+ ) ] ,
373
+ ) ,
374
+ ] ,
375
+ )
388
376
}
389
377
390
378
// --- SYSTEMS ---
0 commit comments