1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
//! The [`Widget`] trait, generic over the message type emitted on interaction.
use frus_core::{Rect, Scene, SemanticsProperties, Size};
use frus_layout::Style;
use crate::interaction::{Cursor, Key, Status};
use crate::portal::Placement;
use crate::runtime::Edit;
use crate::scroll::Axis;
use crate::theme::Theme;
/// A slot built on demand: the closure a `Table` header, a `Table` row or a `Kanban`
/// column takes for a cell that holds a **widget** rather than a string. It is called
/// again on every rebuild, so it hands back a fresh widget each time.
pub type CellFn<Msg = crate::callback::Callback> = Box<dyn Fn() -> Box<dyn Widget<Msg>>>;
/// Axis along which a **reorderable** widget moves while dragging: `Table` columns slide
/// **horizontally** (the default), `Kanban` cards **vertically**. The shell adapts the drag
/// preview (ghost direction, insertion indicator) to this axis.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
pub enum ReorderAxis {
/// Horizontal reordering (columns) — the default.
#[default]
Horizontal,
/// Vertical reordering (stacked cards).
Vertical,
}
/// The **sizing** half of a style: the fields that decide how big a box is, and none
/// of the ones that decide what happens inside it.
///
/// For a wrapper that nests its child ([`crate::Draggable`], [`crate::Hero`]) and wants
/// the box its child would have had. Copying the *whole* style would inset that child
/// twice — once by the wrapper's padding, then again by the child's, which is the same
/// number.
pub(crate) fn sizing_of(style: Style) -> Style {
Style {
width: style.width,
height: style.height,
min_width: style.min_width,
min_height: style.min_height,
max_width: style.max_width,
max_height: style.max_height,
flex_grow: style.flex_grow,
flex_shrink: style.flex_shrink,
flex_basis: style.flex_basis,
aspect_ratio: style.aspect_ratio,
..Default::default()
}
}
/// A widget: a composable interface element.
///
/// `Msg` is the application message type emitted on interaction (a message-passing
/// model, in the Elm/iced style).
/// What the paint walk knows and a widget does not, at the moment its layer filter is
/// asked for.
///
/// Both fields are there for the same reason: they are properties of *where the widget
/// turned out to be*, not of what it was built with. A mask is written in fractions of
/// a box, and the box is only a place on screen once layout has run; a shared backdrop
/// belongs to the nearest enclosing group, and a widget cannot see its own ancestors.
#[derive(Clone, Copy, Debug)]
pub struct FilterContext {
/// The widget's own box, on screen.
pub box_rect: frus_core::Rect,
/// The identity of the nearest enclosing [`crate::BackdropGroup`], if any — the
/// key a backdrop asking to be shared should use.
pub backdrop_group: Option<u64>,
}
/// The axes a widget asks to **fill**: on each, it takes the room its parent leaves it
/// rather than shrink-wrapping its children.
///
/// # Why this is asked and not declared
///
/// `width: 100%` looks like the same thing and is not. A percentage resolves against the
/// parent's **resolved** width, which a parent that shrink-wraps has not got yet — it is
/// waiting on this very child to find out how wide it should be. Both are "full width" in
/// English, and only one can be computed in time:
///
/// | | what it needs | known |
/// |---|---|---|
/// | `width: 100%` | the parent's own width | on the way back **up** |
/// | a fill request | the room being offered | on the way **down** |
///
/// Fifteen widgets in this crate said it the first way and every one of them collapsed
/// under a plain column (milestone 404). Asking is the only phrasing the layout can answer.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct FillAxes {
/// Take the width the parent offers.
pub horizontal: bool,
/// Take the height the parent offers.
pub vertical: bool,
}
/// Where a drag lands along a widget that takes one: see [`Widget::drag_track`].
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct DragTrack {
/// How far in from each end the travel starts, in logical pixels.
pub inset: f32,
/// Whether the travel runs from the right in a right-to-left reading direction.
pub mirrored: bool,
/// How a press and a slide move the value (milestone 650).
pub mode: DragMode,
}
/// **How a press and a slide move a dragged value** (milestone 650) — the reference's
/// `SliderInteraction`, in the terms the shell needs to apply it.
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub enum DragMode {
/// The value goes where the pointer is, from the press on: a tap jumps it, a slide
/// carries it. The default.
#[default]
Follow,
/// The press sets the value; the slide that follows changes nothing.
TapOnly,
/// The press leaves the value where it is; the slide moves it by its own length, from
/// `origin`, the value's place along the travel when the press landed.
Slide {
/// Where the value was, `0..=1` along the travel.
origin: f32,
},
/// As [`Slide`](Self::Slide), and only for a press within `radius` logical pixels of
/// the thumb at `origin`: a press anywhere else starts nothing at all.
SlideThumb {
/// Where the value, and so the thumb, was, `0..=1` along the travel.
origin: f32,
/// How far from the thumb's centre a press still takes it.
radius: f32,
},
/// **Two thumbs on one travel** (milestone 651), the reference's range slider: the
/// press picks one ([`DragTrack::pick_thumb`]) and the drag moves it with the pointer;
/// the widget hears it through [`Widget::on_thumb_drag`].
Thumbs {
/// The two thumbs' places, `0..=1` along the travel, the start first.
values: [f32; 2],
/// How far from a thumb's centre a press is on it.
radius: f32,
},
}
/// A moment of a drag on one of a widget's thumbs: see [`Widget::on_thumb_drag`].
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum ThumbDrag {
/// The thumb was picked: the gesture starts.
Start,
/// It moved.
Move,
/// It was let go.
End,
}
impl DragTrack {
/// The whole width, left to right, following the pointer: what a widget with no
/// opinion answers.
pub const WHOLE: Self = Self {
inset: 0.0,
mirrored: false,
mode: DragMode::Follow,
};
/// Where `x` falls along `rect`'s travel, as a fraction `0..=1`, for a reading
/// direction that is right to left when `rtl`.
///
/// One function, used by a drag's start, every move and its end alike: three copies
/// of this arithmetic would agree on every slider until one of them did not.
pub fn fraction(self, rect: crate::Rect, x: f32, rtl: bool) -> f32 {
self.along(rect, x, rtl).clamp(0.0, 1.0)
}
/// [`fraction`](Self::fraction) before it is held to the travel, so that a slide that
/// runs past an end still measures its whole length.
fn along(self, rect: crate::Rect, x: f32, rtl: bool) -> f32 {
let width = rect.width - 2.0 * self.inset;
let t = if width > 0.0 {
(x - rect.x - self.inset) / width
} else {
0.0
};
if self.mirrored && rtl {
1.0 - t
} else {
t
}
}
/// Whether a press at `x` starts anything at all: always, but for
/// [`DragMode::SlideThumb`], which wants the press on its thumb.
pub fn engages(self, rect: crate::Rect, x: f32, rtl: bool) -> bool {
match self.mode {
DragMode::SlideThumb { origin, radius } => {
let width = (rect.width - 2.0 * self.inset).max(0.0);
let t = if self.mirrored && rtl {
1.0 - origin
} else {
origin
};
let thumb = rect.x + self.inset + t * width;
(x - thumb).abs() <= radius
}
_ => true,
}
}
/// The value a drag pressed at `press_x` and now at `x` stands for, as a fraction of
/// the travel; `None` when this moment changes nothing. `moved` is `false` for the
/// press itself and `true` for every movement after it — and for the release, which
/// is where the slide ended.
///
/// A slide that started from the value moves it by the pointer's movement, as the
/// reference's does, so a thumb grabbed off its centre does not jump to the pointer.
pub fn value_at(
self,
rect: crate::Rect,
press_x: f32,
x: f32,
moved: bool,
rtl: bool,
) -> Option<f32> {
match self.mode {
DragMode::Follow | DragMode::Thumbs { .. } => Some(self.fraction(rect, x, rtl)),
DragMode::TapOnly => (!moved).then(|| self.fraction(rect, press_x, rtl)),
DragMode::Slide { origin } | DragMode::SlideThumb { origin, .. } => moved.then(|| {
(origin + self.along(rect, x, rtl) - self.along(rect, press_x, rtl)).clamp(0.0, 1.0)
}),
}
}
/// **Which thumb a press at `press_x` takes** on a [`DragMode::Thumbs`] track, `0` for
/// the start and `1` for the end, the movement since the press being `dx` — the
/// reference's `_defaultRangeThumbSelector`. The nearer thumb, unless the press is on
/// both, when the first movement decides: towards the start takes the start. `None`
/// while that is undecided, or on a track without thumbs.
pub fn pick_thumb(self, rect: crate::Rect, press_x: f32, dx: f32, rtl: bool) -> Option<usize> {
let DragMode::Thumbs { values, radius } = self.mode else {
return None;
};
let t = self.fraction(rect, press_x, rtl);
let width = (rect.width - 2.0 * self.inset).max(0.0);
let on = |v: f32| (t - v).abs() * width < radius;
if on(values[0]) && on(values[1]) {
// Towards the start is leftwards, or rightwards when the travel runs from the
// right.
let towards_start = if self.mirrored && rtl {
dx > 0.0
} else {
dx < 0.0
};
let towards_end = if self.mirrored && rtl {
dx < 0.0
} else {
dx > 0.0
};
return match (towards_start, towards_end) {
(true, _) => Some(0),
(_, true) => Some(1),
_ => None,
};
}
Some(if t * 2.0 < values[0] + values[1] {
0
} else {
1
})
}
/// The value a drag pressed at `press_x` lets go of at `x`: where the pointer is, where
/// the press set it, or where the slide took it.
pub fn released_at(self, rect: crate::Rect, press_x: f32, x: f32, rtl: bool) -> f32 {
match self.mode {
DragMode::TapOnly => self.fraction(rect, press_x, rtl),
_ => self
.value_at(rect, press_x, x, true, rtl)
.unwrap_or_else(|| self.fraction(rect, x, rtl)),
}
}
}
impl FillAxes {
/// Shrink-wrap on both axes — what a widget with no opinion answers.
pub const NONE: Self = Self {
horizontal: false,
vertical: false,
};
/// Take the width offered; hug the content vertically.
pub const WIDTH: Self = Self {
horizontal: true,
vertical: false,
};
/// Take the height offered; hug the content horizontally.
pub const HEIGHT: Self = Self {
horizontal: false,
vertical: true,
};
/// Take everything offered — a full-screen shell.
pub const BOTH: Self = Self {
horizontal: true,
vertical: true,
};
/// The axes asked for, as one flex direction, or `None` where that cannot be said —
/// neither axis, or both. For the walk, which resolves each axis separately anyway.
pub fn single(self) -> Option<frus_layout::FlexDirection> {
match (self.horizontal, self.vertical) {
(true, false) => Some(frus_layout::FlexDirection::Row),
(false, true) => Some(frus_layout::FlexDirection::Column),
_ => None,
}
}
/// Whether one axis is asked for.
pub fn wants(self, horizontal: bool) -> bool {
if horizontal {
self.horizontal
} else {
self.vertical
}
}
/// The axis a [`frus_layout::FlexDirection`] names, and nothing else.
pub fn along(direction: frus_layout::FlexDirection) -> Self {
if direction.is_horizontal() {
Self::WIDTH
} else {
Self::HEIGHT
}
}
}
/// A **widget**: a node of the tree that is laid out by [`Widget::style`], painted by
/// [`Widget::paint`] and asked what a click means by [`Widget::on_click`]; `Msg` is the
/// message it emits when the reader interacts with it.
///
/// Only those four are required. Everything else — focus, scrolling, editing, semantics,
/// the hooks a container uses to build its children late — has a default that does nothing,
/// so a widget implements what it takes part in and no more.
pub trait Widget<Msg = crate::callback::Callback> {
/// Layout style (handed to `frus-layout`).
fn style(&self) -> Style;
/// The widget's children (possibly empty).
fn children(&self) -> &[Box<dyn Widget<Msg>>];
/// Paints the widget's own decoration, according to its status (hover / focus /
/// cursor / selection) and the current theme.
fn paint(&self, bounds: Rect, status: Status, theme: &Theme, scene: &mut Scene);
/// Message to emit on click (`None` = not clickable).
fn on_click(&self) -> Option<Msg>;
/// Whether a press that lands on this widget and on **nothing inside it** stops
/// here.
///
/// An ordinary widget is transparent to a press it has no message for: the press
/// carries on to whatever is behind. That is right for a label on a card and wrong
/// for a **surface** — a floating panel, a sheet, a bar — where the thing behind is
/// the page and the press reaching it means the panel is dismissed by a click on its
/// own padding, or on a row that said it was unavailable.
///
/// It is registered **before** the widget's children, so anything inside still wins;
/// all this catches is what nothing inside claimed. `false` by default, because a
/// widget that stops presses it does not use is the surprising one.
///
/// This is not [`crate::AbsorbPointer`], which discards the whole subtree's targets.
/// Here the subtree keeps every one of them and only the gaps between them are
/// closed.
fn opaque(&self) -> bool {
false
}
/// **Stable** identity key (independent of the position among siblings).
/// `None` = positional identity. See [`crate::Keyed`].
fn key(&self) -> Option<u64> {
None
}
/// **Short** name of the widget — for the inspector and diagnostic dumps.
/// Defaults to the name of the concrete type, without module path or
/// generics (each implementation gets its own monomorphised copy of this
/// default body). Transparent wrappers (`Box`, [`crate::Keyed`]…) delegate
/// to their content.
fn debug_name(&self) -> &'static str {
short_type_name::<Self>()
}
/// The widget's **accessibility annotation** (role, label, value, state),
/// exposed to assistive technologies through the AccessKit tree. `None` =
/// no semantics of its own (a layout container — its children, though,
/// may have some). See [`frus_core::SemanticsProperties`].
fn semantics(&self) -> Option<SemanticsProperties> {
None
}
/// What this widget says about its **child's** subtree, when it knows something the
/// child cannot know about itself — the [`crate::Semantics`] wrapper, and nothing else
/// so far.
///
/// [`Widget::semantics`] is a widget answering for itself and covers the ordinary
/// case. This covers the one it cannot: a caller handed an already-built widget, with
/// no way in. Read in one place in the walk, the way a
/// [`ModalBarrier`](crate::barrier::ModalBarrier) is — the subtree is walked exactly as
/// usual and what it produced is reconciled afterwards, so a widget deep inside
/// annotates itself without knowing anything is speaking for it.
fn describes(&self) -> Option<crate::semantics::Description> {
None
}
/// Applies a key to the focused widget: mutates the edit state
/// (cursor/selection) and returns a message if the **value** changes.
fn on_edit(&self, _edit: &mut Edit, _key: &Key) -> Option<Msg> {
None
}
/// **Positional** click: a message emitted according to where the click landed (local
/// coordinates from the widget's top-left corner, within the `width × height` box), taking
/// **priority** over [`on_click`](Self::on_click). For clickable sub-regions — e.g. the
/// **suffix** icon of a [`crate::TextField`] (clear / reveal) or a chart **point**
/// (milestone 221). `None` (the default) = no sub-region; the shell falls back to `on_click`.
fn positional_click(
&self,
_local_x: f32,
_local_y: f32,
_width: f32,
_height: f32,
) -> Option<Msg> {
None
}
/// Shape of the **system cursor** wanted at the **local** position `(local_x, local_y)` inside
/// the widget's `width × height` box (milestone 205): `Some(Cursor::Pointer)` over a clickable
/// sub-region (a suffix icon…), `None` (the default) = no opinion, the shell keeps the default
/// cursor. Does not affect clicking; this is purely the pointer's appearance on hover.
fn cursor_icon(
&self,
_local_x: f32,
_local_y: f32,
_width: f32,
_height: f32,
) -> Option<Cursor> {
None
}
/// Cursor index matching a local position (px from the widget's top-left
/// corner) — for placing the caret on click. `local_y` picks the **line** in a
/// multi-line field (ignored on a single line).
///
/// `width` = the field's width, `scroll_cursor` = the cursor from which to recompute
/// the current **scroll** (the same one the render used), so that a click lands right
/// even when the text is scrolled. `None` = not a text field.
fn cursor_at(
&self,
_local_x: f32,
_local_y: f32,
_width: f32,
_scroll_cursor: usize,
) -> Option<usize> {
None
}
/// SingleChildScrollView metrics of a **multi-line** field, for a widget width and a cursor:
/// `(content height, visible box height, caret top, caret height)`, in content
/// space (px). The shell uses them to register the scrollable region and to keep
/// the caret in view. `None` otherwise.
fn text_metrics(&self, _width: f32, _cursor: usize) -> Option<(f32, f32, f32, f32)> {
None
}
/// Frame (input box) of a **multi-line** field within its `rect` — the area where
/// the text scrolls, below the label. Used to place the scrollbar and the
/// scrollable region exactly on the box. `None` otherwise.
fn text_viewport(&self, _rect: crate::Rect) -> Option<crate::Rect> {
None
}
/// Moves the caret vertically in a multi-line field and returns
/// `(new index, visual column used)`.
///
/// - `down`: down (`true`) or up. `page`: jump by a **page** (the visible
/// height) rather than by a **line**.
/// - `goal_x`: remembered target visual column (px) to preserve while crossing
/// shorter lines; `None` = start from the current column. The returned value
/// is the column to remember again for the next jump.
/// - **Line**: `None` if already on the first/last line (or not multi-line) —
/// the shell then moves the focus instead.
/// - **Page**: clamped to the field (it never leaves it); `None` only when not
/// multi-line.
fn caret_vertical(
&self,
_width: f32,
_cursor: usize,
_down: bool,
_page: bool,
_goal_x: Option<f32>,
) -> Option<(usize, f32)> {
None
}
/// The currently selected text (for copy/cut).
fn selected_text(&self, _edit: &Edit) -> Option<String> {
None
}
/// The field's **whole** value, if this widget is a text field — to give the
/// IME its input context (suggestions). `None` otherwise.
fn text_value(&self) -> Option<&str> {
None
}
/// The words this widget shows, **if it takes part in a
/// [`SelectionArea`](crate::SelectionArea)**: a [`Text`](crate::Text), and nothing that is
/// not made of words. The walk registers such a widget as a text stop when it is inside an
/// area, so that a selection can begin, end and pass through it.
fn selection_text(&self) -> Option<&str> {
None
}
/// The character boundary of [`selection_text`](Self::selection_text) nearest a local
/// position (px from the widget's top-left corner) in a box `width` wide — the layout the
/// widget was **drawn** with, which is what a press is hit against.
fn selection_hit(&self, _local_x: f32, _local_y: f32, _width: f32) -> Option<usize> {
None
}
/// The handle that hangs from character boundary `index` of this widget's words — the
/// start handle when `start`, the end handle otherwise — in local coordinates, for a widget
/// `width` wide: where it is painted, and so where a finger takes it. `None` for anything
/// that is not a text.
fn selection_grip(
&self,
_width: f32,
_index: usize,
_start: bool,
) -> Option<crate::SelectionHandle> {
None
}
/// The **bar** a [`SelectionArea`](crate::SelectionArea) offers over its selection, for
/// `context`, when the application has said what it holds
/// ([`SelectionArea::selection_toolbar`](crate::SelectionArea::selection_toolbar)): `Some`
/// of the bar, or `Some(None)` for no bar at all. `None` for anything else — and for an area
/// that was told nothing — whose texts then offer Copy and Select all.
fn area_toolbar(&self, _context: crate::ToolbarContext) -> Option<Option<&dyn Widget<Msg>>> {
None
}
/// The **bar** over the part of a selection area's selection that lies in this widget —
/// `range`, in characters — for `context`, and the box it is placed against in local
/// coordinates, for a widget `width` wide. `None` for anything that is not a text, or when
/// the list for `context` is empty.
fn region_toolbar(
&self,
_context: crate::ToolbarContext,
_width: f32,
_range: (usize, usize),
) -> Option<(Rect, &dyn Widget<Msg>)> {
None
}
/// Whether this widget takes **typing**: a field that can be changed, which is what
/// the software keyboard is for. A text field that may only be read and selected — a
/// [`read_only`](crate::TextField::read_only) one, a [`Text`](crate::Text) made
/// [`selectable`](crate::Text::selectable) — answers `false`: it has a caret and a
/// selection, and no use for a keyboard sliding up over the words being read.
///
/// Defaults to whether it holds a text value at all.
fn takes_typing(&self) -> bool {
self.text_value().is_some()
}
/// The message that puts `value` in this field: the one typing would have produced,
/// for a value the **framework** restores rather than the user typing it.
///
/// Undo needs it and nothing else does. The value is the application's — a field owns
/// its caret and not its text — so an undo cannot reach in and set what is on screen;
/// it has to go back through a message like any other edit, or the next frame would
/// paint the value the application still holds.
fn replace_value(&self, _value: String) -> Option<Msg> {
None
}
/// Range `(start, end)` of the word around the given index (for double-click).
fn word_at(&self, _index: usize) -> Option<(usize, usize)> {
None
}
/// The two handles of the selection in `edit`, start then end, for a field `width`
/// wide whose content is scrolled down by `scroll_y` — where they are painted, and
/// so where a finger takes them. `None` when there is no selection, or this is not
/// a text field.
fn selection_handles(
&self,
_width: f32,
_edit: &Edit,
_scroll_y: f32,
) -> Option<[crate::SelectionHandle; 2]> {
None
}
/// The **bar** this field shows over its selection (Cut, Copy, Paste, Select all — see
/// [`crate::ToolbarItem`]) for `context`, or `None` when there is none to show: this is
/// not a text field, or the application's list for that context is empty.
///
/// The runtime asks it when the shell has marked this field as showing its bar, and
/// floats the answer over everything, anchored on [`selection_anchor`](Self::selection_anchor).
/// One bar per context, built once and kept — a bar is a widget the walk borrows for
/// the frame, and two different lists must not share an identity.
fn selection_toolbar(&self, _context: crate::ToolbarContext) -> Option<&dyn Widget<Msg>> {
None
}
/// The box the bar is placed against, in the field's **local** coordinates: the
/// selection's, or the caret's when nothing is selected. Like
/// [`selection_handles`](Self::selection_handles) it is the paint's own geometry.
fn selection_anchor(&self, _width: f32, _edit: &Edit, _scroll_y: f32) -> Option<Rect> {
None
}
/// The editing action pressing this widget performs **on the focused field**, for a
/// button of the bar that carries no message (see [`crate::EditAction`]).
fn edit_action(&self) -> Option<crate::EditAction> {
None
}
/// Keystrokes this subtree binds to **intents** — see [`crate::Shortcuts`].
fn shortcut_bindings(&self) -> &[(crate::shortcuts::KeyStroke, crate::shortcuts::Intent)] {
&[]
}
/// Keystrokes this subtree binds **straight to messages** — see
/// [`crate::CallbackShortcuts`].
fn shortcut_callbacks(&self) -> &[(crate::shortcuts::KeyStroke, Msg)] {
&[]
}
/// Intents this subtree **answers** — see [`crate::Actions`].
fn action_bindings(&self) -> &[(crate::shortcuts::Intent, Msg)] {
&[]
}
/// Intents this subtree **watches** without answering — see
/// [`crate::ActionListener`].
fn action_listeners(&self) -> &[(crate::shortcuts::Intent, Msg)] {
&[]
}
/// Every keystroke reaching this subtree, handed to a closure — see
/// [`crate::KeyboardListener`]. `None` (the default) is not a listener.
#[allow(clippy::type_complexity)]
fn on_keystroke(
&self,
) -> Option<std::rc::Rc<dyn Fn(crate::shortcuts::KeyStroke) -> Option<Msg>>> {
None
}
/// If `true`, the widget can take keyboard focus (click or Tab).
fn focusable(&self) -> bool {
false
}
/// Message for the focus **arriving in or leaving this widget's subtree** (milestone
/// 660) — the reference's `onFocusChange`: `true` when the focused widget is now this
/// one or inside it and was not, `false` the other way. The shell asks once a frame,
/// after the focus has moved, every widget on the two paths from the root that the move
/// changed, the one that lost it first.
fn on_focus_change(&self, _focused: bool) -> Option<Msg> {
None
}
/// Message for a **press outside this widget while it holds the focus** (milestone
/// 660) — the reference's `onTapOutside`: sent before the press moves the focus.
fn on_tap_outside(&self) -> Option<Msg> {
None
}
/// If `true`, a focusable widget **takes the focus when it appears**: a menu's first
/// row when the menu opens, a field on a screen made to type into (milestone 605). Where
/// the focus came from is remembered, and it goes back there when this one goes.
fn autofocus(&self) -> bool {
false
}
/// If `false`, **nothing inside this subtree** can take focus — the reference's
/// `ExcludeFocus`. A dimmed panel behind a sheet is still drawn and still measured;
/// it simply stops being somewhere Tab can land.
fn descendants_focusable(&self) -> bool {
true
}
/// If `true`, this subtree's focus stops are **skipped by Tab** while remaining
/// focusable by a click — the reference's `ExcludeFocusTraversal`. The two are
/// separate questions: a toolbar button may be reachable with the pointer and still
/// not belong in the keyboard's order.
fn focus_skip_traversal(&self) -> bool {
false
}
/// A **traversal order** for this subtree's focus stops, smallest first — the
/// reference's `NumericFocusOrder`. `None` leaves them in tree order, which is where
/// everything sits until someone says otherwise.
fn focus_order(&self) -> Option<f32> {
None
}
/// If `true`, this subtree is a **traversal group**: an order set inside it is
/// resolved among its own members and nowhere else, so a reordered dialog does not
/// reshuffle the page behind it.
fn focus_group(&self) -> bool {
false
}
/// What this field is **for**, so the platform can fill it in — see
/// [`AutofillHint`](crate::AutofillHint). Empty (the default) is a field that takes
/// no part in autofill at all.
///
/// A list, because a field can legitimately be more than one thing: a sign-in box
/// taking an email address is the username *and* the email.
fn autofill_hints(&self) -> &[crate::AutofillHint] {
&[]
}
/// If `true`, this subtree's fields are **one form** — the reference's
/// `AutofillGroup`. A service shown a password with no username beside it has
/// nothing to save the pair under.
fn autofill_group(&self) -> bool {
false
}
/// If `true`, the widget draws its focus indicator **itself** (the driver then
/// does not stroke the generic ring). E.g. `TextField`.
fn draws_own_focus(&self) -> bool {
false
}
/// If `true`, the widget responds to pointer dragging (sliders, handles).
fn draggable(&self) -> bool {
false
}
/// **Where along a [`draggable`](Self::draggable) widget its drag lands** (milestone
/// 648): how far in from each end the travel starts, and whether it runs from the
/// right in a right-to-left reading direction. The fraction [`on_drag`](Self::on_drag)
/// and its edges are given is measured along that travel. The default is the whole
/// width, left to right.
fn drag_track(&self) -> DragTrack {
DragTrack::WHOLE
}
/// Message for a moment of a drag on one of this widget's thumbs (milestone 651), on a
/// [`DragMode::Thumbs`] track: `thumb` is the one the press picked, `0` for the start,
/// and `fraction` the pointer's place along the travel. A press that has picked none
/// yet sends nothing.
fn on_thumb_drag(&self, _thumb: usize, _moment: ThumbDrag, _fraction: f32) -> Option<Msg> {
None
}
/// Message produced while dragging, `fraction` being the relative horizontal
/// position (`0.0..=1.0`) within the widget's bounds.
fn on_drag(&self, _fraction: f32) -> Option<Msg> {
None
}
/// Message produced when a value drag **begins** — on the press, before the
/// first [`on_drag`](Self::on_drag).
///
/// With [`on_drag_end`](Self::on_drag_end) it brackets the stream: `on_drag` fires
/// on every pixel of the movement, and an application that saves to disk, seeks a
/// video or asks the network on each of those does it sixty times a second. The
/// bracket is what lets it do the cheap thing while the finger is down and the
/// expensive one when it lifts — and without an end there is no moment at which
/// to do it at all.
///
/// Not to be confused with [`on_dropped`](Self::on_dropped), which belongs to
/// drag-and-**drop**: that one moves a thing, this one changes a number.
fn on_drag_start(&self, _fraction: f32) -> Option<Msg> {
None
}
/// Message produced when a value drag **ends** — on the release, with the
/// fraction the pointer finished on.
///
/// See [`on_drag_start`](Self::on_drag_start).
fn on_drag_end(&self, _fraction: f32) -> Option<Msg> {
None
}
/// Message produced by a horizontal drag expressed as a **delta**: `dx` is the
/// movement (logical px) since the last event. For handles that **accumulate**
/// (column resizing), unlike [`on_drag`](Self::on_drag) (an absolute fraction,
/// e.g. a slider). The shell tries it **before** `on_drag`; a widget implements
/// only one of the two.
fn on_drag_delta(&self, _dx: f32) -> Option<Msg> {
None
}
/// If this widget is a **shared element**, its tag. Two heroes with the same tag on
/// the two sides of a route transition are one thing in two places.
/// See [`crate::Hero`].
fn hero_tag(&self) -> Option<u64> {
None
}
/// If this widget can be **picked up** and dropped elsewhere, what it carries.
/// See [`crate::Draggable`].
fn drag_payload(&self) -> Option<u64> {
None
}
/// Does this item lift on a **long press** rather than on the first movement?
/// The answer inside a scrollable, where a plain drag belongs to the scroll.
///
/// It is asked of both kinds of lift — a [`crate::Draggable`] carrying a payload, and a
/// [`crate::ReorderableList`] row carrying itself — because the question is the same
/// one: a list that stops scrolling is a worse bug than an item that does not move.
fn drag_needs_long_press(&self) -> bool {
false
}
/// How solid the item left behind looks while a copy of it is being dragged.
fn drag_ghost_opacity(&self) -> f32 {
1.0
}
/// Message sent when a drag of this item ends, `true` if a target took it.
fn on_dropped(&self, _accepted: bool) -> Option<Msg> {
None
}
/// Is this widget a **drop target**? See [`crate::DragTarget`].
fn drop_zone(&self) -> bool {
false
}
/// Would this target take `payload`? Only asked of a drop target.
fn accepts_drag(&self, _payload: u64) -> bool {
true
}
/// Message sent when an accepted item is dropped on this target.
fn on_drop(&self, _payload: u64) -> Option<Msg> {
None
}
/// Would this target take these **files**, dragged onto the window from outside
/// the application? Only asked of a drop target; none takes files unless it says
/// so. See [`crate::DragTarget::on_files`].
fn accepts_files(&self, _paths: &[std::path::PathBuf]) -> bool {
false
}
/// Message sent when accepted files are dropped on this target.
fn on_files_dropped(&self, _paths: Vec<std::path::PathBuf>) -> Option<Msg> {
None
}
/// If this widget is a **reorderable header**, its column index. The shell uses
/// it to identify the **source** column (on press) and the **target** column
/// (under the pointer on release) of a reordering drag.
fn reorder_index(&self) -> Option<usize> {
None
}
/// Message emitted when this header (the source) is **dropped** on column `to`.
/// The widget knows its own index and the `on_reorder(from, to)` callback.
fn on_reorder(&self, _to: usize) -> Option<Msg> {
None
}
/// Movement **axis** of this reorderable (default [`ReorderAxis::Horizontal`]): the shell
/// orients the drag preview (ghost + insertion indicator) accordingly. `Kanban` cards
/// return [`ReorderAxis::Vertical`].
fn reorder_axis(&self) -> ReorderAxis {
ReorderAxis::Horizontal
}
/// Is a **horizontal** reorderable dropped *between* its neighbours, like a list's row,
/// rather than *into the place* of the one under the pointer, like a table's column?
/// `false` by default, which is the table.
///
/// The two are different gestures, not one gesture on two axes. A column follows the
/// pointer with a continuous slide and takes the index of the column it lands on. A row
/// is inserted before or after the slot it is over — whichever half the pointer is in —
/// with an insertion line, a gap that opens there, and the nearest slot of its own list
/// when the pointer is over none. A widget that answers `true` gets the second.
///
/// Only asked of a horizontal reorderable: every vertical one is inserted between its
/// neighbours already, and answering here changes nothing for it.
fn reorder_inserts(&self) -> bool {
false
}
/// Can this reorderable be **picked up** as a drag source? `true` by default for every
/// reorderable. A **target-only** slot — the drop zone at the end of a Kanban column —
/// returns `false`: a card can be **dropped** there, not **lifted** from it (otherwise the
/// drag would raise an empty ghost that moves nothing).
fn reorder_draggable(&self) -> bool {
true
}
/// Can this reorderable be **dropped onto**? `true` by default, and the mirror image of
/// [`reorder_draggable`](Self::reorder_draggable): a **source-only** grip — a list row's
/// drag handle — returns `false`.
///
/// A handle is a small box inside a much larger row, and the drop is aimed at whatever
/// is topmost under the pointer. Without this, carrying a row over another row's handle
/// would aim at the handle: the insertion line would be drawn across the grip instead of
/// across the row, which is a promise about where the row is going that is not true.
fn reorder_droppable(&self) -> bool {
true
}
/// What to **say** to a screen reader once this reorderable has been moved to `to` — the
/// spoken counterpart of the ghost, for someone who cannot see it land.
///
/// `None` leaves the shell its own wording, which can only speak of the axis: the index
/// a `Kanban` card is dropped at is a flat `column × stride + position` that means
/// nothing read out loud. A widget whose index **is** a position says so itself.
fn reorder_announcement(&self, _to: usize) -> Option<String> {
None
}
/// Text to **announce** to the screen reader when this widget is **activated** (mouse
/// click or Enter/Space) — a live region reads it out loud. Describes the effect the
/// activation **produced** ("Sorted by Name ascending", "All rows selected"), for the
/// blind user who cannot perceive the visual change. `None` = nothing to announce
/// (the default).
fn announce(&self) -> Option<String> {
None
}
/// If `true`, the widget is a **stack**: its children are superimposed layers
/// (the same box), rendered in order (the last one on top).
fn stack(&self) -> bool {
false
}
/// If `true`, the widget is a **section with a sticky header**
/// ([`crate::StickyHeader`]): its first child is painted, and takes taps, at the top of
/// what is visible of the section, over the second (milestone 602).
fn sticky_header(&self) -> bool {
false
}
/// If the widget **places its children with a function** — a
/// [`crate::CustomMultiChildLayout`] — the function and one key per child. The children
/// are then laid out and placed in the walk, by the function, and not in this node's
/// layout (milestone 601).
fn custom_layout(&self) -> Option<crate::customlayout::CustomLayout<'_>> {
None
}
/// If `true`, the widget animates **continuously** (driven by time, not by a
/// target): the framework keeps redrawing. E.g. `CircularProgressIndicator`.
fn continuous(&self) -> bool {
false
}
/// If `true`, this widget is a **repaint boundary**: its subtree is cached
/// (primitives + interaction maps) and **reused as is** as long as its geometry
/// and the interaction state of its descendants do not change — a widget
/// animating elsewhere no longer forces it to repaint.
/// See [`crate::Container::repaint_boundary`] and `paintcache.rs`.
fn repaint_boundary(&self) -> bool {
false
}
/// If the widget is a scrollable container, returns its content.
fn scroll_content(&self) -> Option<&dyn Widget<Msg>> {
None
}
/// If the widget is a **virtualised list**, returns its description (item count,
/// height, factory). Only the visible items are built.
fn virtual_list(
&self,
_viewport: frus_core::Size,
) -> Option<crate::list::VirtualList<'_, Msg>> {
None
}
/// If the widget is a **paged view**, returns its description (page count,
/// axis, factory). Like a virtualised list, only the visible pages are built.
fn page_view(&self) -> Option<crate::pageview::PagedView<'_, Msg>> {
None
}
/// Message sent by a paged view when the page on screen changes.
fn on_page_changed(&self, _page: usize) -> Option<Msg> {
None
}
/// Message sent by a **scroll region** when its offset changes — the reading half
/// of [`crate::ScrollPosition`].
///
/// Silent by default, and that is the answer to what it costs: a region nobody is
/// listening to reports nothing, so a fling over an ordinary list is exactly as
/// cheap as it was. A region somebody *is* listening to sends a message per frame
/// while it moves, because a bar that fades in as the page goes down needs every
/// frame of it — and a region that only wants to know when the end is near says so
/// through [`Widget::scroll_grain`] rather than by being reported less honestly.
fn on_scroll(&self, _position: crate::scrollposition::ScrollPosition) -> Option<Msg> {
None
}
/// How far this region must move before it says so again, in pixels; `0` — the
/// default — reports **every** change.
///
/// A grain suppresses the reports in between, never the last one: a region that
/// comes to rest anywhere other than where it was last reported reports that,
/// whatever the grain. Otherwise a coarse grain would leave the application
/// believing a list was at 1 200 when it settled at 1 247, which is a worse answer
/// than a slower one.
fn scroll_grain(&self) -> f32 {
0.0
}
/// If the widget takes one axis from its content's **preferred** size, returns
/// that axis and the step its measurement is rounded up to. See
/// [`crate::Intrinsic`].
fn intrinsic(&self) -> Option<(crate::constraints::IntrinsicAxis, Option<f32>)> {
None
}
/// If the widget lays its child out to constraints of **its own**, which the
/// child may exceed, returns them. See [`crate::OverflowBox`].
fn overflow_box(&self) -> Option<crate::constraints::Overflow> {
None
}
/// The box this widget **gives its child** as a function of the box it was offered,
/// with the child laid out in it separately and the box then sized to what came
/// back. `None` — the default — means the child shares this node's layout, as
/// everything ordinary does. See [`crate::ConstraintsTransformBox`].
fn constraints_transform(&self) -> Option<crate::constraints::ConstraintsTransform> {
None
}
/// If the box this widget's [`constraints_transform`](Self::constraints_transform) makes
/// **follows its child's size over time** rather than at once, how (milestone 594). See
/// [`crate::AnimatedSize`].
fn animated_size(&self) -> Option<crate::animatedsize::SizeAnimation> {
None
}
/// If the box this widget's [`constraints_transform`](Self::constraints_transform) makes
/// is **a multiple of its child's size** — `(across, down)`, `1` for as big as the child
/// — the multiples (milestones 596 and 597). See [`crate::SizeTransition`] and
/// [`crate::Aligned::width_factor`].
fn size_factor(&self) -> Option<(f32, f32)> {
None
}
/// Whether the box this widget's [`constraints_transform`](Self::constraints_transform)
/// makes **cuts its child** to itself. A reveal does; an anchor with a factor lets its
/// child spill (milestone 597).
fn clips_to_box(&self) -> bool {
false
}
/// If the widget builds its content **from its actual box**, returns the
/// `size → widget` factory. The content is built on the fly: no retained state
/// and no overlay (like a virtualised list item).
fn layout_builder(&self) -> Option<&dyn Fn(Size) -> Box<dyn Widget<Msg>>> {
None
}
/// If the widget draws something **over its scroll region**, returns the
/// `offset → overlay` factory. See [`crate::ScrollOverlay`].
///
/// The region is this widget's first child, so the offset the walk hands over is its
/// own child's and nothing has to be named. Like a `layout_builder`'s content, the
/// overlay is built on the fly and has no retained state.
fn scroll_overlay(&self) -> Option<&crate::scrolloverlay::OverlayBuilder<Msg>> {
None
}
/// SingleChildScrollView axis (or axes), for a scrollable container.
fn scroll_axis(&self) -> crate::scroll::Axis {
crate::scroll::Axis::Vertical
}
/// The edge and fling behaviour of a scrollable container, when this widget
/// wants one in particular. `None` — the usual answer — leaves the choice to
/// the application, which defaults to what the platform does.
fn scroll_physics(&self) -> Option<crate::physics::ScrollPhysics> {
None
}
/// **Whether this area draws a scrollbar**, when it wants its own answer rather than
/// the application's. `None` — the default — follows the application, which follows
/// the platform. See [`crate::Scrollbars`].
fn scrollbars(&self) -> Option<crate::physics::Scrollbars> {
None
}
/// **Keep this area's scrollbar on screen**, instead of letting it fade away when
/// the area stops moving (`scrollbar.dart:214`).
///
/// `None` — the default — lets it fade, which is what a bar over content should do.
/// `Some(true)` pins it: for an area whose content is not obviously scrollable, or
/// one a reader is meant to be able to aim at without scrolling first.
fn thumb_visibility(&self) -> Option<bool> {
None
}
/// What the **software keyboard** should be, when this widget is the focused
/// editable one.
///
/// Only ever asked of the field that has focus — the platform layer finds it the
/// same way it finds the caret — so a widget that is not editable never has to
/// answer, and the default is the ordinary text keyboard with a *Done* key.
///
/// See [`crate::ime`] for what the two halves mean and why the mapping to the
/// platform's numbers is tested rather than trusted.
fn ime(&self) -> crate::ime::Ime {
crate::ime::Ime::default()
}
/// If the widget is a portal, returns its floating content and its placement.
fn overlay(&self) -> Option<(&dyn Widget<Msg>, Placement)> {
None
}
/// Message emitted when the scrim of a modal is clicked (dismissal), if any.
fn overlay_dismiss(&self) -> Option<Msg> {
None
}
/// The colour of the scrim behind this widget's **modal** overlay, when it wants one
/// in particular. `None` — the usual answer — leaves it to the scheme's `scrim`
/// role at the framework's own opacity.
///
/// The alpha is the caller's: a scrim is the one colour whose *transparency* is the
/// whole point, so a fully opaque value here means an opaque scrim, and
/// [`Color::TRANSPARENT`](frus_core::Color::TRANSPARENT) means none at all — an
/// overlay that darkens nothing, which the reference reaches by the same route.
fn overlay_scrim(&self, _theme: &crate::theme::Theme) -> Option<frus_core::Color> {
None
}
/// If `true`, this widget's **anchored** overlay (a menu…) **traps focus**: Tab and the
/// arrow keys cycle within its focusables while it is open (the keyboard pattern of menus).
/// Modal (scrimmed) overlays already trap by default; a tooltip or an autocomplete list
/// (focus stays on the field) do **not**. Default: `false`.
fn overlay_traps_focus(&self) -> bool {
false
}
/// Target of the widget's own animated value (e.g. `1.0` for a switch that is on,
/// `0.0` for off). The runtime drives the retained value towards this target and
/// hands it back through `Status::value`. `None` = no animated value.
fn anim_target(&self) -> Option<f32> {
None
}
/// **Target transform** of an animated one (`Transform::animated`): the runtime
/// tweens the scales and the turn through `anim_duration`/`anim_curve` and hands the
/// interpolated value back through `Runtime::anim_transform`, which the paint walk
/// reads in place of the static `transform_scale`/`transform_rotate`. `None` = the
/// transform does not move.
///
/// The **pivot** is not part of it: see
/// [`TransformValues`](crate::runtime::TransformValues).
fn anim_transform(&self) -> Option<crate::runtime::TransformValues> {
None
}
/// Duration (seconds) of the animated value's transition (`anim_target`).
/// Default: the framework's standard duration.
fn anim_duration(&self) -> f32 {
crate::runtime::ANIM_DURATION
}
/// Easing curve of the animated value's transition (`anim_target`).
/// Default: linear.
fn anim_curve(&self) -> frus_core::Curve {
frus_core::Curve::Linear
}
/// Where the animated value **starts when the widget appears**. `None`, the default: at
/// its target, with no transition, so a switch shown on is simply on. A widget that
/// plays something from its start when it appears — an animation — says `Some(0.0)`,
/// and the value travels to its target in `anim_duration` from the first frame
/// (milestone 691).
fn anim_initial(&self) -> Option<f32> {
None
}
/// If the widget is an **opacity group**, returns the (target) opacity `[0,1]`
/// applied to its whole subtree **as one**: the paint walk wraps its primitives
/// in a composited layer at that opacity — no double-blending where they
/// overlap. `None` = not a group. Combined with `anim_target`, the opacity
/// **animates** (a group fade).
fn opacity_group(&self) -> Option<f32> {
None
}
/// **Target** background colour of an animated background
/// (`Container::animated_color`): the runtime tweens it (through
/// `anim_duration`/`anim_curve`) and hands the interpolated value back in
/// `Status::anim_color`. `None` = no animated colour.
fn anim_color(&self) -> Option<frus_core::Color> {
None
}
/// **Target** size of an animated size (`Container::animated_size`): the runtime
/// tweens it (through `anim_duration`/`anim_curve`) and the interpolated size is
/// injected **at layout** (see `effective_style`). `None` = fixed size.
fn anim_size(&self) -> Option<Size> {
None
}
/// **Target** corner radius of an animated radius (`Container::animated_radius`):
/// the runtime tweens it and hands the interpolated value back in
/// `Status::anim_radius`. `None` = fixed radius.
fn anim_radius(&self) -> Option<frus_core::BorderRadius> {
None
}
/// **Target** padding of an animated padding (`Container::animated_padding`):
/// the runtime tweens it and the interpolated padding is injected **at layout**
/// (see `effective_style`). `None` = fixed padding.
fn anim_padding(&self) -> Option<frus_core::Insets> {
None
}
/// The pair of fractions this node's **offset rule** is made of, animated: an
/// alignment's two fractions, or a slide's. `None` — the default — leaves the rule
/// reading the widget's own numbers.
///
/// One quantity serves both rules because a node has one of them. See
/// [`crate::AnimatedAlign`] and [`crate::AnimatedSlide`], each of which gives the
/// rule it animates a node of its own.
fn anim_offset(&self) -> Option<(f32, f32)> {
None
}
/// **Target pins** of an animated stack layer ([`crate::AnimatedPositioned`]): the
/// runtime tweens them and the interpolated pins are read where the stack lays its
/// layers out. `None` — the default — leaves [`Widget::positioned`] alone.
///
/// A pin that is **unset does not animate**: `None` on an edge is not nought there,
/// it is a box not pinned on that side at all, and moving between the two would be
/// interpolating between two arrangements rather than two values.
fn anim_pins(&self) -> Option<crate::positioned::Positioning> {
None
}
/// **Target fractions** of an animated share of the parent
/// (`FractionallySizedBox::animated`), as `(width factor, height factor)`: the
/// runtime tweens them and the interpolated pair is injected **at layout** (see
/// `effective_style`), like the size and the padding. `None` = fixed factors.
///
/// An axis whose factor is unset follows its content, and the same rule applies:
/// it does not travel to or from a factor, it changes what the axis is doing.
fn anim_fractions(&self) -> Option<(Option<f32>, Option<f32>)> {
None
}
/// **Target text style** an animated subtree is heading for
/// (`AnimatedDefaultTextStyle`). `None` = the subtree inherits whatever it inherits.
///
/// The odd one out of the animated family: what the runtime tweens here is not this
/// node's box or its paint but **the theme everything below it reads**, so the value
/// is consumed by the theme swap rather than by the node. That swap happens at four
/// points of the walk — the layout pass, the relayout fingerprint, the paint, and
/// [`crate::build_deferred`] — and they all go through `crate::ui::scoped_theme`
/// so that they cannot answer differently.
fn anim_text_style(&self) -> Option<frus_core::TextStyle> {
None
}
/// **Alignment** of the single child within the box: the walk offsets the child
/// through the free space according to the alignment's fractions, resolved
/// against the reading direction (physical or directional — see
/// [`frus_core::AlignmentGeometry`]). Being continuous, a `Tween<Alignment>`
/// read in `view()` slides the child. `None` = default flex placement.
fn alignment_geometry(&self) -> Option<frus_core::AlignmentGeometry> {
None
}
/// **Paint offset** `(dx, dy)` applied to the widget's whole subtree: the render
/// and the hit-test are offset **without touching layout** (siblings do not move,
/// the child may overflow its box). Continuous → a `Tween` read in `view()` slides
/// the subtree. `None` = no offset. See [`crate::Transform`].
fn transform_translate(&self) -> Option<(f32, f32)> {
None
}
/// **Paint offset as a fraction of the child's own size** `(fx, fy)`: `(0.5, 0.0)`
/// slides the subtree half its own width to the right. Added to
/// [`Widget::transform_translate`], and offsetting the render and the hit-test the
/// same way, without touching layout. `None` = no offset.
///
/// A fraction rather than a number because the number is not known where the widget
/// is written: the child's size is decided by the layout, and something that has to
/// slide exactly clear of itself — a panel off the edge, a badge half outside its
/// anchor — would otherwise have to be told a width it was never given. See
/// [`crate::FractionalTranslation`].
fn translate_fraction(&self) -> Option<(f32, f32)> {
None
}
/// **Paint scaling** `(sx, sy, pivot)` of the whole subtree: the render and the
/// hit-test are scaled — per axis — around the `pivot` (a
/// [`frus_core::Alignment`] within the box), **without touching layout**. Stays
/// axis-aligned (a scaled rect is still a rect). `None` = no scaling.
/// See [`crate::Transform`].
fn transform_scale(&self) -> Option<(f32, f32, frus_core::Alignment)> {
None
}
/// **Paint rotation** `(angle, pivot)` of the whole subtree: the subtree is
/// painted rotated by `angle` radians (clockwise) around the `pivot` (a
/// [`frus_core::Alignment`] within the box), **without touching layout**. The
/// render goes through a rotated composited layer; the hit-test counter-rotates
/// the point. `None` = no rotation. See [`crate::Transform`].
fn transform_rotate(&self) -> Option<(f32, frus_core::Alignment)> {
None
}
/// **Shape clip** of the whole subtree: the paint walk wraps its primitives in a
/// composited layer whose [`frus_core::ClipShape`] (rounded corners, ellipse)
/// modulates the alpha — whatever falls outside the shape is erased, edges
/// antialiased. `None` = no shape clip. See [`crate::ClipRRect`],
/// [`crate::ClipOval`].
fn clip_shape(&self) -> Option<frus_core::ClipShape> {
None
}
/// The widget's style **once the theme has had its say** — the layout half of the
/// `caller ?? theme ?? framework` chain.
///
/// Defaults to [`Widget::style`], which is what almost every widget wants: only the
/// ones whose *size or spacing* a theme can set need to override this. It exists
/// because `style` has no theme and cannot be given one without touching every
/// implementation; a theme that could only reach `paint` would be able to recolour a
/// divider but not make one thin, which is the setting an application actually asks
/// for (milestone 309).
///
/// A **transparent wrapper must forward this** alongside `style`, or its child's
/// themed size is silently dropped for the unthemed one.
fn style_themed(&self, _theme: &Theme) -> Style {
self.style()
}
/// The theme this widget imposes on **itself and its subtree**, given the one it
/// inherits. `None` — the default — means "whatever came down from above", which is
/// what every widget but [`crate::Themed`] answers.
///
/// This is the third and last thing a theme needed to be usable: milestone 309 gave
/// it per-widget defaults, and this makes those defaults *scoped*. A dark panel on a
/// light page is one theme swapped for a subtree, not a colour written out by hand at
/// every call site inside it.
///
/// It is honoured by **layout as well as paint** — the walk and the layout pass swap
/// the ambient theme on the way down and restore it on the way out — so a subtree
/// theme can change a divider's height, not only its colour. A deferred overlay
/// (a dialog, a drawer, a tooltip) is painted long after the walk has left the node
/// that declared it, so it **carries the theme it was declared under** rather than
/// the root's.
///
/// Boxed because a `Theme` is a page and a half of tokens and this is asked of
/// **every node, every frame**: an `Option<Box<_>>` costs a word on the stack of a
/// recursion as deep as the tree, and the allocation happens only where a subtree
/// actually claims a theme.
fn theme_override(&self, _inherited: &Theme) -> Option<Box<Theme>> {
None
}
/// The **surface** this widget imposes on itself and its subtree, given the one it
/// inherits. `None` — the default — means "whatever came down from above", which is
/// what every widget but [`MediaScope`](crate::MediaScope) answers.
///
/// The counterpart of [`Self::theme_override`], and it exists for the same reason one
/// milestone later: a surface could until now only be narrowed **where a widget is
/// constructed** (`SafeArea::build`), and the widget that knows what to narrow is often
/// not the one doing the constructing. A shell hands its app bar's slot the description
/// that slot should believe in; the bar then decides for itself whether to consume the
/// status bar, which is how the reference splits that job across two widgets.
///
/// Applied by the layout walk on the way down and held for the subtree, so anything
/// reading [`MediaQuery::of`](crate::MediaQuery::of) below this node sees it — including
/// a subtree deferred until [`Self::build_themed`], which runs after the swap.
/// [`crate::build_deferred`], the relayout fingerprint and the paint walk make the same
/// swap; the four staying in step is what keeps the cache and the picture honest.
fn media_override(&self, _inherited: crate::MediaQuery) -> Option<crate::MediaQuery> {
None
}
/// The **shell** this widget imposes on its subtree: what a
/// [`Scaffold`](crate::Scaffold) knows about itself and its slots do not.
///
/// The third of the inherited things, after the theme and the surface, and it exists
/// for the same reason as the second: a slot is handed to a shell **already built**, so
/// the widget that knows there is a drawer is never the one that has to draw the button
/// for it. The reference reads it from the context (`Scaffold.of`), which is how a bar
/// with no `leading` grows a menu button on a screen that has a menu and stays empty on
/// one that does not (`app_bar.dart:1010`).
///
/// `None` — the default — means "whatever came down from above", which is what every
/// widget but [`ScaffoldScope`](crate::ScaffoldScope) answers. Applied by the same four
/// walks as [`Self::media_override`], and for the same reason: an
/// [`AppBar`](crate::AppBar) is composed in [`Self::build_themed`], which runs after the
/// swap, and the relayout fingerprint has to see what the composition saw.
fn scaffold_override(&self) -> Option<crate::ScaffoldInfo> {
None
}
/// The [`ScrollBehavior`](crate::ScrollBehavior) this widget puts in force for **its
/// subtree**, or `None` — the default — for whatever came down from above. Only
/// [`ScrollConfiguration`](crate::ScrollConfiguration) answers otherwise. Applied by
/// the same four walks as [`Self::scaffold_override`]: the scrollables under it record
/// what it decides when they are registered (milestone 616).
fn scroll_behavior_override(&self) -> Option<crate::ScrollBehavior> {
None
}
/// Builds this widget's subtree **from the ambient theme**, for the widgets that
/// defer that decision — see [`ThemeBuilder`](crate::ThemeBuilder). Does nothing by
/// default, which is what all but a handful of widgets want.
///
/// [`Self::style_themed`] and [`Self::paint`] let a theme decide how a widget
/// **looks**. This is for the questions a theme answers *earlier* than that: whether
/// an application bar centres its title decides which children exist and in what
/// order, and by the time anything is being painted the composition has already been
/// made. A widget assembled by a builder — `AppBar::new().build()` — never sees a
/// theme at all.
///
/// Called by the layout pass on the way down, **before** [`Self::children`] is read,
/// under the theme of the subtree the node sits in. It takes `&self` like every other
/// hook, so an implementor needs interior mutability; that is safe here because a
/// widget tree is rebuilt from `view` rather than mutated, so "once per instance" and
/// "once per frame" are the same thing.
fn build_themed(&self, _theme: &Theme) {}
/// [`Self::build_themed`], for the few widgets that also need **who they are** and
/// **what the frame remembers** to compose their subtree. An
/// [`AnimatedSwitcher`](crate::AnimatedSwitcher) keeps what it is letting go of in the
/// runtime, under its own identity, and that is reachable nowhere else before its
/// children are read.
///
/// The walks call this one, and its default is `build_themed`, so a deferred widget that
/// needs neither keeps implementing only that. A **transparent** wrapper must forward it
/// with the identity untouched — it has none of its own — or the widget inside is built
/// through `build_themed` and never learns where it is.
fn build_in(
&self,
_id: crate::interaction::WidgetId,
_runtime: &crate::runtime::Runtime,
theme: &Theme,
) {
self.build_themed(theme)
}
/// **Builds what this node stands for**, before anything else is asked of it.
///
/// A [`Component`](crate::Component) is a widget that is built into another, and what it
/// is built into decides everything the walk asks next — its theme scope, its surface,
/// its children. So the walks call this first, on the way down, before those questions
/// and before [`Self::build_in`]; by the time they are asked, the node answers as what it
/// built. Called under the theme of the enclosing scope, since the scope a node introduces
/// is not known until it is built.
///
/// Idempotent, and the default does nothing. A **transparent** wrapper must forward it
/// with the identity untouched, for the same reason as `build_in`.
fn expand(
&self,
_id: crate::interaction::WidgetId,
_runtime: &crate::runtime::Runtime,
_theme: &Theme,
) {
}
/// Whether this node is an [`AnimatedSwitcher`](crate::AnimatedSwitcher). An identity
/// is a position, so a switcher and the widget that comes to stand where it stood have
/// the same one: this is how the runtime tells the switcher still being there from its
/// having gone, and forgets what it kept for it.
fn switches(&self) -> bool {
false
}
/// What the system bars over this widget should look like — see
/// [`AnnotatedRegion`](crate::AnnotatedRegion). `None` for every widget but that one; a
/// transparent wrapper forwards it, or a keyed region would say nothing.
fn system_ui_style(&self) -> Option<crate::SystemUiOverlayStyle> {
None
}
/// If the widget takes **ink** — the splash a tap leaves on a material surface —
/// the shape and colour to splash in. `None` = no ink, which is the default: a
/// widget has to ask.
///
/// The walk paints the ripples the runtime holds for this widget directly over
/// this widget's own `paint` and **under its children**, which is where a material
/// surface puts them. A widget that draws its own content (a [`crate::Button`]
/// paints its label itself) therefore gets the ink *over* that content — at the
/// splash's alpha, a tint rather than a veil. See [`crate::InkWell`].
fn ink(&self, _theme: &Theme) -> Option<crate::ink::InkStyle> {
None
}
/// A decoration painted **over this widget's children** rather than behind them:
/// the reference's `foregroundDecoration`.
///
/// It is the one place in the walk where a widget paints after its own subtree,
/// and it exists because there is no other way to say it. A border over a
/// photograph, a wash across a tile that is disabled, a sheen over a card — every
/// one of them is a decoration whose whole point is that the content does not
/// cover it, and behind the content is exactly where [`Widget::paint`] puts one.
///
/// The box is this widget's own, the same one `paint` is given. Inside any layer
/// this widget asks for: an opacity group fades it with everything else, a
/// transform carries it, and a shape clip holds it to the shape — which for a
/// decoration wearing that same radius changes nothing.
///
/// `None` is the default, and costs the walk one `Option` check per node.
fn foreground(&self, _theme: &Theme) -> Option<frus_core::BoxDecoration> {
None
}
/// Whether this widget paints **over its own children** too, with
/// [`paint_over`](Self::paint_over) (milestone 652). `false` by default, which spares
/// the walk the status it would compute for it.
fn paints_over(&self) -> bool {
false
}
/// Paints **over this widget's children**, after its subtree, in the box and with the
/// status [`Widget::paint`] is given — the reference's `foregroundPainter`, for what a
/// widget draws that its children must not cover. A range slider's thumbs are one:
/// each thumb's focus stop is a child, and the halo it paints belongs under the thumb.
///
/// Called only when [`paints_over`](Self::paints_over) says so.
fn paint_over(&self, _bounds: Rect, _status: Status, _theme: &Theme, _scene: &mut Scene) {}
/// The **pixel effects** this widget applies to its whole subtree: a blur, a
/// colour transform, a mask, or a filter over what is painted underneath. The
/// paint walk drains the subtree into a composited layer and hands the filter to
/// the renderer, exactly as it does for an opacity group or a shape clip.
///
/// The [`FilterContext`] carries what only the walk knows — where the box ended
/// up, and which backdrop group encloses it. A widget that needs neither ignores
/// it.
///
/// `None` — the default — means no layer and no cost. See [`crate::ColorFiltered`],
/// [`crate::ImageFiltered`], [`crate::ShaderMask`], [`crate::BackdropFilter`].
fn layer_filter(&self, _cx: FilterContext) -> Option<frus_core::LayerFilter> {
None
}
/// `true` when this widget is a **backdrop group**: the backdrops below it that
/// ask to be shared are filtered once between them. See [`crate::BackdropGroup`].
fn backdrop_group(&self) -> bool {
false
}
/// The widget's own **text baseline**: the distance from the top of its box down
/// to the line its letters sit on. `None` — the default — means this widget has no
/// text of its own, and whatever is inside it answers instead.
///
/// It is what makes a price and its currency, or a heading and the note beside it,
/// sit on one line rather than merely in one row. See [`crate::Baseline`] and
/// `Align::Baseline`.
fn text_baseline(&self, _theme: &Theme) -> Option<f32> {
None
}
/// `true` when this subtree should be **left out** of a parent's baseline
/// alignment: it has a baseline, and the parent is to pretend it does not. An icon
/// beside a label, where the label is what the row should line up on. See
/// [`crate::IgnoreBaseline`].
fn ignores_baseline(&self) -> bool {
false
}
/// The **axes this widget asks to fill**: on each, it takes the room the parent
/// leaves it rather than shrink-wrapping its children. [`FillAxes::NONE`] means
/// shrink-wrap on both.
///
/// `MainAxisSize::Max` on a [`crate::Row`] or a [`crate::Column`] is the reason it
/// exists, and there the axis is the widget's own main one; a [`crate::TabBar`] asks
/// for the horizontal one, which is its cross axis; a full-screen shell asks for
/// [`FillAxes::BOTH`].
///
/// It is a question about the *parent*, which is why it is asked rather than written
/// into the style: filling means growing when the parent runs the same way and
/// stretching when it runs across, and a widget cannot know what it was put inside.
/// The layout walk resolves it, where both are in view. **Declaring `width: 100%`
/// instead does not work** and cannot be made to — see [`FillAxes`].
///
/// The theme is here for the same reason it is on [`Widget::measure`]: a text asks to
/// fill because it was told to align inside its box, and a subtree can hand that
/// alignment down. A hook blind to the theme would leave the one setting that arrives
/// by inheritance silently doing nothing.
fn fill_axes(&self, _theme: &Theme) -> FillAxes {
FillAxes::NONE
}
/// The axes on which this widget's size is **only a default** (milestone 590): the
/// room on offer replaces it wherever the widget is asked to fill that axis and the
/// layout can grant it — alone in a box, or across a row or a column. Where it cannot,
/// along a line shared with other children, the default stands.
///
/// The reference gives a list, a page view or a field **all the room offered**, and has
/// nothing to give when that room is unbounded: it stops with an error. A default that
/// stands only there keeps the reference's size wherever it has one, and something on
/// the screen where it has none.
fn soft_extent(&self) -> FillAxes {
FillAxes::NONE
}
/// The width below which this widget must not be squeezed **when its parent runs
/// horizontally** — a line of text that would rather run past the end of a row than
/// be folded into a column of single words. `None` means squeeze freely.
///
/// It is asked rather than written into the style because the same number means two
/// different things on the two axes. Down a column a box is *handed* a width and a
/// floor would refuse it; along a row a box is *asked* how wide it wants to be, and
/// this is the answer it will not go below. The reference draws the same line: a flex
/// leaves its inflexible children an unbounded main axis and never squeezes them,
/// while across it they take the width they are given.
///
/// It is handed the theme for the same reason [`Widget::style_themed`] is: the floor
/// is a *measurement*, and a text whose size comes from an inherited style measures
/// differently. A hook that decided a size without seeing the theme would answer for
/// a font nobody is drawing.
fn main_axis_floor(&self, _theme: &Theme) -> Option<f32> {
None
}
/// If this container gives all of its children the **shape of a tile**, the
/// `width / height` ratio to impose on each of them. `None` = each child keeps
/// its own shape.
///
/// A grid's tiles are the same shape in the reference, and it is the grid that
/// says so — the tile does not know how wide its column came out. Imposed during
/// the walk, like the fill request and the shrink grant, because it needs the
/// children's layout nodes rather than their styles.
fn tile_shape(&self) -> Option<f32> {
None
}
/// If this is a layer **pinned** against its [`crate::Stack`]'s edges
/// ([`crate::Positioned`]), what it pins. `None` = an ordinary layer, sized and
/// placed by the stack's own fit and alignment.
///
/// Read by the stack rather than written into a style: an offset from an edge is not
/// something the layout engine's box model has a field for, and the number it
/// resolves to depends on how big the stack came out.
fn positioned(&self) -> Option<crate::positioned::Positioning> {
None
}
/// How this stack sizes its unpinned layers ([`crate::StackFit`]). Unset,
/// [`Passthrough`](crate::StackFit::Passthrough): each is handed the stack's box, and
/// one with a size of its own keeps it. Meaningless unless [`Widget::stack`] is true.
fn stack_fit(&self) -> crate::StackFit {
crate::StackFit::Passthrough
}
/// Whether this stack is **as big as its largest unpinned layer** (milestone 639), as
/// [`crate::Stack`] is, rather than the size its own style says. Meaningless unless
/// [`Widget::stack`] is true.
fn stack_measured(&self) -> bool {
false
}
/// Whether this stack cuts its layers at its edges. Unset, it does.
fn stack_clips(&self) -> bool {
true
}
/// The reading direction this stack resolves its alignment and its layers' start and
/// end pins in, when it names one. Unset, the theme's.
fn stack_direction(&self) -> Option<frus_core::TextDirection> {
None
}
/// Which layer of this stack is **shown**: the one at that index paints and takes
/// input, and every other one is laid out and then silenced — not drawn, not
/// clickable, not read out. `None`, the default, shows all of them.
///
/// This is [`crate::IndexedStack`], and it is a question for the walk rather than for
/// the widget: a layer that wrapped itself in something to stay quiet would no longer
/// be laid out the way a bare layer is, which is the one thing an indexed stack
/// promises. Meaningless unless [`Widget::stack`] is true.
fn stack_visible(&self) -> Option<usize> {
None
}
/// The box this widget asks the scroll region around it to **keep in view**, in its
/// own coordinates, with a key naming which box it is.
///
/// A tab bar wider than its window is what this is for: the eighth tab is off the
/// side, and nothing about selecting it would otherwise bring it back. The reference
/// scrolls its bar to the selected tab, and so does this.
///
/// The **key** is what makes the region act on a change rather than on every frame.
/// The box moves as the region scrolls, so a region that chased it would pin the
/// content in place and no finger could move it; the key changes only when the widget
/// means a different box.
///
/// `centre` asks for the box in the middle of the window rather than merely inside
/// it — what a tab bar wants, since a selected tab flush against the edge looks like
/// the end of the row. Clamped either way, so the first tab stays at the start.
fn keep_visible(&self, _size: Size, _theme: &Theme) -> Option<crate::ui::KeepVisible> {
None
}
/// Whether this scrollable runs **from the far end** ([`crate::SingleChildScrollView::reverse`]):
/// the content is anchored to the end of the viewport and offsets are counted from
/// there. Meaningless unless [`Widget::scroll_content`] is `Some`.
fn scroll_reverse(&self) -> bool {
false
}
/// The insets a scrollable area puts **around its content**, inside the viewport.
///
/// The padding scrolls with the content rather than shrinking the window onto it,
/// which is the reference's `SliverPadding` and the only reading that is any use:
/// room at the end of a list is reachable by scrolling to it, room taken out of the
/// viewport is not. Read by both the scroll branch and the virtualised list.
fn scroll_padding(&self) -> frus_core::Insets {
frus_core::Insets::ZERO
}
/// If the widget positions its child **by the child's baseline** ([`crate::Baseline`]),
/// the distance from the top of this box at which that baseline should land.
/// `None` = not a baseline box.
fn baseline_target(&self) -> Option<f32> {
None
}
/// If the widget clips its child to an **arbitrary path** (`ClipPath`), returns the
/// path in **local coordinates** (origin at the box's top-left corner). The walk
/// offsets it to the screen and wraps it in a layer whose mask (the path) erases
/// the outside. Takes priority over [`Widget::clip_shape`]. `None` = no path clip.
/// See [`crate::ClipPath`].
fn clip_path(&self) -> Option<&frus_core::Path> {
None
}
/// If the widget is a **dismissible item** ([`crate::Dismissible`]), its
/// configuration for this frame. The shell gives a mostly-sideways drag on it to
/// the dismissal and a mostly-up-and-down one to the enclosing scrollable. `None` =
/// not dismissible.
fn dismissible(&self) -> Option<crate::dismiss::DismissSpec> {
None
}
/// The message a dismissed item dispatches, once it has flown out **and** its gap
/// has closed. `None` = the swipe is shown but removes nothing.
fn on_dismissed(&self, _direction: crate::dismiss::DismissDirection) -> Option<Msg> {
None
}
/// If the widget is the moving panel of a [`crate::DraggableScrollableSheet`], its
/// configuration for this frame. The layout makes it as tall as the retained height,
/// and the shell shares a finger on it between the sheet and the scroll areas inside.
/// `None` = not a sheet.
fn sheet(&self) -> Option<&crate::sheet::SheetSpec> {
None
}
/// The message a sheet dispatches once it has been lowered to nothing. `None` = it
/// cannot be dismissed, or says nothing when it is.
fn on_sheet_dismissed(&self) -> Option<Msg> {
None
}
/// If the widget is a **refresh area** ([`crate::RefreshIndicator`]), its configuration for
/// this frame. Any scrollable inside it routes the movement its physics refuses at
/// the top edge into the pull, instead of into the overscroll glow. `None` = not a
/// refresh area.
fn refresh(&self) -> Option<crate::refresh::RefreshSpec> {
None
}
/// The message a refresh area dispatches when an armed pull is released. `None` =
/// the pull is shown but asks for nothing, which is what an area still waiting for
/// its `on_refresh` looks like.
fn on_refresh(&self) -> Option<Msg> {
None
}
/// What the widget **withholds** from the frame on behalf of its whole subtree:
/// input targets, primitives, accessibility nodes. The walk visits the subtree
/// normally and then discards whatever it added to the selected registries, so a
/// target registered deep inside is caught just as surely as one at the top.
/// `None` = nothing withheld (the default). See [`crate::ModalBarrier`],
/// [`crate::IgnorePointer`], [`crate::AbsorbPointer`], [`crate::Visibility`],
/// [`crate::ExcludeSemantics`].
fn barrier(&self) -> Option<crate::barrier::ModalBarrier> {
None
}
/// If the widget is an **interactive viewport** (`InteractiveViewer`), returns its
/// scale bounds `(min, max)`. The paint walk renders its child in a transformed
/// layer (retained scale + translation, clipped to the viewport); the shell routes
/// drag → pan and wheel/pinch → zoom. `None` = not an interactive viewport.
/// See [`crate::InteractiveViewer`].
fn interactive(&self) -> Option<(f32, f32)> {
None
}
/// If the widget **fits** its child to its box (`FittedBox`), returns the
/// [`frus_core::BoxFit`]: the walk measures the child at its natural size, scales
/// it according to the fit and centres it (composited layer, hit-test through
/// `M⁻¹`). `None` = not a fitter. See [`crate::FittedBox`].
fn fitted(&self) -> Option<frus_core::BoxFit> {
None
}
/// If the widget **rotates** its child by quarter turns (`RotatedBox`), returns
/// the number of quarters. Unlike `Transform`, this **affects layout**: the box
/// swaps its dimensions for an odd number. `None` = not a `RotatedBox`.
/// See [`crate::RotatedBox`].
fn rotated_quarter_turns(&self) -> Option<i32> {
None
}
/// If the widget is a screen navigator, returns `(progress, push?)`. Its children
/// (`[screen]` or `[outgoing, incoming]`) are rendered full-window with a sliding
/// transition.
fn navigator(&self) -> Option<(f32, bool)> {
None
}
/// Whether a finger drives the [`navigator`](Self::navigator)'s transition — a back
/// gesture — so that it follows the finger linearly (milestone 620).
fn navigator_gesture(&self) -> bool {
false
}
/// Whether a [`navigator`](Self::navigator) **clips its pages to its own box**.
/// `true`, which is the reference's default (`Clip.hardEdge`) and the only sane one:
/// a screen sliding in comes from outside the box and has to stop at its edge.
///
/// Consulted only inside the navigator branch of the walk, so it costs nothing for
/// every other widget.
fn navigator_clips(&self) -> bool {
true
}
/// How many of a navigator's first children are **kept but not shown**: the pages under
/// the one on show. They are built, so what their components hold survives, and they are
/// not laid out, drawn or given input. `0`, the default, is a navigator that shows every
/// page it holds.
fn navigator_retained(&self) -> usize {
0
}
/// Message emitted by a **long press** (a press held ~500 ms without movement).
/// The long press *pre-empts* the click: the release that follows does not emit
/// `on_click`.
fn on_long_press(&self) -> Option<Msg> {
None
}
/// Message emitted by a **double tap**: two taps on this widget in quick succession
/// (within 300 ms and 100 px of each other, the reference's numbers). While one is
/// possible, a first tap's [`on_click`](Self::on_click) waits out those 300 ms, so that
/// the second tap of a double tap is not also a tap.
fn on_double_tap(&self) -> Option<Msg> {
None
}
/// Message emitted by a **secondary tap**: a click of the secondary mouse button, usually
/// the right one.
fn on_secondary_tap(&self) -> Option<Msg> {
None
}
/// Whether this widget **hears the pointer's raw events** (milestone 586): a press inside
/// it, and then that pointer wherever it goes until it lifts; and a mouse's hover.
fn pointer_listener(&self) -> bool {
false
}
/// The messages for one raw event of the pointer, on a widget that is a
/// [`pointer_listener`](Self::pointer_listener). Several, when listeners wrap each other at
/// the same place.
fn on_pointer_event(&self, _event: crate::ListenerEvent) -> Vec<Msg> {
Vec::new()
}
/// Whether this widget is a **region the mouse enters and leaves** (milestone 583), and
/// how: the cursor it asks for while the pointer is over it, and whether it hides the
/// regions behind it. `None` for anything that is not one.
fn hover_region(&self) -> Option<crate::HoverRegion> {
None
}
/// Message for the pointer entering, moving over or leaving this region — one whose
/// [`hover_region`](Self::hover_region) is set.
fn on_hover_event(&self, _event: crate::HoverEvent) -> Option<Msg> {
None
}
/// Which way this widget takes a **drag**, if it takes one at all (milestone 582): the
/// shell then reports it through [`on_pan`](Self::on_pan). Inside a scroll, a drag along
/// the scroll's axis stays the scroll's unless this axis claims it.
fn pan_axis(&self) -> Option<crate::PanAxis> {
None
}
/// Message for one moment of a drag — its start, a movement, its end — on a widget whose
/// [`pan_axis`](Self::pan_axis) is set.
fn on_pan(&self, _event: crate::PanEvent) -> Option<Msg> {
None
}
/// Whether this widget wants **the title bar's line** for itself (milestone 640): a
/// [`WindowMenuBar`](crate::WindowMenuBar)'s row. The shell gives it the line where the
/// system allows it.
fn wants_title_bar(&self) -> bool {
false
}
/// What this widget is to the system on the title bar's line, which acts on it: the
/// window's icon or its three buttons (milestone 640).
fn title_bar_role(&self) -> Option<crate::TitleBarRole> {
None
}
/// A drag that moves **this widget's own animated value** ([`anim_target`]) — a
/// switch's thumb following the finger (milestone 638). Given a moment of the drag, the
/// value now and whether the text runs right to left, the value to hold it at; `None`
/// leaves it alone. The shell holds the value there while the finger is down, and when
/// it lifts lets it settle from there, asking [`on_value_release`] what that means.
///
/// [`anim_target`]: Self::anim_target
/// [`on_value_release`]: Self::on_value_release
fn pan_value(&self, _event: crate::PanEvent, _value: f32, _rtl: bool) -> Option<f32> {
None
}
/// Message for a drag that moved this widget's value letting go at `value` — a switch
/// flips when its thumb was let go past half way (milestone 638).
fn on_value_release(&self, _value: f32) -> Option<Msg> {
None
}
/// Key received while **bubbling leaf→root**: the focused widget gets it first,
/// then each ancestor as long as the response is `Ignored`. (E.g. an `OverlayPortal`
/// consumes `Escape` to close itself.)
fn on_key(&self, _key: &crate::interaction::Key) -> crate::interaction::KeyResponse<Msg> {
crate::interaction::KeyResponse::Ignored
}
/// **Measure under constraints**: for a widget whose size depends on the space
/// offered (a paragraph that wraps…), returns the closure wired into taffy.
/// `None` = size fixed by `style()`. Contract: must be `Some` **if and only if**
/// [`Widget::measure_key`] is.
///
/// The theme comes in because the measurement has to agree with the paint. A text
/// that takes its size from an inherited style must be *measured* at that size too;
/// measured at one size and drawn at another, every box on the screen is the wrong
/// height at once, and nothing in the picture says which of the two numbers is wrong.
fn measure(&self, _theme: &Theme) -> Option<frus_layout::MeasureFn<'_>> {
None
}
/// Fingerprint of the **content** [`Widget::measure`] depends on (text, style…),
/// mixed into the relayout fingerprint: without it, two different contents with
/// the same style would be conflated by the cache and would keep a stale
/// geometry. Contract: `Some` if and only if `measure()` is.
///
/// Whatever the theme contributes to the measurement belongs in here as well — a
/// cache key that ignores half of its inputs is a stale layout waiting for the
/// subtree's style to change.
fn measure_key(&self, _theme: &Theme) -> Option<u64> {
None
}
}
/// **Short** type name: without module path or generic parameters
/// (`frus_widgets::text::Text` → `Text`, `Container<Msg>` → `Container`).
pub(crate) fn short_type_name<T: ?Sized>() -> &'static str {
let full = std::any::type_name::<T>();
let no_generics = full.split('<').next().unwrap_or(full);
no_generics.rsplit("::").next().unwrap_or(no_generics)
}
/// Lets an **already boxed** widget be composed where an `impl Widget` is expected
/// (e.g. `Flex::child`). Delegates everything to the contained widget.
impl<Msg> Widget<Msg> for Box<dyn Widget<Msg>> {
fn style(&self) -> Style {
(**self).style()
}
fn style_themed(&self, theme: &Theme) -> Style {
(**self).style_themed(theme)
}
fn theme_override(&self, inherited: &Theme) -> Option<Box<Theme>> {
(**self).theme_override(inherited)
}
fn media_override(&self, inherited: crate::MediaQuery) -> Option<crate::MediaQuery> {
(**self).media_override(inherited)
}
fn scaffold_override(&self) -> Option<crate::ScaffoldInfo> {
(**self).scaffold_override()
}
fn scroll_behavior_override(&self) -> Option<crate::ScrollBehavior> {
(**self).scroll_behavior_override()
}
fn build_themed(&self, theme: &Theme) {
(**self).build_themed(theme)
}
fn build_in(
&self,
id: crate::interaction::WidgetId,
runtime: &crate::runtime::Runtime,
theme: &Theme,
) {
(**self).build_in(id, runtime, theme)
}
fn expand(
&self,
id: crate::interaction::WidgetId,
runtime: &crate::runtime::Runtime,
theme: &Theme,
) {
(**self).expand(id, runtime, theme)
}
fn switches(&self) -> bool {
(**self).switches()
}
fn system_ui_style(&self) -> Option<crate::SystemUiOverlayStyle> {
(**self).system_ui_style()
}
fn repaint_boundary(&self) -> bool {
(**self).repaint_boundary()
}
fn debug_name(&self) -> &'static str {
(**self).debug_name()
}
fn semantics(&self) -> Option<SemanticsProperties> {
(**self).semantics()
}
fn describes(&self) -> Option<crate::semantics::Description> {
(**self).describes()
}
fn children(&self) -> &[Box<dyn Widget<Msg>>] {
(**self).children()
}
fn paint(&self, bounds: Rect, status: Status, theme: &Theme, scene: &mut Scene) {
(**self).paint(bounds, status, theme, scene)
}
fn on_click(&self) -> Option<Msg> {
(**self).on_click()
}
fn opaque(&self) -> bool {
(**self).opaque()
}
fn positional_click(&self, local_x: f32, local_y: f32, width: f32, height: f32) -> Option<Msg> {
(**self).positional_click(local_x, local_y, width, height)
}
fn cursor_icon(&self, local_x: f32, local_y: f32, width: f32, height: f32) -> Option<Cursor> {
(**self).cursor_icon(local_x, local_y, width, height)
}
fn key(&self) -> Option<u64> {
(**self).key()
}
fn on_edit(&self, edit: &mut Edit, key: &Key) -> Option<Msg> {
(**self).on_edit(edit, key)
}
fn cursor_at(
&self,
local_x: f32,
local_y: f32,
width: f32,
scroll_cursor: usize,
) -> Option<usize> {
(**self).cursor_at(local_x, local_y, width, scroll_cursor)
}
fn text_metrics(&self, width: f32, cursor: usize) -> Option<(f32, f32, f32, f32)> {
(**self).text_metrics(width, cursor)
}
fn text_viewport(&self, rect: crate::Rect) -> Option<crate::Rect> {
(**self).text_viewport(rect)
}
fn caret_vertical(
&self,
width: f32,
cursor: usize,
down: bool,
page: bool,
goal_x: Option<f32>,
) -> Option<(usize, f32)> {
(**self).caret_vertical(width, cursor, down, page, goal_x)
}
fn selected_text(&self, edit: &Edit) -> Option<String> {
(**self).selected_text(edit)
}
fn text_value(&self) -> Option<&str> {
(**self).text_value()
}
fn takes_typing(&self) -> bool {
(**self).takes_typing()
}
fn selection_text(&self) -> Option<&str> {
(**self).selection_text()
}
fn region_toolbar(
&self,
context: crate::ToolbarContext,
width: f32,
range: (usize, usize),
) -> Option<(Rect, &dyn Widget<Msg>)> {
(**self).region_toolbar(context, width, range)
}
fn selection_grip(
&self,
width: f32,
index: usize,
start: bool,
) -> Option<crate::SelectionHandle> {
(**self).selection_grip(width, index, start)
}
fn area_toolbar(&self, context: crate::ToolbarContext) -> Option<Option<&dyn Widget<Msg>>> {
(**self).area_toolbar(context)
}
fn selection_hit(&self, local_x: f32, local_y: f32, width: f32) -> Option<usize> {
(**self).selection_hit(local_x, local_y, width)
}
fn replace_value(&self, value: String) -> Option<Msg> {
(**self).replace_value(value)
}
fn word_at(&self, index: usize) -> Option<(usize, usize)> {
(**self).word_at(index)
}
fn selection_handles(
&self,
width: f32,
edit: &Edit,
scroll_y: f32,
) -> Option<[crate::SelectionHandle; 2]> {
(**self).selection_handles(width, edit, scroll_y)
}
fn selection_toolbar(&self, context: crate::ToolbarContext) -> Option<&dyn Widget<Msg>> {
(**self).selection_toolbar(context)
}
fn selection_anchor(&self, width: f32, edit: &Edit, scroll_y: f32) -> Option<Rect> {
(**self).selection_anchor(width, edit, scroll_y)
}
fn edit_action(&self) -> Option<crate::EditAction> {
(**self).edit_action()
}
fn focusable(&self) -> bool {
(**self).focusable()
}
fn autofocus(&self) -> bool {
(**self).autofocus()
}
fn on_focus_change(&self, focused: bool) -> Option<Msg> {
(**self).on_focus_change(focused)
}
fn on_tap_outside(&self) -> Option<Msg> {
(**self).on_tap_outside()
}
fn shortcut_bindings(&self) -> &[(crate::shortcuts::KeyStroke, crate::shortcuts::Intent)] {
(**self).shortcut_bindings()
}
fn shortcut_callbacks(&self) -> &[(crate::shortcuts::KeyStroke, Msg)] {
(**self).shortcut_callbacks()
}
fn action_bindings(&self) -> &[(crate::shortcuts::Intent, Msg)] {
(**self).action_bindings()
}
fn action_listeners(&self) -> &[(crate::shortcuts::Intent, Msg)] {
(**self).action_listeners()
}
fn on_keystroke(
&self,
) -> Option<std::rc::Rc<dyn Fn(crate::shortcuts::KeyStroke) -> Option<Msg>>> {
(**self).on_keystroke()
}
fn descendants_focusable(&self) -> bool {
(**self).descendants_focusable()
}
fn focus_skip_traversal(&self) -> bool {
(**self).focus_skip_traversal()
}
fn focus_order(&self) -> Option<f32> {
(**self).focus_order()
}
fn focus_group(&self) -> bool {
(**self).focus_group()
}
fn autofill_hints(&self) -> &[crate::AutofillHint] {
(**self).autofill_hints()
}
fn autofill_group(&self) -> bool {
(**self).autofill_group()
}
fn draws_own_focus(&self) -> bool {
(**self).draws_own_focus()
}
fn draggable(&self) -> bool {
(**self).draggable()
}
fn drag_track(&self) -> DragTrack {
(**self).drag_track()
}
fn on_thumb_drag(&self, thumb: usize, moment: ThumbDrag, fraction: f32) -> Option<Msg> {
(**self).on_thumb_drag(thumb, moment, fraction)
}
fn on_drag(&self, fraction: f32) -> Option<Msg> {
(**self).on_drag(fraction)
}
fn on_drag_start(&self, fraction: f32) -> Option<Msg> {
(**self).on_drag_start(fraction)
}
fn on_drag_end(&self, fraction: f32) -> Option<Msg> {
(**self).on_drag_end(fraction)
}
fn on_drag_delta(&self, dx: f32) -> Option<Msg> {
(**self).on_drag_delta(dx)
}
fn reorder_index(&self) -> Option<usize> {
(**self).reorder_index()
}
fn on_reorder(&self, to: usize) -> Option<Msg> {
(**self).on_reorder(to)
}
fn reorder_draggable(&self) -> bool {
(**self).reorder_draggable()
}
fn reorder_droppable(&self) -> bool {
(**self).reorder_droppable()
}
fn reorder_announcement(&self, to: usize) -> Option<String> {
(**self).reorder_announcement(to)
}
fn reorder_axis(&self) -> ReorderAxis {
(**self).reorder_axis()
}
fn reorder_inserts(&self) -> bool {
(**self).reorder_inserts()
}
fn announce(&self) -> Option<String> {
(**self).announce()
}
fn stack(&self) -> bool {
(**self).stack()
}
fn sticky_header(&self) -> bool {
(**self).sticky_header()
}
fn custom_layout(&self) -> Option<crate::customlayout::CustomLayout<'_>> {
(**self).custom_layout()
}
fn continuous(&self) -> bool {
(**self).continuous()
}
fn scroll_content(&self) -> Option<&dyn Widget<Msg>> {
(**self).scroll_content()
}
fn virtual_list(&self, viewport: frus_core::Size) -> Option<crate::list::VirtualList<'_, Msg>> {
(**self).virtual_list(viewport)
}
fn page_view(&self) -> Option<crate::pageview::PagedView<'_, Msg>> {
(**self).page_view()
}
fn intrinsic(&self) -> Option<(crate::constraints::IntrinsicAxis, Option<f32>)> {
(**self).intrinsic()
}
fn overflow_box(&self) -> Option<crate::constraints::Overflow> {
(**self).overflow_box()
}
fn constraints_transform(&self) -> Option<crate::constraints::ConstraintsTransform> {
(**self).constraints_transform()
}
fn animated_size(&self) -> Option<crate::animatedsize::SizeAnimation> {
(**self).animated_size()
}
fn size_factor(&self) -> Option<(f32, f32)> {
(**self).size_factor()
}
fn clips_to_box(&self) -> bool {
(**self).clips_to_box()
}
fn hero_tag(&self) -> Option<u64> {
(**self).hero_tag()
}
fn drag_payload(&self) -> Option<u64> {
(**self).drag_payload()
}
fn drag_needs_long_press(&self) -> bool {
(**self).drag_needs_long_press()
}
fn drag_ghost_opacity(&self) -> f32 {
(**self).drag_ghost_opacity()
}
fn on_dropped(&self, accepted: bool) -> Option<Msg> {
(**self).on_dropped(accepted)
}
fn drop_zone(&self) -> bool {
(**self).drop_zone()
}
fn accepts_drag(&self, payload: u64) -> bool {
(**self).accepts_drag(payload)
}
fn on_drop(&self, payload: u64) -> Option<Msg> {
(**self).on_drop(payload)
}
fn accepts_files(&self, paths: &[std::path::PathBuf]) -> bool {
(**self).accepts_files(paths)
}
fn on_files_dropped(&self, paths: Vec<std::path::PathBuf>) -> Option<Msg> {
(**self).on_files_dropped(paths)
}
fn on_page_changed(&self, page: usize) -> Option<Msg> {
(**self).on_page_changed(page)
}
fn on_scroll(&self, position: crate::scrollposition::ScrollPosition) -> Option<Msg> {
(**self).on_scroll(position)
}
fn scroll_grain(&self) -> f32 {
(**self).scroll_grain()
}
fn layout_builder(&self) -> Option<&dyn Fn(Size) -> Box<dyn Widget<Msg>>> {
(**self).layout_builder()
}
fn scroll_overlay(&self) -> Option<&crate::scrolloverlay::OverlayBuilder<Msg>> {
(**self).scroll_overlay()
}
fn scroll_axis(&self) -> Axis {
(**self).scroll_axis()
}
fn scroll_physics(&self) -> Option<crate::physics::ScrollPhysics> {
(**self).scroll_physics()
}
fn scrollbars(&self) -> Option<crate::physics::Scrollbars> {
(**self).scrollbars()
}
fn thumb_visibility(&self) -> Option<bool> {
(**self).thumb_visibility()
}
fn ime(&self) -> crate::ime::Ime {
(**self).ime()
}
fn overlay(&self) -> Option<(&dyn Widget<Msg>, Placement)> {
(**self).overlay()
}
fn overlay_dismiss(&self) -> Option<Msg> {
(**self).overlay_dismiss()
}
fn overlay_scrim(&self, theme: &crate::theme::Theme) -> Option<frus_core::Color> {
(**self).overlay_scrim(theme)
}
fn overlay_traps_focus(&self) -> bool {
(**self).overlay_traps_focus()
}
fn anim_target(&self) -> Option<f32> {
(**self).anim_target()
}
fn anim_transform(&self) -> Option<crate::runtime::TransformValues> {
(**self).anim_transform()
}
fn anim_duration(&self) -> f32 {
(**self).anim_duration()
}
fn anim_initial(&self) -> Option<f32> {
(**self).anim_initial()
}
fn anim_curve(&self) -> frus_core::Curve {
(**self).anim_curve()
}
fn opacity_group(&self) -> Option<f32> {
(**self).opacity_group()
}
fn anim_color(&self) -> Option<frus_core::Color> {
(**self).anim_color()
}
fn anim_size(&self) -> Option<Size> {
(**self).anim_size()
}
fn anim_radius(&self) -> Option<frus_core::BorderRadius> {
(**self).anim_radius()
}
fn anim_padding(&self) -> Option<frus_core::Insets> {
(**self).anim_padding()
}
fn anim_offset(&self) -> Option<(f32, f32)> {
(**self).anim_offset()
}
fn anim_pins(&self) -> Option<crate::positioned::Positioning> {
(**self).anim_pins()
}
fn anim_fractions(&self) -> Option<(Option<f32>, Option<f32>)> {
(**self).anim_fractions()
}
fn anim_text_style(&self) -> Option<frus_core::TextStyle> {
(**self).anim_text_style()
}
fn alignment_geometry(&self) -> Option<frus_core::AlignmentGeometry> {
(**self).alignment_geometry()
}
fn transform_translate(&self) -> Option<(f32, f32)> {
(**self).transform_translate()
}
fn translate_fraction(&self) -> Option<(f32, f32)> {
(**self).translate_fraction()
}
fn transform_scale(&self) -> Option<(f32, f32, frus_core::Alignment)> {
(**self).transform_scale()
}
fn transform_rotate(&self) -> Option<(f32, frus_core::Alignment)> {
(**self).transform_rotate()
}
fn clip_shape(&self) -> Option<frus_core::ClipShape> {
(**self).clip_shape()
}
fn clip_path(&self) -> Option<&frus_core::Path> {
(**self).clip_path()
}
fn layer_filter(&self, cx: FilterContext) -> Option<frus_core::LayerFilter> {
(**self).layer_filter(cx)
}
fn text_baseline(&self, theme: &Theme) -> Option<f32> {
(**self).text_baseline(theme)
}
fn ignores_baseline(&self) -> bool {
(**self).ignores_baseline()
}
fn baseline_target(&self) -> Option<f32> {
(**self).baseline_target()
}
fn fill_axes(&self, theme: &Theme) -> FillAxes {
(**self).fill_axes(theme)
}
fn soft_extent(&self) -> FillAxes {
(**self).soft_extent()
}
fn main_axis_floor(&self, theme: &Theme) -> Option<f32> {
(**self).main_axis_floor(theme)
}
fn tile_shape(&self) -> Option<f32> {
(**self).tile_shape()
}
fn positioned(&self) -> Option<crate::positioned::Positioning> {
(**self).positioned()
}
fn stack_fit(&self) -> crate::StackFit {
(**self).stack_fit()
}
fn stack_measured(&self) -> bool {
(**self).stack_measured()
}
fn stack_clips(&self) -> bool {
(**self).stack_clips()
}
fn stack_direction(&self) -> Option<frus_core::TextDirection> {
(**self).stack_direction()
}
fn stack_visible(&self) -> Option<usize> {
(**self).stack_visible()
}
fn scroll_reverse(&self) -> bool {
(**self).scroll_reverse()
}
fn keep_visible(&self, size: Size, theme: &Theme) -> Option<crate::ui::KeepVisible> {
(**self).keep_visible(size, theme)
}
fn scroll_padding(&self) -> frus_core::Insets {
(**self).scroll_padding()
}
fn backdrop_group(&self) -> bool {
(**self).backdrop_group()
}
fn ink(&self, theme: &Theme) -> Option<crate::ink::InkStyle> {
(**self).ink(theme)
}
fn foreground(&self, theme: &Theme) -> Option<frus_core::BoxDecoration> {
(**self).foreground(theme)
}
fn paints_over(&self) -> bool {
(**self).paints_over()
}
fn paint_over(&self, bounds: Rect, status: Status, theme: &Theme, scene: &mut Scene) {
(**self).paint_over(bounds, status, theme, scene)
}
fn barrier(&self) -> Option<crate::barrier::ModalBarrier> {
(**self).barrier()
}
fn dismissible(&self) -> Option<crate::dismiss::DismissSpec> {
(**self).dismissible()
}
fn on_dismissed(&self, direction: crate::dismiss::DismissDirection) -> Option<Msg> {
(**self).on_dismissed(direction)
}
fn sheet(&self) -> Option<&crate::sheet::SheetSpec> {
(**self).sheet()
}
fn on_sheet_dismissed(&self) -> Option<Msg> {
(**self).on_sheet_dismissed()
}
fn refresh(&self) -> Option<crate::refresh::RefreshSpec> {
(**self).refresh()
}
fn on_refresh(&self) -> Option<Msg> {
(**self).on_refresh()
}
fn interactive(&self) -> Option<(f32, f32)> {
(**self).interactive()
}
fn fitted(&self) -> Option<frus_core::BoxFit> {
(**self).fitted()
}
fn rotated_quarter_turns(&self) -> Option<i32> {
(**self).rotated_quarter_turns()
}
fn navigator(&self) -> Option<(f32, bool)> {
(**self).navigator()
}
fn navigator_gesture(&self) -> bool {
(**self).navigator_gesture()
}
fn navigator_clips(&self) -> bool {
(**self).navigator_clips()
}
fn navigator_retained(&self) -> usize {
(**self).navigator_retained()
}
fn measure(&self, theme: &Theme) -> Option<frus_layout::MeasureFn<'_>> {
(**self).measure(theme)
}
fn measure_key(&self, theme: &Theme) -> Option<u64> {
(**self).measure_key(theme)
}
fn on_long_press(&self) -> Option<Msg> {
(**self).on_long_press()
}
fn on_double_tap(&self) -> Option<Msg> {
(**self).on_double_tap()
}
fn on_secondary_tap(&self) -> Option<Msg> {
(**self).on_secondary_tap()
}
fn pan_axis(&self) -> Option<crate::PanAxis> {
(**self).pan_axis()
}
fn hover_region(&self) -> Option<crate::HoverRegion> {
(**self).hover_region()
}
fn pointer_listener(&self) -> bool {
(**self).pointer_listener()
}
fn on_pointer_event(&self, event: crate::ListenerEvent) -> Vec<Msg> {
(**self).on_pointer_event(event)
}
fn on_hover_event(&self, event: crate::HoverEvent) -> Option<Msg> {
(**self).on_hover_event(event)
}
fn on_pan(&self, event: crate::PanEvent) -> Option<Msg> {
(**self).on_pan(event)
}
fn wants_title_bar(&self) -> bool {
(**self).wants_title_bar()
}
fn title_bar_role(&self) -> Option<crate::TitleBarRole> {
(**self).title_bar_role()
}
fn pan_value(&self, event: crate::PanEvent, value: f32, rtl: bool) -> Option<f32> {
(**self).pan_value(event, value, rtl)
}
fn on_value_release(&self, value: f32) -> Option<Msg> {
(**self).on_value_release(value)
}
fn on_key(&self, key: &crate::interaction::Key) -> crate::interaction::KeyResponse<Msg> {
(**self).on_key(key)
}
}